[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] Re: [fricas-devel] Re: RectangularMatrixCategory shoul
From: |
Martin Rubey |
Subject: |
[Axiom-developer] Re: [fricas-devel] Re: RectangularMatrixCategory should have Finite |
Date: |
14 Dec 2007 16:03:58 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 |
Dear Waldek, Gaby, Tim,
below a patch that makes RMATCAT Finite if it is. A testcase is
R==>RectangularMatrix(2,4, PF 2)
every?(zero?, [lookup(index(i))$R - i for i in 1..2^8])
should give true.
I slightly extended the documentation of HOAGG, since, when I read the
original, I was first led to believe that *domains* that have finiteAggregate
would be finite. Although the docstring doesn't say that, of course.
Martin
Index: aggcat.spad.pamphlet
===================================================================
--- aggcat.spad.pamphlet (Revision 150)
+++ aggcat.spad.pamphlet (Arbeitskopie)
@@ -82,9 +82,31 @@
++ In the current system, all aggregates are homogeneous.
++ Two attributes characterize classes of aggregates.
++ Aggregates from domains with attribute \spadatt{finiteAggregate}
-++ have a finite number of members.
-++ Those with attribute \spadatt{shallowlyMutable} allow an element
+++ have a finite number of members. Of course, such a domain may have an
+++ infinite number of elements, like, for example \spadtype{List}.
+++ Those domains with attribute \spadatt{shallowlyMutable} allow an element
++ to be modified or updated without changing its overall value.
+@
+
+It would probably make sense to make [[HOAGG S]] export [[Finite]], when this
+is the case. The following modifications would be necessary:
+\begin{itemize}
+\item we need another attribute, say, [[constantSizeAggregate]], that says that
+ each aggregate has the same number of members.
+\item we need a way to construct an aggregate given a list of its parts, i.e.,
+ an operation
+\begin{verbatim}
+ construct: List R -> %
+\end{verbatim}
+\end{itemize}
+Then, the exports of [[Finite]] could be implemented similar to
+[[RectangularMatrixCategory]].
+
+We should also consider making [[finiteAggregate]] and
+[[constantSizeAggregate]] categories, rather than attributes. This would make
+a lot of things cleaner.
+
+<<category HOAGG HomogeneousAggregate>>=
HomogeneousAggregate(S:Type): Category == Aggregate with
if S has SetCategory then SetCategory
if S has SetCategory then
Index: matcat.spad.pamphlet
===================================================================
--- matcat.spad.pamphlet (Revision 150)
+++ matcat.spad.pamphlet (Arbeitskopie)
@@ -570,6 +570,8 @@
finiteAggregate
++ matrices are finite
+ if R has Finite then Finite
+
if R has CommutativeRing then Module(R)
--% Matrix creation
@@ -674,6 +676,38 @@
++ \spad{nullSpace(m)}+ returns a basis for the null space of
++ the matrix m.
add
+
+ if R has Finite then
+ size() == (size()$R)**(m*n)
+
+ random() == matrix [[random()$R for i in 1..m] for j in 1..n]
+
+ lookup x ==
+ s := size()$R
+ pow: Integer := 1
+ l := listOfLists(x)
+ res: Integer := 1
+ for r in l repeat
+ for c in r repeat
+ res := res + (lookup(c)$R-1)*pow
+ pow := pow*s
+ res::PositiveInteger
+
+ index i ==
+ s := size()$R
+ old := divide(i-1, s)
+ res: List List R := []
+
+ for i in 1..m repeat
+ row: List R := []
+ for j in 1..n repeat
+ el:R := index((old.remainder + 1)::PositiveInteger)$R
+ row := cons(el, row)
+ old := divide(old.quotient, s)
+ res := cons(reverse! row, res)
+
+ matrix reverse! res
+
nrows x == m
ncols x == n
square? x == m = n