Hi Lucas,
C++ doesn't allow us to overload operator[] with multiple arguments so that indexing has to be with single values - so yes, it's a language thing. This matches the C usage of square brackets where they only accept one value at a time.
The state attribute is automatically set by whatever functions you call - you should never need to mess with it (and in debug mode the class should abort if you try to do something that is inconsistent with the current state of the matrix). Internally, LAPACK
typically modifies matrices in-place so LAPACKFullMatrix behaves in a similar way. The only other place I would look for documentation is that class's own page:
If you have to do Newton iteration by setting up a Jacobian and solving a matrix then what you did makes sense. No matter what, if you are doing iterations, you have to compute a new Jacobian and solve a new linear system. The reinit() call is not expensive
- it just zeros the data, which is O(n^2) for an n x n matrix (as opposed to the LU factorization which is O(n^3)).
If you want to save some time you can reuse Jacobians (and therefore their factorizations) in Newton's method but that will cause things to converge more slowly, but it can be tricky to determine how often to recompute the Jacobian.
Is it bad programming practice to not reinitialize it? It isn't the worst thing you can do, but reinitializing it to guarantee that there aren't any irrelevant values stored is the right choice. In this case I think you have to reinitalize the matrix in order
to keep the state of the matrix consistent (it doesn't make sense to modify a matrix containing an LU factorization computed by LAPACK unless you have some knowledge of how LAPACK internally stores the factorization), so you need to do it no matter what.
Best,
David Wells