Tensor Product

23 views
Skip to first unread message

Sid Andal

unread,
May 9, 2023, 12:32:10 PM5/9/23
to FriCAS - computer algebra system

Problem defining the tensor product of two algebras A2 and A3
as defined below:

FN := PrimeField 11

S2 ==> SQMATRIX(2, FN)

M : S2 := [[10, 7], [3, 8]]
N : S2 := [[9, 2], [5, 1]]

A2 := ALGSC(FN, 2, ['E1, 'E2], [M, N])

V2 := basis()$A2
(E1, E2) := (V2(1), V2(2))

)clear p M N

S3 ==> SQMATRIX(3, FN)

M : S3 := [[5, 3, 10], [9, 4, 7], [2, 10, 1]]
N : S3 := [[4, 2, 5], [6, 1, 7], [10, 5, 8]]
P : S3 := [[7, 3, 9], [8, 1, 5], [4, 2, 7]]

A3 := ALGSC(FN, 3, ['F1, 'F2, 'F3], [M, N, P])

V3 := basis()$A3
(F1, F2, F3) := (V3(1), V3(2), V3(3))

)clear p M N P

using  TensorProduct(R, B1, B2, M1, M2)

with FN for R and A2 and A3 for M1 and M2, resp., but
having trouble defining B1 and B2 in terms of V2 and V3.

SWA

Waldek Hebisch

unread,
May 9, 2023, 4:29:42 PM5/9/23
to fricas...@googlegroups.com
On Tue, May 09, 2023 at 09:32:10AM -0700, Sid Andal wrote:
>
> Problem defining the tensor product of two algebras A2 and A3
> as defined below:
>
> FN := PrimeField 11
>
> S2 ==> SQMATRIX(2, FN)
>
> M : S2 := [[10, 7], [3, 8]]
> N : S2 := [[9, 2], [5, 1]]
>
> A2 := ALGSC(FN, 2, ['E1, 'E2], [M, N])
>
<snip>
> using TensorProduct(R, B1, B2, M1, M2)
>
> with FN for R and A2 and A3 for M1 and M2, resp., but
> having trouble defining B1 and B2 in terms of V2 and V3.

Currently TensorProduct requires that M1 has FreeModuleCategory(R, B1)
and similarly for M2. But AlgebraGivenByStructuralConstants does
not have FreeModuleCategory. So one needs to modify
AlgebraGivenByStructuralConstants to add FreeModuleCategory
and implement needed functions. See attached (only lightly tested)
patch for how one can do this.

--
Waldek Hebisch
ALGSC.diff

Sid Andal

unread,
May 10, 2023, 2:27:25 PM5/10/23
to FriCAS - computer algebra system
The patch file ALGSC.diff was applied to the file naalg.spad (no ALGSC.spad file in the installation src dir)
containing the AlgebraGivenByStructuralConstants entry and compiled.

The Algs A2 and A3 with bases V2 and V3 are as before.

The call to TensorProduct gives an invalid type error:

(22) -> TA := TensorProduct(FN, V2, V3, A2, A3)
 
   V2 is not a valid type.

(22) ->

SWA

Waldek Hebisch

unread,
May 10, 2023, 2:57:24 PM5/10/23
to fricas...@googlegroups.com
On Wed, May 10, 2023 at 11:27:25AM -0700, Sid Andal wrote:
> The patch file ALGSC.diff was applied to the file naalg.spad (no ALGSC.spad
> file in the installation src dir)
> containing the AlgebraGivenByStructuralConstants entry and compiled.
>
> The Algs A2 and A3 with bases V2 and V3 are as before.
>
> The call to TensorProduct gives an invalid type error:
>
> (22) -> TA := TensorProduct(FN, V2, V3, A2, A3)
>
> V2 is not a valid type.


Yes. The patch uses OrderedVariableList. So you need:

o2 := OVAR(['E1, 'E2])
o3 := OVAR(['F1, 'F2, 'F3])

Then

tP := TensorProduct(FN, o2, o3, A2, A3)

works and you can do

tensor((basis()$A2)(1), (basis()$A3)(1))$tP


--
Waldek Hebisch

Sid Andal

unread,
May 16, 2023, 10:41:15 AM5/16/23
to FriCAS - computer algebra system
Obtained the tensor product, TA, of A2 and A3 as before with the following tensor basis:

B11 := tensor(E1, F1)$TA
 

   (18)  E1 # F1
B12 := tensor(E1, F2)$TA
 

   (19)  E1 # F2
B13 := tensor(E1, F3)$TA
 

   (20)  E1 # F3
B21 := tensor(E2, F1)$TA
 

   (21)  E2 # F1
B22 := tensor(E2, F2)$TA
 

   (22)  E2 # F2
B23 := tensor(E2, F3)$TA
 

   (23)  E2 # F3
(24) ->


The vector V, defined below, fails to form the product with itself:


(24) -> V := 2 * B11 + 3 * B23

   (24)  2 E1 # F1 + 3 E2 # F3
(25) ->


(25) -> V * V
   There are 31 exposed and 40 unexposed library operations named *
      having 2 argument(s) but none was determined to be applicable.
      Use HyperDoc Browse, or issue
                                )display op *
      to learn more about the available operations. Perhaps
      package-calling the operation or using coercions on the arguments
      will allow you to apply the operation.
 
   Cannot find a definition or applicable library operation named *
      with argument type(s)
TensorProduct(PrimeField(11),OrderedVariableList([E1,E2]),OrderedVariableList([F1,F2,F3]),AlgebraGivenByStructuralConstants(PrimeField(11),2,[E1,E2],[[[10,7],[3,8]],[[9,2],[5,1]]]),AlgebraGivenByStructuralConstants(PrimeField(11),3,[F1,F2,F3],[[[5,3,10],[9,4,7],[2,10,1]],[[4,2,5],[6,1,7],[10,5,8]],[[7,3,9],[8,1,5],[4,2,7]]]))
TensorProduct(PrimeField(11),OrderedVariableList([E1,E2]),OrderedVariableList([F1,F2,F3]),AlgebraGivenByStructuralConstants(PrimeField(11),2,[E1,E2],[[[10,7],[3,8]],[[9,2],[5,1]]]),AlgebraGivenByStructuralConstants(PrimeField(11),3,[F1,F2,F3],[[[5,3,10],[9,4,7],[2,10,1]],[[4,2,5],[6,1,7],[10,5,8]],[[7,3,9],[8,1,5],[4,2,7]]]))
     
      Perhaps you should use "@" to indicate the required return type,
      or "$" to specify which version of the function you need.

(25) ->


Just wondering, is the tensor product, TA, only a vector-space or is it an algebra too?

Waldek Hebisch

unread,
May 16, 2023, 12:30:27 PM5/16/23
to fricas...@googlegroups.com
module

or is it an
> algebra too?

No, ATM one needs to define ring/algebra structure separately.

--
Waldek Hebisch

Ralf Hemmecke

unread,
May 16, 2023, 12:45:45 PM5/16/23
to fricas...@googlegroups.com
The website

https://fricas.github.io/api/TensorProduct.html

does show *: (%,%)->%.

Ralf

Waldek Hebisch

unread,
May 16, 2023, 1:55:37 PM5/16/23
to fricas...@googlegroups.com
This is defined only in associative case. Sid Andal has
nonassociative algebra. Actually, code for multiplication
should work, but it is conditioned on Algebra(R), so does
not apply in nonassociative case.

--
Waldek Hebisch

Ralf Hemmecke

unread,
May 16, 2023, 3:08:18 PM5/16/23
to fricas...@googlegroups.com
>> https://fricas.github.io/api/TensorProduct.html
>>
>> does show *: (%,%)->%.
>
> This is defined only in associative case. Sid Andal has
> nonassociative algebra. Actually, code for multiplication
> should work, but it is conditioned on Algebra(R), so does
> not apply in nonassociative case.

Oh, uh! Obviously, I should update that website, on my local
installation TensorProduct shows

*: (%, %) -> % if M2 has Algebra R and M1 has Algebra R
from LeftModule %

but it is not online. :-( Sorry.

Ralf

Sid Andal

unread,
May 17, 2023, 12:35:40 PM5/17/23
to FriCAS - computer algebra system
Is there any way around the associativity condition required by Algebra(R)
to make the multiplication applicable to all algebras?

Waldek Hebisch

unread,
May 18, 2023, 10:18:50 AM5/18/23
to fricas...@googlegroups.com
On Wed, May 17, 2023 at 09:35:40AM -0700, Sid Andal wrote:
> Is there any way around the associativity condition required by Algebra(R)
> to make the multiplication applicable to all algebras?

Needed change is small, I commited it now to FriCAS trunk. But
to use it you need to recompile FriCAS.

--
Waldek Hebisch

Sid Andal

unread,
May 19, 2023, 5:39:21 PM5/19/23
to FriCAS - computer algebra system
Compile the entire FriCAS or just the updated/modified spad files?

Waldek Hebisch

unread,
May 19, 2023, 8:52:20 PM5/19/23
to fricas...@googlegroups.com
On Fri, May 19, 2023 at 02:39:21PM -0700, Sid Andal wrote:
> Compile the entire FriCAS or just the updated/modified spad files?

Entire FriCAS. In principle you could recompile only files affected
by the change, but several unmodified files are affected so it
is simpler to recompile entire FriCAS.

--
Waldek Hebisch

Sid Andal

unread,
May 30, 2023, 10:31:20 AM5/30/23
to FriCAS - computer algebra system
Compilation of the updated naalg.spad leads to the following errors:


(1) -> )compile naalg.spad
.
.
.
.
****** Domain: R already in scope
augmenting R: (IntegralDomain)
   processing macro definition LSMP ==> LinearSystemMatrixPackage2 R
   compiling exported coordinates : ($,Vector $) -> Vector R
   Semantic Errors:
      [1] reductum:  first is BOTH a variable and a literal
      [2] coordinates:  LinearSystemMatrixPackage2 is not a known type
 
   Warnings:
      [1] monomial?:  x has no value
      [2] construct:  k has no value
      [3] construct:  c has no value
 
****** comp fails at level 3 with expression: ******
error in function coordinates

(SEQ
 (|:=| (|:| |m| (|NonNegativeInteger|))
  (|::| (|maxIndex| |b|) (|NonNegativeInteger|)))
 (|:=| (|:| |transitionMatrix| (|Matrix| R))
  ((|Sel| (|Matrix| R) |new|) |n| |m| (|Sel| R 0)))
 (REPEAT (IN |i| (SEGMENT 1 |m|))
         (|setColumn!| |transitionMatrix| |i| (|coordinates| (|b| |i|))))
 (|:=| |res| | << |
  ((|Sel| (|LinearSystemMatrixPackage2| R) |solveUniquely|) |transitionMatrix|
   (|coordinates| |x|))
  | >> |)
 (|exit| 1
  (IF (|case| |res| "failed")
      (|error| "coordinates: solveUniquely failed")
      (@ |res| (|Vector| R)))))
****** level 3  ******
$x:= ((Sel (LinearSystemMatrixPackage2 R) solveUniquely) transitionMatrix (coordinates x))
$m:= $EmptyMode
$f:=
((((|i| # #) (|transitionMatrix| # #) (|m| # #) ($$ #) ...)))
 
   >> Apparent user error:
   NoValueMode
    is an unknown mode

(1) ->

Grégory Vanuxem

unread,
May 30, 2023, 10:52:37 AM5/30/23
to fricas...@googlegroups.com
Hello Sid,

Have you tried to completely build the FriCAS Git version, Waldek have committed different things I think. Personally, the copy of FriCAS I'm working on has the totality of FriCAS algebra source code and I do not encounter this issue. May be your FriCAS version is missing algebra  modifications. 

Regards, 
__
Greg

--
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/7ba54f02-a1a3-4fe7-a8a9-6ea403a2775cn%40googlegroups.com.

Grégory Vanuxem

unread,
May 30, 2023, 10:57:51 AM5/30/23
to fricas...@googlegroups.com
With installed sbcl and gcc, just a:

cd fricas && ./configure && make && sudo make install

should do the trick.

Waldek Hebisch

unread,
May 30, 2023, 6:39:21 PM5/30/23
to fricas...@googlegroups.com
You need also earlier tensor-related changes. When you fetch
sources via git you will get complete set of changes.

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