TaucsSolverT.cc 1.97 KB
Newer Older
David Bommes's avatar
David Bommes committed
1 2 3 4 5
#define COMISO_TAUCS_SOLVER_TEMPLATES_C

#include "TaucsSolver.hh"


6 7 8 9
//== COMPILE-TIME PACKAGE REQUIREMENTS ========================================
#include <CoMISo/Config/config.hh>
#if COMISO_TAUCS_AVAILABLE

David Bommes's avatar
David Bommes committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
namespace COMISO {


template< class GMM_MatrixT>
void TaucsSolver::calc_system_gmm( const GMM_MatrixT& _mat)
  {
    COMISO_GMM::get_ccs_symmetric_data( _mat,
				 'l',
				   values_, 
				 rowind_, 
				 colptr_ );

    calc_system();
  }
  

  //-----------------------------------------------------------------------------


template< class GMM_MatrixT>
void TaucsSolver::update_system_gmm( const GMM_MatrixT& _mat)
  {
    COMISO_GMM::get_ccs_symmetric_data( _mat,
				 'l',
				   values_, 
				 rowind_, 
				 colptr_ );

    update_system();
  }



  //-----------------------------------------------------------------------------


template< class GMM_MatrixT>
void TaucsSolver::init_system_gmm( const GMM_MatrixT& _mat)
  {
    COMISO_GMM::get_ccs_symmetric_data( _mat,
				 'l',
				   values_, 
				 rowind_, 
				 colptr_ );
    int n   = colptr_.size()-1;

    mat_.n = n;
    mat_.m = n;
    mat_.flags = TAUCS_DOUBLE | TAUCS_SYMMETRIC | TAUCS_LOWER;

    mat_.colptr   = &(colptr_[0]);
    mat_.rowind   = &(rowind_[0]);
    mat_.values.d = &(values_[0]);

  }


//-----------------------------------------------------------------------------

template< class GMM_MatrixT>
void TaucsSolver::get_matrix_gmm( GMM_MatrixT& _mat)
  {
    gmm::resize( _mat, mat_.n, mat_.n);
    gmm::clear( _mat);
 
    // for all columns
    for(int j=0; j<(int)colptr_.size()-1; ++j)
    {
      // for all lower triangular values
      for(int i=colptr_[j]; i<colptr_[j+1]; ++i)
      {
	// set value
	_mat(rowind_[i],j) = values_[i];
	// symmetric part
	_mat(j,rowind_[i]) = values_[i];
      }
    }
  }

}
90 91 92 93

//=============================================================================
#endif // COMISO_TAUCS_AVAILABLE
//=============================================================================