Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #197963
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> |
| Newsgroups | sci.math, comp.lang.fortran, comp.lang.python |
| Subject | Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? |
| Date | Mon, 7 Sep 2026 04:41:38 -0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 74 |
| Message-ID | <117lfa2$2u9p1$1@dont-email.me> (permalink) |
| References | <WFfnS.67381$kqHe.6119@fx07.ams4> <117k135$2fr7o$1@dont-email.me> <117knq7$2o0bv$4@dont-email.me> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Mon, 07 Sep 2026 04:41:39 +0000 (UTC) |
| Injection-Info | dont-email.me; logging-data="3090209"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+HLQKuKC2iyD3AJi0gZYDD"; posting-host="f823273bc465a27fd3e8b733bef3ebdd" |
| User-Agent | Pan/0.164 (Kupiansk) |
| Cancel-Lock | sha1:VC+Md8jjl26UDxWVQZDm2BLH5U8= sha256:JyMAFUgFrkLqyVlx5X4Sp6k7YwGd74XIisj7b2VM+HU= sha1:SWKr7Lldik9/MppknT+EZg3v558= sha256:qhbQLW6lXcN89EqfSQRy89HlXhf9G1SG5xJxaU1AcNc= |
| Xref | csiph.com sci.math:647459 comp.lang.fortran:126649 comp.lang.python:197963 |
Cross-posted to 3 groups.
Show key headers only | View raw
On Sun, 6 Sep 2026 22:00:39 -0000 (UTC), Lawrence D’Oliveiro wrote:
> 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.
Can we assume you know little to nothing about modern
Fortran? One can write custom operator overloads in
Fortran. Here's a Cartesian point with a translation
and scaling operators.
module pointm
implicit none
type point_t
real x, y, z
end type point_t
interface operator(-)
module procedure translate
end interface
interface operator(*)
module procedure left
module procedure rght
end interface
contains
function translate(pt1, pt2) result(r)
type(point_t) r
type(point_t), intent(in) :: pt1, pt2
r%x = pt1%x - pt2%x
r%y = pt1%y - pt2%y
r%z = pt1%z - pt2%z
end function translate
function left(c, pt1) result(r)
type(point_t) r
real, intent(in) :: c
type(point_t), intent(in) :: pt1
r%x = c * pt1%x
r%y = c * pt1%y
r%z = c * pt1%z
end function left
function rght(pt1, c) result(r)
type(point_t) r
real, intent(in) :: c
type(point_t), intent(in) :: pt1
r%x = c * pt1%x
r%y = c * pt1%y
r%z = c * pt1%z
end function rght
end module pointm
program foo
use pointm
type(point_t) :: a = point_t(1, 1, 1), b = point_t(0.5, 0.75, 2)
print "(3F6.2)", a - b
print "(3F6.2)", 3. * a - 4. * b
end program
--
steve
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-06 23:29 +0800
Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? Thomas Koenig <tkoenig@netcologne.de> - 2026-09-06 15:32 +0000
Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> - 2026-09-06 23:53 +0800
Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? Cóilín Nioclásín Glostéir <thanks-to@Taf.com> - 2026-09-06 17:30 +0000
Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? Thomas Koenig <tkoenig@netcologne.de> - 2026-09-06 19:47 +0000
Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? "David Jones" <dajhawkxx@nowherel.com> - 2026-09-06 18:40 +0000
Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? Thomas Koenig <tkoenig@netcologne.de> - 2026-09-06 19:49 +0000
Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-09-06 22:00 +0000
Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-09-07 10:48 +0800
Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> - 2026-09-07 04:41 +0000
Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-09-07 13:24 +0800
Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-09-07 06:47 +0000
Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-09-07 16:32 +0800
Re: Blog: Is Fortran better than Python for teaching the basics of numerical linear algebra? Thomas Koenig <tkoenig@netcologne.de> - 2026-09-07 05:08 +0000
csiph-web