Skip to content

Commit 42d781e

Browse files
committed
fixes and tensorLog
1 parent 8c61629 commit 42d781e

File tree

4 files changed

+54
-17
lines changed

4 files changed

+54
-17
lines changed

PathSignatures.m2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export {
3636
"lie",
3737
"lieBasis",
3838
"tensorExp",
39+
"tensorLog",
3940
"lyndonShuffle",
4041
"VarWordTable"
4142
-- "type",

PathSignatures/algebra.m2

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,29 @@ expTerm = (tl,l) -> (
288288
-- Given a tensor p with constant term 0, tensorExp(p,k) returns the k-th level component of exp(p)
289289
tensorExp = method();
290290
tensorExp (NCRingElement, ZZ) := (p,k) -> (
291+
if(k==0) then return 1;
291292
if(length (select(terms p, j-> degree j == 0)) > 0) then error("tensorExp expects a nc polynomial with constant term 0.");
292293
s := {1} | toList apply(1..k, i-> sum(select(terms p, j->((degree j) == i))));
293294
comp := unique apply(compositions k, i->delete(0,i));
294295
t := sum(apply(comp, i-> expTerm(s,i)));
295296
return(t);
296297
)
297298

299+
logTerm = (tl,l) -> (
300+
return(1/(length(l)))*product(l,i->(tl_i))
301+
)
302+
303+
-- Given a tensor p with constant term 1, tensorLog(p,k) returns the k-th level component of log(p)
304+
tensorLog = method();
305+
tensorLog (NCRingElement, ZZ) := (p,k) -> (
306+
if(select(terms p, j-> degree j == 0)!= {1}) then error("tensorLog expects a nc polynomial with constant term 1.");
307+
lp := - p + 1;
308+
s := {1} | toList apply(1..k, i-> sum(select(terms lp, j->((degree j) == i))));
309+
comp := unique apply(compositions k, i->delete(0,i));
310+
t := - sum(apply(comp, i-> logTerm(s,i)));
311+
return(t);
312+
)
313+
298314
lyndonShuffleHelper = method();
299315
lyndonShuffleHelper(List,Ring,NCRing) := (l,R,A) -> ( -- R must be a suitable ring of Lyndon words
300316
w := new Array from l;

PathSignatures/documentation.m2

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -792,28 +792,49 @@ Node
792792
tensorExp
793793
(tensorExp, NCRingElement,ZZ)
794794
Headline
795-
Compute the exponential of a tensor.
795+
Compute a component of the exponential of a tensor.
796796
Description
797797
Text
798-
Let $T^n(\mathbb{R}^d)$ denote the tensor algebra on $\mathbb{R}^d$ truncated at $n$. $$
799-
T^n(\mathbb{R}^d):= \bigoplus_{k=0}^{n} \left(\mathbb{R}^d\right)^{\otimes k}
798+
Let $T((\mathbb{R}^d))$ denote the dual of the tensor algebra on $\mathbb{R}^d$, i.e., the space $\prod_k (\mathbb{R}^d)^{\otimes k}$. Given $x \in T(\mathbb{R}^d)$ its exponential is
799+
$$\exp(x) := \sum_{k \geq 0} \frac{1}{k!} x^{\otimes k} \in T((\mathbb{R}^d)).
800800
$$
801-
Then the tensor exponential is a map $$
802-
\mathtt{tensorExp} : T^n(\mathbb{R}^d)\rightarrow T^n(\mathbb{R}^d)
803-
$$
804-
defined by $$
805-
P\mapsto \sum_{r\geq 0} \frac{1}{r!} P^{\otimes k}
806-
$$
807-
If the constant term of the input is not $0$, the constant term of its exponential might not be a rational number
808-
anymore. To avoid this cases, the method is only implemented for tensors with constant term equal to $0$.
801+
$\texttt{tensorExp(x,k)}$ computes the degree $k$ component of $\exp(x)$.
802+
803+
If the constant term of the input is not $0$, the exponential can not be expressed with algebraic coefficients. To avoid this case, the method is only implemented for tensors with constant term equal to $0$.
809804
Example
810805
R = wordAlgebra(2);
811-
P = [1,2]_R + [1]_R
812-
tensorExp(P, 2)
806+
x = [1]_R + [1,2]_R
807+
tensorExp(x, 2)
813808
Caveat
814809
The method is implemented only for tensors with constant term $0$.
815-
References
816-
@HREF {"https://doi.org/10.1017/fms.2019.3", "Varieties Of Signature Tensors (doi.org/10.1017/fms.2019.3)"}@
810+
SeeAlso
811+
lieBasis
812+
tensorLog
813+
-- References
814+
-- @HREF {"https://doi.org/10.1017/fms.2019.3", "Varieties Of Signature Tensors (doi.org/10.1017/fms.2019.3)"}@
815+
816+
Node
817+
Key
818+
tensorLog
819+
(tensorLog, NCRingElement,ZZ)
820+
Headline
821+
Compute a component of the logarithm of a tensor.
822+
Description
823+
Text
824+
Let $T((\mathbb{R}^d))$ denote the dual of the tensor algebra on $\mathbb{R}^d$, i.e., the space $\prod_k (\mathbb{R}^d)^{\otimes k}$. Given $x \in T(\mathbb{R}^d)$ with constant term $1$, its logarithm is
825+
$$\log(x) := - \sum_{k \geq 0} \frac{1}{k} (1-x)^{\otimes k} \in T((\mathbb{R}^d)).
826+
$$
827+
$\texttt{tensorLog(x,k)}$ computes the degree $k$ component of $\log(x)$.
828+
Example
829+
A2 = wordAlgebra(2);
830+
x = 1 + [1]_A2 + 1/2 * [1,1]_A2 + 1/6 * [1,1,1]_A2;
831+
sum(0..3, i -> tensorLog(x, i))
832+
Caveat
833+
The method is implemented only for tensors with constant term $1$.
834+
SeeAlso
835+
tensorExp
836+
-- References
837+
-- @HREF {"https://doi.org/10.1017/fms.2019.3", "Varieties Of Signature Tensors (doi.org/10.1017/fms.2019.3)"}@
817838

818839
Node
819840
Key

PathSignatures/signatures.m2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ polySigGen (List, List, Ring) := RingElement => (l,w, baseR) ->(
119119
k:= length w;
120120
x := getSymbol("x");
121121
R := baseR monoid([x_1..x_k]);
122-
s := getSymbol("s");
123-
S := baseR monoid([s]);
122+
S := baseR monoid([ value("s" | toString(random(1000)))]);
124123
X := apply(l, i-> sum(0..length(i)-1, j -> ((i#j)#1)_S * (S_0)^((i#j)#0#0)));
125124

126125
resd := product for i from 1 to k list (

0 commit comments

Comments
 (0)