Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra?
Lawrence D’Oliveiro <[email protected]>
| Newsgroups | sci.math,comp.lang.fortran,comp.lang.python |
|---|---|
| Organization | A noiseless patient Spider |
| Message-ID | <[email protected]> |
On Sun, 6 Sep 2026 15:32:53 -0000 (UTC), Thomas Koenig wrote:
> Fortran 77 makes little sense, modern Fortran variants (Fortran 90+)
> are available with free compilers and offer much more comfort and
> safety.
Python offers custom operator overloads, so you can write actual
operator expressions for addition, dot product etc -- closer in
appearance to the actual maths -- instead of parenthesis-ridden
function calls.
For a simple example, this method constructs a 3D homogeneous matrix
that performs arbitrary scaling about an arbitrary centre point:
@classmethod
def scaling_about(celf, factor : Vector4, centre : Vector4) :
"constructs a Matrix4 that scales by the specified offset Vector4" \
" about the specified centre."
return \
(
celf.translation(centre)
@
celf.scaling(factor)
@
celf.translation(- centre)
)
#end scaling_about
From the body, you can see intuitively how it works, as the dot
product (“@” being the recommended Python operator to use for this) of
3 separate transformations: from right to left, you move the centre
point to the origin, perform the scaling about the origin, then
translate the origin back to the original centre point.