Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Wherever you go...There you are. -- Buckaroo Banzai


devel / comp.lang.fortran / Re: SCALE intrinsic subprogram (aka a Fortran post)

SubjectAuthor
* SCALE intrinsic subprogram (aka a Fortran post)Steven G. Kargl
+- Re: SCALE intrinsic subprogram (aka a Fortran post)gah4
`* Re: SCALE intrinsic subprogram (aka a Fortran post)gah4
 `* Re: SCALE intrinsic subprogram (aka a Fortran post)pehache
  +* Re: SCALE intrinsic subprogram (aka a Fortran post)Steven G. Kargl
  |`* Re: SCALE intrinsic subprogram (aka a Fortran post)pehache
  | +* Re: SCALE intrinsic subprogram (aka a Fortran post)David Jones
  | |`* Re: SCALE intrinsic subprogram (aka a Fortran post)Thomas Koenig
  | | `* Re: SCALE intrinsic subprogram (aka a Fortran post)Steven G. Kargl
  | |  `* Re: SCALE intrinsic subprogram (aka a Fortran post)David Jones
  | |   `* Re: SCALE intrinsic subprogram (aka a Fortran post)Thomas Koenig
  | |    `- Re: SCALE intrinsic subprogram (aka a Fortran post)David Jones
  | `- Re: SCALE intrinsic subprogram (aka a Fortran post)pehache
  `* Re: SCALE intrinsic subprogram (aka a Fortran post)Thomas Koenig
   `- Re: SCALE intrinsic subprogram (aka a Fortran post)pehache

1
SCALE intrinsic subprogram (aka a Fortran post)

<ui6clh$3idu5$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3747&group=comp.lang.fortran#3747

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: sgk@REMOVEtroutmask.apl.washington.edu (Steven G. Kargl)
Newsgroups: comp.lang.fortran
Subject: SCALE intrinsic subprogram (aka a Fortran post)
Date: Sat, 4 Nov 2023 21:21:53 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <ui6clh$3idu5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 4 Nov 2023 21:21:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6554d0cdcf134d4fd59beabb8e1902f5";
logging-data="3749829"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gNINyQQts6FlpyIY6ZIsB"
User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a
git.gnome.org/pan2)
Cancel-Lock: sha1:s4gmu9hVPThcQiUDMfrAj1/sa4o=
 by: Steven G. Kargl - Sat, 4 Nov 2023 21:21 UTC

The SCALE intrinsic allows one to change the
floating point exponent for a REAL entity.
For example,

program foo
real x
x = 1
print *, scale(x,1) ! print 2
end program

This scaling does not incur a floating point
rounding error.

Question. Anyone know why the Fortran standard (aka J3)
restricted X to be a REAL entity? It would seem that X
could be COMPLEX with obvious equivalence of

SCALE(X,N) = COMPLX(SCALE(X%RE,N),SCALE(X%IM,N),KIND(X%IM))

Should the Fortran be amended?

--
steve

Re: SCALE intrinsic subprogram (aka a Fortran post)

<472d8ab0-e509-43b2-bf6a-67eaf6254494@ugcs.caltech.edu>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3750&group=comp.lang.fortran#3750

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gah@ugcs.caltech.edu (gah4)
Newsgroups: comp.lang.fortran
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
Date: Wed, 15 Nov 2023 17:17:50 -0800
Organization: UW
Lines: 34
Message-ID: <472d8ab0-e509-43b2-bf6a-67eaf6254494@ugcs.caltech.edu>
References: <ui6clh$3idu5$1@dont-email.me>
Reply-To: gah4@u.washington.edu
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="fec60aff88968fe0373ca9227aa8b7f3";
logging-data="2077308"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19U5AJokMibhw1OlgDzs0sF"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:VjvYlQhq9kM9wHfZCFMOk+6w0E4=
Content-Language: en-US
In-Reply-To: <ui6clh$3idu5$1@dont-email.me>
 by: gah4 - Thu, 16 Nov 2023 01:17 UTC

On 11/4/23 2:21 PM, Steven G. Kargl wrote:
> The SCALE intrinsic allows one to change the
> floating point exponent for a REAL entity.
> For example,
>
> program foo
> real x
> x = 1
> print *, scale(x,1) ! print 2
> end program
>
> This scaling does not incur a floating point
> rounding error.
>
> Question. Anyone know why the Fortran standard (aka J3)
> restricted X to be a REAL entity? It would seem that X
> could be COMPLEX with obvious equivalence of
>
> SCALE(X,N) = COMPLX(SCALE(X%RE,N),SCALE(X%IM,N),KIND(X%IM))
>
> Should the Fortran be amended?

Wow, no answer yet.

It does seem that sometimes Fortran is slow to add features, especially
when need for them isn't shown.

It does make sense to have the complex version, though as you note, it
isn't all that hard to get away without it.

If I had a vote, it would be yes.

Re: SCALE intrinsic subprogram (aka a Fortran post)

<d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3751&group=comp.lang.fortran#3751

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gah@ugcs.caltech.edu (gah4)
Newsgroups: comp.lang.fortran
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
Date: Wed, 15 Nov 2023 17:28:06 -0800
Organization: UW
Lines: 34
Message-ID: <d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu>
References: <ui6clh$3idu5$1@dont-email.me>
Reply-To: gah4@u.washington.edu
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="fec60aff88968fe0373ca9227aa8b7f3";
logging-data="2080857"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Hq/3jtK9Yw4mP2/Inl8yh"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Pm18JLmQWjZ+1KQ+cY7oqb8oBBU=
In-Reply-To: <ui6clh$3idu5$1@dont-email.me>
Content-Language: en-US
 by: gah4 - Thu, 16 Nov 2023 01:28 UTC

On 11/4/23 2:21 PM, Steven G. Kargl wrote:
> The SCALE intrinsic allows one to change the
> floating point exponent for a REAL entity.
> For example,
>
> program foo
> real x
> x = 1
> print *, scale(x,1) ! print 2
> end program
>
> This scaling does not incur a floating point
> rounding error.
>
> Question. Anyone know why the Fortran standard (aka J3)
> restricted X to be a REAL entity? It would seem that X
> could be COMPLEX with obvious equivalence of
>
> SCALE(X,N) = COMPLX(SCALE(X%RE,N),SCALE(X%IM,N),KIND(X%IM))
>
> Should the Fortran be amended?

Wow, no answer yet.

It does seem that sometimes Fortran is slow to add features, especially
when need for them isn't shown.

It does make sense to have the complex version, though as you note, it
isn't all that hard to get away without it.

If I had a vote, it would be yes.

Re: SCALE intrinsic subprogram (aka a Fortran post)

<M55BkNACmkeTfoGz6seVpnKP8RA@jntp>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3753&group=comp.lang.fortran#3753

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!paganini.bofh.team!pasdenom.info!from-devjntp
Message-ID: <M55BkNACmkeTfoGz6seVpnKP8RA@jntp>
JNTP-Route: news2.nemoweb.net
JNTP-DataType: Article
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
References: <ui6clh$3idu5$1@dont-email.me> <d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu>
Newsgroups: comp.lang.fortran
JNTP-HashClient: A2nQWPidGqVEhfDvjtjMGdx6awE
JNTP-ThreadID: ui6clh$3idu5$1@dont-email.me
JNTP-Uri: http://news2.nemoweb.net/?DataID=M55BkNACmkeTfoGz6seVpnKP8RA@jntp
User-Agent: Nemo/0.999a
JNTP-OriginServer: news2.nemoweb.net
Date: Thu, 16 Nov 23 11:17:31 +0000
Organization: Nemoweb
JNTP-Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
Injection-Info: news2.nemoweb.net; posting-host="fd5675444fb2abe5cff243786215e1a6f7fd1bea"; logging-data="2023-11-16T11:17:31Z/8402346"; posting-account="44@news2.nemoweb.net"; mail-complaints-to="newsmaster@news2.nemoweb.net"
JNTP-ProtocolVersion: 0.21.1
JNTP-Server: PhpNemoServer/0.94.5
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-JNTP-JsonNewsGateway: 0.96
From: pehache.7@gmail.com (pehache)
 by: pehache - Thu, 16 Nov 2023 11:17 UTC

Le 16/11/2023 à 02:28, gah4 a écrit :
> On 11/4/23 2:21 PM, Steven G. Kargl wrote:
>> The SCALE intrinsic allows one to change the
>> floating point exponent for a REAL entity.
>> For example,
>>
>> program foo
>> real x
>> x = 1
>> print *, scale(x,1) ! print 2
>> end program
>>
>> This scaling does not incur a floating point
>> rounding error.
>>
>> Question. Anyone know why the Fortran standard (aka J3)
>> restricted X to be a REAL entity? It would seem that X
>> could be COMPLEX with obvious equivalence of
>>
>> SCALE(X,N) = COMPLX(SCALE(X%RE,N),SCALE(X%IM,N),KIND(X%IM))
>>
>> Should the Fortran be amended?
>
>
> Wow, no answer yet.
>
> It does seem that sometimes Fortran is slow to add features, especially
> when need for them isn't shown.

The reason is maybe because the standard doesn't specify how a complex
number is internally represented. In practice it is always represented by
a pair (real,imag), but nothing would prevent a compiler representing it
by (module,argument) for instance. Given that, the standard cannot
guarantee the absence of rounding errors.

Re: SCALE intrinsic subprogram (aka a Fortran post)

<uj5sdu$2dehk$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3754&group=comp.lang.fortran#3754

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: sgk@REMOVEtroutmask.apl.washington.edu (Steven G. Kargl)
Newsgroups: comp.lang.fortran
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
Date: Thu, 16 Nov 2023 20:01:02 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <uj5sdu$2dehk$1@dont-email.me>
References: <ui6clh$3idu5$1@dont-email.me>
<d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu>
<M55BkNACmkeTfoGz6seVpnKP8RA@jntp>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 16 Nov 2023 20:01:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3b5debb062ddc27b5e68744dc2f8f20b";
logging-data="2538036"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18B4yzEO8G3lKrptDgRFtC+"
User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a
git.gnome.org/pan2)
Cancel-Lock: sha1:2iT5w/SbooSrrhEdjuGNbMZ+lfs=
 by: Steven G. Kargl - Thu, 16 Nov 2023 20:01 UTC

On Thu, 16 Nov 2023 11:17:31 +0000, pehache wrote:

> Le 16/11/2023 à 02:28, gah4 a écrit :
>> On 11/4/23 2:21 PM, Steven G. Kargl wrote:
>>> The SCALE intrinsic allows one to change the floating point exponent
>>> for a REAL entity.
>>> For example,
>>>
>>> program foo
>>> real x x = 1 print *, scale(x,1) ! print 2
>>> end program
>>>
>>> This scaling does not incur a floating point rounding error.
>>>
>>> Question. Anyone know why the Fortran standard (aka J3) restricted X
>>> to be a REAL entity? It would seem that X could be COMPLEX with
>>> obvious equivalence of
>>>
>>> SCALE(X,N) = COMPLX(SCALE(X%RE,N),SCALE(X%IM,N),KIND(X%IM))
>>>
>>> Should the Fortran be amended?
>>
>>
>> Wow, no answer yet.
>>
>> It does seem that sometimes Fortran is slow to add features, especially
>> when need for them isn't shown.
>
> The reason is maybe because the standard doesn't specify how a complex
> number is internally represented. In practice it is always represented
> by a pair (real,imag), but nothing would prevent a compiler representing
> it by (module,argument) for instance. Given that, the standard cannot
> guarantee the absence of rounding errors.

You are correct that the Fortran standard does not specify
internal datails, and this could be extended to COMPLEX.
It would however be quite strange for a Fortran vendor to
use magnitude and phase given that the Fortran standard does
quite often refer to the real and imaginary parts of a COMPLEX
entity. Not to mention, the Fortran standard has introduced:

3.60.1
complex part designator

9.4.4 Complex parts

R915 complex-part-designator is designator % RE
or designator % IM

PS: If a Fortran vendor used magnitude and phase, then the vendor
would need to specify a sign convention for the phasor. I'm mpt
aware of any vendor that does.

--
steve

Re: SCALE intrinsic subprogram (aka a Fortran post)

<krnko9Fs7u5U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3755&group=comp.lang.fortran#3755

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!nntp.comgw.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: pehache.7@gmail.com (pehache)
Newsgroups: comp.lang.fortran
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
Date: Thu, 16 Nov 2023 23:51:52 +0100
Lines: 51
Message-ID: <krnko9Fs7u5U1@mid.individual.net>
References: <ui6clh$3idu5$1@dont-email.me>
<d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu>
<M55BkNACmkeTfoGz6seVpnKP8RA@jntp> <uj5sdu$2dehk$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net 5D/XsX7aco/Wh2qgYuV2mAO9zZxyrfH8n5qFs5ntGorjgG0Pln
Cancel-Lock: sha1:duz2xpuhQznB7lqExY2CvbJQmGA= sha256:G5FLm9qiPVoE70qON1CCqjXqN0DMk/LBC/aVeqI9pno=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:91.0)
Gecko/20100101 Thunderbird/91.11.0
Content-Language: fr
In-Reply-To: <uj5sdu$2dehk$1@dont-email.me>
 by: pehache - Thu, 16 Nov 2023 22:51 UTC

Le 16/11/2023 à 21:01, Steven G. Kargl a écrit :
>>
>> The reason is maybe because the standard doesn't specify how a complex
>> number is internally represented. In practice it is always represented
>> by a pair (real,imag), but nothing would prevent a compiler representing
>> it by (module,argument) for instance. Given that, the standard cannot
>> guarantee the absence of rounding errors.
>
> You are correct that the Fortran standard does not specify
> internal datails, and this could be extended to COMPLEX.
> It would however be quite strange for a Fortran vendor to
> use magnitude and phase

I fully agree that it would be strange, and I can't see any advantage to
such implementation. Yet, it is not prohibited by the standard.

> given that the Fortran standard does
> quite often refer to the real and imaginary parts of a COMPLEX
> entity.

Yes, but it's at the conceptual level

> Not to mention, the Fortran standard has introduced:
>
> 3.60.1
> complex part designator
>
> 9.4.4 Complex parts
>
> R915 complex-part-designator is designator % RE
> or designator % IM

Yes again, but behind the hood c%re and c%im could be the functions
m*cos(p) and m*sin(p). And on assignement c%re = <expr> or c%im = <expr>
the (m,p) pair could be fully recomputed.

> PS: If a Fortran vendor used magnitude and phase, then the vendor
> would need to specify a sign convention for the phasor. I'm mpt
> aware of any vendor that does.

I don't think so, as the phase component would not be directly
accessible by the user. The vendor could choose any convention as long
as the whole internal stuff is consistent, he could also chose to store
a scaled version of the phase in order to have a better accuracy...

--
"...sois ouvert aux idées des autres pour peu qu'elles aillent dans le
même sens que les tiennes.", ST sur fr.bio.medecine
ST passe le mur du çon : <j3nn2hFmqj7U1@mid.individual.net>

Re: SCALE intrinsic subprogram (aka a Fortran post)

<uj72cm$3d1ob$1@newsreader4.netcologne.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3756&group=comp.lang.fortran#3756

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-dfef-0-e97e-64e4-9592-df34.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
Date: Fri, 17 Nov 2023 06:48:54 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <uj72cm$3d1ob$1@newsreader4.netcologne.de>
References: <ui6clh$3idu5$1@dont-email.me>
<d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu>
<M55BkNACmkeTfoGz6seVpnKP8RA@jntp>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 17 Nov 2023 06:48:54 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-dfef-0-e97e-64e4-9592-df34.ipv6dyn.netcologne.de:2001:4dd7:dfef:0:e97e:64e4:9592:df34";
logging-data="3573515"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 17 Nov 2023 06:48 UTC

pehache <pehache.7@gmail.com> schrieb:
> Le 16/11/2023 à 02:28, gah4 a écrit :
>> On 11/4/23 2:21 PM, Steven G. Kargl wrote:
>>> The SCALE intrinsic allows one to change the
>>> floating point exponent for a REAL entity.
>>> For example,
>>>
>>> program foo
>>> real x
>>> x = 1
>>> print *, scale(x,1) ! print 2
>>> end program
>>>
>>> This scaling does not incur a floating point
>>> rounding error.
>>>
>>> Question. Anyone know why the Fortran standard (aka J3)
>>> restricted X to be a REAL entity? It would seem that X
>>> could be COMPLEX with obvious equivalence of
>>>
>>> SCALE(X,N) = COMPLX(SCALE(X%RE,N),SCALE(X%IM,N),KIND(X%IM))
>>>
>>> Should the Fortran be amended?
>>
>>
>> Wow, no answer yet.
>>
>> It does seem that sometimes Fortran is slow to add features, especially
>> when need for them isn't shown.
>
> The reason is maybe because the standard doesn't specify how a complex
> number is internally represented.

I disagree almost entirely.

Subclause 19.6.5 of F2018, "Events that cause variables to become
defined" has

(13) When a default complex entity becomes defined, all partially
associated default real entities become defined.

(14) When both parts of a default complex entity become defined as
a result of partially associated default real or default complex
entities becoming defined, the default complex entity becomes
defined.

Which means that something like

real :: a(2)
complex :: c
equivalence (a,c)

allows you to set values for a(1) and a(2) and you can expect the
components of c to get the corresponding values.

This is important for FFT.

Now, you might argue that the compiler can invoke "as if", but there
is no practical way to use any other complex representation.

Re: SCALE intrinsic subprogram (aka a Fortran post)

<uj77lh$2nmc6$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3757&group=comp.lang.fortran#3757

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dajhawkxx@nowherel.com (David Jones)
Newsgroups: comp.lang.fortran
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
Date: Fri, 17 Nov 2023 08:18:57 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <uj77lh$2nmc6$1@dont-email.me>
References: <ui6clh$3idu5$1@dont-email.me> <d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu> <M55BkNACmkeTfoGz6seVpnKP8RA@jntp> <uj5sdu$2dehk$1@dont-email.me> <krnko9Fs7u5U1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 17 Nov 2023 08:18:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="40810347f5354b6da094058c4115312d";
logging-data="2873734"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184NXVigAPjO4t6DAfPcKdfzv4WK8gxbBM="
User-Agent: XanaNews/1.21-f3fb89f (x86; Portable ISpell)
Cancel-Lock: sha1:1S2JKbJKRhVap89HrJfYfuVrQNQ=
 by: David Jones - Fri, 17 Nov 2023 08:18 UTC

pehache wrote:

> Le 16/11/2023 à 21:01, Steven G. Kargl a écrit :
> > >
> > > The reason is maybe because the standard doesn't specify how a
> > > complex number is internally represented. In practice it is
> > > always represented by a pair (real,imag), but nothing would
> > > prevent a compiler representing it by (module,argument) for
> > > instance. Given that, the standard cannot guarantee the absence
> > > of rounding errors.
> >
> > You are correct that the Fortran standard does not specify
> > internal datails, and this could be extended to COMPLEX.
> > It would however be quite strange for a Fortran vendor to
> > use magnitude and phase
>
> I fully agree that it would be strange, and I can't see any advantage
> to such implementation. Yet, it is not prohibited by the standard.
>
> > given that the Fortran standard does
> > quite often refer to the real and imaginary parts of a COMPLEX
> > entity.
>
> Yes, but it's at the conceptual level
>
> > Not to mention, the Fortran standard has introduced:
> >
> > 3.60.1
> > complex part designator
> >
> > 9.4.4 Complex parts
> >
> > R915 complex-part-designator is designator % RE
> > or designator % IM
>
> Yes again, but behind the hood c%re and c%im could be the functions
> m*cos(p) and m*sin(p). And on assignement c%re = <expr> or c%im =
> <expr> the (m,p) pair could be fully recomputed.
>
>
> > PS: If a Fortran vendor used magnitude and phase, then the vendor
> > would need to specify a sign convention for the phasor. I'm mpt
> > aware of any vendor that does.
>
> I don't think so, as the phase component would not be directly
> accessible by the user. The vendor could choose any convention as
> long as the whole internal stuff is consistent, he could also chose
> to store a scaled version of the phase in order to have a better
> accuracy...

There seems no reason why the standard might not be extended to allow
the two different types of representations of complex variables to
exist in the same program, as separate data-types, and to interact when
required. Two major questions are:

(i) whether there are any applications that would be more readily and
usefully programmed using the modulus-phase representation?

(ii) the relative speed of both addition and multiplication in the two
representations.?

Re: SCALE intrinsic subprogram (aka a Fortran post)

<krom6tF5cdqU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3758&group=comp.lang.fortran#3758

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: pehache.7@gmail.com (pehache)
Newsgroups: comp.lang.fortran
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
Date: Fri, 17 Nov 2023 09:22:53 +0100
Lines: 77
Message-ID: <krom6tF5cdqU1@mid.individual.net>
References: <ui6clh$3idu5$1@dont-email.me>
<d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu>
<M55BkNACmkeTfoGz6seVpnKP8RA@jntp> <uj72cm$3d1ob$1@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net ix6EZGjyrZd4FoxirfYvhQnQiLaXOStGYZ1tik3skF1VHSkl8D
Cancel-Lock: sha1:TgWC+Foy00P/C1EvrfmkDbkp0P0= sha256:kQAcM+k2bcRdmMveRXJRxwrqqlyiOYWIENIxDfojtiA=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:91.0)
Gecko/20100101 Thunderbird/91.11.0
Content-Language: fr
In-Reply-To: <uj72cm$3d1ob$1@newsreader4.netcologne.de>
 by: pehache - Fri, 17 Nov 2023 08:22 UTC

Le 17/11/2023 à 07:48, Thomas Koenig a écrit :
> pehache <pehache.7@gmail.com> schrieb:
>> Le 16/11/2023 à 02:28, gah4 a écrit :
>>> On 11/4/23 2:21 PM, Steven G. Kargl wrote:
>>>> The SCALE intrinsic allows one to change the
>>>> floating point exponent for a REAL entity.
>>>> For example,
>>>>
>>>> program foo
>>>> real x
>>>> x = 1
>>>> print *, scale(x,1) ! print 2
>>>> end program
>>>>
>>>> This scaling does not incur a floating point
>>>> rounding error.
>>>>
>>>> Question. Anyone know why the Fortran standard (aka J3)
>>>> restricted X to be a REAL entity? It would seem that X
>>>> could be COMPLEX with obvious equivalence of
>>>>
>>>> SCALE(X,N) = COMPLX(SCALE(X%RE,N),SCALE(X%IM,N),KIND(X%IM))
>>>>
>>>> Should the Fortran be amended?
>>>
>>>
>>> Wow, no answer yet.
>>>
>>> It does seem that sometimes Fortran is slow to add features, especially
>>> when need for them isn't shown.
>>
>> The reason is maybe because the standard doesn't specify how a complex
>> number is internally represented.
>
> I disagree almost entirely.
>
> Subclause 19.6.5 of F2018, "Events that cause variables to become
> defined" has
>
> (13) When a default complex entity becomes defined, all partially
> associated default real entities become defined.
>
> (14) When both parts of a default complex entity become defined as
> a result of partially associated default real or default complex
> entities becoming defined, the default complex entity becomes
> defined.
>
> Which means that something like
>
> real :: a(2)
> complex :: c
> equivalence (a,c)
>
> allows you to set values for a(1) and a(2) and you can expect the
> components of c to get the corresponding values.

I almost entirely disagree with your almost entire disagreement :)

The standard requires the complex type to occupy 2 storage units, which
allows the above equivalence, and the above clause tells that a complex
is made of two adjacent reals. However it does not tell what are a(1)
and a(2) precisely : they could be the module + phase (or the imaginary
part and the real part in that order).

>
> This is important for FFT.

We are all relying on the fact that in your above equivalence a(1) is
the real part and a(2) is the imaginary part, all compilers follow this
convention, and nobody would "buy" a compiler that would follow another
convention. Nonetheless this is just a convention, this is not enforced
by the standard.

--
"...sois ouvert aux idées des autres pour peu qu'elles aillent dans le
même sens que les tiennes.", ST sur fr.bio.medecine
ST passe le mur du çon : <j3nn2hFmqj7U1@mid.individual.net>

Re: SCALE intrinsic subprogram (aka a Fortran post)

<ujd2hi$3gsri$1@newsreader4.netcologne.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3766&group=comp.lang.fortran#3766

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-2533-0-189a-74ee-23ef-da11.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
Date: Sun, 19 Nov 2023 13:28:18 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <ujd2hi$3gsri$1@newsreader4.netcologne.de>
References: <ui6clh$3idu5$1@dont-email.me>
<d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu>
<M55BkNACmkeTfoGz6seVpnKP8RA@jntp> <uj5sdu$2dehk$1@dont-email.me>
<krnko9Fs7u5U1@mid.individual.net> <uj77lh$2nmc6$1@dont-email.me>
Injection-Date: Sun, 19 Nov 2023 13:28:18 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-2533-0-189a-74ee-23ef-da11.ipv6dyn.netcologne.de:2001:4dd7:2533:0:189a:74ee:23ef:da11";
logging-data="3699570"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sun, 19 Nov 2023 13:28 UTC

David Jones <dajhawkxx@nowherel.com> schrieb:

> There seems no reason why the standard might not be extended to allow
> the two different types of representations of complex variables to
> exist in the same program, as separate data-types, and to interact when
> required. Two major questions are:
>
> (i) whether there are any applications that would be more readily and
> usefully programmed using the modulus-phase representation?
>
> (ii) the relative speed of both addition and multiplication in the two
> representations.?

Multiplication and especially division would likely be faster - you
would have to multiply the two moduli and add and normalize the
modulus to lie between 0 and 2*pi.

However, the normalization step can have unintended execution
speed consequences if the processor implements it via branches,
and branches can be quite expensive if mispredicted.

_Addition_ is very expensive indeed in polar notation. You have
to calculate the sin() and cos() of each number, add them, and then
call atan2() (with a normalization) to get back the original
representation.

If you're doing a lot of multiplication, and not a lot of addition,
that could actually pay off.

Re: SCALE intrinsic subprogram (aka a Fortran post)

<ujdbk9$3s489$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3767&group=comp.lang.fortran#3767

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: sgk@REMOVEtroutmask.apl.washington.edu (Steven G. Kargl)
Newsgroups: comp.lang.fortran
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
Date: Sun, 19 Nov 2023 16:03:22 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <ujdbk9$3s489$1@dont-email.me>
References: <ui6clh$3idu5$1@dont-email.me>
<d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu>
<M55BkNACmkeTfoGz6seVpnKP8RA@jntp> <uj5sdu$2dehk$1@dont-email.me>
<krnko9Fs7u5U1@mid.individual.net> <uj77lh$2nmc6$1@dont-email.me>
<ujd2hi$3gsri$1@newsreader4.netcologne.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 19 Nov 2023 16:03:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="de898fc6f6c9024f961414a3152572a7";
logging-data="4067593"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/anPo5y1f4OcDXwE07EUxp"
User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a
git.gnome.org/pan2)
Cancel-Lock: sha1:dMiw3LOJaqoCWxHnkODY+2MAYmA=
 by: Steven G. Kargl - Sun, 19 Nov 2023 16:03 UTC

On Sun, 19 Nov 2023 13:28:18 +0000, Thomas Koenig wrote:

> David Jones <dajhawkxx@nowherel.com> schrieb:
>
>> There seems no reason why the standard might not be extended to allow
>> the two different types of representations of complex variables to
>> exist in the same program, as separate data-types, and to interact when
>> required. Two major questions are:
>>
>> (i) whether there are any applications that would be more readily and
>> usefully programmed using the modulus-phase representation?
>>
>> (ii) the relative speed of both addition and multiplication in the two
>> representations.?
>
> Multiplication and especially division would likely be faster - you
> would have to multiply the two moduli and add and normalize the modulus
> to lie between 0 and 2*pi.
>
> However, the normalization step can have unintended execution speed
> consequences if the processor implements it via branches, and branches
> can be quite expensive if mispredicted.
>
> _Addition_ is very expensive indeed in polar notation. You have to
> calculate the sin() and cos() of each number, add them, and then call
> atan2() (with a normalization) to get back the original representation.
>
> If you're doing a lot of multiplication, and not a lot of addition,
> that could actually pay off.

If a vendor used magnitude and phase as the internal representation,
then that vendor would not be around very long. Consider cmplx(0,1).
The magnitude is easy. It is 1. Mathematically, the phase is
pi/2, which is of course not exactly representable.

% tlibm acos -f -a 0.
x = 0.00000000e+00f, /* 0x00000000 */
libm = 1.57079637e+00f, /* 0x3fc90fdb */
mpfr = 1.57079637e+00f, /* 0x3fc90fdb */
ULP = 0.36668
% tlibm cos -f -a 1.57079637
x = 1.57079625e+00f, /* 0x3fc90fda */
libm = 7.54979013e-08f, /* 0x33a22169 */
mpfr = 7.54979013e-08f, /* 0x33a22169 */
ULP = 0.24138

7.549... is significantly different when compared to 0.

--
steve

Re: SCALE intrinsic subprogram (aka a Fortran post)

<ujdl44$3tp5n$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3768&group=comp.lang.fortran#3768

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dajhawkxx@nowherel.com (David Jones)
Newsgroups: comp.lang.fortran
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
Date: Sun, 19 Nov 2023 18:45:24 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <ujdl44$3tp5n$1@dont-email.me>
References: <ui6clh$3idu5$1@dont-email.me> <d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu> <M55BkNACmkeTfoGz6seVpnKP8RA@jntp> <uj5sdu$2dehk$1@dont-email.me> <krnko9Fs7u5U1@mid.individual.net> <uj77lh$2nmc6$1@dont-email.me> <ujd2hi$3gsri$1@newsreader4.netcologne.de> <ujdbk9$3s489$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 19 Nov 2023 18:45:24 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a17f6d9b2936279cd73fb2815c2f30c0";
logging-data="4121783"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WPnJkyUJoqKBEy9YkKAr09G3E2VTkats="
User-Agent: XanaNews/1.21-f3fb89f (x86; Portable ISpell)
Cancel-Lock: sha1:yUogsUaQbtEAs2bJT/+3UbSLXaI=
 by: David Jones - Sun, 19 Nov 2023 18:45 UTC

Steven G. Kargl wrote:

> On Sun, 19 Nov 2023 13:28:18 +0000, Thomas Koenig wrote:
>
> > David Jones <dajhawkxx@nowherel.com> schrieb:
> >
> >> There seems no reason why the standard might not be extended to
> allow >> the two different types of representations of complex
> variables to >> exist in the same program, as separate data-types,
> and to interact when >> required. Two major questions are:
> > >
> >> (i) whether there are any applications that would be more readily
> and >> usefully programmed using the modulus-phase representation?
> > >
> >> (ii) the relative speed of both addition and multiplication in the
> two >> representations.?
> >
> > Multiplication and especially division would likely be faster - you
> > would have to multiply the two moduli and add and normalize the
> > modulus to lie between 0 and 2*pi.
> >
> > However, the normalization step can have unintended execution speed
> > consequences if the processor implements it via branches, and
> > branches can be quite expensive if mispredicted.
> >
> > Addition is very expensive indeed in polar notation. You have to
> > calculate the sin() and cos() of each number, add them, and then
> > call atan2() (with a normalization) to get back the original
> > representation.
> >
> > If you're doing a lot of multiplication, and not a lot of addition,
> > that could actually pay off.
>
> If a vendor used magnitude and phase as the internal representation,
> then that vendor would not be around very long. Consider cmplx(0,1).
> The magnitude is easy. It is 1. Mathematically, the phase is
> pi/2, which is of course not exactly representable.
>
> % tlibm acos -f -a 0.
> x = 0.00000000e+00f, /* 0x00000000 */
> libm = 1.57079637e+00f, /* 0x3fc90fdb */
> mpfr = 1.57079637e+00f, /* 0x3fc90fdb */
> ULP = 0.36668
> % tlibm cos -f -a 1.57079637
> x = 1.57079625e+00f, /* 0x3fc90fda */
> libm = 7.54979013e-08f, /* 0x33a22169 */
> mpfr = 7.54979013e-08f, /* 0x33a22169 */
> ULP = 0.24138
>
> 7.549... is significantly different when compared to 0.

If it were worth doing, the obvious thing to do would be to use a
formulation where you store a multiple of pi or 2*pi as the effective
argument, with computations done to respect a standard range.

Re: SCALE intrinsic subprogram (aka a Fortran post)

<uje0ht$3hhkc$1@newsreader4.netcologne.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3770&group=comp.lang.fortran#3770

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-2533-0-68ec-5669-f850-19c5.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
Date: Sun, 19 Nov 2023 22:00:29 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <uje0ht$3hhkc$1@newsreader4.netcologne.de>
References: <ui6clh$3idu5$1@dont-email.me>
<d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu>
<M55BkNACmkeTfoGz6seVpnKP8RA@jntp> <uj5sdu$2dehk$1@dont-email.me>
<krnko9Fs7u5U1@mid.individual.net> <uj77lh$2nmc6$1@dont-email.me>
<ujd2hi$3gsri$1@newsreader4.netcologne.de> <ujdbk9$3s489$1@dont-email.me>
<ujdl44$3tp5n$1@dont-email.me>
Injection-Date: Sun, 19 Nov 2023 22:00:29 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-2533-0-68ec-5669-f850-19c5.ipv6dyn.netcologne.de:2001:4dd7:2533:0:68ec:5669:f850:19c5";
logging-data="3720844"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sun, 19 Nov 2023 22:00 UTC

David Jones <dajhawkxx@nowherel.com> schrieb:
> Steven G. Kargl wrote:
>
>> On Sun, 19 Nov 2023 13:28:18 +0000, Thomas Koenig wrote:
>>
>> > David Jones <dajhawkxx@nowherel.com> schrieb:
>> >
>> >> There seems no reason why the standard might not be extended to
>> allow >> the two different types of representations of complex
>> variables to >> exist in the same program, as separate data-types,
>> and to interact when >> required. Two major questions are:
>> > >
>> >> (i) whether there are any applications that would be more readily
>> and >> usefully programmed using the modulus-phase representation?
>> > >
>> >> (ii) the relative speed of both addition and multiplication in the
>> two >> representations.?
>> >
>> > Multiplication and especially division would likely be faster - you
>> > would have to multiply the two moduli and add and normalize the
>> > modulus to lie between 0 and 2*pi.
>> >
>> > However, the normalization step can have unintended execution speed
>> > consequences if the processor implements it via branches, and
>> > branches can be quite expensive if mispredicted.
>> >
>> > Addition is very expensive indeed in polar notation. You have to
>> > calculate the sin() and cos() of each number, add them, and then
>> > call atan2() (with a normalization) to get back the original
>> > representation.
>> >
>> > If you're doing a lot of multiplication, and not a lot of addition,
>> > that could actually pay off.
>>
>> If a vendor used magnitude and phase as the internal representation,
>> then that vendor would not be around very long. Consider cmplx(0,1).
>> The magnitude is easy. It is 1. Mathematically, the phase is
>> pi/2, which is of course not exactly representable.
>>
>> % tlibm acos -f -a 0.
>> x = 0.00000000e+00f, /* 0x00000000 */
>> libm = 1.57079637e+00f, /* 0x3fc90fdb */
>> mpfr = 1.57079637e+00f, /* 0x3fc90fdb */
>> ULP = 0.36668
>> % tlibm cos -f -a 1.57079637
>> x = 1.57079625e+00f, /* 0x3fc90fda */
>> libm = 7.54979013e-08f, /* 0x33a22169 */
>> mpfr = 7.54979013e-08f, /* 0x33a22169 */
>> ULP = 0.24138
>>
>> 7.549... is significantly different when compared to 0.
>
> If it were worth doing, the obvious thing to do would be to use a
> formulation where you store a multiple of pi or 2*pi as the effective
> argument, with computations done to respect a standard range.

It could also make sense to use a fixed-number representation for
the phase; having special accuracy around zero, as floating point
numbers do, may not be a large advantage.

The normalization step could then be a simple "and", masking
away the top bits.

This is, however, more along the lines of what a user-defined
complex type could look like, not what Fortran compilers could
reasonably provide :-)

Re: SCALE intrinsic subprogram (aka a Fortran post)

<ujfd4d$9hgk$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3772&group=comp.lang.fortran#3772

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dajhawk18xx@@nowhere.com (David Jones)
Newsgroups: comp.lang.fortran
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
Date: Mon, 20 Nov 2023 10:41:17 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <ujfd4d$9hgk$1@dont-email.me>
References: <ui6clh$3idu5$1@dont-email.me> <d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu> <M55BkNACmkeTfoGz6seVpnKP8RA@jntp> <uj5sdu$2dehk$1@dont-email.me> <krnko9Fs7u5U1@mid.individual.net> <uj77lh$2nmc6$1@dont-email.me> <ujd2hi$3gsri$1@newsreader4.netcologne.de> <ujdbk9$3s489$1@dont-email.me> <ujdl44$3tp5n$1@dont-email.me> <uje0ht$3hhkc$1@newsreader4.netcologne.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 20 Nov 2023 10:41:17 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3e41b4cb89325373baabb40e47cd30c0";
logging-data="312852"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/3rvdJdoyn2KKYycFwP201FmJpQDmkj34="
User-Agent: XanaNews/1.21-f3fb89f (x86; Portable ISpell)
Cancel-Lock: sha1:e5/INuVUVgGQWCYDqazTk3RD71A=
 by: David Jones - Mon, 20 Nov 2023 10:41 UTC

Thomas Koenig wrote:

> David Jones <dajhawkxx@nowherel.com> schrieb:
> > Steven G. Kargl wrote:
> >
> >> On Sun, 19 Nov 2023 13:28:18 +0000, Thomas Koenig wrote:
> >>
> >> > David Jones <dajhawkxx@nowherel.com> schrieb:
> >> >
> >> >> There seems no reason why the standard might not be extended to
> >> allow >> the two different types of representations of complex
> >> variables to >> exist in the same program, as separate data-types,
> >> and to interact when >> required. Two major questions are:
> >> > >
> >> >> (i) whether there are any applications that would be more
> readily >> and >> usefully programmed using the modulus-phase
> representation? >> > >
> >> >> (ii) the relative speed of both addition and multiplication in
> the >> two >> representations.?
> >> >
> >> > Multiplication and especially division would likely be faster -
> you >> > would have to multiply the two moduli and add and normalize
> the >> > modulus to lie between 0 and 2*pi.
> >> >
> >> > However, the normalization step can have unintended execution
> speed >> > consequences if the processor implements it via branches,
> and >> > branches can be quite expensive if mispredicted.
> >> >
> >> > Addition is very expensive indeed in polar notation. You have to
> >> > calculate the sin() and cos() of each number, add them, and then
> >> > call atan2() (with a normalization) to get back the original
> >> > representation.
> >> >
> >> > If you're doing a lot of multiplication, and not a lot of
> addition, >> > that could actually pay off.
> >>
> >> If a vendor used magnitude and phase as the internal
> representation, >> then that vendor would not be around very long.
> Consider cmplx(0,1). >> The magnitude is easy. It is 1.
> Mathematically, the phase is >> pi/2, which is of course not exactly
> representable. >>
> >> % tlibm acos -f -a 0.
> >> x = 0.00000000e+00f, /* 0x00000000 */
> >> libm = 1.57079637e+00f, /* 0x3fc90fdb */
> >> mpfr = 1.57079637e+00f, /* 0x3fc90fdb */
> >> ULP = 0.36668
> >> % tlibm cos -f -a 1.57079637
> >> x = 1.57079625e+00f, /* 0x3fc90fda */
> >> libm = 7.54979013e-08f, /* 0x33a22169 */
> >> mpfr = 7.54979013e-08f, /* 0x33a22169 */
> >> ULP = 0.24138
> >>
> >> 7.549... is significantly different when compared to 0.
> >
> > If it were worth doing, the obvious thing to do would be to use a
> > formulation where you store a multiple of pi or 2*pi as the
> > effective argument, with computations done to respect a standard
> > range.
>
> It could also make sense to use a fixed-number representation for
> the phase; having special accuracy around zero, as floating point
> numbers do, may not be a large advantage.
>
> The normalization step could then be a simple "and", masking
> away the top bits.
>
> This is, however, more along the lines of what a user-defined
> complex type could look like, not what Fortran compilers could
> reasonably provide :-)

Any extension to the existing standard is at least possible. But the
real question is whether there are enough (or any at all) applications
that require only (or mainly) complex multiplications as opposed to
additions. I can't think of any.

Re: SCALE intrinsic subprogram (aka a Fortran post)

<dyq9goI9ws79pp5-vBu-nQvNLUQ@jntp>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3787&group=comp.lang.fortran#3787

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!news.hispagatos.org!news.nntp4.net!pasdenom.info!from-devjntp
Message-ID: <dyq9goI9ws79pp5-vBu-nQvNLUQ@jntp>
JNTP-Route: news2.nemoweb.net
JNTP-DataType: Article
Subject: Re: SCALE intrinsic subprogram (aka a Fortran post)
References: <ui6clh$3idu5$1@dont-email.me> <d0d36fcf-a20d-475c-a688-df9b6ac3db80@ugcs.caltech.edu>
<M55BkNACmkeTfoGz6seVpnKP8RA@jntp> <uj5sdu$2dehk$1@dont-email.me> <krnko9Fs7u5U1@mid.individual.net>
Newsgroups: comp.lang.fortran
JNTP-HashClient: R71EIcCa0phCXrJmVZ1s5qMDFOo
JNTP-ThreadID: ui6clh$3idu5$1@dont-email.me
JNTP-Uri: http://news2.nemoweb.net/?DataID=dyq9goI9ws79pp5-vBu-nQvNLUQ@jntp
User-Agent: Nemo/0.999a
JNTP-OriginServer: news2.nemoweb.net
Date: Thu, 21 Dec 23 15:52:03 +0000
Organization: Nemoweb
JNTP-Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
Injection-Info: news2.nemoweb.net; posting-host="fd5675444fb2abe5cff243786215e1a6f7fd1bea"; logging-data="2023-12-21T15:52:03Z/8544361"; posting-account="44@news2.nemoweb.net"; mail-complaints-to="newsmaster@news2.nemoweb.net"
JNTP-ProtocolVersion: 0.21.1
JNTP-Server: PhpNemoServer/0.94.5
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-JNTP-JsonNewsGateway: 0.96
From: pehache.7@gmail.com (pehache)
 by: pehache - Thu, 21 Dec 2023 15:52 UTC

Le 16/11/2023 à 23:51, pehache a écrit :
> Le 16/11/2023 à 21:01, Steven G. Kargl a écrit :
>>>
>>> The reason is maybe because the standard doesn't specify how a complex
>>> number is internally represented. In practice it is always represented
>>> by a pair (real,imag), but nothing would prevent a compiler representing
>>> it by (module,argument) for instance. Given that, the standard cannot
>>> guarantee the absence of rounding errors.
>>
>> You are correct that the Fortran standard does not specify
>> internal datails, and this could be extended to COMPLEX.
>> It would however be quite strange for a Fortran vendor to
>> use magnitude and phase
>
> I fully agree that it would be strange, and I can't see any advantage to
> such implementation. Yet, it is not prohibited by the standard.
>
>> given that the Fortran standard does
>> quite often refer to the real and imaginary parts of a COMPLEX
>> entity.
>
> Yes, but it's at the conceptual level
>
>> Not to mention, the Fortran standard has introduced:
>>
>> 3.60.1
>> complex part designator
>>
>> 9.4.4 Complex parts
>>
>> R915 complex-part-designator is designator % RE
>> or designator % IM
>
> Yes again, but behind the hood c%re and c%im could be the functions
> m*cos(p) and m*sin(p). And on assignement c%re = <expr> or c%im = <expr>
> the (m,p) pair could be fully recomputed.

Well, after all I have to disagree with myself...

Since it's possible to get pointers to these designators:

complex, allocatable, target :: c(:)
real, pointer :: rr(:), ri(:)
rr => c(:)%re
ri => c(:)%im

The compiler has really no other choice than implementating a complex by a
(real,imaginary) pair. If %re and %im were hidden functions, such pointer
assignments would not be possible. Still, the order is not clearly
enforced, and it could be (imaginary,real)

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor