more robust handling of aux_mem

This commit is contained in:
conrad
2026-06-16 12:33:54 +10:00
parent 453bef9283
commit 033c93196c
2 changed files with 53 additions and 5 deletions
+28 -3
View File
@@ -807,11 +807,29 @@ Cube<eT>::Cube(eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols, cons
{
init_cold();
arrayops::copy( memptr(), aux_mem, n_elem );
if(aux_mem == nullptr)
{
arrayops::fill_zeros(memptr(), n_elem);
}
else
{
arrayops::copy( memptr(), aux_mem, n_elem );
}
}
else
{
create_mat();
if(aux_mem == nullptr)
{
access::rw(mem_state) = 0;
init_cold();
arrayops::fill_zeros(memptr(), n_elem);
}
else
{
create_mat();
}
}
}
@@ -835,7 +853,14 @@ Cube<eT>::Cube(const eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols
init_cold();
arrayops::copy( memptr(), aux_mem, n_elem );
if(aux_mem == nullptr)
{
arrayops::fill_zeros(memptr(), n_elem);
}
else
{
arrayops::copy( memptr(), aux_mem, n_elem );
}
}
+25 -2
View File
@@ -1369,7 +1369,23 @@ Mat<eT>::Mat(eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols, const
{
init_cold();
arrayops::copy( memptr(), aux_mem, n_elem );
if(aux_mem == nullptr)
{
arrayops::fill_zeros(memptr(), n_elem);
}
else
{
arrayops::copy( memptr(), aux_mem, n_elem );
}
}
else
if(aux_mem == nullptr)
{
access::rw(mem_state) = 0;
init_cold();
arrayops::fill_zeros(memptr(), n_elem);
}
}
@@ -1392,7 +1408,14 @@ Mat<eT>::Mat(const eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols)
init_cold();
arrayops::copy( memptr(), aux_mem, n_elem );
if(aux_mem == nullptr)
{
arrayops::fill_zeros(memptr(), n_elem);
}
else
{
arrayops::copy( memptr(), aux_mem, n_elem );
}
}