Example #1
0
std::unique_ptr<WTableCell> WTableRow::createCell(int column)
{
  if (table_)
    return table_->createCell(rowNum(), column);
  else
    return std::unique_ptr<WTableCell>(new WTableCell());
}
Example #2
0
/*-------------------------------------------------------------*/
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)); 
      }
    }      
  }
}
Example #3
0
 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)); 
   }
 }    
Example #4
0
/*-------------------------------------------------------------*/
void AzDvect::rbind(const AzDvect *v) {
  int old_num = rowNum(); 
  int new_num = old_num + v->rowNum(); 
  resize(new_num);
  int ex;
  for (ex = 0; ex < v->rowNum(); ++ex) {
    elm[old_num+ex] = v->elm[ex]; 
  }
}
Example #5
0
WTableCell *WTableRow::elementAt(int column)
{
  if (table_)
    return table_->elementAt(rowNum(), column);
  else {
    expand(column + 1);
    return cells_[column].get();
  }
}
Example #6
0
 /*---  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]); 
   }
 }
 /*--------------------------------------*/
 virtual void to_dense(AzBytArr *s, int digits) const {
   int row; 
   for (row = 0; row < rowNum(); ++row) {
     double val = get(row); 
     if (row > 0) {
       s->c(" "); 
     }
     s->cn(val, digits); 
   }
 }
Example #8
0
/*-------------------------------------------------------------*/
void AzDvect::scale_smat(AzSmat *ms) 
{
  const char *eyec = "AzDvect::scale_smat"; 
  if (ms->rowNum() != rowNum()) {
    throw new AzException(eyec, "#row mismatch"); 
  }
  int col; 
  for (col = 0; col < ms->colNum(); ++col) {
    if (ms->isZero(col)) continue; 
    AzSvect *vs = ms->col_u(col); 
    AzDvect v_tmp(vs); 
    v_tmp.scale(this); 
    AzIFarr ifa; v_tmp.nonZero(&ifa); 
    vs->load(&ifa); 
  }
}
  /*--------------------------------------*/
  virtual void writeText_sparse(const char *fn, const AzIntArr *ia, int digits) const {
    AzFile file(fn); 
    file.open("wb"); 
    AzBytArr s_header("sparse "); s_header.cn(rowNum()); s_header.nl(); 
    s_header.writeText(&file);

    int num; 
    const int *cxs = ia->point(&num); 
    int ix; 
    for (ix = 0; ix < num; ++ix) {
      int cx = cxs[ix];  
      AzBytArr s; 
      col(cx)->to_sparse(&s, digits); 
      s.nl(); 
      s.writeText(&file); 
    }
    file.close(true); 
  }
Example #10
0
WTableCell *WTableRow::elementAt(int column)
{
  return table_->elementAt(rowNum(), column);
}
 /*--------------------------------------*/
 virtual void writeText(const char *fn, int digits) const {
   AzIntArr ia; 
   ia.range(0, rowNum()); 
   writeText(fn, &ia, digits);  
 }