}
}
- $matrix = $AoA;
+ @{ $matrix } = @{ $AoA };
return wantarray ? @{ $matrix } : $matrix;
}
+sub matrix_deflate_rows
+{
+ # Martin A. Hansen, September 2009.
+
+ # Reduces the number of elements in all rows,
+ # by collectiong elements in buckets that are
+ # averaged.
+
+ my ( $matrix, # AoA data structure
+ $new_size
+ ) = @_;
+
+ # Returns nothing.
+
+ my ( $row );
+
+ foreach $row ( @{ $matrix } ) {
+ list_deflate( $row, $new_size );
+ }
+}
+
+
+sub matrix_deflate_cols
+{
+ # Martin A. Hansen, September 2009.
+
+ # Reduces the number of elements in all columns,
+ # by collectiong elements in buckets that are
+ # averaged.
+
+ my ( $matrix, # AoA data structure
+ $new_size
+ ) = @_;
+
+ # Returns nothing.
+
+ my ( $col );
+
+ matrix_flip( $matrix );
+
+ foreach $col ( @{ $matrix } ) {
+ list_deflate( $col, $new_size );
+ }
+
+ matrix_flip( $matrix );
+}
+
+
sub matrix_rotate_right
{
# Martin A. Hansen, April 2007
sub cols_get
{
- # Martin A. Hansen, April 2007
+ # Martin A. Hansen, April 2007.
# returns a range of requested columns from a given matrix
# Defaltes a list of values to a specified size
# and at the same time average the values.
- my ( $list,
- $new_size,
+ my ( $list, # list to deflate
+ $new_size, # new number of elements in list
) = @_;
# Returns nothing.
$bucket_size = int( $old_size / $new_size );
$bucket_rest = $old_size - ( $new_size * $bucket_size );
- print STDERR "old_size: $old_size new_size: $new_size bucket_size: $bucket_size bucket_rest: $bucket_rest\n";
-
$i = 0;
while ( $i < $new_size )