matrixops.pd (PDL-2.082) | : | matrixops.pd (PDL-2.083) | ||
---|---|---|---|---|
pp_addhdr(' | pp_addhdr(' | |||
#include <math.h> | #include <math.h> | |||
'); | '); | |||
use strict; | use strict; | |||
use warnings; | use warnings; | |||
use PDL::Types qw(ppdefs_all); | ||||
pp_addpm({At=>'Top'},<<'EOD'); | pp_addpm({At=>'Top'},<<'EOD'); | |||
use strict; | use strict; | |||
use warnings; | use warnings; | |||
=head1 NAME | =head1 NAME | |||
PDL::MatrixOps -- Some Useful Matrix Operations | PDL::MatrixOps -- Some Useful Matrix Operations | |||
=head1 SYNOPSIS | =head1 SYNOPSIS | |||
skipping to change at line 1364 | skipping to change at line 1365 | |||
###################################################################### | ###################################################################### | |||
### squaretotri | ### squaretotri | |||
### | ### | |||
# this doesn't need to be changed to support bad values | # this doesn't need to be changed to support bad values | |||
# I could put 'HandleBad => 1', but it would just cause an | # I could put 'HandleBad => 1', but it would just cause an | |||
# unnecessary increase (admittedly small) in the amount of | # unnecessary increase (admittedly small) in the amount of | |||
# code | # code | |||
# | # | |||
pp_def("squaretotri", | pp_def("squaretotri", | |||
Pars => 'a(n,n); b(m)', | Pars => 'a(n,n); [o]b(m)', | |||
GenericTypes => [ppdefs_all], | ||||
RedoDimsCode => '$SIZE(m) = ($SIZE(n) * ($SIZE(n)+1))/2;', | ||||
Code => ' | Code => ' | |||
register int mna=0, nb=0, ns = $SIZE (n); | register PDL_Indx mna=0, nb=0; | |||
if($SIZE (m) != (ns * (ns+1))/2) { | loop(m) %{ | |||
$CROAK("Wrong sized args for squaretotri"); | $b() = $a(n0 => mna, n1 => nb); | |||
} | mna++; if(mna > nb) {mna = 0; nb ++;} | |||
broadcastloop %{ | ||||
loop(m) %{ | ||||
$b() = $a(n0 => mna, n1 => nb); | ||||
mna++; if(mna > nb) {mna = 0; nb ++;} | ||||
%} | ||||
%} | %} | |||
', | ', | |||
Doc => ' | Doc => '=for ref | |||
=for ref | ||||
Convert a symmetric square matrix to triangular vector storage. | ||||
=cut | ||||
Convert a lower-triangular square matrix to triangular vector storage. | ||||
Ignores upper half of input. | ||||
', | ', | |||
); | ); | |||
pp_addpm({At=>'Bot'},<<'EOD'); | pp_addpm({At=>'Bot'},<<'EOD'); | |||
=head1 AUTHOR | =head1 AUTHOR | |||
Copyright (C) 2002 Craig DeForest (deforest@boulder.swri.edu), | Copyright (C) 2002 Craig DeForest (deforest@boulder.swri.edu), | |||
R.J.R. Williams (rjrw@ast.leeds.ac.uk), Karl Glazebrook | R.J.R. Williams (rjrw@ast.leeds.ac.uk), Karl Glazebrook | |||
(kgb@aaoepp.aao.gov.au). There is no warranty. You are allowed to | (kgb@aaoepp.aao.gov.au). There is no warranty. You are allowed to | |||
End of changes. 5 change blocks. | ||||
16 lines changed or deleted | 11 lines changed or added |