Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
0
 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];
 }
Ejemplo n.º 4
0
 // 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);
 }