| 800 | } |
| 801 | |
| 802 | inline void allocate(const int size, bool as_byte = false) { |
| 803 | if (this->vals == nullptr) { |
| 804 | if (as_byte) { |
| 805 | this->size = (size + sizeof(float) - 1) / sizeof(float); |
| 806 | } else { |
| 807 | this->size = size; |
| 808 | } |
| 809 | this->vals = (float*) malloc(sizeof(float) * this->size); |
| 810 | } |
| 811 | return; |
| 812 | } |
| 813 | inline float get_norm() { |
| 814 | return cblas_snrm2(this->size, this->vals, 1); |
| 815 | } |