6DeviceDenseMatrix<Ty>::DeviceDenseMatrix(
size_t row,
size_t col,
bool sym)
10 , m_data{muda::Extent2D{col, row}}
14DeviceDenseMatrix<Ty>::DeviceDenseMatrix(DeviceDenseMatrix&& other)
17 , m_data{std::move(other.m_data)}
23DeviceDenseMatrix<Ty>& DeviceDenseMatrix<Ty>::operator=(DeviceDenseMatrix&& other)
29 m_data = std::move(other.m_data);
37void DeviceDenseMatrix<Ty>::reshape(
size_t row,
size_t col)
45void DeviceDenseMatrix<Ty>::fill(Ty value)
51void DeviceDenseMatrix<Ty>::copy_to(Eigen::MatrixX<Ty>& mat)
const
53 std::vector<Ty> host_data;
54 m_data.copy_to(host_data);
55 mat.resize(m_row, m_col);
57 for(
size_t i = 0; i < m_row; ++i)
59 for(
size_t j = 0; j < m_col; ++j)
61 mat(i, j) = host_data[j * m_row + i];
66void DeviceDenseMatrix<Ty>::copy_to(std::vector<Ty>& vec)
const
71DeviceDenseMatrix<Ty>::DeviceDenseMatrix(
const Eigen::MatrixX<Ty>& mat)
73 reshape(mat.rows(), mat.cols());
74 std::vector<Ty> host_data(m_row * m_col);
76 for(
size_t i = 0; i < m_row; ++i)
78 for(
size_t j = 0; j < m_col; ++j)
80 host_data[j * m_row + i] = mat(i, j);
83 m_data.copy_from(host_data);
86DeviceDenseMatrix<Ty>& DeviceDenseMatrix<Ty>::operator=(
const Eigen::MatrixX<Ty>& mat)
88 if(mat.rows() != m_row || mat.cols() != m_col)
90 reshape(mat.rows(), mat.cols());
92 std::vector<Ty> host_data(m_row * m_col);
94 for(
size_t i = 0; i < m_row; ++i)
96 for(
size_t j = 0; j < m_col; ++j)
98 host_data[j * m_row + i] = mat(i, j);
102 m_data.copy_from(host_data);
105template <
typename Ty>
106DenseMatrixView<Ty> DeviceDenseMatrix<Ty>::T()
108 return DenseMatrixView{m_data, m_row, m_col,
true, m_sym};
111template <
typename Ty>
112CDenseMatrixView<Ty> DeviceDenseMatrix<Ty>::T()
const
114 return CDenseMatrixView{m_data, m_row, m_col,
true, m_sym};
117template <
typename Ty>
118DenseMatrixView<Ty> DeviceDenseMatrix<Ty>::view()
120 return DenseMatrixView<Ty>{m_data.view(), m_row, m_col,
false, m_sym};
123template <
typename Ty>
124CDenseMatrixView<Ty> DeviceDenseMatrix<Ty>::view()
const
126 return CDenseMatrixView<Ty>{m_data.view(), m_row, m_col,
false, m_sym};
129template <
typename Ty>
130DeviceDenseMatrix<Ty>::operator CDenseMatrixView<Ty>()
const
134template <
typename Ty>
135DeviceDenseMatrix<Ty>::operator DenseMatrixView<Ty>()