.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Math::Cephes::Matrix 3pm" .TH Math::Cephes::Matrix 3pm "2021-06-22" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Math::Cephes::Matrix \- Perl interface to the cephes matrix routines .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 12 \& use Math::Cephes::Matrix qw(mat); \& # \*(Aqmat\*(Aq is a shortcut for Math::Cephes::Matrix\->new \& my $M = mat([ [1, 2, \-1], [2, \-3, 1], [1, 0, 3]]); \& my $C = mat([ [1, 2, 4], [2, 9, 2], [6, 2, 7]]); \& my $D = $M\->add($C); # D = M + C \& my $Dc = $D\->coef; \& for (my $i=0; $i<3; $i++) { \& print "row $i:\en"; \& for (my $j=0; $j<3; $j++) { \& print "\etcolumn $j: $Dc\->[$i]\->[$j]\en"; \& } \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module is a layer on top of the basic routines in the cephes math library for operations on square matrices. In the following, a Math::Cephes::Matrix object is created as .PP .Vb 1 \& my $M = Math::Cephes::Matrix\->new($arr_ref); .Ve .PP where \f(CW$arr_ref\fR is a reference to an array of arrays, as in the following example: .PP .Vb 1 \& $arr_ref = [ [1, 2, \-1], [2, \-3, 1], [1, 0, 3] ] .Ve .PP which represents .PP .Vb 3 \& / 1 2 \-1 \e \& | 2 \-3 1 | \& \e 1 0 3 / .Ve .PP A copy of a \fIMath::Cephes::Matrix\fR object may be done as .PP .Vb 1 \& my $M_copy = $M\->new(); .Ve .SS "Methods" .IX Subsection "Methods" .IP "\fIcoef\fR: get coefficients of the matrix" 4 .IX Item "coef: get coefficients of the matrix" .Vb 1 \& SYNOPSIS: \& \& my $c = $M\->coef; \& \& DESCRIPTION: .Ve .Sp This returns an reference to an array of arrays containing the coefficients of the matrix. .IP "\fIclr\fR: set all coefficients equal to a value." 4 .IX Item "clr: set all coefficients equal to a value." .Vb 1 \& SYNOPSIS: \& \& $M\->clr($n); \& \& DESCRIPTION: .Ve .Sp This sets all the coefficients of the matrix identically to \fI\f(CI$n\fI\fR. If \fI\f(CI$n\fI\fR is not given, a default of 0 is used. .IP "\fIadd\fR: add two matrices" 4 .IX Item "add: add two matrices" .Vb 1 \& SYNOPSIS: \& \& $P = $M\->add($N); \& \& DESCRIPTION: .Ve .Sp This sets \f(CW$P\fR equal to \f(CW$M\fR + \f(CW$N\fR. .IP "\fIsub\fR: subtract two matrices" 4 .IX Item "sub: subtract two matrices" .Vb 1 \& SYNOPSIS: \& \& $P = $M\->sub($N); \& \& DESCRIPTION: .Ve .Sp This sets \f(CW$P\fR equal to \f(CW$M\fR \- \f(CW$N\fR. .IP "\fImul\fR: multiply two matrices or a matrix and a vector" 4 .IX Item "mul: multiply two matrices or a matrix and a vector" .Vb 1 \& SYNOPSIS: \& \& $P = $M\->mul($N); \& \& DESCRIPTION: .Ve .Sp This sets \f(CW$P\fR equal to \f(CW$M\fR * \f(CW$N\fR. This method can handle matrix multiplication, when \f(CW$N\fR is a matrix, as well as matrix-vector multiplication, where \f(CW$N\fR is an array reference representing a column vector. .IP "\fIdiv\fR: divide two matrices" 4 .IX Item "div: divide two matrices" .Vb 1 \& SYNOPSIS: \& \& $P = $M\->div($N); \& \& DESCRIPTION: .Ve .Sp This sets \f(CW$P\fR equal to \f(CW$M\fR * ($N)^(\-1). .IP "\fIinv\fR: invert a matrix" 4 .IX Item "inv: invert a matrix" .Vb 1 \& SYNOPSIS: \& \& $I = $M\->inv(); \& \& DESCRIPTION: .Ve .Sp This sets \f(CW$I\fR equal to ($M)^(\-1). .IP "\fItransp\fR: transpose a matrix" 4 .IX Item "transp: transpose a matrix" .Vb 1 \& SYNOPSIS: \& \& $T = $M\->transp(); \& \& DESCRIPTION: .Ve .Sp This sets \f(CW$T\fR equal to the transpose of \f(CW$M\fR. .IP "\fIsimq\fR: solve simultaneous equations" 4 .IX Item "simq: solve simultaneous equations" .Vb 1 \& SYNOPSIS: \& \& my $M = Math::Cephes::Matrix\->new([ [1, 2, \-1], [2, \-3, 1], [1, 0, 3]]); \& my $B = [2, \-1, 10]; \& my $X = $M\->simq($B); \& for (my $i=0; $i<3; $i++) { \& print "X[$i] is $X\->[$i]\en"; \& } .Ve .Sp where \f(CW$M\fR is a \fIMath::Cephes::Matrix\fR object, \f(CW$B\fR is an input array reference, and \f(CW$X\fR is an output array reference. .Sp .Vb 1 \& DESCRIPTION: .Ve .Sp A set of N simultaneous equations may be represented in matrix form as .Sp .Vb 1 \& M X = B .Ve .Sp where M is an N x N square matrix and X and B are column vectors of length N. .IP "\fIeigens\fR: eigenvalues and eigenvectors of a real symmetric matrix" 4 .IX Item "eigens: eigenvalues and eigenvectors of a real symmetric matrix" .Vb 1 \& SYNOPSIS: \& \& my $S = Math::Cephes::Matrix\->new([ [1, 2, 3], [2, 2, 3], [3, 3, 4]]); \& my ($E, $EV1) = $S\->eigens(); \& my $EV = $EV1\->coef; \& for (my $i=0; $i<3; $i++) { \& print "For i=$i, with eigenvalue $E\->[$i]\en"; \& my $v = []; \& for (my $j=0; $j<3; $j++) { \& $v\->[$j] = $EV\->[$i]\->[$j]; \& } \& print "The eigenvector is @$v\en"; \& } .Ve .Sp where \f(CW$M\fR is a \fIMath::Cephes::Matrix\fR object representing a real symmetric matrix. \f(CW$E\fR is an array reference containing the eigenvalues of \f(CW$M\fR, and \f(CW$EV\fR is a \fIMath::Cephes::Matrix\fR object representing the eigenvalues, the \fIith\fR row corresponding to the \fIith\fR eigenvalue. .Sp .Vb 1 \& DESCRIPTION: .Ve .Sp If M is an N x N real symmetric matrix, and X is an N component column vector, the eigenvalue problem .Sp .Vb 1 \& M X = lambda X .Ve .Sp will in general have N solutions, with X the eigenvectors and lambda the eigenvalues. .SH "BUGS" .IX Header "BUGS" Please report any to Randy Kobes .SH "COPYRIGHT" .IX Header "COPYRIGHT" The C code for the Cephes Math Library is Copyright 1984, 1987, 1989, 2002 by Stephen L. Moshier, and is available at http://www.netlib.org/cephes/. Direct inquiries to 30 Frost Street, Cambridge, \s-1MA 02140.\s0 .PP The perl interface is copyright 2000, 2002 by Randy Kobes. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.