dense vector wrapper on host: double type
| 755 | |
| 756 | // dense vector wrapper on host: double type |
| 757 | class HostDnVecDouble { |
| 758 | public: |
| 759 | int size; |
| 760 | double* vals; |
| 761 | |
| 762 | HostDnVecDouble(): size(0), vals(nullptr) {} |
| 763 | HostDnVecDouble(const int size, bool as_byte = false): size(size), vals(nullptr) { |
| 764 | this->allocate(size, as_byte); |
| 765 | } |
| 766 | |
| 767 | inline void allocate(const int size, bool as_byte = false) { |
| 768 | if (this->vals == nullptr) { |
| 769 | if (as_byte) { |
| 770 | this->size = (size + sizeof(double) - 1) / sizeof(double); |
| 771 | } else { |
| 772 | this->size = size; |
| 773 | } |
| 774 | this->vals = (double*) malloc(sizeof(double) * this->size); |
| 775 | } |
| 776 | return; |
| 777 | } |
| 778 | inline double get_norm() { |
| 779 | return cblas_dnrm2(this->size, this->vals, 1); |
| 780 | } |
| 781 | |
| 782 | ~HostDnVecDouble() { |
| 783 | if (this->vals != nullptr) { |
| 784 | free(this->vals); |
| 785 | this->vals = nullptr; |
| 786 | } |
| 787 | // std::cout << "HostDnVecDouble destructor called!" << std::endl; |
| 788 | } |
| 789 | }; |
| 790 | |
| 791 | // dense vector wrapper on host: float type |
| 792 | class HostDnVecFloat { |
nothing calls this directly
no outgoing calls
no test coverage detected