1 #ifndef MKL_MATRIX_HEADER_HPP 2 #define MKL_MATRIX_HEADER_HPP 5 #include "shared_ptr.hpp" 9 typedef STD_TR1::shared_ptr<mkl_Matrix> ref;
10 typedef STD_TR1::shared_ptr<const mkl_Matrix> const_ref;
17 const complex* raw_storage()
const {
return get_storage();};
18 complex* raw_storage() {
return get_storage();};
20 const complex* raw_storage(
const row r,
const column c)
const {
return get_storage(r,c);};
21 complex* raw_storage(
const row r,
const column c) {
return get_storage(r,c);};;
23 enum trans {t_n,t_c,t_t};
24 void set_mkl_t_flag(trans t){tf = t;};
26 void flip_mkl_t_flag();
28 const char* t_flag()
const;
32 int ld()
const {
return ld_();};
35 static const char* c_t_n;
36 static const char* c_t_c;
37 static const char* c_t_t;
41 size_t num_rows()
const {
if (tf == t_n)
return n_rows();
return n_cols();}
42 size_t num_cols()
const {
if (tf == t_n)
return n_cols();
return n_rows();}
44 void scale(complex v);
46 void apply_two(
const complex* phi,
47 complex* result)
const;
49 virtual size_t n_rows()
const = 0;
50 virtual size_t n_cols()
const = 0;
52 virtual const complex* get_storage()
const = 0;
53 virtual complex* get_storage() = 0;
55 virtual const complex* get_storage(
const row r,
const column c)
const = 0;
56 virtual complex* get_storage(
const row r,
const column c) = 0;
58 virtual int ld_()
const{
59 if (tf == t_n)
return num_of_rows();
68 column c,
size_t colsize): myM(&t),
69 start(t.raw_storage(r,c)),
87 size_t n_rows()
const {
return rows;};
88 size_t n_cols()
const {
return cols;};
90 const complex* get_storage()
const {
return start;};
91 complex* get_storage() {
return start;};
93 const complex* get_storage(
const row r,
const column c)
const {
94 return myM->raw_storage(r+my_r,c+my_c);};
95 complex* get_storage(
const row r,
const column c){
96 return myM->raw_storage(r+my_r,c+my_c);};
99 myM->
Insert(r + my_r,c + my_c,v);
103 myM->
Add(r + my_r,c + my_c,v);
106 void scale(complex v);
109 return myM->
Get(r + my_r,c + my_c);
112 int ld_()
const {
return myM->ld();};
136 : data(p), nc(c.get()), nr(r.get()){};
139 : data(p), nc(r.get()), nr(r.get()){};
150 data[index(r,c)] = v;
154 data[index(r,c)] += v;
158 return data[index(r,c)];
161 const complex* get_storage()
const {
return data;};
162 complex* get_storage(){
return data;};
164 const complex* get_storage(
const row r,
165 const column c)
const {
return &data[index(r,c)];};
166 complex* get_storage(
const row r,
167 const column c){
return &data[index(r,c)];};
169 size_t index(
row r,
column c)
const {
return r.get() + c.get()*nr;};
171 size_t n_rows()
const {
return nr;};
172 size_t n_cols()
const {
return nc;};
180 std::vector<complex> get_diag()
const;
181 complex* get_diag(complex*)
const;
185 std::vector<complex> data;
189 data[index(r,c)] = v;
193 data[index(r,c)] += v;
197 return data[index(r,c)];
200 const complex* get_storage()
const {
return &data[0];};
201 complex* get_storage(){
return &data[0];};
203 const complex* get_storage(
const row r,
204 const column c)
const {
return &data[index(r,c)];};
205 complex* get_storage(
const row r,
206 const column c){
return &data[index(r,c)];};
209 size_t index(
row r,
column c)
const {
return r.get() + c.get()*N;};
211 size_t n_rows()
const {
return N;};
212 size_t n_cols()
const {
return N;};
220 : nc(c.get()), nr(r.get()), data(nc*nr){};
225 void resize(
const row r,
const column c);
228 size_t n_rows()
const {
return nr;};
229 size_t n_cols()
const {
return nc;};
233 std::vector<complex> data;
235 size_t index(
row r,
column c)
const {
return r.get() + c.get()*nr;};
238 data[index(r,c)] = v;
242 data[index(r,c)] += v;
246 return data[index(r,c)];
249 const complex* get_storage()
const{
return &data[0];};
250 complex* get_storage() {
return &data[0];};
251 const complex* get_storage(
const row r,
252 const column c)
const{
return &data[index(r,c)];};
253 complex* get_storage(
const row r,
254 const column c) {
return &data[index(r,c)];};
void Insert(row r, column c, complex v)
Insert an element at a given position (overwritten if already there)
Definition: matrix.hpp:92
complex Get(row r, column c) const
Obtain an element at a given position.
Definition: matrix.hpp:96
Definition: mkl_matrix.hpp:132
Definition: mkl_matrix.hpp:216
Definition: mkl_matrix.hpp:175
Definition: mkl_matrix.hpp:7
Definition: mkl_matrix.hpp:65
This Base-Class offers Matrix-Vector multiplication and scaling.
Definition: matrix.hpp:322
void Add(row r, column c, complex v)
Add an element at a given position.
Definition: matrix.hpp:94
Definition: mkl_matrix.hpp:115