From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:ac8:4253:: with SMTP id r19mr284807qtm.116.1588194486462; Wed, 29 Apr 2020 14:08:06 -0700 (PDT) X-Received: by 2002:a9d:6315:: with SMTP id q21mr28752715otk.16.1588194486135; Wed, 29 Apr 2020 14:08:06 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!fdn.fr!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 29 Apr 2020 14:08:05 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=176.151.7.118; posting-account=hya6vwoAAADTA0O27Aq3u6Su3lQKpSMz NNTP-Posting-Host: 176.151.7.118 References: <6c2c0e35-af07-4169-8be5-464ec7fd0fd5@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <5abd8196-b4cf-4394-9e5a-af034797f785@googlegroups.com> Subject: Re: GNAT vs Matlab - operation on multidimensional complex matrices From: vincent.diemunsch@gmail.com Injection-Date: Wed, 29 Apr 2020 21:08:06 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:58528 Date: 2020-04-29T14:08:05-07:00 List-Id: Le mardi 31 mars 2020 21:20:45 UTC+2, Simon Wright a =C3=A9crit=C2=A0: > Shark8 writes: >=20 > > Ok then; the following should have convention Fortran IIRC: > > > > type tCubeReal is array (1..NumChannels, 1..NumAngles, 1..NumRanges) of= mReal > > with Convention =3D> Fortran; >=20 > I wondered about this; the code ran considerably slower with Convention > =3D> Fortran. In Row Major (Convention Fortran) one needs to iterate on the first dimensi= on, then the second and finally the third, to stay on contiguous regions in= memory (and hence in the cache). So the loop must put the first dimension = in the center : for p in M=E2=80=99Range(3) loop for n in M=E2=80=99Range (2) loop for m in M=E2=80=99Range (1) loop ... M(m, n, p) This is somehow counter-intuitive. But Row Major (like Little-endian with w= hich it is closely related) has more properties (like extracting a submatri= x or conforming to classical linear algebra) and is therefore preferred by = scientists. Regards, Vincent