ALGSC....

19 views
Skip to first unread message

Sid Andal

unread,
Oct 19, 2022, 3:55:54 PM10/19/22
to FriCAS - computer algebra system

The library function ALGSC assigns the algebra to a particular name/tag:

Alg := ALGSC(-, -, -, -)

Is it possible to construct the name dynamically instead of a fixed name,
like Alg, above?

In particular, when defining many algebras over the same vec-space,
I'd like to pick the names in a loop indexing thru an array of names.

Thanks,
SWA

Waldek Hebisch

unread,
Oct 20, 2022, 3:18:13 PM10/20/22
to fricas...@googlegroups.com
It is not clear what you really want. Above "name" is
'AlgebraGivenByStructuralConstants(...)' with arguments instead of
dots. The instruction you gave assigns algebra (a type) to a
variable. This variable is holding a type, which may look
somewhat unusual if you are used to different programming
languages, but otherwise is usual programming language variable.
If you do not want to write instructions with many different
variable names, then you can use usual programming language
solutions: use arrays or lists. Simple example (using
simpler types than ALGSC) for using array is:

(3) -> a_tab := new(10, Void)$PrimitiveArray(Type)

LISP output:
UNPRINTABLE
Type: PrimitiveArray(Type)
(4) -> a_tab(1) := DoubleFloat

(4) DoubleFloat
Type: Type
(5) -> 1::a_tab(1)

(5) 1.0
Type: DoubleFloat

So, you can assign types to array entries, and you can reference
array entries where you need types. Of course, instend of 1 you
can use different indices, which in case of PrimitiveArray is from
0 up to upper value which in our case is 9 (since we requested
array having 10 elements).

Similar example using a list:

(8) -> l : List(Type) := []

LISP output:
NIL
Type: List(Type)
(9) -> l := cons(DoubleFloat, l)

LISP output:
(UNPRINTABLE)
Type: List(Type)
(10) -> 1.0::first(l)

(10) 1.0
Type: DoubleFloat

Both fit well to use in a loop.

Note: there are significant limitations to what can be done with
types in similar computations. In particular, you may be forced
to write your code in Spad.

--
Waldek Hebisch

Sid Andal

unread,
Oct 22, 2022, 11:34:34 AM10/22/22
to FriCAS - computer algebra system
The question was not entirely clear and a little ambiguous....basically, what I was trying to do was something like this:

For a fixed R and N define a set of algebras:

for i in 1..20 repeat
     S.i := a list of symbols depending on i
     L.i := a list of square N x N R-matrices with entries based on i
     A.i := ALGSC(R, N, S.i, L.i)
     i := i + 1

Tried PrimitiveArray(Type) for various usual types and they all worked fine but it didn't seem to allow assigning
the algebra type above.  Perhaps, these types of constructions are only possible in Spad as it was pointed out?
 

Ralf Hemmecke

unread,
Oct 22, 2022, 1:00:22 PM10/22/22
to fricas...@googlegroups.com
> The question was not entirely clear and a little ambiguous....basically,
> what I was trying to do was something like this:
>
> For a fixed R and N define a set of algebras:
>
> for i in 1..20 repeat
>      S.i := a list of symbols depending on i
>      L.i := a list of square N x N R-matrices with entries based on i
>      A.i := ALGSC(R, N, S.i, L.i)
>      i := i + 1

Sid,

such a for-loop is completely useless, because it doesn't solve any problem.

Cannot you describe the actual problem that you want to solve. Perhaps
you do not even need to create an array of algebras. But since the
problem is not clear, nobody can suggest a way to help you to solve it.

Ralf
Reply all
Reply to author
Forward
0 new messages