PDL::L...Special(3pm)

πŸ’– PDL::L...Special πŸ’–

okay bestie, gather round, because this is the PDL::LinearAlgebra::Special page from the User Contributed Perl Documentation, and it is literally your one-stop shop for building famous matrices without doing the math yourself. it's giving constructor-core. πŸŽ€


✨ NAME ✨

PDL::LinearAlgebra::Special β€” Special matrices for PDL πŸ¦‹


🌸 SYNOPSIS 🌸

use PDL::LinearAlgebra::Special;

$a = mhilb(5,5);

like, that's it. that's the whole vibe check. πŸ’…


πŸ’« DESCRIPTION πŸ’«

so this module is basically a lil friend group of constructors for well known matrices. you want a famous matrix? boom, it's here. you want to build it by hand and suffer? not on this module's watch. no cap. ✨


πŸ”₯ FUNCTIONS πŸ”₯


πŸ‘‘ mhilb

constructs a Hilbert matrix, either from a specifications list or from a template ndarray. iconic behaviour fr fr.

PDL(Hilbert)  = mpart(PDL(template) | ARRAY(specification))

my $hilb   = mhilb(float,5,5);

🧚 mtri

returns a zeroed matrix with the upper or lower triangular part pulled from another matrix. and if the matrix you hand it isn't square? you get a trapezoid matrix instead. it supports broadcasting, bestie, we love that. it uses tricpy or tricpy. πŸ’€

PDL = mtri(PDL, SCALAR)
SCALAR : UPPER = 0 | LOWER = 1, default = 0

my $a = random(10,10);
my $b = mtri($a, 0);

🌈 mvander

returns a (primal) Vandermonde matrix from a vector. slay.

mvander(M,P) is a rectangular version of mvander(P) with M Columns.


πŸ’œ mpart

returns the antisymmetric and symmetric part of a real or complex square matrix. it's giving split-it-in-two energy. πŸ™ˆ

( PDL(antisymmetric), PDL(symmetric) )  = mpart(PDL, SCALAR(conj))
conj : if true Return AntiHermitian, Hermitian part.

my $a = random(10,10);
my ( $antisymmetric, $symmetric )  = mpart($a);

πŸ“ mhankel

returns a Hankel matrix, also known as a persymmetric matrix. and yes it handles complex data, we're not scared of complex here. πŸ’…

mhankel(c,r), where c and r are vectors, returns a matrix whose first column is c and whose last row is r. The last element of c prevails. mhankel(c) returns a matrix with the element below the skew diagonal (anti-diagonal) equal to zero. If c is a scalar number, make it from a sequence beginning at one.

the elements are:

H (i,j) = c (i+j),  i+j+1 <= m;
H (i,j) = r (i+j-m+1),  otherwise
where m is the size of the vector.

if c is a scalar number, its determinant can be computed by:

    floor(n/2)    n
Det(H(n)) = (-1)      *      n

⭐ mtoeplitz

returns a toeplitz matrix. also handles complex data. we stay versatile. πŸ’–

mtoeplitz(c,r), where c and r are vectors, returns a matrix whose first column is c and whose last row is r. The last element of c prevails. mtoeplitz(c) returns a symmetric matrix.


πŸŽ€ mpascal

returns a Pascal matrix (yes, from Pascal's triangle) of order N.

mpascal(N,uplo).
uplo:
  0 => upper triangular (Cholesky factor),
  1 => lower triangular (Cholesky factor),
  2 => symmetric.

so this matrix comes from writing Pascal's triangle (whose elements are binomial coefficients from index and/or index sum) as a matrix and truncating appropriately. the symmetric Pascal is positive definite, and its inverse has integer entries. highkey elegant.

their determinants are all equal to one, and:

S = L * U
where S, L, U are symmetric, lower and upper pascal matrix respectively.

πŸ¦‹ mcompanion

returns a matrix with characteristic polynomial equal to p if p is monic. and if p is not monic, the characteristic polynomial of A is equal to p/c, where c is the coefficient of largest degree in p (and here p is in descending order, bestie, don't forget).

mcompanion(PDL(p),SCALAR(charpol)).
charpol:
  0 => first row is -P(1:n-1)/P(0),
  1 => last column is -P(1:n-1)/P(0),

πŸ’Œ AUTHOR πŸ’Œ

Copyright (C) Grégory Vanuxem 2005-2007. 🫢

This library is free software; you can redistribute it and/or modify it under the terms of the artistic license as specified in the Artistic file.


and that's the whole page, bestie β€” no notes, you ate. πŸ’…βœ¨

signing off: this was perl v5.42.3, dated 2026-08-21, from the PDL::L...Special(3pm) era of the User Contributed Perl Documentation. stay special. πŸ’–πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from