summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-05-16 18:59:32 +0000
committerKarl Berry <karl@freefriends.org>2009-05-16 18:59:32 +0000
commitd58096d4311dd4c37a182f874923be19df9391f6 (patch)
tree0966ac5babb111bf25f937fb2fd0dc9b29b00150
parenta8faed6991f5b2ac497fcd32cb600b32fe0763e1 (diff)
pst-math 0.4 (13may09)
git-svn-id: svn://tug.org/texlive/trunk@13127 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/generic/pst-math/Changes1
-rw-r--r--Master/texmf-dist/dvips/pst-math/pst-math.pro80
-rw-r--r--Master/texmf-dist/tex/latex/pst-math/pst-math.sty2
3 files changed, 80 insertions, 3 deletions
diff --git a/Master/texmf-dist/doc/generic/pst-math/Changes b/Master/texmf-dist/doc/generic/pst-math/Changes
index b45e32673f0..9848d512b23 100644
--- a/Master/texmf-dist/doc/generic/pst-math/Changes
+++ b/Master/texmf-dist/doc/generic/pst-math/Changes
@@ -1,4 +1,5 @@
..... pst-math.pro
+0.4 2009-05-11 added SystemEqnSolver
0.3 2009-01-20 added SIMPSON for numeric integration (dr/hv)
0.2 2007-08-30 added GAMMA function (hv)
0.1 first CTAN version (cj)
diff --git a/Master/texmf-dist/dvips/pst-math/pst-math.pro b/Master/texmf-dist/dvips/pst-math/pst-math.pro
index 711bb8f167c..a99b6ed5d26 100644
--- a/Master/texmf-dist/dvips/pst-math/pst-math.pro
+++ b/Master/texmf-dist/dvips/pst-math/pst-math.pro
@@ -5,8 +5,8 @@
% Author : Christophe JORSSEN
% Author : Herbert Voß <hvoss@tug.org>
% Created the : Sat 20 March 2004
-% Last Mod : $Date: 2009/01/19 $
-% Version : 1.2 $
+% Last Mod : $Date: 2009/05/11 $
+% Version : 0.4 $
%
/PI 3.14159265359 def
/ENeperian 2.71828182846 def
@@ -147,6 +147,82 @@
exch 5 -1 roll 6 div mul mark 10 2 roll cleartomark
end
} def
+% ------------------------------------ math stuff ----------------------------------
+%
+% Matrix A in arrays of rows A[[row1][row2]...]
+% with [row1]=[a11 a12 ... b1]
+% returns on stack solution vector X=[x1 x2 ... xn]
+/SolveLinEqSystem { % on stack matrix M=[A,b] (A*x=b)
+ 10 dict begin % hold all ocal
+ /A exch def
+ /Rows A length def % Rows = number of rows
+ /Cols A 0 get length def % Cols = number of columns
+ /Index [ 0 1 Rows 1 sub { } for ] def % Index = [0 1 2 ... Rows-1]
+ /col 0 def
+ /row 0 def
+ /PR Rows array def % PR[c] = pivot row for row row
+ { % starts the loop, find pivot entry in row r
+ col Cols ge row Rows ge or { exit } if % col < Cols and row < Rows else exit
+ /pRow row def % pRow = pivot row
+ /max A row get col get abs def % get A[row[col]], first A[0,0]
+ row 1 add 1 Rows 1 sub { % starts for loop 1 1 Rows-1
+ /j exch def % index counter
+ /x A j get col get abs def % get A[j[r]]
+ x max gt { % x>max, then save position
+ /pRow j def
+ /max x def
+ } if
+ } for % now we have the row with biggest A[0,1]
+ % with pRow = the pivot row
+ max 0 gt { % swap entries pRow and row in i
+ /tmp Index row get def
+ Index row Index pRow get put
+ Index pRow tmp put % and columns pRow and row in A
+ /tmp A row get def
+ A row A pRow get put
+ A pRow tmp put % pivot
+ /row0 A row get def % the pivoting row
+ /p0 row0 col get def % the pivot value
+ row 1 add 1 Rows 1 sub { % start for loop
+ /j exch def
+ /c1 A j get def
+ /p c1 col get p0 div def
+ c1 col p put % subtract (p1/p0)*row[i] from row[j]
+ col 1 add 1 Cols 1 sub { % start for loop
+ /i exch def
+ c1 dup i exch % c1 i c1
+ i get row0 i get p mul sub put
+ } for
+ } for
+ PR row col put
+ /col col 1 add def
+ /row row 1 add def
+ }{ % all zero entries
+ /row row 1 add def % continue loop with same row
+ } ifelse
+ } loop
+ /X A def % solution vector
+ A Rows 1 sub get dup
+ Cols 1 sub get exch
+ Cols 2 sub get div
+ X Rows 1 sub 3 -1 roll put % X[n]
+ Rows 2 sub -1 0 { % for loop to calculate X[i]
+ /xi exch def % current index
+ A xi get % i-th row
+ /Axi exch def
+ /sum 0 def
+ Cols 2 sub -1 xi 1 add {
+ /n exch def
+ /sum sum Axi n get X n get mul add def
+ } for
+ Axi Cols 1 sub get % b=Axi[Cols-1]
+ sum sub % b-sum
+ Axi xi get div % b-sum / Axi[xi]
+ X xi 3 -1 roll put % X[xi]
+ } for
+ X
+ end
+} def
%
%
% END pst-math.pro
diff --git a/Master/texmf-dist/tex/latex/pst-math/pst-math.sty b/Master/texmf-dist/tex/latex/pst-math/pst-math.sty
index 9fb99e25041..38f32e640b6 100644
--- a/Master/texmf-dist/tex/latex/pst-math/pst-math.sty
+++ b/Master/texmf-dist/tex/latex/pst-math/pst-math.sty
@@ -4,6 +4,6 @@
[\filedate\space v\fileversion\space `PST-math' (hv)]
\IfFileExists{pst-math.pro}{%
\ProvidesFile{pst-math.pro}
- [2009/01/20 v. 0.3, PostScript prologue file (hv)]
+ [2009/05/11 v. 0.4, PostScript prologue file (hv)]
\@addtofilelist{pst-math.pro}}{}%
\endinput