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)); } }
/*--------------------------------------*/ virtual void writeText(const char *fn, int digits, bool doSparse=false, bool doAppend=false) const { AzIntArr ia; ia.range(0, colNum()); writeText(fn, &ia, digits, doSparse, doAppend); }
double max() const { double mymax = 0; int cx; for (cx = 0; cx < colNum(); ++cx) { double colmax = col(cx)->max(); if (cx == 0 || colmax > mymax) mymax = colmax; } return mymax; }
double min() const { double mymin = 0; int cx; for (cx = 0; cx < colNum(); ++cx) { double colmin = col(cx)->min(); if (cx == 0 || colmin < mymin) mymin = colmin; } return mymin; }
/*--- 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]); } }
RcppExport SEXP GetPoint(SEXP x,SEXP p,SEXP c) { try { Rcpp::XPtr< flann::Index<flann::L2<float> > > index(x); Rcpp::NumericVector point(p); Rcpp::NumericVector colNum(c); float* indexPoint = index->getPoint(point[0]); Rcpp::NumericVector results; for(int i=0;i<colNum[0];i++) { results.push_back(*(indexPoint+i)); } return results; // -Wall } catch( std::exception &ex ) { // or use END_RCPP macro forward_exception_to_r( ex ); } catch(...) { ::Rf_error( "c++ exception (unknown reason)" ); } return R_NilValue; // -Wall }
inline void set(double val) { int col; for (col = 0; col < colNum(); ++col) { col_u(col)->set(val); } }