Exemplo n.º 1
0
void
computeSV(flens::GeMatrix<flens::FullStorage<T, cxxblas::ColMajor> > &A, T &cB, T &CB) {
    flens::GeMatrix<flens::FullStorage<T, cxxblas::ColMajor> > U(A.numRows(),A.numRows()),
                                                               V(A.numCols(),A.numCols());
    DenseVector<Array<T> > s(A.numCols());
    int iterations = svd(A,s,U,V);
    CB = s(s.firstIndex());
    cB = s(s.lastIndex());
}
Exemplo n.º 2
0
void
computeEV(flens::GeMatrix<flens::FullStorage<T, cxxblas::ColMajor> > &A, T &cB, T &CB) {
    flens::GeMatrix<flens::FullStorage<T, cxxblas::ColMajor> > U(A.numRows(),A.numRows()),
                                                               V(A.numCols(),A.numCols());
    int N = A.numRows();
    DenseVector<Array<T> > wr(N), wi(N);
    flens::GeMatrix<flens::FullStorage<T, cxxblas::ColMajor> > vl,vr;
    ev(false, false, A, wr, wi, vl, vr);
    cB=wr(wr.firstIndex()), CB=wr(wr.lastIndex());
    for (int i=1; i<=wr.lastIndex(); ++i) {
        cB = std::min(cB,wr(i));
        CB = std::max(CB,wr(i));
    }
}
Exemplo n.º 3
0
void TriangleInvert(flens::GeMatrix<FS> &A, flens::DenseVector<flens::Array<int> > &p)
{
  assert(A.numRows()==A.numCols());

  int info = flens::tri(A, p);

  if (info != 0) {
    std::ostringstream oss;
    if (info < 0) {
      oss << "Internal FLENS/Lapack error: Error in argument " << -info
        << " of xxtri call.";
    }
    else {  // info > 0
      oss << "Error in triangle inversion: The matrix is singular with its " << info
        << " diagonal element exactly equal to zero.";
    }
    throw Exception(oss.str());
  }

}
void
read(flens::GeMatrix<flens::FullStorage<ElementType> > &GeMatrix, std::string filename)
{
	typedef int IndexType;
	IndexType j,k;
	FILE * in;

	// Format check
	std::string format;
	if ((typeid(ElementType)==typeid(int))
		|| (typeid(ElementType)==typeid(unsigned int))
		|| (typeid(ElementType)==typeid(long int))
		|| (typeid(ElementType)==typeid(long unsigned int))) format = "%d";
	else format = "%lf";


	if( (in = fopen(filename.c_str(),"r")) ==NULL)
	{
		perror("read: ");
		return;
	}
	if (fscanf(in,"%d %d",&j, &k)==0)
	{
		GeMatrix.resize(0,0);
	}
	else
	{ 
		GeMatrix.resize(j,k);
		for(IndexType r=1; r<=GeMatrix.numRows(); ++r)
		{
			for(IndexType c=1; c<=GeMatrix.numCols(); ++c)
			{
				fscanf(in, format.c_str(), &GeMatrix(r,c));
			}
		}
	}
};