25 SparseMatrix AB(
A.rows()*B.rows(),
A.cols()*B.cols());
31 Eigen::VectorXi nnzA = Eigen::VectorXi::Zero(
A.outerSize());
32 Eigen::VectorXi nnzB = Eigen::VectorXi::Zero(B.outerSize());
33 Eigen::VectorXi nnzAB = Eigen::VectorXi::Zero(AB.outerSize());
36 for (
int jA = 0; jA <
A.outerSize(); ++jA)
40 for (SparseMatrix::InnerIterator itA(
A, jA); itA; ++itA)
48 for (
int jB = 0; jB < B.outerSize(); ++jB)
52 for (SparseMatrix::InnerIterator itB(B, jB); itB; ++itB)
62 for (
int i = 0;
i < nnzA.rows(); ++
i)
64 for (
int j = 0; j < nnzB.rows(); ++j)
66 nnzAB(innz) = nnzA(
i) * nnzB(j);
73 double tolerance = std::numeric_limits<SparseMatrix::Scalar>::epsilon();
76 for (
int jA = 0; jA <
A.outerSize(); ++jA)
78 for (SparseMatrix::InnerIterator itA(
A, jA); itA; ++itA)
80 if (std::abs(itA.value()) > tolerance)
82 int jrow = itA.row() * B.rows();
83 int jcol = itA.col() * B.cols();
85 for (
int jB = 0; jB < B.outerSize(); ++jB)
87 for (SparseMatrix::InnerIterator itB(B, jB); itB; ++itB)
89 if (std::abs(itA.value()*itB.value()) > tolerance)
91 int row = jrow + itB.row();
92 int col = jcol + itB.col();
93 AB.insert(row,
col) = itA.value() * itB.value();
108 SparseMatrix temp1(1, 1);
109 temp1.insert(0, 0) = 1;
110 SparseMatrix temp2 = temp1;
114 for (
const auto& vec : vectors)
117 if (counter % 2 == 0)
119 temp1 = kroneckerProduct(temp2, vec);
123 temp2 = kroneckerProduct(temp1, vec);
130 if (counter % 2 == 0)
141 DenseVector temp1(1);
143 DenseVector temp2 = temp1;
147 for (
const auto& vec : vectors)
150 if (counter % 2 == 0)
152 temp1 = kroneckerProduct(temp2, vec);
156 temp2 = kroneckerProduct(temp1, vec);
163 if (counter % 2 == 0)
174 SparseMatrix temp1(1, 1);
175 temp1.insert(0, 0) = 1;
176 SparseMatrix temp2 = temp1;
180 for (
const auto& mat : matrices)
183 if (counter % 2 == 0)
185 temp1 = kroneckerProduct(temp2, mat);
189 temp2 = kroneckerProduct(temp1, mat);
196 if (counter % 2 == 0)