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.
[ Parent
| on HN ]
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.