From a40a9b079ca4c84b52fb1c44f538a674fd345d06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 8 Jun 2021 17:58:40 +0200
Subject: [PATCH] sparse_hessian_times_B_kronecker_C MEX: bugfix relating to
 number of rows of B and C

In practice however, it seems that this bug never hits, because B and C always
have the same number of rows when the MEX is called.
---
 mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc b/mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc
index 5eaa7eee59..f15e512231 100644
--- a/mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc
+++ b/mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2007-2020 Dynare Team
+ * Copyright © 2007-2021 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -114,8 +114,8 @@ sparse_hessian_times_B_kronecker_C(const mwIndex *isparseA, const mwIndex *jspar
           if (k1 < k2) // otherwise column ii of A does not have non zero elements (and there is nothing to compute).
             {
               ++nz_in_column_ii_of_A;
-              mwIndex iC = ii % mB;
-              mwIndex iB = ii / mB;
+              mwIndex iC = ii % mC;
+              mwIndex iB = ii / mC;
               double cb = C[jC*mC+iC]*B[jB*mB+iB];
               /*
               ** Loop over the non zero entries of A(:,ii).
-- 
GitLab