News for hackers. Stuff that matters.
Re:Why physicists still use Fortran (2015) by sbmassey on Sunday October 15, 2017 @01:33PM (#15478088)
Fair enough then, I suppose that in C you have to do something like that if you want both that your matrix size is decidable at runtime, and to be able to index it with m[x][y] rather than some function.
Re:Why physicists still use Fortran (2015) by iamrecursion on Sunday October 15, 2017 @02:43PM (#15478509)
That’s not strictly true. You can malloc an m*n sized array and then assign to another array the pointer to the head of each column, allowing you standard style indexing.
Re:Why physicists still use Fortran (2015) by PeterisP on Sunday October 15, 2017 @03:18PM (#15478745)
If you do that, every access will actually dereference that pointer and won't be able to optimize the standard style indexing to a multiplication and addition, so this still carries a significant performance cost.
Re:Why physicists still use Fortran (2015) by Peaker on Sunday October 15, 2017 @04:20PM (#15479084)
You can always use a macro (or inline function, if the array is a rich wrapper type):

  arr(m, x, y)
Not quite as nice, but not too bad.