/*-------------------------------------------------------------*/ void AzDmat::prod(const AzDmat *m0, const AzDmat *m1, bool is_m0_tran, bool is_m1_tran) { const char *eyec = "AzDmat::prod"; if (is_m1_tran) { throw new AzException(eyec, "No support for the transpose of the second matrix"); } if (is_m0_tran) { reform(m0->colNum(), m1->colNum()); for (int col = 0; col < m1->colNum(); ++col) { AzDvect *myv = col_u(col); const AzDvect *v1 = m1->col(col); for (int row = 0; row < rowNum(); ++row) { double val = m0->col(col)->innerProduct(v1); myv->set(row, val); } } } else { reform(m0->rowNum(), m1->colNum()); for (int col = 0; col < m1->colNum(); ++col) { AzDvect *myv = col_u(col); const AzDvect *v1 = m1->col(col); for (int row1 = 0; row1 < v1->rowNum(); ++row1) { myv->add(m0->col(row1), v1->get(row1)); } } } }
/*--- x times transpose(x) ---*/ void add_xxT(const AzDvect *v) { if (v->rowNum() != rowNum() || v->rowNum() != colNum()) { throw new AzException("AzDmat::add_xxT", "shape mismatch"); } const double *val = v->point(); int rx; for (rx = 0; rx < v->rowNum(); ++rx) { col_u(rx)->add(v, val[rx]); } }
void cbind(const AzDmat *m) { if (colNum() <= 0 || rowNum() <= 0) { set(m); return; } if (m->rowNum() != rowNum()) { throw new AzException("AzDmat::cbind", "shape mismatch"); } int org_num = colNum(); int new_num = org_num + m->colNum(); resize(new_num); int cx; for (cx = 0; cx < m->colNum(); ++cx) { col_u(org_num+cx)->set(m->col(cx)); } }
inline void load(int col, AzIFarr *ifa_row_val) { col_u(col)->load(ifa_row_val); }
inline void set(double val) { int col; for (col = 0; col < colNum(); ++col) { col_u(col)->set(val); } }