PETSc(3pm)

πŸ“¦
version 1.24.1 Β· 5 versions
, in debian trixie, ubuntu resolute

πŸ’– 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 PETSc MAT_FILE_CLASSID. default is 1211216. if you wanna see where that number comes from, peek at petsc/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. default 8192. πŸ“¦

πŸ’« 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. default 8192.
  • 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 is do (like, as in the Perl do thing, 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 (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:


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