549 |
for r in args: |
for r in args: |
550 |
out=out.replace("%%a%s%%"%c,r) |
out=out.replace("%%a%s%%"%c,r) |
551 |
return out |
return out |
552 |
|
#======================================================================================================= |
553 |
|
# eigenvalues |
554 |
|
#======================================================================================================= |
555 |
|
import numarray.linear_algebra |
556 |
|
name="eigenvalues" |
557 |
|
for case0 in ["array","Symbol","constData","taggedData","expandedData"]: |
558 |
|
for sh0 in [ (1,1), (2,2), (3,3)]: |
559 |
|
text=" #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" |
560 |
|
tname="test_%s_%s_dim%s"%(name,case0,sh0[0]) |
561 |
|
text+=" def %s(self):\n"%tname |
562 |
|
a_0=makeArray(sh0,[-1.,1]) |
563 |
|
a_0=(a_0+numarray.transpose(a_0))/2. |
564 |
|
ev=numarray.linear_algebra.eigenvalues(a_0) |
565 |
|
ev.sort() |
566 |
|
if case0 in ["taggedData", "expandedData"]: |
567 |
|
a1_0=makeArray(sh0,[-1.,1]) |
568 |
|
a1_0=(a1_0+numarray.transpose(a1_0))/2. |
569 |
|
ev1=numarray.linear_algebra.eigenvalues(a1_0) |
570 |
|
ev1.sort() |
571 |
|
else: |
572 |
|
a1_0=a_0 |
573 |
|
ev1=ev |
574 |
|
text+=mkText(case0,"arg",a_0,a1_0) |
575 |
|
text+=" res=%s(arg)\n"%name |
576 |
|
if case0=="Symbol": |
577 |
|
text+=mkText("array","s",a_0,a1_0) |
578 |
|
text+=" sub=res.substitute({arg:s})\n" |
579 |
|
res="sub" |
580 |
|
text+=mkText("array","ref",ev,ev1) |
581 |
|
else: |
582 |
|
res="res" |
583 |
|
text+=mkText(case0,"ref",ev,ev1) |
584 |
|
text+=mkTypeAndShapeTest(case0,(sh0[0],),"res") |
585 |
|
text+=" self.failUnless(Lsup(%s-ref)<=self.RES_TOL*Lsup(ref),\"wrong result\")\n"%res |
586 |
|
|
587 |
|
if case0 == "taggedData" : |
588 |
|
t_prog_with_tags+=text |
589 |
|
else: |
590 |
|
t_prog+=text |
591 |
|
print test_header |
592 |
|
# print t_prog |
593 |
|
print t_prog_with_tags |
594 |
|
print test_tail |
595 |
|
1/0 |
596 |
|
|
597 |
#======================================================================================================= |
#======================================================================================================= |
598 |
# slicing |
# slicing |