Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //matrix constructor
- mat::mat(int nrows,int ncols){
- this->nrows=nrows;
- this->ncols=ncols;
- this->dat=new float *[nrows];
- for(int i=0;i<nrows;i++){
- this->dat[i]=new float[ncols];
- for(int j=0;j<ncols;j++){
- this->dat[i][j]=-9999;
- }
- }
- }
- template<typename T>
- class mat {
- //matrix constructor
- mat(int nrows,int ncols) {
- this->nrows=nrows;
- this->ncols=ncols;
- this->dat=new T *[nrows];
- // ^
- for(int i=0;i<nrows;i++){
- this->dat[i]=new T[ncols];
- // ^
- for(int j=0;j<ncols;j++){
- this->dat[i][j]=-9999;
- }
- }
- };
- template<typename T>
- class mat {
- //matrix constructor
- mat(int nrows_,int ncols_)
- : nrows(nrows_) , ncols(ncols_) {
- dat.resize(nrows);
- for(int i=0;i<nrows;i++) {
- dat[i].resize(ncols);
- for(int j=0;j<ncols;j++) {
- dat[i][j]=-9999;
- }
- }
- }
- private:
- int nrows;
- int ncols;
- std::vector<std::vector<T>> dat;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement