const-correctness in header files
Posted: Wed Nov 20, 2013 5:11 am
Dear all,
I have a question regarding the const-correctness in header files. Let's take for example
magma_int_t magma_dgetrs_gpu( char trans, magma_int_t n, magma_int_t nrhs, double *dA, magma_int_t ldda, magma_int_t *ipiv, double *dB, magma_int_t lddb, magma_int_t *info);
If I look in the source code, I would expect a different definition:
magma_int_t magma_dgetrs_gpu( char trans, magma_int_t n, magma_int_t nrhs, const double *dA, magma_int_t ldda, const magma_int_t *ipiv, double *dB, magma_int_t lddb, magma_int_t *info);
since the matrix A and the vector piv are not changed by the function. The same holds for some other functions.
In contrast, the function magma_dprint and magma_dprint_gpu are defined with the const attribute.
CUBLAS also uses it in the declarations.
So, why are the const attributes often missing in MAGMA? It would be helpful the have them.
I have a question regarding the const-correctness in header files. Let's take for example
magma_int_t magma_dgetrs_gpu( char trans, magma_int_t n, magma_int_t nrhs, double *dA, magma_int_t ldda, magma_int_t *ipiv, double *dB, magma_int_t lddb, magma_int_t *info);
If I look in the source code, I would expect a different definition:
magma_int_t magma_dgetrs_gpu( char trans, magma_int_t n, magma_int_t nrhs, const double *dA, magma_int_t ldda, const magma_int_t *ipiv, double *dB, magma_int_t lddb, magma_int_t *info);
since the matrix A and the vector piv are not changed by the function. The same holds for some other functions.
In contrast, the function magma_dprint and magma_dprint_gpu are defined with the const attribute.
CUBLAS also uses it in the declarations.
So, why are the const attributes often missing in MAGMA? It would be helpful the have them.