> Suppose there's a function like this:
> 
> f(a, b, c, g) == vector([matrix([[g(i, j, k) for k in 1..c] for j in
> 1..b]) for i in 1..a])
> 
> And then if I try to do something like this:
> 
> f(2, 3, 5, (i, j, k) +-> i * j * k) + f(2, 3, 5, (i, j, k) +-> i + j + k)
> 
> or this
> 
> f(2, 3, 5, (i, j, k) +-> i * j * k) - f(2, 3, 5, (i, j, k) +-> i + j + k)
> 
> ... I get an error about the missing library operation.

> At first I thought: why not make Vector(R) be an AbelianGroup if R is
> an AbelianGroup. And make Matrix(R) be an AbelianGroup if R is an
> AbelianGroup.

Neither of which is mathematically correct. What would you expect to get
for this:

  vector [1] + vector [2,3]

? AbelianSemiGroup requires the + operation to be a total function.

> After thinking about it some more, I'm actually not sure why couldn't
> every HomogeneousAggregate(S) have AbelianGroup if S is an
> AbelianGroup. And other algebraic structures apart from AbelianGroup,
> too.

Of course it might be questionable whether the condition for the export
of + from Vector (namely "if R has AbelianSemiGroup") is a good choice.
http://fricas.github.io/api/VectorCategory.html#l566563746f7243617465676f7279-2b

Given that the + for Vector is a partial function anyway, it would have
been enough to just require that the parameter domain R of Vector
provides an operation +: (%, %)->% even if it is neither commutative nor
does fulfil any other "good" properties. But do we really want this?

If you know what your matrix sizes are and what your vector sizes are,
then you should be able to program (in a .spad file) a domain

N ==> NonNegativeinteger
VectorMatrix(m: N, n: N, d: N, R: Join(SemiRng, AbelianMonoid)): E == I
 where
  M ==> RectangularMatrix(m, n, R)
  E ==> DirectProductCategory(d, M) with
          create: ((N,N,N) -> R) -> %
  I ==> DirectProduct(d, M) add
    create(g: (N,N,N) -> R): % ==
      directProduct vector [_
        rectangularMatrix matrix(_
          [[g(i, j, k) for k in 1..n] for j in 1..m])_
        for i in 1..d]

WARNING: I haven't tested the code above, but hopefully you see how it
could go.

You should be able to add two elements of the above "VectorMatrix".

Ralf

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/e489ca44-e988-b6c1-b338-2ff76718e014%40hemmecke.org.

Reply via email to