summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/mat_cr.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/plib/mat_cr.h')
-rw-r--r--src/lib/netlist/plib/mat_cr.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/lib/netlist/plib/mat_cr.h b/src/lib/netlist/plib/mat_cr.h
index 3cf2570b725..7fc5d46b85d 100644
--- a/src/lib/netlist/plib/mat_cr.h
+++ b/src/lib/netlist/plib/mat_cr.h
@@ -67,13 +67,20 @@ namespace plib
, m_size(n)
{
for (index_type i=0; i<n+1; i++)
- A[i] = 0;
+ row_idx[i] = 0;
}
~matrix_compressed_rows_t() = default;
constexpr index_type size() const { return static_cast<index_type>((N>0) ? N : m_size); }
+ void clear()
+ {
+ nz_num = 0;
+ for (index_type i=0; i < size() + 1; i++)
+ row_idx[i] = 0;
+ }
+
void set_scalar(const T scalar)
{
for (index_type i=0, e=nz_num; i<e; i++)
@@ -86,7 +93,7 @@ namespace plib
while (ri < row_idx[r+1] && col_idx[ri] < c)
ri++;
// we have the position now;
- if (nz_num > 0 && col_idx[ri] == c)
+ if (ri < row_idx[r+1] && col_idx[ri] == c)
A[ri] = val;
else
{
@@ -97,7 +104,7 @@ namespace plib
}
A[ri] = val;
col_idx[ri] = c;
- for (C i = row_idx[r]; i < size()+1;i++)
+ for (C i = r + 1; i < size() + 1; i++)
row_idx[i]++;
nz_num++;
if (c==r)