Allocate memory for the values
| 229 | |
| 230 | // Allocate memory for the values |
| 231 | void allocate() { |
| 232 | if (this->vals == nullptr) { |
| 233 | this->vals = (T*)malloc(sizeof(T) * total_size); |
| 234 | if (this->vals && is_initial_value) { |
| 235 | std::fill(this->vals, this->vals + total_size, initial_value); |
| 236 | } |
| 237 | }else{ |
| 238 | std::cout << "Error: Vec already allocated!" << std::endl; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | // Print matrix, if matrix is larger the 3-dimension then donot print |
| 243 | void print() { |