5 #ifndef FML__INTERNALS_MATRIX_H
6 #define FML__INTERNALS_MATRIX_H
29 template <
typename REAL>
34 bool is_square()
const {
return (this->m==this->n);};
36 len_t
nrows()
const {
return m;};
38 len_t
ncols()
const {
return n;};
41 REAL*
data_ptr()
const {
return data;};
49 bool should_free()
const {
return free_data;};
50 void check_index(
const len_t i)
const;
51 void check_index(
const len_t i,
const len_t j)
const;
52 void printval(
const REAL val, uint8_t ndigits)
const;
58 template <
typename REAL>
61 if (i < 0 || i >= (this->m * this->n))
62 throw std::runtime_error(
"index out of bounds");
65 template <
typename REAL>
68 if (i < 0 || i >= this->m || j < 0 || j >= this->n)
69 throw std::runtime_error(
"index out of bounds");
78 fml::print::printf(
"%d ", val);
85 fml::print::printf(
"%.*f ", ndigits, (
float)val);
89 template <
typename REAL>
92 fml::print::printf(
"%.*f ", ndigits, val);