Hey Guys, I have a doubt in c++ I am trying to develop a complex number matrix (a+bi) which takes 320k values in each row. Initially, we dump zeros into a matrix like this (0+0i).

Then during the execution of the program, we dump the data we have obtained.

Then during the execution of the program, we dump the data we have obtained.

Do more with

EXPERT OFFICE^{®} is a registered trademark of EXPERTS EXCHANGE^{®}

Write a Complex class.

Write a generic Matrix class.

Instanciate a Matric<Complex> object.

A Matrix class can start as follow:

```
#ifndef _MATRIX_T
#define _MATRIX_T
#include <vector>
#include <cassert>
template<class T>
class Matrix{
public:
Matrix(std::size_t width, std::size_t height, T const& t = T{}) :
w{width},
h{height},
datas{w*h, t}
{}
Matrix(Matrix const& m) = default;
Matrix& operator=(Matrix const& m) = default;
Matrix(Matrix&& m) noexcept = default;
Matrix& operator=(Matrix&& m) noexcept = default;
T const& operator()(std::size_t x, std::size_t y) const{
assert(x < w && y < h && "Out of bound");
return datas[y*w+x];
}
T& operator()(std::size_t x, std::size_t y){
assert(x < w && y < h && "Out of bound");
return datas[y*w+x];
}
std::size_t width() const{ return w; }
std::size_t height() const{ return h; }
private:
std::size_t w;
std::size_t h;
std::vector<T> datas;
};
#endif
```

you could try to use a complex number class (or struct) that only needs 8 byte storage. for example by using float type for a and b. or if the number of decimal places is fixed by using integer type (it giv3s 9 to 10 significant figures both for and b) . even then, you will need some mechanisms to store the whole matrix to hard disc and load only a part of rows and columns for the calculations.

Sara

## Premium Content

You need an Expert Office subscription to comment.Start Free Trial