What is this error message???

5 views
Skip to first unread message

Grégory Vanuxem

unread,
May 28, 2024, 1:11:15 PM5/28/24
to fricas...@googlegroups.com
Hello,

(12) -> unitNormal complex(7,0)$JWSGINT

>> Error detected within library code:
Bug: ridiculous record representation

(12) ->

Not very "professional"...

In fact, Void return value instead of a Record, I forgot a branch.
Secondly, it was not handled at compile time.

- Greg

Grégory Vanuxem

unread,
May 28, 2024, 1:25:45 PM5/28/24
to fricas...@googlegroups.com
To add to this, usually the compiler complains with something like "No
value branch is an unknown mode", not always though, RetractIfCan
accepts it sometimes apparently if you do not handle the "failed"
case..

Waldek Hebisch

unread,
May 28, 2024, 4:34:21 PM5/28/24
to fricas...@googlegroups.com
On Tue, May 28, 2024 at 07:10:35PM +0200, Grégory Vanuxem wrote:
> Hello,
>
> (12) -> unitNormal complex(7,0)$JWSGINT
>
> >> Error detected within library code:
> Bug: ridiculous record representation
>
> (12) ->
>
> Not very "professional"...

Well, the message clearly says what was detected: in place which
expected a Recored appreared something with unexpected representation.

> In fact, Void return value instead of a Record, I forgot a branch.
> Secondly, it was not handled at compile time.


withoust seeing code that triggers this it it hard to say who
is guilty and what exactly happended.

--
Waldek Hebisch

Grégory Vanuxem

unread,
May 28, 2024, 7:46:31 PM5/28/24
to fricas...@googlegroups.com
Le mar. 28 mai 2024 à 22:34, Waldek Hebisch <de...@fricas.org> a écrit :
>
> On Tue, May 28, 2024 at 07:10:35PM +0200, Grégory Vanuxem wrote:
> > Hello,
> >
> > (12) -> unitNormal complex(7,0)$JWSGINT
> >
> > >> Error detected within library code:
> > Bug: ridiculous record representation
> >
> > (12) ->
> >
> > Not very "professional"...
>
> Well, the message clearly says what was detected: in place which
> expected a Recored appreared something with unexpected representation.

That was not a problem, that made me smile. I was just surprised by
the "ridiculous " word. Usually error messages are neutral and
informative, this one is like: Ridiculous! Do it again!

> > In fact, Void return value instead of a Record, I forgot a branch.
> > Secondly, it was not handled at compile time.
>
>
> withoust seeing code that triggers this it it hard to say who
> is guilty and what exactly happended.

It was a typo in a Gaussian integer domain using another Integer
domain than the FriCAS one, a domain without parameters like
GaussianInteger() == Complex(Integer) for example.

The commented code is the good one, a missing equal sign:

unitNormal x ==
zero? x => [1, x, 1]
one? x => [1, 1, 1]
re := real(x); im := imag(x)
re > 0 =>
--im >= 0 => [1, x, 1]
im > 0 => [1, x, 1]
im < 0 => [-imaginary(), complex(-im, re), imaginary()]
im <= 0 => [-1, -x, -1]
[imaginary(), complex(im, -re), -imaginary()]

It was quickly coded, and can be better probably, to avoid tons of
coercion issues to Expression(MyGaussianInteger) with trigonometric
functions. Elements of this domain are not intended to be coerced to
Expression(*) but that is how panAxiom is implemented.

I am coding toy domains using the Wolfram™ Symbolic Transport Protocol
for development purposes. And am adding a Gaussian Integer domain with
the Wolfram™ Kernel behind it. I will also probably do some tests with
"high" precision floating point numbers to compare results from
different floating point implementations (symbolic things are in the
pipeline also of course) . The WolframKernel is free for this purpose,
I no longer own Wolfram Mathematica ™, I was a student at that time
(not in mathematics)

- Greg


> --
> Waldek Hebisch
>
> --
> You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/ZlY_yzgNQ8smIQMs%40fricas.org.

Grégory Vanuxem

unread,
May 28, 2024, 8:07:39 PM5/28/24
to fricas...@googlegroups.com
Pff, not the good code, the commented one, reverting it made me do
another mistake, but the idea is there.

Waldek Hebisch

unread,
May 28, 2024, 10:51:40 PM5/28/24
to fricas...@googlegroups.com
On Wed, May 29, 2024 at 01:45:50AM +0200, Grégory Vanuxem wrote:
> Le mar. 28 mai 2024 à 22:34, Waldek Hebisch <de...@fricas.org> a écrit :
> >
> > On Tue, May 28, 2024 at 07:10:35PM +0200, Grégory Vanuxem wrote:
>
> > > In fact, Void return value instead of a Record, I forgot a branch.
> > > Secondly, it was not handled at compile time.
> >
> >
> > withoust seeing code that triggers this it it hard to say who
> > is guilty and what exactly happended.
>
> It was a typo in a Gaussian integer domain using another Integer
> domain than the FriCAS one, a domain without parameters like
> GaussianInteger() == Complex(Integer) for example.
>
> The commented code is the good one, a missing equal sign:
>
> unitNormal x ==
> zero? x => [1, x, 1]
> one? x => [1, 1, 1]
> re := real(x); im := imag(x)
> re > 0 =>
> --im >= 0 => [1, x, 1]
> im > 0 => [1, x, 1]
> im < 0 => [-imaginary(), complex(-im, re), imaginary()]
> im <= 0 => [-1, -x, -1]
> [imaginary(), complex(im, -re), -imaginary()]

Spad compiler does not check if your exits are complete, in general
Spad compiler does not understand your condition so it can not
infer that something is missing. Theoretically Spad compiler
could be modified to always require uncondital result, but that
would be inconvenient. Probably better would be to add a
call to 'error' so that missing return is detected.

I guess it is question of coding style, it is hard for me to
imagene writing code like the above. I would rather write
the critical part as:

im > 0 => [1, x, 1]
[-imaginary(), complex(-im, re), imaginary()]

(assuming that this is good choice) or

im > 0 => [1, x, 1]
im < 0 => [-imaginary(), complex(-im, re), imaginary()]
error "should not happen"

To say the truth, I probably would use different normalization,
so code would be quite different.

--
Waldek Hebisch

Ralf Hemmecke

unread,
May 29, 2024, 1:20:14 AM5/29/24
to fricas...@googlegroups.com
>> unitNormal x ==
>> zero? x => [1, x, 1]
>> one? x => [1, 1, 1]
>> re := real(x); im := imag(x)
>> re > 0 =>
>> --im >= 0 => [1, x, 1]
>> im > 0 => [1, x, 1]
>> im < 0 => [-imaginary(), complex(-im, re), imaginary()]
>> im <= 0 => [-1, -x, -1]
>> [imaginary(), complex(im, -re), -imaginary()]

Given that zero? x is checked at the beginning and assuming that zero? x
means "zero?(real(x)) and zero?(imag(x))", how can im=0 happen in the
commented case?

Ralf

Grégory Vanuxem

unread,
May 29, 2024, 4:44:14 AM5/29/24
to fricas...@googlegroups.com
Hello,

I know my code is very bad, but I was working on something else. I'm used to encountering many pitfalls, bugs from myself or others, omissions here and there, not necessarily from me, and if I stop each time, or fix everything, I don't make any progress. I come back to this part of the code afterwards, of course, I put markers on it. It's _draft_ code. I was fed up with this code and in fact it allowed me to see that perhaps in the WSTP protocol MathLink can support sending the Julia boolean type ‘bool: true|false’ to the Wolfram engine => True|False, just one line of code that I'm going to submit and, in passing, ask here to add perhaps a very simple but very practical language construction, the conditonal ternary operator (condition ? exprIfTrue : exprIfFalse). I don't think the Spad compiler handles it. Like C, Perl, Julia etc.

Frankly, I've been raging about my laptop and this function, it was getting late and I just wanted to avoid seeing an incalculable number of errors passed on to the Wolfram engine. and just read:

sin(1+2%i::Gaussian WS) => sin(1+2%i)

After that, the job goes on.

- Greg

Grégory Vanuxem

unread,
May 29, 2024, 4:49:32 AM5/29/24
to fricas...@googlegroups.com
Yes... And it is still not satisfactory, I have to rewrite it. It is
not poetry I admit.

- Greg

Waldek Hebisch

unread,
May 29, 2024, 8:26:04 AM5/29/24
to fricas...@googlegroups.com
Take x = 2

--
Waldek Hebisch

Waldek Hebisch

unread,
May 29, 2024, 8:39:13 AM5/29/24
to fricas...@googlegroups.com
On Wed, May 29, 2024 at 10:43:36AM +0200, Grégory Vanuxem wrote:
> Hello,
>
> I know my code is very bad, but I was working on something else. I'm used
> to encountering many pitfalls, bugs from myself or others, omissions here
> and there, not necessarily from me, and if I stop each time, or fix
> everything, I don't make any progress. I come back to this part of the code
> afterwards, of course, I put markers on it. It's _draft_ code. I was fed up
> with this code and in fact it allowed me to see that perhaps in the WSTP
> protocol MathLink can support sending the Julia boolean type ‘bool:
> true|false’ to the Wolfram engine => True|False, just one line of code that
> I'm going to submit and, in passing, ask here to add perhaps a very simple
> but very practical language construction, the conditonal ternary operator
> (condition ? exprIfTrue : exprIfFalse). I don't think the Spad compiler
> handles it. Like C, Perl, Julia etc.

We have ternary operator, it is spelled 'if condition then exprIfTrue else
exprIfFalse'. As a shorthand one can write '(condition => exprIfTrue ;
exprIfFalse)'. I do not think that using C syntax for it would be
good idea.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages