aboutsummaryrefslogtreecommitdiff
path: root/src/algebra
diff options
context:
space:
mode:
Diffstat (limited to 'src/algebra')
-rw-r--r--src/algebra/Makefile.in3
-rw-r--r--src/algebra/Makefile.pamphlet3
-rw-r--r--src/algebra/catdef.spad.pamphlet5
-rw-r--r--src/algebra/exposed.lsp.pamphlet1
-rw-r--r--src/algebra/vector.spad.pamphlet52
5 files changed, 60 insertions, 4 deletions
diff --git a/src/algebra/Makefile.in b/src/algebra/Makefile.in
index ca09293a..5d04110f 100644
--- a/src/algebra/Makefile.in
+++ b/src/algebra/Makefile.in
@@ -612,6 +612,7 @@ $(OUT)/DIRPROD.$(FASLEXT): $(OUT)/DIRPCAT.$(FASLEXT)
$(OUT)/DIRPCAT.$(FASLEXT): $(OUT)/VSPACE.$(FASLEXT) $(OUT)/IVECTOR.$(FASLEXT)
$(OUT)/MATRIX.$(FASLEXT): $(OUT)/MATCAT.$(FASLEXT)
$(OUT)/BTAGG.$(FASLEXT): $(OUT)/BOOLE.$(FASLEXT)
+$(OUT)/LINELT.$(FASLEXT): $(OUT)/VSPACE.$(FASLEXT) $(OUT)/FM.$(FASLEXT)
axiom_algebra_layer_10 = \
RESULT BFUNCT BPADIC ANY \
@@ -640,7 +641,7 @@ axiom_algebra_layer_10 = \
FUNDESC XPBWPOLY SMATCAT SMATCAT- \
RMATRIX RMATCAT RMATCAT- DIRPROD \
DIRPCAT DIRPCAT- IVECTOR MATRIX \
- MATCAT MATCAT- IIARRAY2
+ MATCAT MATCAT- IIARRAY2 LINELT
axiom_algebra_layer_10_nrlibs = \
diff --git a/src/algebra/Makefile.pamphlet b/src/algebra/Makefile.pamphlet
index b51a660e..2a600ccb 100644
--- a/src/algebra/Makefile.pamphlet
+++ b/src/algebra/Makefile.pamphlet
@@ -619,6 +619,7 @@ $(OUT)/DIRPROD.$(FASLEXT): $(OUT)/DIRPCAT.$(FASLEXT)
$(OUT)/DIRPCAT.$(FASLEXT): $(OUT)/VSPACE.$(FASLEXT) $(OUT)/IVECTOR.$(FASLEXT)
$(OUT)/MATRIX.$(FASLEXT): $(OUT)/MATCAT.$(FASLEXT)
$(OUT)/BTAGG.$(FASLEXT): $(OUT)/BOOLE.$(FASLEXT)
+$(OUT)/LINELT.$(FASLEXT): $(OUT)/VSPACE.$(FASLEXT) $(OUT)/FM.$(FASLEXT)
axiom_algebra_layer_10 = \
RESULT BFUNCT BPADIC ANY \
@@ -647,7 +648,7 @@ axiom_algebra_layer_10 = \
FUNDESC XPBWPOLY SMATCAT SMATCAT- \
RMATRIX RMATCAT RMATCAT- DIRPROD \
DIRPCAT DIRPCAT- IVECTOR MATRIX \
- MATCAT MATCAT- IIARRAY2
+ MATCAT MATCAT- IIARRAY2 LINELT
axiom_algebra_layer_10_nrlibs = \
diff --git a/src/algebra/catdef.spad.pamphlet b/src/algebra/catdef.spad.pamphlet
index 104c4f10..1c22c456 100644
--- a/src/algebra/catdef.spad.pamphlet
+++ b/src/algebra/catdef.spad.pamphlet
@@ -295,12 +295,15 @@ OrderedType(): Category == BasicType with
++ a model of the category \spadtype{OrderedType}.
)abbrev domain ORDSTRCT OrderedStructure
OrderedStructure(T: Type,f: (T,T) -> Boolean): Public == Private where
- Public == Join(OrderedType,HomotopicTo T)
+ Public == Join(OrderedType,HomotopicTo T) with
+ if T has CoercibleTo OutputForm then CoercibleTo OutputForm
Private == add
Rep == T
coerce(x: %): T == rep x
coerce(y: T): % == per y
x < y == f(rep x,rep y)
+ if T has CoercibleTo OutputForm then
+ coerce(x: %): OutputForm == rep(x)::OutputForm
@
diff --git a/src/algebra/exposed.lsp.pamphlet b/src/algebra/exposed.lsp.pamphlet
index 66f6278f..ba666e3a 100644
--- a/src/algebra/exposed.lsp.pamphlet
+++ b/src/algebra/exposed.lsp.pamphlet
@@ -231,6 +231,7 @@
(|LetAst| . LETAST)
(|Library| . LIB)
(|LieSquareMatrix| . LSQM)
+ (|LinearElement| . LINELT)
(|LinearOrdinaryDifferentialOperator| . LODO)
(|LinearSystemMatrixPackage| . LSMP)
(|LinearSystemMatrixPackage1| . LSMP1)
diff --git a/src/algebra/vector.spad.pamphlet b/src/algebra/vector.spad.pamphlet
index 08ec4b60..05474370 100644
--- a/src/algebra/vector.spad.pamphlet
+++ b/src/algebra/vector.spad.pamphlet
@@ -447,11 +447,60 @@ DirectProductFunctions2(dim, A, B): Exports == Implementation where
reduce(f, v, b) == reduce(f, v::VA, b)
@
+
+\section{Vector space of finite dimension given by a basis}
+
+<<domain LINELT LinearElement>>=
+)abbrev domain LINELT LinearElement
+++ Author: Gabriel Dos Reis
+++ Date Created: June 30, 2010
+++ Date Last Modified: June 30, 2010
+++ Description:
+++ A simple data structure for elements that form a
+++ vector space of finite dimension over a given field,
+++ with a given symbolic basis.
+LinearElement(K,B): Public == Private where
+ K: Field
+ B: List Symbol
+ macro Basis == OrderedVariableList B
+ Public == Join(VectorSpace K,CoercibleFrom Basis) with
+ linearElement: (List K,List Basis) -> %
+ ++ \spad{linearElement([x1,..,xn],[b1,..,bn]) constructs
+ ++ a linear element with coordinates \spad{[x1,..,xn]} with
+ ++ respect to the basis elements \spad{b1},...\spad{bn}.
+ coordinates: % -> Vector K
+ ++ \spad{coordinates x} returns the coordinates of the linear
+ ++ element with respect to the basis \spad{B}.
+ Private == FreeModule(K,Basis) add
+ coerce(b: Basis): % ==
+ per monomial(1$K,b)
+
+ dimension() ==
+ size()$Basis::CardinalNumber
+
+ linearElement(cs,bs) ==
+ null cs or null bs => per 0$Rep
+ reduce(_+@(%,%)->%,
+ [per monomial(c,b) for c in cs for b in bs])
+
+ coordinates x ==
+ n := #B
+ v: Vector K := new(n,0$K)
+ ts := terms rep x
+ for i in 1..n repeat
+ t := first ts
+ lookup first t = i =>
+ v.i := second t
+ ts := rest ts
+ v
+@
+
+
\section{License}
<<license>>=
--Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
--All rights reserved.
---Copyright (C) 2007-2009, Gabriel Dos Reis.
+--Copyright (C) 2007-2010, Gabriel Dos Reis.
--All rights reserved.
--
--Redistribution and use in source and binary forms, with or without
@@ -492,6 +541,7 @@ DirectProductFunctions2(dim, A, B): Exports == Implementation where
<<category DIRPCAT DirectProductCategory>>
<<domain DIRPROD DirectProduct>>
<<package DIRPROD2 DirectProductFunctions2>>
+<<domain LINELT LinearElement>>
@
\eject