LDAC(3pm)
β¨ NAME β¨
PDL::CCS::IO::LDAC β LDA-C format text I/O for PDL::CCS::Nd
ok so bestie, you've landed on the LDAC(3pm) page, which lives in the User Contributed Perl Documentation section of the manual. it's giving "sparse matrix girlies, this one's for you" π
if you've got a PDL::CCS::Nd object and you wanna yeet it to/from LDA-C text files, you are SO in the right place.
π SYNOPSIS π
use PDL;
use PDL::CCS::Nd;
use PDL::CCS::IO::LDAC;
##-- (Document x Term) matrix
$dtm = PDL::CCS::Nd->newFromWhich($which,$nzvals);
ccs_writeldac($dtm,"dtm.ldac"); # write a sparse LDA-C text file
$dtm2 = ccs_readldac("dtm.ldac"); # read a sparse LDA-C text file
###-- (Term x Document) matrix in document-primary format
$tdm = $dtm->xchg(0,1)->make_physically_indexed();
ccs_writeldac($tdm,"tdm.ldac", {transpose=>1});
$dtm2 = ccs_readldac("tdm.ldac", {transpose=>1});
like, look at her. write, read, and if your matrix is vibing in the other orientation, just transpose=>1 and move on. no cap. π₯
π¦ I/O Utilities π¦
ccs_writeldac
write a 2d PDL::CCS::Nd (Document x Term) matrix out as an LDA-C text file. that's the whole assignment, bestie.
now here's the β¨plot twistβ¨: if the transpose option is specified and true, your input matrix $ccs gets treated as a (Term x Document) matrix, and the output lines correspond to logical dimension 1 of $ccs. otherwise? output lines correspond to logical dimension 0 of $ccs, which is expected to be a (Document x Term) matrix. so like, know which way your matrix is facing before you commit, fr fr π«Ά
ccs_writeldac($ccs,$filename_or_fh)
ccs_writeldac($ccs,$filename_or_fh,\%opts)
Options %opts:
header => $bool, ##-- do/don't write a header to the output file (default=do)
transpose => $bool, ##-- treat input $ccs as (Term x Document) matrix (default=don't)
header => $boolβ do you want a header written to the output file or not? default is do (write that header, queen) πtranspose => $boolβ treat the input$ccsas a (Term x Document) matrix. default is don't. no transposing unless you ask for it πΈ
ccs_readldac
read a 2d (Document x Term) matrix in from an LDA-C text file and hand it back to you as a PDL::CCS::Nd object. iconic behaviour, honestly.
and same energy as her sibling: if the transpose option is specified and true, the output matrix $ccs will be a (Term x Document) matrix, and the input lines correspond to logical dimension 1 of $ccs. otherwise, input lines correspond to logical dimension 0 of $ccs, which gets returned as a (Document x Term) matrix. two orientations, one function π
$ccs = ccs_readldac($filename_or_fh)
$ccs = ccs_readldac($filename_or_fh,\%opts)
Options %opts:
header => $bool, ##-- do/don't try to read header data from the output file (default=do)
type => $type, ##-- value datatype (default: from header or $PDL::IO::Misc::deftype)
transpose => $bool, ##-- generate a (Term x Document) matrix (default=don't)
sorted => $bool, ##-- assume input is lexicographically sorted (only if not transposed; default=don't)
header => $boolβ should she try to read header data from the output file? default is do β¨type => $typeβ the value datatype. default comes from the header, or from$PDL::IO::Misc::deftypeif there's no header to steal it from πtranspose => $boolβ generate a (Term x Document) matrix instead. default is don't π¦sorted => $boolβ assume the input is lexicographically sorted. only if not transposed (iykyk), default is don't π
π ACKNOWLEDGEMENTS π
- Perl by Larry Wall.
- PDL by Karl Glazebrook, Tuomas J. Lukka, Christian Soeller, and others.
- LDA-C package by by David M. Blei.
π AUTHOR π
Bryan Jurish <moocow@cpan.org>
Copyright Policy
Copyright (C) 2015-2024, Bryan Jurish. All rights reserved.
This package is free software, and entirely without warranty. You may redistribute it and/or modify it under the same terms as Perl itself. (yes bestie, "entirely without warranty" means exactly what it says β no takebacks, no safety net, read it and weep π)
π SEE ALSO π
perlPDLPDL::CCS::NdPDL::CCS::IO::FastRawPDL::CCS::IO::FITSPDL::CCS::IO::MatrixMarket- the LDA-C package documentation at
http://www.cs.princeton.edu/~blei/lda-c/...
ok that's the whole page, you're officially a certified LDA-C text I/O girlie now π§ββοΈ this was perl v5.40.0, dated 2025-01-04, and yes, you just read all of LDAC(3pm). go forth and slay your sparse matrices π β¨π
π¦ 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