From a42415533597b1c37f13d58649953b80e039231c Mon Sep 17 00:00:00 2001 From: Ed J Date: Sun, 21 Jan 2024 12:54:44 +0000 Subject: [PATCH] zap long-obsolete unused funcs, relocate code next to doc --- Basic/Core/Core.pm | 79 ++++++---------------------------------------- 1 file changed, 10 insertions(+), 69 deletions(-) diff --git a/Basic/Core/Core.pm b/Basic/Core/Core.pm index fa8c8dd0c..4c8da4788 100644 --- a/Basic/Core/Core.pm +++ b/Basic/Core/Core.pm @@ -3458,67 +3458,6 @@ sub PDL::dog { ###################### Misc internal routines #################### -# Recursively pack an N-D array ref in format [[1,1,2],[2,2,3],[2,2,2]] etc -# package vars $level and @dims must be initialised first. - -sub rpack { - my ($ptype,$x) = @_; my ($ret,$type); - - $ret = ""; - if (ref($x) eq "ARRAY") { - - if (defined($dims[$level])) { - barf 'Array is not rectangular' unless $dims[$level] == scalar(@$x); - }else{ - $dims[$level] = scalar(@$x); - } - - $type = ref($$x[0]); - if ($type) { - $level++; - for(@$x) { - barf 'Array is not rectangular' unless $type eq ref($_); # Equal types - $ret .= rpack($ptype,$_); - } - $level--; - } else { - # These are leaf nodes - $ret = pack $ptype, map {defined($_) ? $_ : $PDL::undefval} @$x; - } - } elsif (ref($x) eq "PDL") { - barf 'Cannot make a new ndarray from two or more ndarrays, try "cat"'; - } else { - barf "Don't know how to make a PDL object from passed argument"; - } - return $ret; -} - -sub rcopyitem { # Return a deep copy of an item - recursively - my $x = shift; - my ($y, $key, $value); - if (ref(\$x) eq "SCALAR") { - return $x; - }elsif (ref($x) eq "SCALAR") { - $y = $$x; return \$y; - }elsif (ref($x) eq "ARRAY") { - $y = []; - for (@$x) { - push @$y, rcopyitem($_); - } - return $y; - }elsif (ref($x) eq "HASH") { - $y={}; - while (($key,$value) = each %$x) { - $$y{$key} = rcopyitem($value); - } - return $y; - }elsif (blessed($x)) { - return $x->copy; - }else{ - barf ('Deep copy of object failed - unknown component with type '.ref($x)); - } -0;} - # N-D array stringifier sub strND { @@ -3674,14 +3613,6 @@ sub str2D{ return $ret; } -# -# Sleazy hcpy saves me time typing -# -sub PDL::hcpy { - $_[0]->hdrcpy($_[1]); - $_[0]; -} - ########## Docs for functions in Core.xs ################## # Pod docs for functions that are imported from Core.xs and are # not documented elsewhere. Currently this is not a complete @@ -3900,6 +3831,16 @@ Switch on/off automatic header copying, with PDL pass-through C sets or clears the hdrcpy flag of a PDL, and returns the PDL itself. That makes it convenient for inline use in expressions. +=cut + +# +# Sleazy hcpy saves me time typing +# +sub PDL::hcpy { + $_[0]->hdrcpy($_[1]); + $_[0]; +} + =head2 online_cpus =for ref