1 #ifndef CONSTANTSIZEMATRIX_H 2 #define CONSTANTSIZEMATRIX_H 22 template<
class T,
typename ALLOC = std::allocator<T>>
29 if (n_max <= 0 || n > n_max || m_max <= 0 || m > m_max)
30 throw std::runtime_error(
"Cannot construct ConstantSizeMatrix with an invalid size");
45 template<
class RHS,
typename allocator = ALLOC,
typename = IsHostSafe<allocator>>
48 if (this->
data_.capacity() < rhs.size())
49 throw std::runtime_error(
"Constant size vector cannot fit matrix to be copied.");
50 data_.assign(rhs.begin(), rhs.end());
55 throw std::runtime_error(
"Constant size vector cannot fit matrix to be copied.");
57 throw std::runtime_error(
"ConstantSizeMatrix.copy(ConstantSizeMatrix& rhs) &rhs == this");
64 throw std::runtime_error(
"ConstantSizeMatrix cannot take assignment of larger than max size");
70 throw std::runtime_error(
"ConstnatSizedMatrix assignment for mismatched n_max not yet supported.");
75 template<
template<
typename,
class>
class RHS,
82 if (this->
data_.capacity() < rhs.size())
83 throw std::runtime_error(
"ConstantSizeMatrix cannot be assigned a matrix larger than itself.");
84 data_.assign(rhs.begin(), rhs.end());
88 template<
class TP,
class ALLOCP,
typename = IsHostSafe<ALLOC>,
typename = IsHostSafe<ALLOCP>>
93 std::basic_ostringstream<char>
error;
94 error <<
"ConstantSizeMatrix cannot take assignment of larger than max size (" <<
n_max_ <<
" by " <<
m_max_ 96 throw std::runtime_error(
error.str());
100 std::basic_ostringstream<char>
error;
101 error <<
"ConstantSizeMatrix cannot be assigned a matrix dimension larger than n_max (" <<
n_max_ <<
")\n";
102 throw std::runtime_error(
error.str());
106 for (
size_t row = 0; row < rhs.
rows(); ++row)
119 template<
typename Allocator = ALLOC,
typename = IsHostSafe<Allocator>>
124 throw std::runtime_error(
"ConstantSizeMatrix doesn't support access to second row values through operator()");
128 template<
typename Allocator = ALLOC,
typename = IsHostSafe<Allocator>>
133 throw std::runtime_error(
"ConstantSizeMatrix doesn't support access to second row values through operator()");
138 template<
typename Allocator = ALLOC,
typename = IsHostSafe<Allocator>>
145 template<
typename Allocator = ALLOC,
typename = IsHostSafe<Allocator>>
165 std::ostringstream
error;
166 error <<
"You cannot resize a constant size matrix beyond its initial max dimensions ( " <<
m <<
"," <<
n <<
" > " 168 throw std::domain_error(
error.str());
ConstantSizeMatrix< T, ALLOC > & operator=(const Matrix< TP, ALLOCP > &rhs)
helper functions for EinsplineSetBuilder
void copy(const RHS &rhs)
Methods for assignment or copy of identically sized or smaller ConstantSizeMatrix<T, ALLOC>.
std::enable_if_t< qmc_allocator_traits< Allocator >::is_host_accessible > IsHostSafe
ConstantSizeMatrix & operator=(const ConstantSizeMatrix &rhs)
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
T & operator()(size_t i, size_t j)
void error(char const *m)
const T * operator[](size_t i) const
void resize(size_t m, size_t n)
ConstantSizeMatrix(const ConstantSizeMatrix &csm)
ConstantSizeMatrix(size_t m, size_t n, size_t m_max, size_t n_max, T val=T())
Drop in replacement for OhmmsMatrix as a storage object backed by PooledMemory, does not support PETE...
void copy(const ConstantSizeMatrix &rhs)
T operator()(size_t i) const
const T & operator()(size_t i, size_t j) const
std::vector< T, ALLOC > data_
ConstantSizeMatrix< T, ALLOC > & operator=(const RHS< TP, ALLOCP > &rhs)