spad
QuadraticForm(n, K): T == Impl where
n: PositiveInteger
K: Field
SM ==> SquareMatrix
V ==> DirectProduct
T ==> AbelianGroup with
quadraticForm: SM(n, K) -> %
++ quadraticForm(m) creates a quadratic form from a symmetric,
++ square matrix m.
matrix: % -> SM(n, K)
++ matrix(qf) creates a square matrix from the quadratic form qf.
elt: (%, V(n, K)) -> K
++ elt(qf,v) evaluates the quadratic form qf on the vector v,
++ producing a scalar.
coerce: % -> InputForm
Impl ==> SM(n,K) add
Rep := SM(n,K)
import List InputForm
coerce(q:%):InputForm ==
convert(['quadraticForm,algCoerceInteractive(q,SM(n,K),InputForm)$Lisp pretend InputForm])
quadraticForm m ==
not symmetric? m =>
error "quadraticForm requires a symmetric matrix"
m::%
matrix q == q pretend SM(n,K)
elt(q,v) == dot(v, (matrix q * v))
spad
Compiling FriCAS source code from file
/var/zope2/var/LatexWiki/1043127575028836965-25px001.spad using
old system compiler.
processing macro definition SM ==> SquareMatrix
processing macro definition V ==> DirectProduct
processing macro definition T$ ==> -- the constructor category
processing macro definition Impl ==> -- the constructor capsule
------------------------------------------------------------------------
initializing NRLIB QFORM for QuadraticForm
compiling into NRLIB QFORM
importing List InputForm
compiling exported coerce : $ -> InputForm
Time: 0.22 SEC.
compiling exported quadraticForm : SquareMatrix(n,K) -> $
Time: 0.01 SEC.
compiling exported matrix : $ -> SquareMatrix(n,K)
QFORM;matrix;$Sm;3 is replaced by q
Time: 0.01 SEC.
compiling exported elt : ($,DirectProduct(n,K)) -> K
Time: 0.11 SEC.
(time taken in buildFunctor: 0)
;;; *** |QuadraticForm| REDEFINED
;;; *** |QuadraticForm| REDEFINED
Time: 0 SEC.
Warnings:
[1] coerce: pretend(InputForm) -- should replace by @
Cumulative Statistics for Constructor QuadraticForm
Time: 0.35 seconds
--------------non extending category----------------------
.. QuadraticForm(#1,#2) of cat
(|Join| (|AbelianGroup|)
(CATEGORY |domain|
(SIGNATURE |quadraticForm| ($ (|SquareMatrix| |#1| |#2|)))
(SIGNATURE |matrix| ((|SquareMatrix| |#1| |#2|) $))
(SIGNATURE |elt| (|#2| $ (|DirectProduct| |#1| |#2|)))
(SIGNATURE |coerce| ((|InputForm|) $)))) has no
(|SquareMatrixCategory| |#1| |#2| (|DirectProduct| |#1| |#2|)
(|DirectProduct| |#1| |#2|)) finalizing NRLIB QFORM
Processing QuadraticForm for Browser database:
--------(quadraticForm (% (SM n K)))---------
--------(matrix ((SM n K) %))---------
--------(elt (K % (V n K)))---------
--->/usr/local/lib/fricas/target/x86_64-unknown-linux/../../src/algebra/QFORM.spad-->QuadraticForm((coerce ((InputForm) %))): Not documented!!!!
--->/usr/local/lib/fricas/target/x86_64-unknown-linux/../../src/algebra/QFORM.spad-->QuadraticForm(constructor): Not documented!!!!
--->/usr/local/lib/fricas/target/x86_64-unknown-linux/../../src/algebra/QFORM.spad-->QuadraticForm(): Missing Description
------------------------------------------------------------------------
QuadraticForm is now explicitly exposed in frame initial
QuadraticForm will be automatically loaded when needed from
/var/zope2/var/LatexWiki/QFORM.NRLIB/QFORM
axiom
)show QuadraticForm
QuadraticForm(n: PositiveInteger,K: Field) is a domain constructor
Abbreviation for QuadraticForm is QFORM
This constructor is exposed in this frame.
------------------------------- Operations --------------------------------
?*? : (Integer,%) -> % ?*? : (PositiveInteger,%) -> %
?+? : (%,%) -> % ?-? : (%,%) -> %
-? : % -> % ?=? : (%,%) -> Boolean
0 : () -> % coerce : % -> InputForm
coerce : % -> OutputForm ?.? : (%,DirectProduct(n,K)) -> K
hash : % -> SingleInteger latex : % -> String
matrix : % -> SquareMatrix(n,K) sample : () -> %
zero? : % -> Boolean ?~=? : (%,%) -> Boolean
?*? : (NonNegativeInteger,%) -> %
quadraticForm : SquareMatrix(n,K) -> %
subtractIfCan : (%,%) -> Union(%,"failed")
Test
axiom
parse(s:String):InputForm == ncParseFromString(s)$Lisp pretend InputForm
Function declaration parse : String -> InputForm has been added to
workspace.
Type: Void
axiom
parse("Integer")
axiom
Compiling function parse with type String -> InputForm
axiom
qf := quadraticForm matrix [[1,2],[2,-1]]
Type: QuadraticForm
?(2,Fraction Integer)
axiom
qf::InputForm
axiom
unparse %
Type: String
axiom
parse %
axiom
interpret(%)$INFORM1(QuadraticForm(2,Fraction Integer))
Type: QuadraticForm
?(2,Fraction Integer)