NCExpandReplaceRepeatedSelfAdjoint[expr,rules]
repeatedly applies NCReplaceRepeatedSelfAdjoint
and
NCExpand
until the results does not change.
NCExpandedReplaceRepeatedSelfAdjoint[expr,rules,options]
uses options
.
See also: NCReplaceRepeatedSelfAdjoint, NCExpandReplaceRepeated, NCExpandReplaceRepeatedSymmetric.
NCReplaceListSelfAdjoint[expr, rules]
applies
NCMakeRuleSelfAdjoint
to rules
before calling
NCReplaceList
.
NCReplaceListSelfAdjoint[expr,rules,options]
uses
options
.
See also: NCReplaceList, NCMakeRuleSelfAdjoint.
NCRSA
is an alias for
NCReplaceSymmetric
.
See also: NCReplaceSymmetric.
NCRASA
is an alias for
NCReplaceAllSymmetric
.
See also: NCReplaceAllSymmetric.
NCRRSA
is an alias for
NCReplaceRepeatedSymmetric
.
See also: NCReplaceRepeatedSymmetric.
NCRLSA
is an alias for
NCReplaceListSymmetric
.
See also: NCReplaceListSymmetric.
NCMatrixExpand[expr]
expands inv
and
**
of matrices appearing in nc expression
expr
. It effectively substitutes inv
for
NCInverse
and **
by NCDot
.
NCMatrixReplaceAll[expr,rules]
applies a rule or list of
rules rules
in an attempt to transform each part of the nc
expression expr
.
NCMatrixReplaceAll
works as NCReplaceAll
but takes extra steps to make sure substitutions work with matrices.
See also: NCReplaceAll, NCMatrixReplaceRepeated.
NCMatrixReplaceRepeated[expr,rules]
repeatedly performs
replacements using rule or list of rules rules
until
expr
no longer changes.
NCMatrixReplaceRepeated
works as
NCReplaceRepeated
but takes extra steps to make sure
substitutions work with matrices.
See also: NCReplaceRepeated, NCMatrixReplaceAll.
NCReplacePowerRule[rule]
transforms rules that consist
of a noncommutative monomial so that symbols appearing on the left and
on right of the monomial also match positive powers of that symbol.
See also: NCReplace, NCReplaceAll, NCReplaceList, NCReplaceRepeated.
Members are:
NCSymmetricQ[expr]
returns True if
expr
is symmetric, i.e. if tp[exp] == exp
.
NCSymmetricQ
attempts to detect symmetric variables
using NCSymmetricTest
.
See also: NCSelfAdjointQ, NCSymmetricTest.
NCSymmetricTest[expr]
attempts to establish symmetry of
expr
by assuming symmetry of its variables.
NCSymmetricTest[exp,options]
uses
options
.
NCSymmetricTest
returns a list of two elements:
expr
symmetric.The following options can be given:
SymmetricVariables
: list of variables that should be
considered symmetric; use All
to make all variables
symmetric;ExcludeVariables
: list of variables that should not be
considered symmetric; use All
to exclude all
variables;Strict
: treats as non-symmetric any variable that
appears inside tp
.See also: NCSymmetricQ, NCNCSelfAdjointTest.
NCSymmetricPart[expr]
returns the symmetric
part of expr
.
NCSymmetricPart[exp,options]
uses
options
.
NCSymmetricPart[expr]
returns a list of two
elements:
expr
;NCSymmetricPart[expr]
returns {$Failed, {}}
if expr
is not symmetric.
For example:
{answer, symVars} = NCSymmetricPart[a ** x + x ** tp[a] + 1];
returns
answer = 2 a ** x + 1
symVars = {x}
The following options can be given:
SymmetricVariables
: list of variables that should be
considered symmetric; use All
to make all variables
symmetric;ExcludeVariables
: list of variables that should not be
considered symmetric; use All
to exclude all
variables.Strict
: treats as non-symmetric any variable that
appears inside tp
.See also: NCSymmetricTest.
NCSelfAdjointQ[expr]
returns true if expr
is self-adjoint, i.e. if aj[exp] == exp
.
See also: NCSymmetricQ, NCSelfAdjointTest.
NCSelfAdjointTest[expr]
attempts to establish whether
expr
is self-adjoint by assuming that some of its variables
are self-adjoint or symmetric.
NCSelfAdjointTest[expr,options]
uses
options
.
NCSelfAdjointTest
returns a list of three elements:
expr
self-adjoint.The following options can be given:
SelfAdjointVariables
: list of variables that should be
considered self-adjoint; use All
to make all variables
self-adjoint;SymmetricVariables
: list of variables that should be
considered symmetric; use All
to make all variables
symmetric;ExcludeVariables
: list of variables that should not be
considered symmetric; use All
to exclude all
variables.Strict
: treats as non-self-adjoint any variable that
appears inside aj
.See also: NCSelfAdjointQ.
NCSimplifyRational is a package with function that simplifies noncommutative expressions and certain functions of their inverses.
NCSimplifyRational
simplifies rational noncommutative
expressions by repeatedly applying a set of reduction rules to the
expression. NCSimplifyRationalSinglePass
does only a single
pass.
Rational expressions of the form
inv[A + terms]
are first normalized to
inv[1 + terms/A]/A
using NCNormalizeInverse
. Here A
is
commutative.
For each inv
found in expression, a custom set of rules
is constructed based on its associated NC Groebner basis.
For example, if
inv[mon1 + ... + K lead]
where lead
is the leading monomial with the highest
degree then the following rules are generated:
| Original | Transformed |
|---|---|
| inv[mon1 + … + K lead] lead | (1 - inv[mon1 + … + K lead] (mon1 + …))/K |
| lead inv[mon1 + … + K lead] | (1 - (mon1 + …) inv[mon1 + … + K lead])/K |
Finally the following pattern based rules are applied:
| Original | Transformed |
|---|---|
| inv[a] inv[1 + K a b] | inv[a] - K b inv[1 + K a b] |
| inv[a] inv[1 + K a] | inv[a] - K inv[1 + K a] |
| inv[1 + K a b] inv[b] | inv[b] - K inv[1 + K a b] a |
| inv[1 + K a] inv[a] | inv[a] - K inv[1 + K a] |
| inv[1 + K a b] a | a inv[1 + K b a] |
| inv[A inv[a] + B b] inv[a] | (1/A) inv[1 + (B/A) a b] |
| inv[a] inv[A inv[a] + K b] | (1/A) inv[1 + (B/A) b a] |
| inv[1 + K a b] a b | (1 - inv[1 + K a b])/K |
| inv[1 + K a] a | (1 - inv[1 + K a])/K |
| a b inv[1 + K a b] | (1 - inv[1 + K a b])/K |
| a inv[1 + K a] | (1 - inv[1 + K a])/K |
NCPreSimplifyRational
only applies pattern based rules
from the table above once.
Rules in NCSimplifyRational
and
NCPreSimplifyRational
are applied repeatedly.
Rules in NCSimplifyRationalSinglePass
and
NCPreSimplifyRationalSinglePass
are applied only once.
The particular ordering of monomials used by
NCSimplifyRational
is the one implied by the
NCPolynomial
format. This ordering is a variant of the
deg-lex ordering where the lexical ordering is Mathematica’s natural
ordering.
NCSimplifyRational
is limited by its rule list and what
rules are best is unknown and might depend on additional assumptions.
For example:
NCSimplifyRational[y ** inv[y + x ** y]]
returns y ** inv[y + x ** y]
not
inv[1 + x]
, which is what one would expect if
y
were to be invertible. Indeed,
NCSimplifyRational[inv[y] ** inv[inv[y] + x ** inv[y]]]
does return inv[1 + x]
, since in this case the appearing
of inv[y]
trigger rules that implicitely assume
y
is invertible.
Members are:
Aliases:
NCNormalizeInverse[expr]
transforms all rational NC
expressions of the form inv[K + b]
into
inv[1 + (1/K) b]/K
if A
is commutative.
See also: NCSimplifyRational, NCSimplifyRationalSinglePass.
NCSimplifyRational[expr]
repeatedly applies
NCSimplifyRationalSinglePass
in an attempt to simplify the
rational NC expression expr
.
See also: NCNormalizeInverse, NCSimplifyRationalSinglePass.
NCSR
is an alias for
NCSimplifyRational
.
See also: NCSimplifyRational.
NCSimplifyRationalSinglePass[expr]
applies a series of
custom rules only once in an attempt to simplify the rational NC
expression expr
.
See also: NCNormalizeInverse, NCSimplifyRational.
NCPreSimplifyRational[expr]
repeatedly applies
NCPreSimplifyRationalSinglePass
in an attempt to simplify
the rational NC expression expr
.
See also: NCNormalizeInverse, NCPreSimplifyRationalSinglePass.
NCPreSimplifyRationalSinglePass[expr]
applies a series
of custom rules only once in an attempt to simplify the rational NC
expression expr
.
See also: NCNormalizeInverse, NCPreSimplifyRational.
NCDiff is a package containing several functions that are used in noncommutative differention of functions and polynomials.
Members are:
Members being deprecated:
NCDirectionalD[expr, {var1, h1}, ...]
takes the
directional derivative of expression expr
with respect to
variables var1
, var2
, … successively in the
directions h1
, h2
, ….
For example, if:
expr = a**inv[1+x]**b + x**c**x
then
NCDirectionalD[expr, {x,h}]
returns
h**c**x + x**c**h - a**inv[1+x]**h**inv[1+x]**b
In the case of more than one variables
NCDirectionalD[expr, {x,h}, {y,k}]
takes the directional
derivative of expr
with respect to x
in the
direction h
and with respect to y
in the
direction k
. For example, if:
expr = x**q**x - y**x
then
NCDirectionalD[expr, {x,h}, {y,k}]
returns
h**q**x + x**q*h - y**h - k**x
NCGrad[expr, var1, ...]
gives the nc gradient of the
expression expr
with respect to variables
var1
, var2
, …. If there is more than one
variable then NCGrad
returns the gradient in a list.
The transpose of the gradient of the nc expression expr
is the derivative with respect to the direction h
of the
trace of the directional derivative of expr
in the
direction h
.
For example, if:
expr = x**a**x**b + x**c**x**d
then its directional derivative in the direction h
is
NCDirectionalD[expr, {x,h}]
which returns
h**a**x**b + x**a**h**b + h**c**x**d + x**c**h**d
and
NCGrad[expr, x]
returns the nc gradient
a**x**b + b**x**a + c**x**d + d**x**c
For example, if:
expr = x**a**x**b + x**c**y**d
is a function on variables x
and y
then
NCGrad[expr, x, y]
returns the nc gradient list
{a**x**b + b**x**a + c**y**d, d**x**c}
IMPORTANT: The expression returned by NCGrad is the transpose or the adjoint of the standard gradient. This is done so that no assumption on the symbols are needed. The calculated expression is correct even if symbols are self-adjoint or symmetric.
See also: NCDirectionalD.
NCHessian[expr, {var1, h1}, ...]
takes the second
directional derivative of nc expression expr
with respect
to variables var1
, var2
, … successively in the
directions h1
, h2
, ….
For example, if:
expr = y**inv[x]**y + x**a**x
then
NCHessian[expr, {x,h}, {y,s}]
returns
2 h**a**h + 2 s**inv[x]**s - 2 s**inv[x]**h**inv[x]**y -
2 y**inv[x]**h**inv[x]**s + 2 y**inv[x]**h**inv[x]**h**inv[x]**y
In the case of more than one variables
NCHessian[expr, {x,h}, {y,k}]
takes the second directional
derivative of expr
with respect to x
in the
direction h
and with respect to y
in the
direction k
.
See also: NCDiretionalD, NCGrad.
DirectionalD[expr,var,h]
takes the directional
derivative of nc expression expr
with respect to the single
variable var
in direction h
.
DEPRECATION NOTICE: This syntax is limited to one variable and is being deprecated in favor of the more general syntax in NCDirectionalD.
See also: NCDirectionalD.
NCIntegrate[expr,{var1,h1},...]
attempts to calculate
the nc antiderivative of nc expression expr
with respect to
the single variable var
in direction h
.
For example:
NCIntegrate[x**h+h**x, {x,h}]
returns
x**x
See also: NCDirectionalD.
NCConvexity is a package that provides functionality to determine whether a rational or polynomial noncommutative function is convex.
Members are:
NCIndependent[list]
attempts to determine whether the nc
entries of list
are independent.
Entries of NCIndependent
can be nc polynomials or nc
rationals.
For example:
NCIndependent[{x,y,z}]
return True while
NCIndependent[{x,0,z}]
NCIndependent[{x,y,x}]
NCIndependent[{x,y,x+y}]
NCIndependent[{x,y,A x + B y}]
NCIndependent[{inv[1+x]**inv[x], inv[x], inv[1+x]}]
all return False.
See also: NCConvexityRegion.
NCConvexityRegion[expr,vars]
is a function which can be
used to determine whether the nc rational expr
is convex in
vars
or not.
For example:
d = NCConvexityRegion[x**x**x, {x}];
returns
d = {2 x, -2 inv[x]}
from which we conclude that x**x**x
is not convex in
x
because \(x \succ 0\)
and \(-{x}^{-1} \succ 0\) cannot
simultaneously hold.
NCConvexityRegion
works by factoring the
NCHessian
, essentially calling:
hes = NCHessian[expr, {x, h}];
then
{lt, mq, rt} = NCMatrixOfQuadratic[hes, {h}]
to decompose the Hessian into a product of a left row vector,
lt
, times a middle matrix, mq
, times a right
column vector, rt
. The middle matrix, mq
, is
factored using the NCLDLDecomposition
:
{ldl, p, s, rank} = NCLDLDecomposition[mq];
{lf, d, rt} = GetLDUMatrices[ldl, s];
from which the output of NCConvexityRegion is the a list with the
block-diagonal entries of the matrix d
.
See also: NCHessian, NCMatrixOfQuadratic, NCLDLDecomposition.
Members are:
tpMat[mat]
gives the transpose of matrix
mat
using tp
.
See also: ajMat, coMat, NCDot.
ajMat[mat]
gives the adjoint transpose of matrix
mat
using aj
instead of
ConjugateTranspose
.
See also: tpMat, coMat, NCDot.
coMat[mat]
gives the conjugate of matrix
mat
using co
instead of
Conjugate
.
See also: tpMat, ajMat, NCDot.
NCDot[mat1, mat2, ...]
gives the matrix multiplication
of mat1
, mat2
, … using
NonCommutativeMultiply
rather than Times
.
Notes:
The experienced matrix analyst should always remember that the Mathematica convention for handling vectors is tricky.
{{1,2,4}}
is a 1x3 matrix or a row
vector;{{1},{2},{4}}
is a 3x1 matrix or a column
vector;{1,2,4}
is a vector but not a
matrix. Indeed whether it is a row or column vector depends on
the context. We advise not to use vectors.See also: tpMat, ajMat, coMat.
NCInverse[mat]
gives the nc inverse of the square matrix
mat
. NCInverse
uses partial pivoting to find a
nonzero pivot.
NCInverse
is primarily used symbolically. Usually the
elements of the inverse matrix are huge expressions. We recommend using
NCSimplifyRational
to improve the results.
See also: tpMat, ajMat, coMat.
NCMatrixDecompositions
provide noncommutative versions
of the linear algebra algorithms in the package MatrixDecompositions.
See the documentation for the package MatrixDecompositions for details on the algorithms and options.
Members are:
NCLUDecompositionWithPartialPivoting
is a noncommutative
version of NCLUDecompositionWithPartialPivoting.
The following options
can be given:
ZeroTest
(PossibleZeroQ
): function used to
decide if a pivot is zero;RightDivide
(NCRightDivide): function used to divide a
vector by an entry;Dot
(NCDot): function used to
multiply vectors and matrices;Pivoting
(NCLUPartialPivoting): function used to
sort rows for pivoting;SuppressPivoting
(False
): whether to
perform pivoting or not.See also: LUDecompositionWithPartialPivoting.
NCLUDecompositionWithCompletePivoting
is a
noncommutative version of NCLUDecompositionWithCompletePivoting.
The following options
can be given:
ZeroTest
(PossibleZeroQ
): function used to
decide if a pivot is zero;RightDivide
(NCRightDivide): function used to divide a
vector by an entry;Dot
(NCDot): function used to
multiply vectors and matrices;Pivoting
(NCLUCompletePivoting): function used to
sort rows for pivoting;SuppressPivoting
(False
): whether to
perform pivoting or not.See also: LUDecompositionWithCompletePivoting.
NCLDLDecomposition
is a noncommutative version of LDLDecomposition.
The following options
can be given:
ZeroTest
(PossibleZeroQ
): function used to
decide if a pivot is zero;RightDivide
(NCRightDivide): function used to divide a
vector by an entry on the right;LeftDivide
(NCLeftDivide):
function used to divide a vector by an entry on the left;Dot
(NCDot
): function used to multiply
vectors and matrices;CompletePivoting
(NCLUCompletePivoting): function used to
sort rows for complete pivoting;PartialPivoting
(NCLUPartialPivoting): function used to
sort matrices for complete pivoting;Inverse
(NCLUInverse):
function used to invert 2x2 diagonal blocks;SelfAdjointMatrixQ
(NCSelfAdjointQ): function to test if matrix
is self-adjoint;SuppressPivoting
(False
): whether to
perform pivoting or not.See also: LUDecompositionWithCompletePivoting.
NCUpperTriangularSolve
is a noncommutative version of UpperTriangularSolve.
See also: UpperTriangularSolve.
NCLowerTriangularSolve
is a noncommutative version of LowerTriangularSolve.
See also: LowerTriangularSolve.
NCLUInverse
is a noncommutative version of LUInverse.
See also: LUInverse.
NCLUPartialPivoting
is a noncommutative version of LUPartialPivoting.
See also: LUPartialPivoting.
NCLUCompletePivoting
is a noncommutative version of LUCompletePivoting.
See also: LUCompletePivoting.
NCLeftDivide[x,y]
divides each entry of the list
y
by x
on the left.
For example:
NCLeftDivide[x, {a,b,c}]
returns
{inv[x]**a, inv[x]**b, inv[x]**c}
See also: NCRightDivide.
NCRightDivide[x,y]
divides each entry of the list
x
by y
on the right.
For example:
NCRightDivide[{a,b,c}, y]
returns
{a**inv[y], b**inv[y], c**inv[y]}
See also: NCLeftDivide.
MatrixDecompositions
is a package that implements
various linear algebra algorithms, such as LU Decomposition
with partial and complete pivoting, and LDL
Decomposition. The algorithms have been written with correctness
and ease of customization rather than efficiency as the main goals. They
were originally developed to serve as the core of the noncommutative
linear algebra algorithms for NCAlgebra.
See the package NCMatrixDecompositions for noncommutative versions of these algorithms.
Members are:
LUDecompositionWithPartialPivoting[m]
generates a
representation of the LU decomposition of the rectangular matrix
m
.
LUDecompositionWithPartialPivoting[m, options]
uses
options
.
LUDecompositionWithPartialPivoting
returns a list of two
elements:
LUDecompositionWithPartialPivoting
is similar in
functionality with the built-in LUDecomposition
. It
implements a partial pivoting strategy in which the sorting can
be configured using the options listed below. It also applies to general
rectangular matrices as well as square matrices.
The triangular factors are recovered using GetLUMatrices or GetFullLUMatrices.

LUDecompositionWithCompletePivoting[m]
generates a
representation of the LU decomposition of the rectangular matrix
m
.
LUDecompositionWithCompletePivoting[m, options]
uses
options
.
LUDecompositionWithCompletePivoting
returns a list of
four elements:
LUDecompositionWithCompletePivoting
implements a
complete pivoting strategy in which the sorting can be
configured using the options listed below. It also applies to general
rectangular matrices as well as square matrices.
The triangular factors are recovered using GetLUMatrices or GetFullLUMatrices.
The following options
can be given:
ZeroTest
(PossibleZeroQ
): function used to
decide if a pivot is zero;Divide
(Divide
): function used to divide a
vector by an entry;Dot
(Dot
): function used to multiply
vectors and matrices;Pivoting
(LUCompletePivoting): function used to
sort rows for pivoting;See also: LUDecomposition, GetLUMatrices, GetFullLUMatrices, LUCompletePivoting, LUDecompositionWithPartialPivoting.
LDLDecomposition[m]
generates a representation of the
LDL decomposition of the symmetric or self-adjoint matrix
m
.
LDLDecomposition[m, options]
uses
options
.
LDLDecomposition
returns a list of four elements:
LUDecompositionWithCompletePivoting
implements a
Bunch-Parlett pivoting strategy in which the sorting can be
configured using the options listed below. It applies only to square
symmetric or self-adjoint matrices.
The triangular factors are recovered using GetLDUMatrices or GetFullLDUMatrices.
The following options
can be given:
ZeroTest
(PossibleZeroQ
): function used to
decide if a pivot is zero;RightDivide
(Divide
): function used to
divide a vector by an entry on the right;LeftDivide
(Divide
): function used to
divide a vector by an entry on the left;Dot
(Dot
): function used to multiply
vectors and matrices;CompletePivoting
(LUCompletePivoting): function used to
sort rows for complete pivoting;PartialPivoting
(LUPartialPivoting): function used to sort
matrices for complete pivoting;Inverse
(Inverse
): function used to invert
2x2 diagonal blocks;SelfAdjointMatrixQ
(HermitianQ): function to test if
matrix is self-adjoint;SuppressPivoting
(False
): whether to
perform pivoting or not.See also: LUDecompositionWithPartialPivoting, LUDecompositionWithCompletePivoting, GetLUMatrices, GetFullLDUMatrices, LUCompletePivoting, LUPartialPivoting.
UpperTriangularSolve[u, b]
solves the upper-triangular
system of equations \(u x = b\) using
back-substitution.
For example:
x = UpperTriangularSolve[u, b];
returns the solution x
.
See also: LUDecompositionWithPartialPivoting, LUDecompositionWithCompletePivoting, LDLDecomposition.
LowerTriangularSolve[l, b]
solves the lower-triangular
system of equations \(l x = b\) using
forward-substitution.
For example:
x = LowerTriangularSolve[l, b];
returns the solution x
.
See also: LUDecompositionWithPartialPivoting, LUDecompositionWithCompletePivoting, LDLDecomposition.
LUInverse[a]
calculates the inverse of matrix
a
.
LUInverse
uses the LUDecompositionWithPartialPivoting
and the triangular solvers LowerTriangularSolve and UpperTriangularSolve.
See also: LUDecompositionWithPartialPivoting.
GetLUMatrices[lu]
extracts lower- and upper-triangular
blocks produced by LDUDecompositionWithPartialPivoting
and
LDUDecompositionWithCompletePivoting
.
GetLUMatrices[lu, p, q, rank]
extracts compact lower-
and upper-triangular blocks produced by
LDUDecompositionWithPartialPivoting
and
LDUDecompositionWithCompletePivoting
taking into account
permutations and the matrix rank.
For example:
{lu, p} = LUDecompositionWithPartialPivoting[mat];
{l, u} = GetLUMatrices[lu];
and
{lu, p, q, rank} = LUDecompositionWithCompletePivoting[mat];
{l, u} = GetLUMatrices[lu, p, q, rank];
returns the lower-triangular factor l
and
upper-triangular factor u
as SparseArray
s.
See also: LUDecompositionWithPartialPivoting, LUDecompositionWithCompletePivoting, GetFullLUMatrices.
GetFullLUMatrices[m]
extracts lower- and
upper-triangular blocks produced by
LDUDecompositionWithPartialPivoting
and
LDUDecompositionWithCompletePivoting
.
GetFullLUMatrices[lu, p, q, rank]
extracts compact
lower- and upper-triangular blocks produced by
LDUDecompositionWithPartialPivoting
and
LDUDecompositionWithCompletePivoting
taking into account
permutations and the matrix rank.
GetFullLUMatrices
is equivalent to
Normal @@ GetLUMatrices
See also: GetLUMatrices, LUDecompositionWithPartialPivoting, LUDecompositionWithCompletePivoting.
GetLDUMatrices[ldu, s]
extracts lower-, upper-triangular
and diagonal blocks produced by LDLDecomposition
.
GetLDUMatrices[ldu, p, s, rank]
extracts compact lower-
and upper-triangular blocks produced by LDLDecomposition
taking into account permutations and the matrix rank.
For example:
{ldl, p, s, rank} = LDLDecomposition[mat];
{l,d,u} = GetLDUMatrices[ldl,s];
and
{l, d, u} = GetLDUMatrices[ldl, p, s, rank];
returns the lower-triangular factor l
, the
upper-triangular factor u
, and the block-diagonal factor
d
as SparseArray
s.
See also: LDLDecomposition, GetFullLDUMatrices.
GetLDUMatrices[ldl, s]
extracts lower-, upper-triangular
and diagonal blocks produced by LDLDecomposition
.
GetLDUMatrices[ldu, p, s, rank]
extracts compact lower-
and upper-triangular blocks produced by LDLDecomposition
taking into account permutations and the matrix rank.
GetFullLDUMatrices
is equivalent to
Normal @@ GetLDUMatrices
See also: LDLDecomposition, GetLDUMatrices.
GetDiagonal[m]
extracts the diagonal entries of matrix
m
.
GetDiagonal[m, s]
extracts the block-diagonal entries of
matrix m
with block size s
.
For example:
d = GetDiagonal[{{1,-1,0},{-1,2,0},{0,0,3}}];
returns
d = {1,2,3}
and
d = GetDiagonal[{{1,-1,0},{-1,2,0},{0,0,3}}, {2,1}];
returns
d = {{{1,-1},{-1,2}},3}
See also: LDLDecomposition.
LUPartialPivoting[v]
returns the index of the element
with largest absolute value in the vector v
. If
v
is a matrix, it returns the index of the element with
largest absolute value in the first column.
LUPartialPivoting[v, f]
sorts with respect to the
function f
instead of the absolute value.
See also: LUDecompositionWithPartialPivoting, LUCompletePivoting.
LUCompletePivoting[m]
returns the row and column index
of the element with largest absolute value in the matrix
m
.
LUCompletePivoting[v, f]
sorts with respect to the
function f
instead of the absolute value.
See also: LUDecompositionWithCompletePivoting, LUPartialPivoting.
NCOutput is a package that can be used to beautify the display of noncommutative expressions. NCOutput does not alter the internal representation of nc expressions, just the way they are displayed on the screen.
Members are:
NCSetOutput[options]
controls the display of expressions
in a special format without affecting the internal representation of the
expression.
The following options
can be given:
NonCommutativeMultiply
(False
): If
True
x**y
is displayed as ‘\(\mathrm{x} \bullet \mathrm{y}\)’;tp
(True
): If True
tp[x]
is displayed as ‘\(\mathrm{x}^\mathrm{T}\)’;inv
(True
): If True
inv[x]
is displayed as ‘\(\mathrm{x}^{-1}\)’;aj
(True
): If True
aj[x]
is displayed as ‘\(\mathrm{x}^*\)’;co
(True
): If True
co[x]
is displayed as ‘\(\bar{\mathrm{x}}\)’;rt
(True
): If True
rt[x]
is displayed as ‘\(\mathrm{x}^{1/2}\)’.All
: Set all available options to True
or
False
.Members are:
NCTeX[expr]
typesets the LaTeX version of
expr
produced with TeXForm or NCTeXForm using LaTeX.
NCRunDVIPS[file]
run dvips on file
.
Produces a ps output.
NCRunLaTeX[file]
typesets the LaTeX file
with latex. Produces a dvi output.
NCRunLaTeX[file]
typesets the LaTeX file
with pdflatex. Produces a pdf output.
NCRunPDFViewer[file]
display pdf file
.
NCRunPS2PDF[file]
run pd2pdf on file
.
Produces a pdf output.
Members are:
NCTeXForm[expr]
prints a LaTeX version of
expr
.
The format is compatible with AMS-LaTeX.
Should work better than the Mathematica TeXForm
:)
NCTeXFormSetStarStar[string]
replaces the standard ’**’
for string
in noncommutative multiplications.
For example:
NCTeXFormSetStarStar["."]
uses a dot (.
) to replace
NonCommutativeMultiply
(**
).
See also: NCTeXFormSetStar.
NCTeXFormSetStar[string]
replaces the standard ’*’ for
string
in noncommutative multiplications.
For example:
NCTeXFormSetStar[" "]
uses a space () to replace
Times
(*
).
Members are:
NCRun[command]
is a replacement for the built-in
Run
command that gives a bit more control over the
execution process.
NCRun[command, options]
uses options
.
The following options
can be given:
Verbose
(True
): print information on
command being run;CommandPrefix
(""
): prefix to
command
;See also: Run
.
These are commands for automatically testing if our algorithms
produce the correct answer. Problems and answers are stored under the
directory NC/TESTING
.
Members are:
NCTest[expr,answer]
asserts whether expr
is
equal to answer
. The result of the test is collected when
NCTest
is run from NCTestRun
.
See also: NCTestCheck, NCTestRun, NCTestSummarize.
NCTestCheck[expr,messages]
evaluates expr
and asserts that the messages in messages
have been issued.
The result of the test is collected when NCTest
is run from
NCTestRun
.
NCTestCheck[expr,answer,messages]
also asserts whether
expr
is equal to answer
.
NCTestCheck[expr,answer,messages,quiet]
quiets messages
in quiet
.
See also: NCTest, NCTestRun, NCTestSummarize.
NCTest[list]
runs the test files listed in
list
after appending the ‘.NCTest’ suffix and return the
results.
For example:
results = NCTestRun[{"NCCollect", "NCSylvester"}]
will run the test files “NCCollect.NCTest” and “NCSylvester.NCTest”
and return the results in results
.
See also: NCTest, NCTestCheck, NCTestSummarize.
NCTestSummarize[results]
will print a summary of the
results in results
as produced by
NCTestRun
.
See also: NCTestRun.
Members are:
NCDebug[level, message]
prints the objects
message
if level is higher than the current
DebugLevel
option.
Use SetOptions[NCDebug, DebugLevel -> level]
to set
up the current debug level.
Available options are:
DebugLevel
(0): current debug level;DebugLogFile
($Ouput
): current file to
which messages are printed.NCUtil is a package with a collection of utilities used throughout NCAlgebra.
Members are:
NCGrabSymbols[expr]
returns a list with all
Symbols appearing in expr
.
NCGrabSymbols[expr,f]
returns a list with all
Symbols appearing in expr
as the single argument
of function f
.
For example:
NCGrabSymbols[inv[x] + y**inv[1+inv[1+x**y]]]
returns {x,y}
and
NCGrabSymbols[inv[x] + y**inv[1+inv[1+x**y]], inv]
returns {inv[x]}
.
See also: NCGrabFunctions, NCGrabNCSymbols.
NCGrabSymbols[expr]
returns a list with all NC
Symbols appearing in expr
.
NCGrabSymbols[expr,f]
returns a list with all NC
Symbols appearing in expr
as the single argument
of function f
.
See also: NCGrabSymbols, NCGrabFunctions.
NCGrabFunctions[expr]
returns a list with all fragments
of expr
containing functions.
NCGrabFunctions[expr,f]
returns a list with all
fragments of expr
containing the function
f
.
For example:
NCGrabFunctions[inv[x] + tp[y]**inv[1+inv[1+tp[x]**y]], inv]
returns
{inv[1+inv[1+tp[x]**y]], inv[1+tp[x]**y], inv[x]}
and
NCGrabFunctions[inv[x] + tp[y]**inv[1+inv[1+tp[x]**y]]]
returns
{inv[1+inv[1+tp[x]**y]], inv[1+tp[x]**y], inv[x], tp[x], tp[y]}
See also: NCGrabSymbols.
NCGrabIndeterminants[expr]
returns a list with first
level symbols and nc expressions involved in sums and nc products in
expr
.
For example:
NCGrabIndeterminants[y - inv[x] + tp[y]**inv[1+inv[1+tp[x]**y]]]
returns
{y, inv[x], inv[1 + inv[1 + tp[x] ** y]], tp[y]}
See also: NCGrabFunctions, NCGrabSymbols.
NCVariables[expr]
gives a list of all independent nc
variables in the expression expr
.
For example:
NCVariables[B + A y ** x ** y - 2 x]
returns
{x,y}
See also: NCGrabSymbols.
NCConsolidateList[list]
produces two lists:
list
where
repeated entries have been suppressed;list
.For example:
{list,index} = NCConsolidateList[{z,t,s,f,d,f,z}];
results in:
list = {z,t,s,f,d};
index = {1,2,3,4,5,4,1};
See also: Union
NCConsistentQ[expr]
returns True is
expr
contains no commutative products or inverses involving
noncommutative variables.
NCSymbolOrSubscriptQ[expr]
returns True if
expr
is a symbol or a symbol subscript.
See also: NCSymbolOrSubscriptExtendedQ, NCNonCommutativeSymbolOrSubscriptQ, NCNonCommutativeSymbolOrSubscriptExtendedQ, NCPowerQ.
NCSymbolOrSubscriptExtendedQ[expr]
returns True
if expr
is a symbol, a symbol subscript, or the transpose
(tp
) or adjoint (aj
) of a symbol or symbol
subscript.
See also: NCSymbolOrSubscriptQ, NCNonCommutativeSymbolOrSubscriptQ, NCNonCommutativeSymbolOrSubscriptExtendedQ, NCPowerQ.
NCLeafCount[expr]
returns an number associated with the
complexity of an expression:
PossibleZeroQ[expr] == True
then
NCLeafCount[expr]
is -Infinity
;NumberQ[expr]] == True
then
NCLeafCount[expr]
is Abs[expr]
;NCLeafCount[expr]
is
-LeafCount[expr]
;NCLeafCount
is Listable
.
See also: LeafCount
.
NCReplaceData[expr, rules]
applies rules
to
expr
and convert resulting expression to standard
Mathematica, for example replacing **
by
.
.
NCReplaceData
does not attempt to resize entries in
expressions involving matrices. Use NCToExpression
for
that.
See also: NCToExpression.
NCToExpression[expr, rules]
applies rules
to expr
and convert resulting expression to standard
Mathematica.
NCToExpression
attempts to resize entries in expressions
involving matrices.
See also: NCReplaceData.
NotMatrixQ[expr]
is equivalent to
Not[MatrixQ[expr]]
.
See also: MatrixQ
.
This chapter describes packages that handle special data structures that enable fast calculations in Mathematica.
Members are:
NCPoly[coeff, monomials, vars]
constructs a
noncommutative polynomial object in variables vars
where
the monomials have coefficient coeff
.
Monomials are specified in terms of the symbols in the list
vars
as in NCPolyMonomial.
For example:
vars = {x,y,z};
poly = NCPoly[{-1, 2}, {{x,y,x}, {z}}, vars];
constructs an object associated with the noncommutative polynomial
\(2 z - x y x\) in variables
x
, y
and z
.
The internal representation varies with the implementation but it is
so that the terms are sorted according to a degree-lexicographic order
in vars
. In the above example,
x < y < z
.
The construction:
vars = {{x},{y,z}};
poly = NCPoly[{-1, 2}, {{x,y,x}, {z}}, vars];
represents the same polyomial in a graded degree-lexicographic order
in vars
, in this example,
x << y < z
.
See also: NCPolyMonomial, NCIntegerDigits, NCFromDigits.
NCPolyMonomial[monomial, vars]
constructs a
noncommutative monomial object in variables vars
.
Monic monomials are specified in terms of the symbols in the list
vars
, for example:
vars = {x,y,z};
mon = NCPolyMonomial[{x,y,x},vars];
returns an NCPoly
object encoding the monomial \(xyx\) in noncommutative variables
x
,y
, and z
. The actual
representation of mon
varies with the implementation.
Monomials can also be specified implicitly using indices, for example:
mon = NCPolyMonomial[{0,1,0}, 3];
also returns an NCPoly
object encoding the monomial
\(xyx\) in noncommutative variables
x
,y
, and z
.
If graded ordering is supported then
vars = {{x},{y,z}};
mon = NCPolyMonomial[{x,y,x},vars];
or
mon = NCPolyMonomial[{0,1,0}, {1,2}];
construct the same monomial \(xyx\)
in noncommutative variables x
,y
, and
z
this time using a graded order in which
x << y < z
.
There is also an alternative syntax for NCPolyMonomial
that allows users to input the monomial along with a coefficient using
rules and the output of NCFromDigits. For
example:
mon = NCPolyMonomial[{3, 3} -> -2, 3];
or
mon = NCPolyMonomial[NCFromDigits[{0,1,0}, 3] -> -2, 3];
represent the monomial \(-2 xyx\)
that has coefficient -2
.
See also: NCPoly, NCIntegerDigits, NCFromDigits.
NCPolyConstant[value, vars]
constructs a noncommutative
monomial object in variables vars
representing the constant
value
.
For example:
NCPolyConstant[3, {x, y, z}]
constructs an object associated with the constant 3
in
variables x
, y
and z
.
See also: NCPoly, NCPolyMonomial.
NCPolyConvert[poly, vars]
convert NCPoly
poly
to the ordering implied by vars
.
For example, if
vars1 = {{x, y, z}};
coeff = {1, 2, 3, -1, -2, -3, 1/2};
mon = {{}, {x}, {z}, {x, y}, {x, y, x, x}, {z, x}, {z, z, z, z}};
poly1 = NCPoly[coeff, mon, vars1];
with respect to the ordering
\(x \ll y \ll z\)
then
vars2 = {{x},{y,z}};
poly2 = NCPolyConvert[poly, vars];
is the same polynomial as poly1
but in the ordering
\(x \ll y < z\)
See also: NCPoly, NCPolyCoefficient.
NCPolyFromCoefficientArray[mat, vars]
returns an
NCPoly
constructed from the coefficient array
mat
in variables vars
.
For example, for mat
equal to the
SparseArray
corresponding to the rules:
{{1} -> 1, {2} -> 2, {6} -> -1, {50} -> -2, {4} -> 3, {11} -> -3, {121} -> 1/2}
the commands
vars = {{x},{y,z}};
NCPolyFromCoefficientArray[mat, vars]
return
NCPoly[{1, 2}, <|{0, 0, 0} -> 1, {0, 1, 0} -> 2, {1, 0, 2} -> 3, {1, 1, 1} -> -1,
{1, 1, 6} -> -3, {1, 3, 9} -> -2, {4, 0, 80} -> 1/2|>]
See also: NCPolyCoefficientArray, NCPolyCoefficient.
NCPolyFromGramMatrix[mat, vars]
returns an
NCPoly
constructed from the Gram matrix mat
in
variables vars
.
For example, for mat
equal to the
SparseArray
corresponding to the rules:
{{1, 1} -> 1, {2, 1} -> 2, {2, 3} -> -1, {4, 1} -> 3, {4, 2} -> -3, {6, 5} -> -2, {13, 13} -> 1/2}
the commands
vars = {{x},{y,z}};
NCPolyFromGramMatrix[mat, vars]
return
NCPoly[{1, 2}, <|{0, 0, 0} -> 1, {0, 1, 0} -> 2, {1, 0, 2} -> 3, {1, 1, 1} -> -1,
{1, 1, 6} -> -3, {1, 3, 9} -> -2, {4, 0, 80} -> 1/2|>]
See also: NCPolyGramMatrix, NCPolyFromGramMatrixFactors.
NCPolyFromGramMatrixFactors[lmat, rmat, vars]
returns
two lists of NCPoly
s constructed from the factors of the
Gram matrix lmat
and rmat
in variables
vars
.
For example, for mat = lmat . rmat
in which the factors
lmat
and rmat
are SparseArray
s
corresponding to the rules:
{{1, 3} -> 1/2, {1, 5} -> 1, {2, 3} -> 1, {4, 1} -> 1, {6, 2} -> 1, {13, 4} -> 1}
{{1, 2} -> -3, {1, 1} -> 3, {2, 5} -> -2, {3, 1} -> 2, {3, 3} -> -1, {4, 13} -> 1/2, {5, 3} -> 1/2}
and commands
vars = {{x},{y,z}};
{lpoly, rpoly} = NCPolyFromGramMatrixFactors[lmat, rmat, vars]
return lpoly
equal to the list of polynomials
{NCPoly[{1, 2}, <|{1, 0, 1} -> 1|>], NCPoly[{1, 2}, <|{1, 1, 6} -> 1|>], NCPoly[{1, 2}, <|{0, 0, 0} -> 1/2, {1, 0, 2} -> 1|>], NCPoly[{1, 2}, <|{2, 0, 4} -> 1|>], NCPoly[{1, 2}, <|{0, 0, 0} -> 1|>]},
and rpoly
equal to
{NCPoly[{1, 2}, <|{0, 0, 0} -> 3, {1, 0, 2} -> -3|>], NCPoly[{1, 2}, <|{2, 0, 7} -> -2|>], NCPoly[{1, 2}, <|{0, 0, 0} -> 2, {0, 1, 0} -> -1|>], NCPoly[{1, 2}, <|{2, 0, 4} -> 1/2|>], NCPoly[{1, 2}, <|{0, 1, 0} -> 1/2|>]}}
See also: NCPolyFromGramMatrix, NCPolyGramMatrix.
NCPolyMonomialQ[poly]
returns True
if
poly
is a NCPoly
monomial.
See also: NCPoly, NCPolyMonomial.
NCPolyDegree[poly]
returns the degree of the nc
polynomial poly
.
See also: NCPolyPartialDegree
NCPolyPartialDegree[poly]
returns the maximum degree
appearing in the monomials of the nc polynomial poly
.
See also: NCPolyDegree
NCPolyMonomialDegree[poly]
returns the partial degree of
each symbol appearing in the monomials of the nc polynomial
poly
.
See also: NCPolyDegree
NCPolyNumberOfVariables[poly]
returns the number of
variables of the nc polynomial poly
.
NCPolyNumberOfTerms[poly]
returns the number of terms of
the nc polynomial poly
.
NCPolyCoefficient[poly, mon]
returns the coefficient of
the monomial mon
in the nc polynomial
poly
.
For example, in:
coeff = {1, 2, 3, -1, -2, -3, 1/2};
mon = {{}, {x}, {z}, {x, y}, {x, y, x, x}, {z, x}, {z, z, z, z}};
vars = {x,y,z};
poly = NCPoly[coeff, mon, vars];
c = NCPolyCoefficient[poly, NCPolyMonomial[{x,y},vars]];
returns
c = -1
See also: NCPoly, NCPolyMonomial.
NCPolyCoefficientArray[poly]
returns a coefficient array
corresponding to the monomials in the nc polynomial
poly
.
For example:
coeff = {1, 2, 3, -1, -2, -3, 1/2};
mon = {{}, {x}, {z}, {x, y}, {x, y, x, x}, {z, x}, {z, z, z, z}};
vars = {x,y,z};
poly = NCPoly[coeff, mon, vars];
mat = NCPolyCoefficient[poly];
returns mat
as a SparseArray
corresponding
to the rules:
{{1} -> 1, {2} -> 2, {6} -> -1, {50} -> -2, {4} -> 3, {11} -> -3, {121} -> 1/2}
See also: NCPolyFromCoefficientArray, NCPolyCoefficient.
NCPolyGramMatrix[poly]
returns a Gram matrix
corresponding to the monomials in the nc polynomial
poly
.
For example:
coeff = {1, 2, 3, -1, -2, -3, 1/2};
mon = {{}, {x}, {z}, {x, y}, {x, y, x, x}, {z, x}, {z, z, z, z}};
vars = {x,y,z};
poly = NCPoly[coeff, mon, vars];
mat = NCPolyGramMatrix[poly];
returns mat
as a SparseArray
corresponding
to the rules:
{{1, 1} -> 1, {2, 1} -> 2, {2, 3} -> -1, {4, 1} -> 3, {4, 2} -> -3, {6, 5} -> -2, {13, 13} -> 1/2}
See also: NCPolyFromGramMatrix.
NCPolyGetCoefficients[poly]
returns a list with the
coefficients of the monomials in the nc polynomial
poly
.
For example:
vars = {x,y,z};
poly = NCPoly[{-1, 2}, {{x,y,x}, {z}}, vars];
coeffs = NCPolyGetCoefficients[poly];
returns
coeffs = {2,-1}
The coefficients are returned according to the current graded
degree-lexicographic ordering, in this example
x < y < z
.
See also: NCPolyGetDigits, NCPolyCoefficient, NCPoly.
NCPolyGetDigits[poly]
returns a list with the digits
that encode the monomials in the nc polynomial poly
as
produced by NCIntegerDigits.
For example:
vars = {x,y,z};
poly = NCPoly[{-1, 2}, {{x,y,x}, {z}}, vars];
digits = NCPolyGetDigits[poly];
returns
digits = {{2}, {0,1,0}}
The digits are returned according to the current ordering, in this
example x < y < z
.
See also: NCPolyGetCoefficients, NCPoly.
NCPolyGetIntegers[poly]
returns a list with the digits
that encode the monomials in the nc polynomial poly
as
produced by NCFromDigits.
For example:
vars = {x,y,z};
poly = NCPoly[{-1, 2}, {{x,y,x}, {z}}, vars];
digits = NCPolyGetIntegers[poly];
returns
digits = {{1,2}, {3,3}}
The digits are returned according to the current ordering, in this
example x < y < z
.
See also: NCPolyGetCoefficients, NCPoly.
NCPolyLeadingMonomial[poly]
returns an
NCPoly
representing the leading term of the nc polynomial
poly
.
For example:
vars = {x,y,z};
poly = NCPoly[{-1, 2}, {{x,y,x}, {z}}, vars];
lead = NCPolyLeadingMonomial[poly];
returns an NCPoly
representing the monomial \(x y x\). The leading monomial is computed
according to the current ordering, in this example
x < y < z
. The actual representation of
lead
varies with the implementation.
See also: NCPolyLeadingTerm, NCPolyMonomial, NCPoly.
NCPolyLeadingTerm[poly]
returns a rule associated with
the leading term of the nc polynomial poly
as understood by
NCPolyMonomial.
For example:
vars = {x,y,z};
poly = NCPoly[{-1, 2}, {{x,y,x}, {z}}, vars];
lead = NCPolyLeadingTerm[poly];
returns
lead = {3,3} -> -1
representing the monomial \(- x y
x\). The leading monomial is computed according to the current
ordering, in this example x < y < z
.
See also: NCPolyLeadingMonomial, NCPolyMonomial, NCPoly.
NCPolyOrderType[poly]
returns the type of monomial order
in which the nc polynomial poly
is stored. Order can be
NCPolyGradedDegLex
or NCPolyDegLex
.
See also: NCPoly,
NCPolyToRule[poly]
returns a Rule
associated with polynomial poly
. If
poly = lead + rest
, where lead
is the leading
term in the current order, then NCPolyToRule[poly]
returns
the rule lead -> -rest
where the coefficient of the
leading term has been normalized to 1
.
For example:
vars = {x, y, z};
poly = NCPoly[{-1, 2, 3}, {{x, y, x}, {z}, {x, y}}, vars];
rule = NCPolyToRule[poly]
returns the rule lead -> rest
where lead
represents is the nc monomial \(x y x\)
and rest
is the nc polynomial \(2
z + 3 x y\)
See also: NCPolyLeadingTerm, NCPolyLeadingMonomial, NCPoly.
NCPolyTermsOfDegree[p, d]
returns a polynomial
p
in which only the monomials with degree d
are present. The degree d
is a list with the partial
degrees on each variable.
For example:
vars = {x, y};
poly = NCPoly[{1, 2, 3, 4}, {{x}, {x, y}, {y, x}, {x, x}}, vars];
corresponds to the polynomial \(x + 2 x y + 3 y x + 4 x^2\) and
NCPolyTermsOfTotalDegree[p, {1,1}]
returns
NCPoly[{1, 1}, {1, 1, 1} -> 2, {1, 1, 2} -> 3|>]
which corresponds to the polyomial \(2 x y + 3 y x\). Likewise
NCPolyTermsOfTotalDegree[p, {2,0}]
returns
NCPoly[{1, 1}, {0, 2, 0} -> 4|>]
which corresponds to the polyomial \(4 x^2\).
See also: NCPolyTermsOfTotalDegree.
NCPolyTermsOfTotalDegree[p, d]
returns a polynomial
p
in which only the monomials with total degree
d
are present. The degree d
is an integer.
For example:
vars = {x, y};
poly = NCPoly[{1, 2, 3, 4}, {{x}, {x, y}, {y, x}, {x, x}}, vars];
corresponds to the polynomial \(x + 2 x y + 3 y x + 4 x^2\) and
NCPolyTermsOfTotalDegree[p, 2]
returns
NCPoly[{1, 1}, <|{0, 2, 0} -> 4, {1, 1, 1} -> 2, {1, 1, 2} -> 3|>]
which corresponds to the polyomial \(2 x y + 3 y x + 4 x^2\).
See also: NCPolyTermsOfDegree.
NCPolyQuadraticTerms[p]
returns a polynomial with only
the “square” quadratic terms of p
.
For example:
vars = {{x, y, z}}
coeff = {1, 1, 4, 3, 2, -1}
digits = {{}, {x}, {y, x}, {z, x}, {z, y}, {x, z, z, y}}
p = NCPoly[coeff, digits, vars, TransposePairs -> {{x, y}}]
corresponds to the polynomial \(p(x,y,z) =
-x.z.z.y + 2 z.y + 3 z.x + 4 y.x + x + 1\) in which \(x\) and \(y\) are transposes of each other, that is
\(y = x^T\). Its NCPoly
object is
NCPoly[{3}, <|{0, 0} -> 1, {1, 0} -> 1, {2, 3} -> 4, {2, 6} -> 3, {2, 7} -> 2, {4, 25} -> -1|>, TransposePairs -> {{0, 1}}]
A call to
NCPolyQuadraticTerms[p]
results in
NCPoly[{3}, <|{0, 0} -> 1, {2, 3} -> 4, {4, 25} -> -1|>, TransposePairs -> {{0, 1}}]
corresponding to the polynomial \(-x.z.z.y + 4 y.x + 1\) which contains only “square” quadratic terms of \(p(x,y,z)\).
See also:
NCPolyQuadraticChipset
(#NCPolyQuadraticChipset).
NCPolyQuadraticChipset[p]
returns a polynomial with only
the “half” terms of p
that can be in an NC SOS
decomposition of p
.
For example:
vars = {{x, y, z}}
coeff = {1, 1, 4, 3, 2, -1}
digits = {{}, {x}, {y, x}, {z, x}, {z, y}, {x, z, z, y}}
p = NCPoly[coeff, digits, vars, TransposePairs -> {{x, y}}]
corresponds to the polynomial \(p(x,y,z) =
-x.z.z.y + 2 z.y + 3 z.x + 4 y.x + x + 1\) in which \(x\) and \(y\) are transposes of each other, that is
\(y = x^T\). Its NCPoly
object is
NCPoly[{3}, <|{0, 0} -> 1, {1, 0} -> 1, {2, 3} -> 4, {2, 6} -> 3, {2, 7} -> 2, {4, 25} -> -1|>, TransposePairs -> {{0, 1}}]
A call to
NCPolyQuadraticChipset[p]
results in
NCPoly[{3}, <|{0, 0} -> 1, {1, 0} -> 1, {1, 1} -> 1, {2, 2} -> 1|>, TransposePairs -> {{0, 1}}]
corresponding to the polynomial \(x.z + y +
x + 1\) that contains only terms which contain monomials with the
“left half” of the monomials of \(p(x,y,z)\) which can appear in an NC SOS
decomposition of p
.
See also:
NCPolyQuadraticTerms
(#NCPolyQuadraticTerms).
NCPolyReverseMonomials[p]
reverses the order of the
symbols appearing in each monomial of the polynomial p
.
For example:
vars = {x, y};
poly = NCPoly[{1, 2, 3, 4}, {{x}, {x, y}, {y, x}, {x, x}}, vars];
corresponds to the polynomial \(x + 2 x y + 3 y x + 4 x^2\) and
NCPolyReverseMonomials[p]
returns
NCPoly[{1, 1}, <|{0, 1, 0} -> 1, {0, 2, 0} -> 4, {1, 1, 2} -> 2, {1, 1, 1} -> 3|>]
which correspond to the polynomial \(x + 2 y x + 3 x y + 4 x^2\).
See also: NCIntegerReverse.
NCPolyGetOptions[p]
returns the options embedded in the
polynomial p
.
Available options are:
TransposePairs
: list with pairs of variables to be
treated as transposes of each other;SelfAdjointPairs
: list with pairs of variables to be
treated as adjoints of each other.NCPolyDisplay[poly]
prints the noncommutative polynomial
poly
.
NCPolyDisplay[poly, vars]
uses the symbols in the list
vars
.
NCPolyDisplayOrder[vars]
prints the order implied by the
list of variables vars
.
NCPolyDivideDigits[F,G]
returns the result of the
division of the leading digits lf and lg.
NCPolyDivideLeading[lF,lG,base]
returns the result of
the division of the leading Rules lf and lg as returned by
NCGetLeadingTerm.
NCPolyNormalize[poly]
makes the coefficient of the
leading term of p
to unit. It also works when
poly
is a list.
NCPolySum[f,g]
returns a NCPoly that is the sum of the
NCPoly’s f and g.
NCPolyProduct[f,g]
returns a NCPoly that is the product
of the NCPoly’s f and g.
NCPolyQuotientExpand[q,g]
returns a NCPoly that is the
left-right product of the quotient as returned by
NCPolyReduceWithQuotient
by the NCPoly g
. It
also works when g
is a list.
NCPolyReduce[polys, rules]
reduces the list of
NCPoly
s polys
with respect to the list of
NCPoly
s rules
. The substitutions implied by
rules
are applied repeatedly to the polynomials in the
polys
until no further reduction occurs.
NCPolyReduce[polys]
reduces each polynomial in the list
of NCPoly
s polys
with respect to the remaining
elements of the list of polyomials polys
. It traverses the
list of polys just once. Use NCPolyReduceRepeated to continue
applying NCPolyReduce
until no further reduction
occurs.
By default, NCPolyReduce
only reduces the leading
monomial in the current order. Use the optional boolean flag
Complete
to completely reduce all monomials. For
example,
NCPolyReduce[polys, rules, Complete -> True]
NCPolyReduce[polys, Complete -> True]
Other available options are: - MaxIterationsFactor
(default = 10): limits the maximum number of iterations in reducing each
polynomial by MaxIterationsFactor
times the number of terms
in the polynomial. - MaxDepth
(default = 1): control how
many monomials are reduced by NCPolyReduce
; by default
MaxDepth
is set to one so that just the leading monomial is
reduced. Setting Complete -> True
effectively sets
MaxDepth
to Infinity
. - ZeroTest
(default = NCPolyPossibleZeroQ
): which test to use when
assessing that a monomial is zero. This option is useful when the
coefficients are floating points, in which case one might substitute
ZeroTest
for an approximate zero test.
See also: NCPolyGroebner, NCPolyReduceRepeated, NCPolyReduceWithQuotient.
NCPolyReduceRepeated[polys]
applies NCPolyReduce
successively to the list of polynomials polys
until the
remainder does not change.
See also: NCPolyReduce, NCPolyReduceWithQuotient.
NCPolyReduceWithQuotient[f, g]
works as NCPolyReduce but also returns a list with the
quotient that can be expanded usinn NCPolyQuotientExpand.
For example
{qf, r} = NCPolyReduceWithQuotient[f, g];
q = NCPolyQuotientExpand[qf, g];
returns the list qf
which is then expanded into the
quotient q
.
The same options in NCPolyReduce can be
used with NCPolyReduceWithQuotient
.
See also: NCPolyReduce, NCPolyQuotientExpand.
NCPolyHankelMatrix[poly]
produces the nc Hankel
matrix associated with the polynomial poly
and also
their shifts per variable.
For example:
vars = {{x, y}};
poly = NCPoly[{1, -1}, {{x, y}, {y, x}}, vars];
{H, Hx, Hy} = NCPolyHankelMatrix[poly]
results in the matrices
H = {{ 0, 0, 0, 1, -1 },
{ 0, 0, 1, 0, 0 },
{ 0, -1, 0, 0, 0 },
{ 1, 0, 0, 0, 0 },
{ -1, 0, 0, 0, 0 }}
Hx = {{ 0, 0, 1, 0, 0 },
{ 0, 0, 0, 0, 0 },
{ -1, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 }}
Hy = {{ 0, -1, 0, 0, 0 },
{ 1, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0 }}
which are the Hankel matrices associated with the commutator \(x y - y x\).
See also: NCPolyRealization, NCDigitsToIndex.
NCPolyRealization[poly]
calculate a minimal descriptor
realization for the polynomial poly
.
NCPolyRealization
uses NCPolyHankelMatrix
and the resulting realization is compatible with the format used by
NCRational
.
For example:
vars = {{x, y}};
poly = NCPoly[{1, -1}, {{x, y}, {y, x}}, vars];
{{a0,ax,ay},b,c,d} = NCPolyRealization[poly]
produces a list of matrices {a0,ax,ay}
, a column vector
b
and a row vector c
, and a scalar
d
such that
\[c . (a0 + ax \, x + ay \, y)^{-1} . b + d = x y - y x\]
See also: NCPolyHankelMatrix, NCRational.
NCPolyVarsToIntegers[vars]
converts the list of symbols
vars
into a list of integers corresponding to the graded
ordering implied by vars
.
For example:
NCPolyVarsToIntegers[{{x},{y,z}}]
returns {1,2}
, indicating that there are a total of
three variables with the last two ranking higher than the first.
NCPolyVarsToIntegers
raises
NCPoly::InvalidList
in case it cannot correctly parse the
list of variables.
If vars
is a list of integers,
NCPolyVarsToIntegers
returns this list intact.
See also: NCPoly.
NCFromDigits[list, b]
constructs a representation of a
monomial in b
encoded by the elements of list
where the digits are in base b
.
NCFromDigits[{list1,list2}, b]
applies
NCFromDigits
to each list1
,
list2
, ….
List of integers are used to codify monomials. For example the list
{0,1}
represents a monomial \(xy\) and the list {1,0}
represents the monomial \(yx\). The
call
NCFromDigits[{0,0,0,1}, 2]
returns
{4,1}
in which 4
is the degree of the monomial \(xxxy\) and 1
is
0001
in base 2
. Likewise
NCFromDigits[{0,2,1,1}, 3]
returns
{4,22}
in which 4
is the degree of the monomial \(xzyy\) and 22
is
0211
in base 3
.
If b
is a list, then degree is also a list with the
partial degrees of each letters appearing in the monomial. For
example:
NCFromDigits[{0,2,1,1}, {1,2}]
returns
{3, 1, 22}
in which 3
is the partial degree of the monomial \(xzyy\) with respect to letters
y
and z
, 1
is the partial degree
with respect to letter x
and 22
is
0211
in base 3 = 1 + 2
.
This construction is used to represent graded degree-lexicographic orderings.
See also: NCIntegerDigits.
NCIntegerDigits[n,b]
is the inverse of the
NCFromDigits
.
NCIntegerDigits[{list1,list2}, b]
applies
NCIntegerDigits
to each list1
,
list2
, ….
For example:
NCIntegerDigits[{4,1}, 2]
returns
{0,0,0,1}
in which 4
is the degree of the monomial
x**x**x**y
and 1
is 0001
in base
2
. Likewise
NCIntegerDigits[{4,22}, 3]
returns
{0,2,1,1}
in which 4
is the degree of the monomial
x**z**y**y
and 22
is 0211
in base
3
.
If b
is a list, then degree is also a list with the
partial degrees of each letters appearing in the monomial. For
example:
NCIntegerDigits[{3, 1, 22}, {1,2}]
returns
{0,2,1,1}
in which 3
is the partial degree of the monomial
x**z**y**y
with respect to letters y
and
z
, 1
is the partial degree with respect to
letter x
and 22
is 0211
in base
3 = 1 + 2
.
See also: NCFromDigits.
NCIntegerReverse[n,b]
reverses the integer
n
on the base b
as returned by
NCFromDigits
.
NCIntegerReverse[{list1,list2}, b]
applies
NCIntegerReverse
to each list1
,
list2
, ….
For example:
NCIntegerReverse[{4,1}, 2]
in which {4,1}
correspond to the digits
{1,0,0,0}
returns
{4, 8}
which correspond to the digits {1,0,0,0}
.
See also: NCIntegerDigits.
NCDigitsToIndex[digits, b]
returns the index that the
monomial represented by digits
in the base b
would occupy in the standard monomial basis.
NCDigitsToIndex[{digit1,digits2}, b]
applies
NCDigitsToIndex
to each digit1
,
digit2
, ….
NCDigitsToIndex[digits, b, Reverse -> True]
returns
the index as occupied by the permuted digits.
NCDigitsToIndex
returns the same index for graded or
simple basis.
For example:
digits = {0, 1};
NCDigitsToIndex[digits, 2]
NCDigitsToIndex[digits, {2}]
NCDigitsToIndex[digits, {1, 1}]
all return
5
which is the index of the monomial \(x y\) in the standard monomial basis of polynomials in \(x\) and \(y\). Likewise
digits = {{}, {1}, {0, 1}, {0, 2, 1, 1}};
NCDigitsToIndex[digits, 2]
returns
{1,3,5,27}
Finally
NCDigitsToIndex[{0, 1}, 2, Reverse -> True]
returns 6
instead of 5
.
See also: NCFromDigits, NCIntegerDigits.
When list a
is longer than list b
,
NCPadAndMatch[a,b]
returns the minimum number of elements
from list a that should be added to the left and right of list
b
so that a = l b r
. When list b
is longer than list a
, return the opposite match.
NCPadAndMatch
returns all possible matches with the
minimum number of elements.
The package NCPolyInterface
provides a basic interface
between NCPoly
and
NCAlgebra
.
Note that to take full advantage of the speed-up possible with
NCPoly
one should not use these functions. It is always faster to convert to and manipulateNCPoly
expressions directly!
Members are:
NCToNCPoly[expr, var]
constructs a noncommutative
polynomial object in variables var
from the nc expression
expr
.
For example
NCToNCPoly[x**y - 2 y**z, {x, y, z}]
constructs an object associated with the noncommutative polynomial
\(x y - 2 y z\) in variables
x
, y
and z
. The internal
representation is so that the terms are sorted according to a
degree-lexicographic order in vars
. In the above example,
\(x < y < z\).
NCPolyToNC[poly, vars]
constructs an nc expression from
the noncommutative polynomial object poly
in variables
vars
. Monomials are specified in terms of the symbols in
the list var
.
For example
poly = NCToNCPoly[x**y - 2 y**z, {x, y, z}];
expr = NCPolyToNC[poly, {x, y, z}];
returns
expr = x**y - 2 y**z
See also: NCPolyToNC, NCPoly.
NCMonomialOrderQ[list]
returns True
if the
expressions in list
represents a valid monomial
ordering.
NCMonomialOrderQ
is used by NCMonomialOrder to decided whether a
proposed ordering is valid or not. However, NCMonomialOrder
is much more forgiving when it comes to the format of the order.
See also: NCMonomialOrder, NCRationalToNCPoly.
NCMonomialOrder[var1, var2, ...]
returns an array
representing a monomial order.
For example
NCMonomialOrder[a,b,c]
returns
{{a},{b},{c}}
corresponding to the lex order \(a \ll b \ll c\).
If one uses a list of variables rather than a single variable as one of the arguments, then multigraded lex order is used. For example
NCMonomialOrder[{a,b,c}]
returns
{{a,b,c}}
corresponding to the graded lex order \(a < b < c\).
Another example:
NCMonomialOrder[{{a, b}, {c}}]
or
NCMonomialOrder[{a, b}, c]
both return
{{a,b},{c}}
corresponding to the multigraded lex order \(a < b \ll c\).
See also: NCMonomialOrderQ, NCRationalToNCPoly, SetMonomialOrder.
NCRationalToNCPoly[expr, vars]
generates a
representation of the noncommutative rational expression or list of
rational expressions expr
in vars
which has
commutative coefficients.
NCRationalToNCPoly[expr, vars]
generates one or more
NCPoly
s in which vars
is used to set a
monomial ordering as per NCMonomialOrder.
NCRationalToNCPolynomial
creates one variable for each
inv
expression in vars
appearing in the
rational expression expr
. It also created additional
relations to encode the inverse. It also creates additional variables to
represent tp
and aj
.
It returns a list of four elements:
NCPoly
s;inv
s, tp
s, and aj
s;For example:
exp = a+tp[a]-inv[a];
order = NCMonomialOrder[a,b];
{rels,vars,rules,labels} = NCRationalToNCPoly[exp, order]
returns
rels = {
NCPoly[{2,1,1},<|{0,0,1,0} -> 1,{0,0,1,1} -> 1,{1,0,0,3} -> -1|>],
NCPoly[{2,1,1},<|{0,0,0,0} -> -1,{1,0,1,12} -> 1|>],
NCPoly[{2,1,1},<|{0,0,0,0} -> -1,{1,0,1,3} -> 1|>]
}
vars = {{a,tp51},{b},{rat50}},
rules = {rat50 -> inv[a],tp51 -> tp[a]},
labels = {{a,tp[a]},{b},{inv[a]}}
The variable tp51
was created to represent
tp[a]
and rat50
was created to represent
inv[a]
. The additional relations in rels
correspond to a**rat50 - 1
and rat50**a - 1
,
which encode the rational relation rat50 - inv[a]
.
NCRationalToPoly
also handles rational expressions, not
only rational variables. For example:
expr = a ** inv[1 - a] ** a;
order = NCMonomialOrder[a, inv[1 - a]];
{rels, vars, rules, labels} = NCRationalToNCPoly[expr, order]
returns
rels = {
NCPoly[{1,1},<|{1,2,2} -> 1|>],
NCPoly[{1,1},<|{0,0,0} -> -1,{1,0,1} -> 1,{1,1,2} -> -1|>],
NCPoly[{1,1},<|{0,0,0} -> -1,{1,0,1} -> 1,{1,1,1} -> -1|>]
}
vars = {{a},{rat54}}
rules = {rat54 -> inv[1 - a]},
labels = {{a},{inv[1 - a]}}
Note how rat54
encodes the rational expression
inv[1-a]
.
See also: NCMonomialOrder, NCMonomialOrderQ, NCPolyToNC, NCPoly, NCRationalToNCPolynomial.
NCRuleToPoly[a -> b]
converts the rule
a -> b
into the relation a - b
.
For instance:
NCRuleToPoly[x**y**y -> x**y - 1]
returns
x**y**y - x**y + 1
NCToRule[exp, vars]
converts the NC polynomial
exp
into a rule a -> b
in which
a
is the leading monomial according to the ordering implied
by vars
.
For instance:
NCToRule[x**y**y - x**y + 1, {x,y}]
returns
x**y**y -> x**y - 1
NOTE: This command is not efficient. If you need to sort polynomials you should consider using NCPoly directly.
See also: NCToNCPoly
NCReduce[polys, rules, vars, options]
reduces the list
of polynomials in polys
by the list of polynomials in
rules
in the variables vars
. The substitutions
implied by rules
are applied repeatedly to the polynomials
in the polys
until no further reduction occurs.
Note that the exact meaning of rules depends on the polynomial
ordering implied by the vars
. For example, if
polys = x^3 + x ** y
rules = x^2 - x ** y
then
NCReduce[polys, rules, {y, x}]
produces
x ** y + x ** y ** x
because x^2 - x ** y
is interpreted as
x^2 -> x ** y
, while
NCReduce[polys, rules, {x, y}]
produces
x^2 + x^3
because x^2 - x ** y
is interpreted as
x ** y -> x^2
.
By default, NCReduce
only reduces the leading monomial
in the current order. Use the optional boolean flag
Complete
to completely reduce all monomials. For
example,
NCReduce[polys, rules, Complete -> True]
NCReduce[polys, Complete -> True]
See NCPolyReduce for a complete list of
options
.
NCReduce[polys, vars, options]
reduces each polynomial
in the list of NCPoly
s polys
with respect to
the remaining elements of the list of polyomials polys
. It
traverses the list of polys just once. Use NCReduceRepeated to continue applying
NCReduce
until no further reduction occurs.
NCReduce
converts polys
and
rules
to NCPoly polynomials and apply NCPolyReduce.
See also: NCReduceRepeated, NCPolyReduce.
NCReduceRepeated[polys, vars]
applies
NCReduce
successively to the list of polys
in
variables vars
until the remainder does not change.
See also: NCReduce, NCPolyReduceRepeated.
NCMonomialList[poly, vars]
gives the list of all
monomials in the polynomial poly
in variables
vars
.
For example:
vars = {x, y}
expr = B + A y ** x ** y - 2 x
NCMonomialList[expr, vars]
returns
{1, x, y ** x ** y}
See also: NCCoefficientRules, NCCoefficientList, NCVariables.
NCCoefficientRules[poly, vars]
gives a list of rules
between all the monomials polynomial poly
in variables
vars
.
For example:
vars = {x, y}
expr = B + A y ** x ** y - 2 x
NCCoefficientRules[expr, vars]
returns
{1 -> B, x -> -2, y ** x ** y -> A}
See also: NCMonomialList, NCCoefficientRules, NCVariables.
NCCoefficientList[poly, vars]
gives the list of all
coefficients in the polynomial poly
in variables
vars
.
For example:
vars = {x, y}
expr = B + A y ** x ** y - 2 x
NCCoefficientList[expr, vars]
returns
{B, -2, A}
See also: NCMonomialList, NCCoefficientRules, NCVariables.
NCCoefficientQ[expr]
returns True if expr
is a valid polynomial coefficient.
For example:
SetCommutative[A]
NCCoefficientQ[1]
NCCoefficientQ[A]
NCCoefficientQ[2 A]
all return True
and
SetNonCommutative[x]
NCCoefficientQ[x]
NCCoefficientQ[x**x]
NCCoefficientQ[Exp[x]]
all return False
.
IMPORTANT: NCCoefficientQ[expr]
does
not expand expr
. This means that
NCCoefficientQ[2 (A + 1)]
will return
False
.
See also: NCMonomialQ, NCPolynomialQ
NCCoefficientQ[expr]
returns True if expr
is an nc monomial.
For example:
SetCommutative[A]
NCMonomialQ[1]
NCMonomialQ[x]
NCMonomialQ[A x ** y]
NCMonomialQ[2 A x ** y ** x]
all return True
and
NCMonomialQ[x + x ** y]
returns False
.
IMPORTANT: NCMonomialQ[expr]
does not
expand expr
. This means that
NCMonomialQ[2 (A + 1) x**x]
will return
False
.
See also: NCCoefficientQ, NCPolynomialQ
NCPolynomialQ[expr]
returns True if expr
is
an nc polynomial with commutative coefficients.
For example:
NCPolynomialQ[A x ** y]
all return True
and
NCMonomialQ[x + x ** y]
returns False
.
IMPORTANT: NCPolynomialQ[expr]
does
expand expr
. This means that
NCPolynomialQ[(x + y)^3]
will return True
.
See also: NCCoefficientQ, NCMonomialQ
This package contains functionality to convert an nc polynomial expression into an expanded efficient representation that can have commutative or noncommutative coefficients.
For example the polynomial
exp = a**x**b - 2 x**y**c**x + a**c
in variables x
and y
can be converted into
an NCPolynomial using
p = NCToNCPolynomial[exp, {x,y}]
which returns
p = NCPolynomial[a**c, <|{x}->{{1,a,b}},{x**y,x}->{{2,1,c,1}}|>, {x,y}]
Members are:
NCPolynomial[indep,rules,vars]
is an expanded efficient
representation for an nc polynomial in vars
which can have
commutative or noncommutative coefficients.
The nc expression indep
collects all terms that are
independent of the letters in vars
.
The Association rules
stores terms in the
following format:
{mon1, ..., monN} -> {scalar, term1, ..., termN+1}
where:
mon1, ..., monN
: are nc monomials in vars;scalar
: contains all commutative coefficients; andterm1, ..., termN+1
: are nc expressions on letters
other than the ones in vars which are typically the noncommutative
coefficients of the polynomial.vars
is a list of Symbols.
For example the polynomial
a**x**b - 2 x**y**c**x + a**c
in variables x
and y
is stored as:
NCPolynomial[a**c, <|{x}->{{1,a,b}},{x**y,x}->{{2,1,c,1}}|>, {x,y}]
NCPolynomial specific functions are prefixed with NCP, e.g. NCPDegree.
See also: NCToNCPolynomial
, NCPolynomialToNC
, NCPTermsToNC
.
NCToNCPolynomial[p, vars]
generates a representation of
the noncommutative polynomial p
in vars
which
can have commutative or noncommutative coefficients.
NCToNCPolynomial[p]
generates an
NCPolynomial
in all nc variables appearing in
p
.
Example:
exp = a**x**b - 2 x**y**c**x + a**c
p = NCToNCPolynomial[exp, {x,y}]
returns
NCPolynomial[a**c, <|{x}->{{1,a,b}},{x**y,x}->{{2,1,c,1}}|>, {x,y}]
See also: NCPolynomial
, NCPolynomialToNC
.
NCPolynomialToNC[p]
converts the NCPolynomial
p
back into a regular nc polynomial.
See also: NCPolynomial
, NCToNCPolynomial
.
NCRationalToNCPolynomial[r, vars]
generates a
representation of the noncommutative rational expression r
in vars
which can have commutative or noncommutative
coefficients.
NCRationalToNCPolynomial[r]
generates an
NCPolynomial
in all nc variables appearing in
r
.
NCRationalToNCPolynomial
creates one variable for each
inv
expression in vars
appearing in the
rational expression r
. It returns a list of three
elements:
NCPolynomial
;inv
s;For example:
exp = a**inv[x]**y**b - 2 x**y**c**x + a**c
{p,rvars,rules} = NCRationalToNCPolynomial[exp, {x,y}]
returns
p = NCPolynomial[a**c, <|{rat1**y}->{{1,a,b}},{x**y,x}->{{2,1,c,1}}|>, {x,y,rat1}]
rvars = {rat1}
rules = {rat1->inv[x]}
See also: NCToNCPolynomial
,
NCPolynomialToNC
.
NCPTermsOfDegree[p,deg]
gives all terms of the
NCPolynomial p
of degree deg
.
The degree deg
is a list with the degree of each
symbol.
For example:
p = NCPolynomial[0, <|{x,y}->{{2,a,b,c}},
{x,x}->{{1,a,b,c}},
{x**x}->{{-1,a,b}}|>, {x,y}]
NCPTermsOfDegree[p, {1,1}]
returns
<|{x,y}->{{2,a,b,c}}|>
and
NCPTermsOfDegree[p, {2,0}]
returns
<|{x,x}->{{1,a,b,c}}, {x**x}->{{-1,a,b}}|>
See also: NCPTermsOfTotalDegree
,NCPTermsToNC
.
NCPTermsOfDegree[p,deg]
gives all terms of the
NCPolynomial p
of total degree deg
.
The degree deg
is the total degree.
For example:
p = NCPolynomial[0, <|{x,y}->{{2,a,b,c}},
{x,x}->{{1,a,b,c}},
{x**x}->{{-1,a,b}}|>, {x,y}]
NCPTermsOfDegree[p, 2]
returns
<|{x,y}->{{2,a,b,c}},{x,x}->{{1,a,b,c}},{x**x}->{{-1,a,b}}|>
See also: NCPTermsOfDegree
,NCPTermsToNC
.
NCPTermsToNC
gives a nc expression corresponding to
terms produced by NCPTermsOfDegree
or
NCPTermsOfTotalDegree
.
For example:
terms = <|{x,x}->{{1,a,b,c}}, {x**x}->{{-1,a,b}}|>
NCPTermsToNC[terms]
returns
a**x**b**c-a**x**b
See also: NCPTermsOfDegree
,NCPTermsOfTotalDegree
.
NCPDegree[p]
gives the degree of the NCPolynomial
p
.
See also: NCPMonomialDegree
.
NCPMonomialDegree[p]
gives the degree of each monomial
in the NCPolynomial p
.
See also: NCDegree
.
NCPCoefficients[p, m]
gives all coefficients of the
NCPolynomial p
in the monomial m
.
For example:
exp = a**x**b - 2 x**y**c**x + a**c + d**x
p = NCToNCPolynomial[exp, {x, y}]
NCPCoefficients[p, {x}]
returns
{{1, d, 1}, {1, a, b}}
and
NCPCoefficients[p, {x**y, x}]
returns
{{-2, 1, c, 1}}
See also: NCPTermsToNC
.
NCPLinearQ[p]
gives True if the NCPolynomial
p
is linear.
See also: NCPQuadraticQ
.
NCPQuadraticQ[p]
gives True if the NCPolynomial
p
is quadratic.
See also: NCPLinearQ
.
NCPCompatibleQ[p1,p2,...]
returns True if the
polynomials p1
,p2
,… have the same variables
and dimensions.
See also: NCPSameVariablesQ, NCPMatrixQ.
NCPSameVariablesQ[p1,p2,...]
returns True if
the polynomials p1
,p2
,… have the same
variables.
See also: NCPCompatibleQ, NCPMatrixQ.
NCMatrixQ[p]
returns True if the polynomial
p
is a matrix polynomial.
See also: NCPCompatibleQ.
NCPNormalizes[p]
gives a normalized version of
NCPolynomial p where all factors that have free commutative products are
collectd in the scalar.
This function is intended to be used mostly by developers.
See also: NCPolynomial
NCPPlus[p1,p2,...]
gives the sum of the nc polynomials
p1
,p2
,… .
NCPTimes[s,p]
gives the product of a commutative
s
times the nc polynomial p
.
NCPDot[p1,p2,...]
gives the product of the nc
polynomials p1
,p2
,… .
NCPSort[p]
gives a list of elements of the NCPolynomial
p
in which monomials are sorted first according to their
degree then by Mathematica’s implicit ordering.
For example
NCPSort[NCToNCPolynomial[c + x**x - 2 y, {x,y}]]
will produce the list
{c, -2 y, x**x}
See also: NCPDecompose, NCDecompose, NCCompose.
NCPDecompose[p]
gives an association of elements of the
NCPolynomial p
in which elements of the same order are
collected together.
For example
NCPDecompose[NCToNCPolynomial[a**x**b+c+d**x**e+a**x**e**x**b+a**x**y, {x,y}]]
will produce the Association
<|{1,0}->a**x**b + d**x**e, {1,1}->a**x**y, {2,0}->a**x**e**x**b, {0,0}->c|>
See also: NCPSort, NCDecompose, NCCompose.
NCQuadratic is a package that provides functionality to handle quadratic polynomials in NC variables.
Members are:
NCToNCQuadratic[p, vars]
is shorthand for
NCPToNCQuadratic[NCToNCPolynomial[p, vars]]
See also: NCToNCQuadratic,NCToNCPolynomial.
NCPToNCQuadratic[p]
gives an expanded representation for
the quadratic NCPolynomial
p
.
NCPToNCQuadratic
returns a list with four elements:
NCSylvester
;SparseArray
;Example:
exp = d + x + x**x + x**a**x + x**e**x + x**b**y**d + d**y**c**y**d;
vars = {x,y};
p = NCToNCPolynomial[exp, vars];
{p0,sylv,left,middle,right} = NCPToNCQuadratic[p];
produces
p0 = d
sylv = <|x->{{1},{1},SparseArray[{{1}}]}, y->{{},{},{}}|>
left = {x,d**y}
middle = SparseArray[{{1+a+e,b},{0,c}}]
right = {x,y**d}
See also: NCSylvester,NCQuadraticToNCPolynomial,NCPolynomial.
NCQuadraticToNC[{const, lin, left, middle, right}]
is
shorthand for
NCPolynomialToNC[NCQuadraticToNCPolynomial[{const, lin, left, middle, right}]]
See also: NCQuadraticToNCPolynomial,NCPolynomialToNC.
NCQuadraticToNCPolynomial[rep]
takes the list
rep
produced by NCPToNCQuadratic
and converts
it back to an NCPolynomial
.
NCQuadraticToNCPolynomial[rep,options]
uses options.
The following options can be given:
Collect
(True): controls whether the
coefficients of the resulting NCPolynomial
are collected to
produce the minimal possible number of terms.See also: NCPToNCQuadratic, NCPolynomial.
NCMatrixOfQuadratic[p, vars]
gives a factorization of
the symmetric quadratic function p
in noncommutative
variables vars
and their transposes.
NCMatrixOfQuadratic
checks for symmetry and
automatically sets variables to be symmetric if possible.
Internally it uses NCPToNCQuadratic and NCQuadraticMakeSymmetric.
It returns a list of three elements:
For example:
expr = x**y**x + z**x**x**z;
{left,middle,right}=NCMatrixOfQuadratics[expr, {x}];
returns:
left={x, z**x}
middle=SparseArray[{{y,0},{0,1}}]
right={x,x**z}
The answer from NCMatrixOfQuadratics
always satisfies
p = NCDot[left,middle,right]
.
See also: NCPToNCQuadratic, NCQuadraticMakeSymmetric.
NCQuadraticMakeSymmetric[{p0, sylv, left, middle, right}]
takes the output of NCPToNCQuadratic
and produces,
if possible, an equivalent symmetric representation in which
Map[tp, left] = right
and middle
is a
symmetric matrix.
See also: NCPToNCQuadratic.
NCSylvester is a package that provides functionality to handle linear polynomials in NC variables.
Members are:
NCToNCSylvester[p, vars]
is shorthand for
NCPToNCSylvester[NCToNCPolynomial[p, vars]]
See also: NCToNCSylvester, NCToNCPolynomial.
NCPToNCSylvester[p]
gives an expanded representation for
the linear NCPolynomial
p
.
NCPToNCSylvester
returns a list with two elements:
the first is a the independent term;
the second is an association where each key is one of the variables and each value is a list with three elements:
SparseArray
.Example:
p = NCToNCPolynomial[2 + a**x**b + c**x**d + y, {x,y}];
{p0,sylv} = NCPolynomialToNCSylvester[p]
produces
p0 = 2
sylv = <|x->{{a,c},{b,d},SparseArray[{{1,0},{0,1}}]},
y->{{1},{1},SparseArray[{{1}}]}|>
See also: NCSylvesterToNCPolynomial, NCSylvesterToNC, NCToNCSylvester, NCPolynomial.
NCSylvesterToNC[{const, lin}]
is shorthand for
NCPolynomialToNC[NCSylvesterToNCPolynomial[{const, lin}]]
See also: NCSylvesterToNCPolynomial, NCPolynomialToNC.
NCSylvesterToNCPolynomial[rep]
takes the list
rep
produced by NCPToNCSylvester
and converts
it back to an NCPolynomial
.
NCSylvesterToNCPolynomial[rep,options]
uses
options
.
The following options
can be given: *
Collect
(True): controls whether the coefficients
of the resulting NCPolynomial are collected to produce the minimal
possible number of terms.
See also: NCPToNCSylvester, NCToNCSylvester, NCPolynomial.
This is an interface to a Gröebner Bases code that runs purely under Mathematica. The actual algorithm is implemented in the package NCPolyGroebner. Its function names, inputs and outputs are very similar (but not always exactly the same) to the ones provided in the legacy package NCGB, which requires both Mathematica and auxiliary executables compiled from C++ to run. NCGBX may run slower on some medium size problems but will succeed on large size problems which might fail under NCGB.
Members are:
SetMonomialOrder[var1, var2, ...]
sets the current
monomial order.
For example
SetMonomialOrder[a,b,c]
sets the lex order \(a \ll b \ll c\).
If one uses a list of variables rather than a single variable as one of the arguments, then multigraded lex order is used. For example
SetMonomialOrder[{a,b,c}]
sets the graded lex order \(a < b < c\).
Another example:
SetMonomialOrder[{{a, b}, {c}}]
or
SetMonomialOrder[{a, b}, c]
set the multigraded lex order \(a < b \ll c\).
Finally
SetMonomialOrder[{a,b}, {c}, {d}]
or
SetMonomialOrder[{a,b}, c, d]
is equivalent to the following two commands
SetKnowns[a,b]
SetUnknowns[c,d]
There is also an older syntax which is still supported:
SetMonomialOrder[{a, b, c}, n]
sets the order of monomials to be \(a <
b < c\) and assigns them grading level n
.
SetMonomialOrder[{a, b, c}, 1]
is equivalent to SetMonomialOrder[{a, b, c}]
. When using
this older syntax the user is responsible for calling ClearMonomialOrder to make sure that the
current order is empty before starting.
In Version 6, SetMonomialOrder
uses NCMonomialOrder, and NCMonomialOrderQ.
See also: ClearMonomialOrder, GetMonomialOrder, PrintMonomialOrder, SetKnowns, SetUnknowns, NCMonomialOrder, NCMonomialOrderQ.
SetKnowns[var1, var2, ...]
records the variables
var1
, var2
, … to be corresponding to known
quantities.
SetUnknowns
and Setknowns
prescribe a
monomial order with the knowns at the the bottom and the unknowns at the
top.
For example
SetKnowns[a,b]
SetUnknowns[c,d]
is equivalent to
SetMonomialOrder[{a,b}, {c}, {d}]
which corresponds to the order \(a < b \ll c \ll d\) and
SetKnowns[a,b]
SetUnknowns[{c,d}]
is equivalent to
SetMonomialOrder[{a,b}, {c, d}]
which corresponds to the order \(a < b \ll c < d\).
Note that SetKnowns
flattens grading so that
SetKnowns[a,b]
and
SetKnowns[{a},{b}]
result both in the order \(a < b\).
Successive calls to SetUnknowns
and
SetKnowns
overwrite the previous knowns and unknowns. For
example
SetKnowns[a,b]
SetUnknowns[c,d]
SetKnowns[c,d]
SetUnknowns[a,b]
results in an ordering \(c < d \ll a \ll b\).
See also: SetUnknowns, SetMonomialOrder.
SetUnknowns[var1, var2, ...]
records the variables
var1
, var2
, … to be corresponding to unknown
quantities.
SetUnknowns
and SetKnowns
prescribe a
monomial order with the knowns at the the bottom and the unknowns at the
top.
For example
SetKnowns[a,b]
SetUnknowns[c,d]
is equivalent to
SetMonomialOrder[{a,b}, {c}, {d}]
which corresponds to the order \(a < b \ll c \ll d\) and
SetKnowns[a,b]
SetUnknowns[{c,d}]
is equivalent to
SetMonomialOrder[{a,b}, {c, d}]
which corresponds to the order \(a < b \ll c < d\).
Note that SetKnowns
flattens grading so that
SetKnowns[a,b]
and
SetKnowns[{a},{b}]
result both in the order \(a < b\).
Successive calls to SetUnknowns
and
SetKnowns
overwrite the previous knowns and unknowns. For
example
SetKnowns[a,b]
SetUnknowns[c,d]
SetKnowns[c,d]
SetUnknowns[a,b]
results in an ordering \(c < d \ll a \ll b\).
See also: SetKnowns, SetMonomialOrder.
ClearMonomialOrder[]
clear the current monomial
ordering.
It is only necessary to use ClearMonomialOrder
if using
the indexed version of SetMonomialOrder
.
See also: SetKnowns, SetUnknowns, SetMonomialOrder, ClearMonomialOrder, PrintMonomialOrder.
GetMonomialOrder[]
returns the current monomial ordering
in the form of a list.
For example
SetMonomialOrder[{a,b}, {c}, {d}]
order = GetMonomialOrder[]
returns
order = {{a,b},{c},{d}}
See also: SetKnowns, SetUnknowns, SetMonomialOrder, ClearMonomialOrder, PrintMonomialOrder.
PrintMonomialOrder[]
prints the current monomial
ordering.
For example
SetMonomialOrder[{a,b}, {c}, {d}]
PrintMonomialOrder[]
print \(a < b \ll c \ll d\).
See also: SetKnowns, SetUnknowns, SetMonomialOrder, ClearMonomialOrder, PrintMonomialOrder.
NCMakeGB[{poly1, poly2, ...}, k]
attempts to produces a
nc Gröbner Basis (GB) associated with the list of nc polynomials
{poly1, poly2, ...}
. The GB algorithm proceeds through
at most k
iterations until a Gröbner basis is
found for the given list of polynomials with respect to the order
imposed by SetMonomialOrder.
If NCMakeGB
terminates before finding a GB the message
NCMakeGB::Interrupted
is issued.
The output of NCMakeGB
is a list of rules with left side
of the rule being the leading monomial of the polynomials in
the GB.
For example:
SetMonomialOrder[x];
gb = NCMakeGB[{x^2 - 1, x^3 - 1}, 20]
returns
gb = {x -> 1}
that corresponds to the polynomial \(x - 1\), which is the nc Gröbner basis for the ideal generated by \(x^2-1\) and \(x^3-1\).
NCMakeGB[{poly1, poly2, ...}, k, options]
uses
options
.
For example
gb = NCMakeGB[{x^2 - 1, x^3 - 1}, 20, RedudeBasis -> True]
runs the Gröbner basis algortihm and completely reduces the output set of polynomials.
The following options
can be given:
ReduceBasis
(True
): control whether the
resulting basis output by the command is a reduced Gröbner basis at the
completion of the algorithm. This corresponds to running
NCReduce
with the Boolean flag True
to
completely reduce the output basis. Can be set globally as
SetOptions[NCMakeGB, ReturnBasis -> True]
.SimplifyObstructions
(True
): control
whether whether to remove obstructions before constructing more
S-polynomials;SortObstructions
(False
): control whether
obstructions are sorted before being processed;SortBasis
(False
): control whether initial
basis is sorted before initiating algorithm;VerboseLevel
(1
): control level of
verbosity from 0
(no messages) to 5
(very
verbose);PrintBasis
(False
): if True
prints current basis at each major iteration;PrintObstructions
(False
): if
True
prints current list of obstructions at each major
iteration;PrintSPolynomials
(False
): if
True
prints every S-polynomial formed at each minor
iteration.ReturnRules
(True
): if True
rules representing relations in which the left-hand side is the leading
monomial are returned instead of polynomials. Use False
for
backward compatibility. Can be set globally as
SetOptions[NCMakeGB, ReturnRules -> False]
.NCMakeGB
makes use of the algorithm
NCPolyGroebner
implemented in NCPolyGroebner.
In Version 6, NCMakeGB
uses NCRationalToNCPoly to add additional
relations involving rational variables and rational terms.
See also: NCRationalToNCPoly, NCReduce, ClearMonomialOrder, GetMonomialOrder, PrintMonomialOrder, SetKnowns, SetUnknowns, NCPolyGroebner.
NCProcess[{poly1, poly2, ...}, k]
finds a new generating
set for the ideal generated by {poly1, poly2, ...}
using NCMakeGB then produces an summary report on the
findings.
Not all features of NCProcess
in the old
NCGB
C++ version are supported yet.
See also: NCMakeGB.
NCGBSimplifyRational[expr]
creates a set of relations
for each rational expression and sub-expression found in
expr
which are used to produce simplification rules using
NCMakeGB then replaced using NCReduce.
For example:
expr = x ** inv[1 - x] - inv[1 - x] ** x
NCGBSimplifyRational[expr]
or
expr = inv[1 - x - y ** inv[1 - x] ** y] - 1/2 (inv[1 - x + y] + inv[1 - x - y])
NCGBSimplifyRational[expr]
both result in 0
.
This packages implements a Gröebner Bases algorithm that runs purely under Mathematica. This algorithm is the one called by the user-friendly functions in the package NCGBX.
Members are:
NCPolyGroebner[G, iter]
computes the noncommutative
Groebner basis of the list of NCPoly
polynomials
G
. The algorithm either converges before or is interrupted
when the number of iterations reach iter
.
NCPolyGroebner[G, iter, options]
uses
options
.
The following options
can be given:
SimplifyObstructions
(True
) whether to
remove obstructions before constructing more S-polynomials;SortObstructions
(False
) whether to sort
obstructions using Mora’s SUGAR ranking;SortBasis
(False
) whether to sort basis
before starting algorithm;Labels
({}
) list of labels to use in
verbose printing;VerboseLevel
(1
): function used to decide
if a pivot is zero;PrintBasis
(False
): function used to
divide a vector by an entry;PrintObstructions
(False
);PrintSPolynomials
(False
);The algorithm is based on (Mora 1994) and uses the terminology there.
See also: NCPoly.
Starting with version 6.0.0 our legacy Gröebner Bases algorithm that requires both Mathematica and auxiliary executables compiled from C++ to run has been completely replaced by NCGBX.
See older versions of the NC documentation for a complete description of the legacy C++ code functionality.
NCSDP is a package that allows the symbolic manipulation and numeric solution of semidefinite programs.
Members are:
NCSDP[inequalities,vars,obj,data]
converts the list of
NC polynomials and NC matrices of polynomials inequalities
that are linear in the unknowns listed in vars
into the
semidefinite program with linear objective obj
. The
semidefinite program (SDP) should be given in the following canonical
form:
max <obj, vars> s.t. inequalities <= 0.
It returns a list with two entries:
Both entries should be supplied to SDPSolve in order to numerically solve the semidefinite program. For example:
{abc, rules} = NCSDP[inequalities, vars, obj, data];
generates an instance of SDPSylvester that can be solved using:
<< SDPSylvester`
{Y, X, S, flags} = SDPSolve[abc, rules];
NCSDP
uses the user supplied rules in data
to set up the problem data.
NCSDP[inequalities,vars,data]
converts problem into a
feasibility semidefinite program.
NCSDP[inequalities,vars,obj,data,options]
uses
options
.
The following options
can be given:
DebugLevel
(0
): control printing of
debugging information.See also: NCSDPForm, NCSDPDual, SDPSolve.
NCSDPForm[[inequalities,vars,obj]
prints out a pretty
formatted version of the SDP expressed by the list of NC polynomials and
NC matrices of polynomials inequalities
that are linear in
the unknowns listed in vars
.
See also: NCSDP, NCSDPDualForm.
{dInequalities, dVars, dObj} = NCSDPDual[inequalities,vars,obj]
calculates the symbolic dual of the SDP expressed by the list of NC
polynomials and NC matrices of polynomials inequalities
that are linear in the unknowns listed in vars
with linear
objective obj
into a dual semidefinite in the following
canonical form:
max <dObj, dVars> s.t. dInequalities == 0, dVars >= 0.
{dInequalities, dVars, dObj} = NCSDPDual[inequalities,vars,obj,dualVars]
uses the symbols in dualVars
as dVars
.
NCSDPDual[inequalities,vars,...,options]
uses
options
.
The following options
can be given:
DualSymbol
("w"
): letter to be used as
symbol for dual variable;DebugLevel
(0
): control printing of
debugging information.See also: NCSDPDualForm, NCSDP.
NCSDPForm[[dInequalities,dVars,dObj]
prints out a pretty
formatted version of the dual SDP expressed by the list of NC
polynomials and NC matrices of polynomials dInequalities
that are linear in the unknowns listed in dVars
with linear
objective dObj
.
See also: NCSDPDual, NCSDPForm.
SDP
is a package that provides data structures for the
numeric solution of semidefinite programs of the form: \[
\begin{aligned}
\max_{y, S} \quad & b^T y \\
\text{s.t.} \quad & A y + S = c \\
& S \succeq 0
\end{aligned}
\] where \(S\) is a symmetric
positive semidefinite matrix and \(y\)
is a vector of decision variables.
See the package SDP for a potentially more efficient alternative to the basic implementation provided by this package.
Members are:
SDPMatrices[f, G, y]
converts the symbolic linear
functions f
, G
in the variables y
associated to the semidefinite program:
\[ \begin{aligned} \min_y \quad & f(y), \\ \text{s.t.} \quad & G(y) \succeq 0 \end{aligned} \]
into numerical data that can be used to solve an SDP in the form:
\[ \begin{aligned} \max_{y, S} \quad & b^T y \\ \text{s.t.} \quad & A y + S = c \\ & S \succeq 0 \end{aligned} \]
SDPMatrices
returns a list with three entries:
A
;b
;c
.For example:
f = -x
G = {{1, x}, {x, 1}}
vars = {x}
{A,b,c} = SDPMatrices[f, G, vars]
results in
A = {{{{0, -1}, {-1, 0}}}}
b = {{{1}}}
c = {{{1, 0}, {0, 1}}}
All data is stored as SparseArray
s.
See also: SDPSolve.
SDPSolve[{A,b,c}]
solves an SDP in the form:
\[ \begin{aligned} \max_{y, S} \quad & b^T y \\ \text{s.t.} \quad & A y + S = c \\ & S \succeq 0 \end{aligned} \]
SDPSolve
returns a list with four entries:
PrimalFeasible
: True
if primal problem is
feasible;FeasibilityRadius
: less than one if primal problem is
feasible;PrimalFeasibilityMargin
: close to zero if primal
problem is feasible;DualFeasible
: True
if dual problem is
feasible;DualFeasibilityRadius
: close to zero if dual problem is
feasible.For example:
{Y, X, S, flags} = SDPSolve[abc]
solves the SDP abc
.
SDPSolve[{A,b,c}, options]
uses
options
.
options
are those of PrimalDual.
See also: SDPMatrices.
SDPEval[A, y]
evaluates the linear function \(A y\) in an SDP
.
This is a convenient replacement for SDPPrimalEval in which the list y
can be used directly.
See also: SDPPrimalEval, SDPDualEval, SDPSolve, SDPMatrices.
SDPPrimalEval[A, {{y}}]
evaluates the linear function
\(A y\) in an SDP
.
See SDPEval for a convenient replacement for
SDPPrimalEval
in which the list y
can be used
directly.
See also: SDPEval, SDPDualEval, SDPSolve, SDPMatrices.
SDPDualEval[A, X]
evaluates the linear function \(A^* X\) in an SDP
.
See also: SDPPrimalEval, SDPSolve, SDPMatrices.
SDPSylvesterEval[a, W]
returns a matrix representation
of the Sylvester mapping \(A^* (W A (\Delta_y)
W)\) when applied to the scaling W
.
SDPSylvesterEval[a, Wl, Wr]
returns a matrix
representation of the Sylvester mapping \(A^*
(W_l A (\Delta_y) W_r)\) when applied to the left- and
right-scalings Wl
and Wr
.
See also: SDPPrimalEval, SDPDualEval.
SDPFlat
is a package that provides data structures for
the numeric solution of semidefinite programs of the form: \[
\begin{aligned}
\max_{y, S} \quad & b^T y \\
\text{s.t.} \quad & A y + S = c \\
& S \succeq 0
\end{aligned}
\] where \(S\) is a symmetric
positive semidefinite matrix and \(y\)
is a vector of decision variables.
It is a potentially more efficient alternative to the basic implementation provided by the package SDP.
Members are:
SDPFlatData[{a,b,c}]
converts the triplet
{a,b,c}
from the format of the package SDP to the SDPFlat
format.
It returns a list with four entries:
a
;AFlat
;c
,
cFlat
;See also: SDP.
SDPFlatPrimalEval[aFlat, y]
evaluates the linear
function \(A y\) in an
SDPFlat
.
See also: SDPFlatDualEval, SDPFlatSylvesterEval.
SDPFlatDualEval[aFlat, X]
evaluates the linear function
\(A^* X\) in an
SDPFlat
.
See also: SDPFlatPrimalEval, SDPFlatSylvesterEval.
SDPFlatSylvesterEval[a, aFlat, W]
returns a matrix
representation of the Sylvester mapping \(A^*
(W A (\Delta_y) W)\) when applied to the scaling
W
.
SDPFlatSylvesterEval[a, aFlat, Wl, Wr]
returns a matrix
representation of the Sylvester mapping \(A^*
(W_l A (\Delta_y) W_r)\) when applied to the left- and
right-scalings Wl
and Wr
.
See also: SDPFlatPrimalEval, SDPFlatDualEval.
SDPSylvester
is a package that provides data structures
for the numeric solution of semidefinite programs of the form: \[
\begin{aligned}
\max_{y, S} \quad & \sum_i \operatorname{trace}(b_i^T y_i) \\
\text{s.t.} \quad & A y + S = \frac{1}{2} \sum_i a_i y_i b_i +
(a_i y_i b_i)^T + S = C \\
& S \succeq 0
\end{aligned}
\] where \(S\) is a symmetric
positive semidefinite matrix and \(y = \{ y_1,
\ldots, y_n \}\) is a list of matrix decision variables.
Members are:
SDPEval[A, y]
evaluates the linear function \(A y = \frac{1}{2} \sum_i a_i y_i b_i + (a_i y_i
b_i)^T\) in an SDPSylvester
.
This is a convenient replacement for SDPSylvesterPrimalEval in which the
list y
can be used directly.
See also: SDPSylvesterPrimalEval, SDPSylvesterDualEval.
SDPSylvesterPrimalEval[a, y]
evaluates the linear
function \(A y = \frac{1}{2} \sum_i a_i y_i
b_i + (a_i y_i b_i)^T\) in an SDPSylvester
.
See SDPSylvesterEval for a convenient
replacement for SDPPrimalEval
in which the list
y
can be used directly.
See also: SDPSylvesterDualEval, SDPSylvesterSylvesterEval.
SDPSylvesterDualEval[A, X]
evaluates the linear function
\(A^* X = \{ b_1 X a_1, \cdots, b_n X a_n
\}\) in an SDPSylvester
.
For example
See also: SDPSylvesterPrimalEval, SDPSylvesterSylvesterEval.
SDPSylvesterEval[a, W]
returns a matrix representation
of the Sylvester mapping \(A^* (W A (\Delta_y)
W)\) when applied to the scaling W
.
SDPSylvesterEval[a, Wl, Wr]
returns a matrix
representation of the Sylvester mapping \(A^*
(W_l A (\Delta_y) W_r)\) when applied to the left- and
right-scalings Wl
and Wr
.
See also: SDPSylvesterPrimalEval, SDPSylvesterDualEval.
PrimalDual
provides an algorithm for solving a pair of
primal-dual semidefinite programs in the form \[
\tag{Primal}
\begin{aligned}
\min_{X} \quad & \operatorname{trace}(c X) \\
\text{s.t.} \quad & A^*(X) = b \\
& X \succeq 0
\end{aligned}
\] \[
\tag{Dual}
\begin{aligned}
\max_{y, S} \quad & b^T y \\
\text{s.t.} \quad & A(y) + S = c \\
& S \succeq 0
\end{aligned}
\] where \(X\) is the primal
variable and \((y,S)\) are the dual
variables.
The algorithm is parametrized and users should provide their own means of evaluating the mappings \(A\), \(A^*\) and also the Sylvester mapping \[ A^*(W_l A(\Delta_y) W_r) \] used to solve the least-square subproblem.
Users can develop custom algorithms that can take advantage of special structure, as done for instance in NCSDP.
The algorithm constructs a feasible solution using the Self-Dual Embedding of [].
Members are:
PrimalDual[PrimalEval,DualEval,SylvesterEval,b,c]
solves
the semidefinite program using a primal dual method.
PrimalEval
should return the primal mapping \(A^*(X)\) when applied to the current primal
variable X
as in PrimalEval @@ X
.
DualEval
should return the dual mapping \(A(y)\) when applied to the current dual
variable y
as in DualEval @@ y
.
SylvesterVecEval
should return a matrix representation
of the Sylvester mapping \(A^* (W_l A
(\Delta_y) W_r)\) when applied to the left- and right-scalings
Wl
and Wr
as in
SylvesterVecEval @@ {Wl, Wr}
.
PrimalDual[PrimalEval,DualEval,SylvesterEval,b,c,options]
uses options
.
The following options
can be given:
Method
(PredictorCorrector
): choice of
method for updating duality gap; possible options are
ShortStep
, LongStep
and
PredictorCorrector
;
SearchDirection
(NT
): choice of search
direction to use; possible options are NT
for
Nesterov-Todd, KSH
for HRVM/KSH/M, KSHDual
for
dual HRVM/KSH/M;
FeasibilityTol
(10^-3): tolerance used to assess
feasibility;
GapTol
(10^-9): tolerance used to assess
optimality;
MaxIter
(250): maximum number of iterations
allowed;
SparseWeights
(True
): whether weights
should be converted to a SparseArray
;
RationalizeIterates
(False
): whether to
rationalize iterates in an attempt to construct a rational
solution;
SymmetricVariables
({}
): list of index
of dual variables to be considered symmetric.

Members are:
NCPolySOS[degree, var]
returns an NCPoly
with symbolic coefficients on the variable var
corresponding to a possible Gram representation of an noncommutative SOS
polynomial of degree degree
and its corresponding Gram
matrix.
NCPolySOS[poly, var]
uses NCPolyQuadraticChipset to generate a
sparse Gram representation of the noncommutative polynomial
poly
.
NCPolySOS[degree]
and NCPolySOS[p]
returns
the answer in terms of a newly created unique symbol.
For example,
{q,Q,x} = NCPolySOS[4];
returns the symbolic SOS NCPoly
q
and its
Gram matrix Q
expressed in terms of the variable
x
, and
{q,Q,x,chipset} = NCPolySOS[poly];
returns the symbolic NCPoly q
and its Gram matrix
Q
corresponding to terms in the quadratic
chipset
expressed in terms of the variable
x
.
See also: NCPolySOSToSDP, NCPolyQuadraticChipset
{sdp, vars, sol, solQ} = NCPolySOSToSDP[ps, Qs, var]
returns a semidefinite constraint sdp
in the variables
vars
and the rules sol
and solQ
that can be used to solve for variables in the list of SOS NCPoly
ps
and the list of Gram matrices Qs
.
For example,
{q, Q, $, chipset} = NCPolySOS[poly, q]; {sdp, vars, sol, solQ} = NCPolySOSToSDP[{poly - q}, {Q}, z];
generate the semidefinite constraints spd
in the
variables vars
which are feasible if and only if the
NCPoly
poly
is SOS.
See also: NCPolySOS.
Sections in this chapter describe experimental packages which are still under development.
This package contains functionality to convert an nc rational expression into a descriptor representation.
For example the rational
exp = 1 + inv[1 + x]
in variables x
and y
can be converted into
an NCPolynomial using
p = NCToNCPolynomial[exp, {x,y}]
which returns
p = NCPolynomial[a**c, <|{x}->{{1,a,b}},{x**y,x}->{{2,1,c,1}}|>, {x,y}]
Members are:
NCRational::usage
NCToNCRational::usage
NCRationalToNC::usage
NCRationalToCanonical::usage
CanonicalToNCRational::usage
NCROrder::usage
NCRLinearQ::usage
NCRStrictlyProperQ::usage
NCRPlus::usage
NCRTimes::usage
NCRTranspose::usage
NCRInverse::usage
NCRControllableRealization::usage
NCRControllableSubspace::usage
NCRObservableRealization::usage
NCRMinimalRealization::usage
WARNING: OBSOLETE PACKAGE WILL BE REPLACED BY NCRational
The package NCRealization implements an algorithm due to N. Slinglend for producing minimal realizations of nc rational functions in many nc variables. See “Toward Making LMIs Automatically”.
It actually computes formulas similar to those used in the paper “Noncommutative Convexity Arises From Linear Matrix Inequalities” by J William Helton, Scott A. McCullough, and Victor Vinnikov. In particular, there are functions for calculating (symmetric) minimal descriptor realizations of nc (symmetric) rational functions, and determinantal representations of polynomials.
Members are:
NCDescriptorRealization[RationalExpression,UnknownVariables]
returns a list of 3 matrices {C,G,B}
such that \(C G^{-1} B\) is the given
RationalExpression
.
i.e. NCDot[C,NCInverse[G],B] === RationalExpression
.
C
and B
do not contain any
UnknownsVariables
and G
has linear entries in
the UnknownVariables
.
NCDeterminantalRepresentationReciprocal[Polynomial,Unknowns]
returns a linear pencil matrix whose determinant equals
Constant * CommuteEverything[Polynomial]
. This uses the
reciprocal algorithm: find a minimal descriptor realization of
inv[Polynomial]
, so Polynomial
must be nonzero
at the origin.
NCMatrixDescriptorRealization[RationalMatrix,UnknownVariables]
is similar to NCDescriptorRealization
except it takes a
Matrix with rational function entries and returns a matrix of
lists of the vectors/matrix {C,G,B}
. A different
{C,G,B}
for each entry.
NCMinimalDescriptorRealization[RationalFunction,UnknownVariables]
returns {C,G,B}
where
NCDot[C,NCInverse[G],B] == RationalFunction
, G
is linear in the UnknownVariables
, and the realization is
minimal (may be pinned).
NCSymmetricDescriptorRealization[RationalSymmetricFunction, Unknowns]
combines two steps:
NCSymmetrizeMinimalDescriptorRealization[NCMinimalDescriptorRealization[RationalSymmetricFunction, Unknowns]]
.
NCSymmetricDeterminantalRepresentationDirect[SymmetricPolynomial,Unknowns]
returns a linear pencil matrix whose determinant equals
Constant * CommuteEverything[SymmetricPolynomial]
. This
uses the direct algorithm: Find a realization of 1 -
NCSymmetricPolynomial,…
NCSymmetricDeterminantalRepresentationReciprocal[SymmetricPolynomial,Unknowns]
returns a linear pencil matrix whose determinant equals
Constant * CommuteEverything[NCSymmetricPolynomial]
. This
uses the reciprocal algorithm: find a symmetric minimal descriptor
realization of inv[NCSymmetricPolynomial]
, so
NCSymmetricPolynomial must be nonzero at the origin.
NCSymmetrizeMinimalDescriptorRealization[{C,G,B},Unknowns]
symmetrizes the minimal realization {C,G,B}
(such as output
from NCMinimalRealization
) and outputs
{Ctilda,Gtilda}
corresponding to the realization
{Ctilda, Gtilda,Transpose[Ctilda]}
.
WARNING: May produces errors if the realization doesn’t correspond to a symmetric rational function.
NonCommutativeLift[Rational]
returns a noncommutative
symmetric lift of Rational
.
SignatureOfAffineTerm[Pencil,Unknowns]
returns a list of
the number of positive, negative and zero eigenvalues in the affine part
of Pencil
.
TestDescriptorRealization[Rat,{C,G,B},Unknowns]
checks
if Rat
equals \(C G^{-1}
B\) by substituting random 2-by-2 matrices in for the unknowns.
TestDescriptorRealization[Rat,{C,G,B},Unknowns,NumberOfTests]
can be used to specify the NumberOfTests
, the default being
5.
PinnedQ[Pencil_,Unknowns_]
is True or False.
PinningSpace[Pencil_,Unknowns_]
returns a matrix whose
columns span the pinning space of Pencil
. Generally, either
an empty matrix or a d-by-1 matrix (vector).
The transpose of the gradient of the nc expression
expr
is the derivative with respect to the direction
h
of the trace of the directional derivative of
expr
in the direction h
.↩
Contrary to what happens with symbolic inversion of
matrices with commutative entries, there exist multiple formulas for the
symbolic inverse of a matrix with noncommutative entries. Furthermore,
it may be possible that none of such formulas is “correct”. Indeed, it
is easy to construct a matrix m
with block structure as
shown that is invertible but for which none of the blocks
a
, b
, c
, and d
are
invertible. In this case no correct formula exists for the
calculation of the inverse of m
.↩
This is in contrast with the commutative \(x^4\) which is convex everywhere. See (Camino et al. 2003) for details.↩
The reason is that making an operator Flat
is a convenience that comes with a price: lack of control over execution
and evaluation. Since NCAlgebra
has to operate at a very
low level this lack of control over evaluation is fatal. Indeed, making
NonCommutativeMultiply
have an attribute Flat
will throw Mathematica into infinite loops in seemingly trivial
noncommutative expressions. Hey, email us if you find a way around that
:)↩
One might have encountered this difficulty when trying
to match a product of commutative variables in a commutative monomial
such as x y^2 /. x y -> z
which fails to match
x y^2
even though x y^2
is equal to
(x y) y
.↩
The actual rule in this case is the more complicated
a^n:_Integer?Positive:1**c**b^m:_Integer?Positive:1 -> a^(n-1)**d**b^(m-1)
with additional checks that prevent the rule from working with negative
powers.↩
By the way, I find that behavior of Mathematica’s
Module
questionable, since something like
F[exp_] := Module[{aa, bb},
SetNonCommutative[aa, bb];
aa**bb
]
would not fail to treat aa
and bb
locally.
It is their appearance in a rule that triggers the mostly odd
behavior.↩
Formerly MatMult[m1,m2]
.↩


The distant trees were still afraid of the winter sky, yet take their gems closed for fear
of hail or a frost. But something in the plowed field awakens and comes up hoping in the
rain, a beneficial rain. #tree #wheat #field #plowed #rain #awakening #robertomacrì #digital
processing.


Is it possible for isDirectory()
and isFile()
both to
return false?
Yes—if the pathName of the File
object
does not name an existing file or an existing directory,
then both methods return false.
However, if the thing named by pathName does exist,
then one method or the other returns true (but not both).
You have reached the end this chapter. You may wish to test the existence of the following topics. Click on a subject that interests you to go to where it was discussed.
exists()
method.
File
object in
Stream constructors.
File.


Advanced Search
Select Domain
{{domain?.text}}
{{domain?.text}}
Filter By
Your search did not return any results for active records.
Would you like to return inactive records in your search results.