MCPcopy Create free account
hub / github.com/ComputationalRobotics/XM-code / HostDnVecDouble

Class HostDnVecDouble

XM/include/Utils/memory.h:757–789  ·  view source on GitHub ↗

dense vector wrapper on host: double type

Source from the content-addressed store, hash-verified

755
756// dense vector wrapper on host: double type
757class 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
792class HostDnVecFloat {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected