PETSc(3pm)
π PETSc(3pm) π
okay bestie, so this is a User Contributed Perl Documentation page, and it's literally about PDL::CCS::IO::PETSc β which is, and I quote, PETSc-compatible I/O for PDL::CCS::Nd. π Like. That's the whole vibe. Reading and writing sparse matrices in PETSc's binary format, and honestly? slay.
β¨ NAME β¨
PDL::CCS::IO::PETSc β PETSc-compatible I/O for PDL::CCS::Nd. that's it, that's the name, no notes. π
π SYNOPSIS π
so first you gotta pull in your modules, obviously:
use PDL;
use PDL::CCS::Nd;
use PDL::CCS::IO::PETSc;
then like, imagine a sparse 2d matrix, right? you build it from a $which and some $nzvals:
##-- sparse 2d matrix
$ccs = PDL::CCS::Nd->newFromWhich($which,$nzvals);
and now the fun part β write it out, read it back, boom, icon behavior:
ccs_wpetsc($ccs,"ccs.petsc"); # write a sparse binary PETSc file
$ccs2 = ccs_rpetsc("ccs.petsc"); # read a sparse binary PETSc file
like the way that's literally four lines of code and you're done?? obsessed. πβ¨
π¦ I/O Utilities π¦
π« ccs_wpetsc
Write a 2d PDL::CCS::Nd matrix in PETSc sparse binary format. no cap, that's what it does. π
ccs_wpetsc($ccs,$filename_or_fh)
ccs_wpetsc($ccs,$filename_or_fh,\%opts)
Options %opts β here's the menu bestie, pick your faves:
class_id => $intβ the PETScMAT_FILE_CLASSID. default is1211216. if you wanna see where that number comes from, peek atpetsc/include/petscmat.h. π§pack_int => $packβ pack template for PETSc integers. default'N'.pack_val => $packβ pack template for PETSc values. default'd>'.ioblock => $sizeβ I/O block size. default8192. π¦
π« ccs_rpetsc
REad a 2d PDL::CCS::Nd matrix from PETSc sparse binary format. (yes the capital "RE" is doing main character energy, we respect it.) π«Ά
$ccs = ccs_rpetsc($filename_or_fh)
$ccs = ccs_rpetsc($filename_or_fh,\%opts)
Options %opts β round two, let's go:
pack_int => $packβ pack template for PETSc integers. default'N'.pack_val => $packβ pack template for PETSc values. default'd>'.ioblock => $sizeβ I/O block size. default8192.type => $typeβ value type to return. default is double.sorted => $boolβ assume the input is lexicographically sorted. β οΈ note bestie: this only applies if not transposted. default isdo(like, as in the Perldothing, iykyk).flags => $flagsβ flags for the new ccs object. default is$PDL::CCS::Nd::CCSND_FLAGS_DEFAULT. π
πΈ ACKNOWLEDGEMENTS πΈ
giving credit where credit is due, periodt:
- Perl by Larry Wall. π
- PDL by Karl Glazebrook, Tuomas J. Lukka, Christian Soeller, and others. π
π AUTHOR π
Bryan Jurish <moocow@cpan.org> β shoutout to the legend. π
π Copyright Policy π
Copyright (C) 2015-2024, Bryan Jurish. All rights reserved.
This package is free software, and entirely without warranty (yes, fr fr, no promises, no guarantees, read that twice). You may redistribute it and/or modify it under the same terms as Perl itself. π
π₯ SEE ALSO π₯
go read these too, bestie, they're all connected:
perlPDLPDL::CCS::NdPDL::CCS::IO::FastRawPDL::CCS::IO::FITSPDL::CCS::IO::MatrixMarketPDL::CCS::IO::LDAC- the PETSc binary matrix format definition at <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatLoad.html>
- the PETSc homepage at <http://www.mcs.anl.gov/petsc/>
...(yes, literally, that's in the list, we keep it. π)
and that's the whole page!! this one's from perl v5.40.0, dated 2025-01-04, and it's the PETSc(3pm) page β mwah, thanks for reading, go write some sparse matrices bestie πβ¨π¦π
π¦ where this page comes from
- debian trixie: libpdl-ccs-perl 1.24.1-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libpdl-ccs-perl 1.24.1-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms