void VectorView::set_to_product(const MatrixView& m, const VectorView& v, const bool transpose) { CBLAS_TRANSPOSE tr; if (transpose){ tr = CblasTrans; assert(m.cols() == length()); assert(m.rows() == v.length()); } else { tr = CblasNoTrans; assert(m.cols() == v.length()); assert(m.rows() == length()); } cblas_dgemv(CblasColMajor, tr, m.rows(), m.cols(), 1.0, m.data(), m.stride(), v.data(), 1, 0.0, data_, 1); }
double compute_allele_freq(const VectorView snp_genotypes) { double macount = 0; size_t ngenos = 0; for (size_t i = 0; i < snp_genotypes.length(); ++i){ if (snp_genotypes(i) >= 0){ macount += snp_genotypes(i); ++ngenos; } } return macount / (2.0 * ngenos); }
Vector(const VectorView &v) : VectorView(NULL, v.length_mem(), v.length()) { init(); for (size_t i = 0; i < length_; ++i) data_[i] = v.data()[i]; }
// static methods static double dotproduct(const VectorView &v1, const VectorView &v2) { assert(v1.length() == v2.length()); return cblas_ddot(v1.length(), v1.data_, 1, v2.data_, 1); }