Some questions about gen class

Librairie C++ de calcul formel/ C++ symbolic computation library

Modérateur : xcasadmin

lukamar
Messages : 294
Inscription : ven. juin 30, 2017 9:55 am
Localisation : Zagreb, Croatia

Some questions about gen class

Message par lukamar » mar. déc. 19, 2017 1:23 pm

Hello Bernard,

Can you help me to clarify some details about gen class? I have a few questions.
1. How do I know when gen holds an error message (generated by undeferr function)? Is it enough to check subtype==-1?
2. Is there an "at_" variable assigned to Hadamard/Schur matrix product?
3. What's the difference between is_real and is_approx? I assume that is_approx just checks for a floating point number. But I haven't figured out what does REAL unary type mean... What purpose are gen unary types SPOL1, EXT, USER, EQW and POINTER used for?
4. What are gen_binary_types for?

I also have some questions about giac::context structure.
1. What are globalcontextptr and globalptr fields for?
2. How are contexts organized? I see that it has "parent" and "previous" fields... How does one use these?
3. What are quoted_global_vars, rootofs and tabptr fields?
4. How does one set parameters for a context (Digits, epsilon etc.)?

Thanks in advance!
Luka

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

Re: Some questions about gen class

Message par jocaps » mer. déc. 20, 2017 5:10 am

Hello Luka,

I am just half guessing. But isn't at_pointprod the Hadamard product? I haven't tried it myself but just looked at the C code.

Jose

lukamar
Messages : 294
Inscription : ven. juin 30, 2017 9:55 am
Localisation : Zagreb, Croatia

Re: Some questions about gen class

Message par lukamar » mer. déc. 20, 2017 7:46 am

Thanks, Jose. You're right, at_pointprod corresponds to Hadamard product indeed, I've just tried it. I missed at_pointprod as I thought it has to be at_dotprod...

parisse
Messages : 5084
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Some questions about gen class

Message par parisse » mer. déc. 20, 2017 3:33 pm

lukamar a écrit :Hello Bernard,

Can you help me to clarify some details about gen class? I have a few questions.
1. How do I know when gen holds an error message (generated by undeferr function)? Is it enough to check subtype==-1?
The easiest is to call is_undef(g)
3. What's the difference between is_real and is_approx? I assume that is_approx just checks for a floating point number. But I haven't figured out what does REAL unary type mean... What purpose are gen unary types SPOL1, EXT, USER, EQW and POINTER used for?
is_real checks that the argument does not contain complex numbers, while is_approx checks that there are no approx data. _REAL is for multi-precision floats (MPFR type), SPOL1 for univariate series expansion (sparse polynomial), EXT for algebraic extensions (of Q), USER for user defined data type, currently it's used for Galois field extensions, EQW for the FLTK equation writer, and POINTER is used for cached graphics in 2d graphs in FLTK.
4. What are gen_binary_types for?
This is used in case structures for binary operator type dispatch.
I also have some questions about giac::context structure.
1. What are globalcontextptr and globalptr fields for?
2. How are contexts organized? I see that it has "parent" and "previous" fields... How does one use these?
3. What are quoted_global_vars, rootofs and tabptr fields?
4. How does one set parameters for a context (Digits, epsilon etc.)?

Thanks in advance!
Luka
You should not directly handle globalcontextptr, etc. If you want to modify the context, there is a command in global.cc/.h that should do it, for example Digits is associated to decimal_digits(contextptr), epsilon to epsilon(contextptr) etc.

lukamar
Messages : 294
Inscription : ven. juin 30, 2017 9:55 am
Localisation : Zagreb, Croatia

Re: Some questions about gen class

Message par lukamar » mer. déc. 20, 2017 7:54 pm

Why is gen::is_constant not returning true for _FRAC type? It returns true for 0.5 but false for 1/2 (entered as fraction(1,2))...

parisse
Messages : 5084
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Some questions about gen class

Message par parisse » jeu. déc. 21, 2017 7:05 am

Well, the name is somewhat misleading, it is used to check that it is a "valid" coefficient inside a polynomial or algebraic extension (I mean you don't have to care about fraction reduction or symbolic or identifier). It's easy to "clone" the method and add the fraction type to the true return value.

Répondre