Assuming that your arrays v and c are double arrays, you can just use the aux memory constructors:
From the armadillo doc:
mat(aux_mem*, n_rows, n_cols, copy_aux_mem = true, strict = true)
Create a matrix using data from writeable auxiliary memory. By default the matrix allocates its own memory and copies data from the auxiliary memory (for safety). However, if copy_aux_mem is set to false, the matrix will instead directly use the auxiliary memory (ie. no copying). This is faster, but can be dangerous unless you know what you're doing!
The strict variable comes into effect only if copy_aux_mem is set to false (ie. the matrix is directly using auxiliary memory). If strict is set to true, the matrix will be bound to the auxiliary memory for its lifetime; the number of elements in the matrix can't be changed (directly or indirectly). If strict is set to false, the matrix will not be bound to the auxiliary memory for its lifetime, ie., the size of the matrix can be changed. If the requested number of elements is different to the size of the auxiliary memory, new memory will be allocated and the auxiliary memory will no longer be used.
- mat(const aux_mem*, n_rows, n_cols)
Create a matrix by copying data from read-only auxiliary memory.
Which means you can create your matrixes by copying your source data like this:
mat A_Copy(v, SIZE, 1);
mat B_Copy(c, SIZE, 1);
Or you can actually reuse the memory you already have allocated for your arrays to create read-only matrixes, like this:
mat A_InPlace(v, SIZE, 1, /*copy_aux_mem*/false, /*strict*/true);
mat B_InPlace(c, SIZE, 1, /*copy_aux_mem*/false, /*strict*/true);
This gets even simpler if you use vectors
vec A_Vec_Copy(v, SIZE);
vec B_Vec_Copy(c, SIZE);
Or:
vec A_Vec_InPlace(v, SIZE, false, true);
vec B_Vec_InPlace(c, SIZE, false, true);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…