24 typedef ValueT ValueType;
25 typedef MatrixInternal<ValueType> ThisType;
29 MatrixInternal(
bool is_variable_block =
false)
30 : m_profile(
new ProfileType(is_variable_block))
35 void setValues(ValueT value)
37 m_values.fill(value) ;
40 ConstArrayView<ValueType> getValues()
const {
return m_values; }
42 UniqueArray<ValueType>& getValues() {
return m_values; }
44 ValueType* getDataPtr() {
return m_values.data(); }
46 ValueType
const* getDataPtr()
const {
return m_values.data(); }
51 const CSRStructInfo& getCSRProfile()
const {
return *m_profile; }
53 Integer getRowSize(Integer row)
const {
return m_profile->getRowSize(row); }
55 void scal(ValueType
const* diag)
57 auto nrows = m_profile->getNRows() ;
58 auto kcol = m_profile->kcol() ;
59 for(
int irow=0;irow<nrows;++irow)
61 ValueType scal = diag[irow] ;
62 for(
int k=kcol[irow];k<kcol[irow+1];++k)
67 void clear() { m_values.resize(0); }
69 MatrixInternal<ValueT>* clone()
const {
return new MatrixInternal<ValueT>(*
this); }
72 void copy(
const MatrixInternal<T>& internal)
74 m_values.copy(internal.getValues());
75 m_profile->copy(internal.getCSRProfile());
79 void copy(
const MatrixInternal<T>& internal, Integer block_size1, Integer block_size2, Integer nb_blocks)
81 auto const& values2 = internal.getValues() ;
82 if(block_size1==block_size2)
83 m_values.copy(values2);
84 else if(block_size1==1)
86 Integer stride2 = block_size2*block_size2 ;
88 m_values.resize(nb_blocks) ;
89 for(Integer ib=0;ib<nb_blocks;++ib)
91 m_values[ib] = values2[offset2];
97 Integer stride1 = block_size1*block_size1 ;
98 Integer stride2 = block_size2*block_size2 ;
100 Integer offset2 = 0 ;
101 m_values.resize(nb_blocks*stride1) ;
102 for(Integer ib=0;ib<nb_blocks;++ib)
104 for(Integer i=0;i<block_size1;++i)
105 for(Integer j=0;j<block_size1;++j)
106 m_values[offset1 + i*block_size1+j] = values2[offset2+ i*block_size2+j];
111 m_profile->copy(internal.getCSRProfile());
116 return m_is_update !=
true;
129 bool m_is_update =
false;
130 UniqueArray<ValueType> m_values;
131 std::shared_ptr<CSRStructInfo> m_profile;