const correctness

const correctness


I wrote a modular PDE-solver in C++ which makes heavy use of PARDISO and CRS-matrix-vector-multiplication. Everything works fine so far and PARDISO is really a great solver for a huge class of PDEs. The declaration for the multiplication-subroutine in the MKL is as follow

void mkl_dcsrgemv(char *transa, int *m, double *a, int *ia, int *ja, double *x, double *y);

Although nothing is affected by calling mkl_dsrgemv except *y, there are no const modifiers. A better declaration should be like

void mkl_dcsrgemv(char *transa, int *m, const double *a, const int *ia, const int *ja, const double *x, double *y);

This would allow better and more correct coding, since there is no need to const-cast-away modifiers or declare friend classes. Debugging or proving correctness of code could be more easier. Same for the PARDISO-Interface, of course.

Anyway, thanks for the nice tools!

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.