PDL::LinearAlgebra

PDL::LinearAlgebra Perl module contains linear algebra utils for PDL.
Download

PDL::LinearAlgebra Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Grgory Vanuxem
  • Publisher web site:
  • http://search.cpan.org/~ellipse/PDL-LinearAlgebra-0.06/Real/real.pd

PDL::LinearAlgebra Tags


PDL::LinearAlgebra Description

PDL::LinearAlgebra Perl module contains linear algebra utils for PDL. PDL::LinearAlgebra Perl module contains linear algebra utils for PDL.SYNOPSIS use PDL::LinearAlgebra; $a = random (100,100); ($U, $s, $V) = mdsvd($a);This module provides a convenient interface to PDL::LinearAlgebra::Real and PDL::LinearAlgebra::Complex.FUNCTIONSsetlaerrorSet action type when error is encountered, returns previous type. Available values are NO, WARN and BARF (predefined constants). If, for example, in computation of the inverse, singularity is detected, the routine can silently return values from computation (see manuals), warn about singularity or barf. BARF is the default value. $a = sequence(5,5); $err = setlaerror(NO); ($inv, $info)= minv($a); if ($info){ # Change the diagonal (the inverse doesn't exist but it's an example) $a->diagonal(0,1)+=1e-8; ($inv, $info)= minv($a); } if ($info){ print "Can't compute the inversen"; } else{ print "Inverse of $a is $inv"; } setlaerror($err);getlaerrorGet error type. 0 => NO, 1 => WARN, 2 => BARFt PDL = t(PDL, SCALAR(conj)) conj : Conjugate Transpose = 1 | Transpose = 0, default = 1;Convenient function for transposing real or complex 2D array(s). For PDL::Complex, if conj is true returns conjugate transpose array(s) and doesn't support dataflow. Supports threading.issym PDL = issym(PDL, SCALAR|PDL(tol),SCALAR(hermitian)) tol : tolerance value, default: 1e-8 for double else 1e-5 hermitian : Hermitian = 1 | Symmetric = 0, default = 1;Check symmetricity/Hermitianicity of matrix. Supports threading.diagReturn i-th diagonal if matrix in entry or matrix with i-th diagonal with entry. I-th diagonal returned flows data back&forth. Can be used as lvalue subs if your perl supports it. Supports threading. PDL = diag(PDL, SCALAR(i), SCALAR(vector))) i : i-th diagonal, default = 0 vector : create diagonal matrices by threading over row vectors, default = 0 my $a = random(5,5); my $diag = diag($a,2); # If your perl support lvaluable subroutines. $a->diag(-2) .= pdl(1,2,3); # Construct a (5,5,5) PDL (5 matrices) with # diagonals from row vectors of $a $a->diag(0,1)tritosymReturn symmetric or Hermitian matrix from lower or upper triangular matrix. Supports inplace and threading. Uses tricpy or ctricpy from Lapack. PDL = tritosym(PDL, SCALAR(uplo), SCALAR(conj)) uplo : UPPER = 0 | LOWER = 1, default = 0 conj : Hermitian = 1 | Symmetric = 0, default = 1; # Assume $a is symmetric triangular my $a = random(10,10); my $b = tritosym($a);positiviseReturn entry pdl with changed sign by row so that average of positive sign > 0. In other words thread among dimension 1 and row = -row if Sum(sign(row)) < 0. Works inplace. my $a = random(10,10); $a -= 0.5; $a->xchg(0,1)->inplace->positivise;mcrossprodCompute the cross-product of two matrix: A' x B. If only one matrix is given, take B to be the same as A. Supports threading. Uses crossprod or ccrossprod. PDL = mcrossprod(PDL(A), (PDL(B)) my $a = random(10,10); my $crossproduct = mcrossprod($a);mrankCompute the rank of a matrix, using a singular value decomposition. from Lapack. SCALAR = mrank(PDL, SCALAR(TOL)) TOL: tolerance value, default : mnorm(dims(PDL),'inf') * mnorm(PDL) * EPS my $a = random(10,10); my $b = mrank($a, 1e-5);mnormCompute norm of real or complex matrix Supports threading. PDL(norm) = mnorm(PDL, SCALAR(ord)); ord : 0|'inf' : Infinity norm 1|'one' : One norm 2|'two' : norm 2 (default) 3|'fro' : frobenius norm my $a = random(10,10); my $norm = mnrom($a);mdetCompute determinant of a general square matrix using LU factorization. Supports threading. Uses getrf or cgetrf from Lapack. PDL(determinant) = mdet(PDL); my $a = random(10,10); my $det = mdet($a);mposdetCompute determinant of a symmetric or Hermitian positive definite square matrix using Cholesky factorization. Supports threading. Uses potrf or cpotrf from Lapack. (PDL, PDL) = mposdet(PDL, SCALAR) SCALAR : UPPER = 0 | LOWER = 1, default = 0 my $a = random(10,10); my $det = mposdet($a);mcondCompute the condition number (two-norm) of a general matrix.The condition number (two-norm) is defined: norm (a) * norm (inv (a)).Uses a singular value decomposition. Supports threading. PDL = mcond(PDL) my $a = random(10,10); my $cond = mcond($a);mrcondEstimate the reciprocal condition number of a general square matrix using LU factorization in either the 1-norm or the infinity-norm.The reciprocal condition number is defined: 1/(norm (a) * norm (inv (a)))Supports threading. PDL = mrcond(PDL, SCALAR(ord)) ord : 0 : Infinity norm (default) 1 : One norm my $a = random(10,10); my $rcond = mrcond($a,1);morthReturn an orthonormal basis of the range space of matrix A. PDL = morth(PDL(A), SCALAR(tol)) tol : tolerance for determining rank, default: 1e-8 for double else 1e-5 my $a = random(10,10); my $ortho = morth($a, 1e-8);mnullReturn an orthonormal basis of the null space of matrix A. PDL = mnull(PDL(A), SCALAR(tol)) tol : tolerance for determining rank, default: 1e-8 for double else 1e-5 my $a = random(10,10); my $null = mnull($a, 1e-8);minvCompute inverse of a general square matrix using LU factorization. Supports inplace and threading. Uses getrf and getri or cgetrf and cgetri from Lapack and return inverse, info in array context. PDL(inv) = minv(PDL) my $a = random(10,10); my $inv = minv($a);mtriinvCompute inverse of a triangular matrix. Supports inplace and threading. Uses trtri or ctrtri from Lapack. Returns inverse, info in array context. (PDL, PDL(info))) = mtriinv(PDL, SCALAR(uplo), SCALAR|PDL(diag)) uplo : UPPER = 0 | LOWER = 1, default = 0 diag : UNITARY DIAGONAL = 1, default = 0 # Assume $a is upper triangular my $a = random(10,10); my $inv = mtriinv($a);Requirements:· Perl Requirements: · Perl


PDL::LinearAlgebra Related Software