File: working.cdb

package info (click to toggle)
cadabra2 2.4.3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,796 kB
  • sloc: ansic: 133,450; cpp: 92,064; python: 1,530; javascript: 203; sh: 184; xml: 182; objc: 53; makefile: 51
file content (68 lines) | stat: -rw-r--r-- 1,262 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

ex1=Ex(0)
ex2=Ex('0')
ex3=Ex('1')
print ex1==ex2
print ex2==ex3
print ex1==0

def defaults(ex):
    collect_terms(ex)


def test():
    {m,n,p,a,b}::AntiCommuting.
    ex1:=p m n a;
    sort_product(ex1);
    print(ex1)
    tst1:= - a m n p - @(ex1)
    collect_terms(tst1)
    if tst1==0:
        print 'ex1 ok'
    else:
        print 'ex1 not ok'
    ex2:= A_{m n} ( B_{m p}+C_{m p} );
    distribute(ex2);	
    tst2:= A_{m n} B_{m p} + A_{m n} C_{m p} - @(ex2)
    print(tst2)
    map(defaults, [tst2])
    if tst2==0:
        print 'ex2 ok'
    else:
        print 'ex2 not ok'

test()

# This does not see the property declared in test():
ex3:=p m n a;
sort_product(ex3);
tst3:= a m n p - @(ex3)
collect_terms(tst3)
if tst3==0:
    print 'ex3 ok'
else:
    print 'ex3 not ok'


# Test with scope, index relabelling and python calls.

{m,n,p,q,r,s,t}::Indices.

def test(inex):
    ex:= A_{m n} ( B_{m p}+C_{m p} ) @(inex)
    distribute(ex);
    repl:= B_{m p} -> K_{m n} K_{n p}
    substitute(ex, repl)
    return ex

myex:= D^{n q}
print test(myex)

# Automatic renaming of dummies upon using @(...).
#
{m,n,p,q}::Indices.
ex := A_{m n} B_{m n};
ex2 := @(ex) @(ex);
tst2 := A_{m n} B_{m n} A_{p q} B_{p q} - @(ex2);
collect_terms(tst2)
assert(tst2==0)