void Gradient::vector_bwd(const ExprVector& v, ExprLabel** compL, const ExprLabel& y) { if (v.dim.is_vector()) { for (int i=0; i<v.length(); i++) compL[i]->g->i()+=y.g->v()[i]; } else { if (v.row_vector()) for (int i=0; i<v.length(); i++) compL[i]->g->v()+=y.g->m()[i]; else for (int i=0; i<v.length(); i++) compL[i]->g->v()+=y.g->m().col(i); } }
void HC4Revise::vector_bwd(const ExprVector& v, ExprLabel** compL, const ExprLabel& y) { if (v.dim.is_vector()) { for (int i=0; i<v.length(); i++) if ((compL[i]->d->i() &= y.d->v()[i]).is_empty()) throw EmptyBoxException(); } else { if (v.row_vector()) for (int i=0; i<v.length(); i++) { if ((compL[i]->d->v()&=y.d->m().col(i)).is_empty()) throw EmptyBoxException(); } else for (int i=0; i<v.length(); i++) { if ((compL[i]->d->v()&=y.d->m().row(i)).is_empty()) throw EmptyBoxException(); } } }
void Affine2Eval::vector_fwd(const ExprVector& v, const ExprLabel** compL, ExprLabel& y) { assert(v.type()!=Dim::SCALAR); assert(v.type()!=Dim::MATRIX_ARRAY); if (v.dim.is_vector()) { for (int i=0; i<v.length(); i++) { y.af2->v()[i]=compL[i]->af2->i(); y.d->v()[i]=compL[i]->d->i(); } } else { if (v.row_vector()) for (int i=0; i<v.length(); i++) { y.af2->m().set_col(i,compL[i]->af2->v()); y.d->m().set_col(i,compL[i]->d->v()); } else for (int i=0; i<v.length(); i++) { y.af2->m().set_row(i,compL[i]->af2->v()); y.d->m().set_row(i,compL[i]->d->v()); } } }