Re:Fortran 2023
by waynecochran on Wednesday November 22, 2023 @01:02PM
(#38382668)
C++ Eigen has become the defacto replacement for arrays for matrices and vectors. I am thinking this should make it more competitive w fortran in this domain.
Pick out the even (i,j where both even) elements from a matrix
m[0::2, 0::2] // Numpy
m(0::2, 0::2) // Fortran [1]
m(seq(0, last, 2), seq(0, last, 2)) // C++ Eigen
[1] If you have declared the array to start indexing from 0.
In C++ it is possible to define adequate types and operations for good support of multi-dimensional arrays, but this means that a user must choose some additional libraries to get the support that does not exist in the base language, unlike with Fortran.
C++ can be much better than Fortran for scientific computing, but only after a significant initial effort of establishing a well-specified programming style, based on selecting an appropriate non-obsolete subset of C++ and after selecting carefully a set of libraries that provide all the missing features.
For someone whose main job is not programming, using Fortran can be simpler.