42 #ifndef COO_MATRIX_TMPL_CONVERT_TO_SPARSE_COMPRESSED_COLUMN_DEF_H
43 #define COO_MATRIX_TMPL_CONVERT_TO_SPARSE_COMPRESSED_COLUMN_DEF_H
45 #include "AbstractLinAlgPack_COOMatrixTmplConvertToSparseCompressedColumnDecl.hpp"
47 namespace AbstractLinAlgPack {
49 template<
class T_COOM>
54 ,
const IVector::value_type* col_perm
60 typename T_COOM::difference_type loc_co = m.col_offset();
61 for(
typename T_COOM::const_iterator itr = m.begin(); itr != m.end(); ++itr )
62 num_in_col[ col_perm[ col_offset + loc_co + itr->col_j() -1 ] -1 ]++;
66 typename T_COOM::difference_type loc_ro = m.row_offset();
67 for(
typename T_COOM::const_iterator itr = m.begin(); itr != m.end(); ++itr ) {
69 num_in_col[ col_perm[ col_offset + loc_ro + i - 1 ] - 1 ]++;
75 template<
class T_COOM>
76 void COOM_insert_nonzeros(
82 ,
const IVector::value_type* row_perm
83 ,
const IVector::value_type* col_perm
85 , FortranTypes::f_dbl_prec* D_val
86 , FortranTypes::f_int* D_row_i )
89 typename T_COOM::difference_type
90 loc_ro = m.row_offset(),
91 loc_co = m.col_offset();
94 for(
typename T_COOM::const_iterator itr = m.begin(); itr != m.end(); ++itr ) {
96 i = loc_ro + itr->row_i(),
97 j = loc_co + itr->col_j();
99 ele = next_nz_in_col[ col_perm[ col_offset + j - 1 ] - 1 ]++;
100 D_val[ ele - 1 ] = alpha * itr->value();
102 D_row_i[ ele - 1 ] = row_perm[ row_offset + i - 1 ];
107 for(
typename T_COOM::const_iterator itr = m.begin(); itr != m.end(); ++itr ) {
109 i = loc_co + itr->col_j(),
110 j = loc_ro + itr->row_i();
112 ele = next_nz_in_col[ col_perm[ col_offset + j - 1 ] - 1 ]++;
113 D_val[ ele - 1 ] = alpha * itr->value();
115 D_row_i[ ele - 1 ] = row_perm[ row_offset + i - 1 ];
120 template<
class T_COOM>
121 value_type COOM_insert_scaled_nonzeros(
124 , value_type scaled_max_ele
127 ,
const IVector::value_type* row_perm
128 ,
const IVector::value_type* col_perm
130 , FortranTypes::f_dbl_prec* D_val
131 , FortranTypes::f_int* D_row_i )
133 value_type alpha = 0;
134 for(
typename T_COOM::const_iterator itr = m.begin(); itr != m.end(); ++itr ) {
135 register const value_type val = ::fabs( itr->value() );
136 if( val > alpha ) alpha = val;
139 alpha = scaled_max_ele / alpha;
140 COOM_insert_nonzeros( m, trans, alpha, row_offset
141 , col_offset, row_perm, col_perm, next_nz_in_col, D_val, D_row_i );
147 #endif // COO_MATRIX_TMPL_CONVERT_TO_SPARSE_COMPRESSED_COLUMN_DEF_H