| 1 | package ICC::Profile::matf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | our $VERSION = 0.33; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # revised 2016-12-03 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Copyright © 2004-2018 by William B. Birkett | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # add development directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use lib 'lib'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # inherit from Shared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 7 | ▶ | use parent qw(ICC::Shared); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # enable static variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 7 | ▶ | use feature 'state'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # create new matf object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # hash keys are: ('header', 'matrix', 'offset') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # 'header' value is a hash reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # 'matrix' value is a 2D array reference -or- Math::Matrix object -or- positive integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # 'offset' value is a 1D array reference -or- numeric value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # when the 'matrix' value is a positive integer, an identity matrix of that size is created | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # when the 'offset' value is a numeric value, an array containing that value is created | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # when the parameters are input and output arrays, the 'fit' method is called on the object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # parameters: ([ref_to_attribute_hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # parameters: (ref_to_input_array, ref_to_output_array, [offset_flag]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # returns: (ref_to_object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # get object class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | ▶ | my $class = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=32.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # create empty matf object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | my $self = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | {}, # header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | [], # matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | [] # offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # local parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 5 | my ($info); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # if there are parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 5 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # if one parameter, a hash reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if (@_ == 1 && ref($_[0]) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # make new matf object from attribute hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | _new_from_hash($self, shift()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # if two or three parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ▶ | } elsif (@_ == 2 || @_ == 3) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
@_ == 2 or @_ == 3
MC/DC0%0/2
@_ == 2 or @_ == 3
@_ == 2
@_ == 3
Truth table0%0/3
A or B
A= @_ == 2B= @_ == 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # fit the object to data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | ($info = fit($self, @_)) && croak("'matf' fit operation failed with error $info"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | croak('\'matf\' invalid parameter(s)'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # bless object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 5 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # return object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 5 | return($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # make CAT (chromatic adaptation transform) object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # using linear Bradford transform (see Annex E of 'ICC1v43_2010-12.pdf') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # default PCS is ICC D50, normalized to adopted white point (SRC) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # parameters: (src_XYZ_vector, [pcs_XYZ_vector]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # returns: (ref_to_object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | sub bradford { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # get object class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | my $class = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bradford: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # create empty matf object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $self = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | {}, # header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | [], # matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | [] # offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my ($brad, $srct, $pcst, $ratio); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my ($src, $pcs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # if pcs values are undefined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if (! defined($pcs)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # set pcs xyz values to ICC D50 (normalized) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $pcs = [map {$_ * $src->[1]} 0.9642, 1, 0.8249]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # make Bradford matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $brad = Math::Matrix->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | [0.8951, 0.2664, -0.1614], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | [-0.7502, 1.7135, 0.0367], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | [0.0389, -0.0685, 1.0296] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # compute pcs cone values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $pcst = $brad * (Math::Matrix->new($pcs)->transpose); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # compute src cone values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $srct = $brad * (Math::Matrix->new($src)->transpose); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # make cone ratio matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $ratio = Math::Matrix->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | [$srct->[0][0]/$pcst->[0][0], 0, 0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | [0, $srct->[1][0]/$pcst->[1][0], 0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | [0, 0, $srct->[2][0]/$pcst->[2][0]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # set header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $self->[0] = {'src' => $src, 'pcs' => $pcs, 'type' => 'bradford'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # set matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $self->[1] = ($ratio * $brad)->concat($brad)->solve; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # bless object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # return object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | return($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # make CAT (chromatic adaptation transform) object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # using CAT02 transform (see CIE CIECAM02) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # default PCS is ICC D50, normalized to adopted white point (SRC) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # parameters: (src_XYZ_vector, [pcs_XYZ_vector]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # returns: (ref_to_object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | sub cat02 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # get object class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | my $class = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cat02: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # create empty matf object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $self = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | {}, # header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | [], # matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | [] # offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my ($cat02, $srct, $pcst, $ratio); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my ($src, $pcs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # if pcs values are undefined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if (! defined($pcs)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # set pcs xyz values to ICC D50 (normalized) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $pcs = [map {$_ * $src->[1]} 0.9642, 1, 0.8249]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # make CAT02 matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $cat02 = Math::Matrix->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | [0.7328, 0.4296, -0.1624], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | [-0.7036, 1.6975, 0.0061], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | [0.0030, 0.0136, 0.9834] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # compute pcs cone values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $pcst = $cat02 * (Math::Matrix->new($pcs)->transpose); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # compute src cone values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $srct = $cat02 * (Math::Matrix->new($src)->transpose); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # make cone ratio matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $ratio = Math::Matrix->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | [$srct->[0][0]/$pcst->[0][0], 0, 0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | [0, $srct->[1][0]/$pcst->[1][0], 0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | [0, 0, $srct->[2][0]/$pcst->[2][0]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # set header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $self->[0] = {'src' => $src, 'pcs' => $pcs, 'type' => 'cat02'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # set matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $self->[1] = ($ratio * $cat02)->concat($cat02)->solve; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # bless object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # return object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | return($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # make CAT (chromatic adaptation transform) object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # just scales the src XYZ values to the pcs, not a true CAT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # default PCS is ICC D50, normalized to adopted white point (SRC) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # parameters: (src_XYZ_vector, [pcs_XYZ_vector]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # returns: (ref_to_object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | sub quasi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # get object class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | my $class = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quasi: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # create empty matf object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $self = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | {}, # header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | [], # matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | [] # offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my ($src, $pcs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # if pcs values are undefined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if (! defined($pcs)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # set pcs xyz values to ICC D50 (normalized) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $pcs = [map {$_ * $src->[1]} (0.9642, 1, 0.8249)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # set header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $self->[0] = {'src' => $src, 'pcs' => $pcs, 'type' => 'quasi'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # set matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $self->[1] = Math::Matrix->diagonal($pcs->[0]/$src->[0], $pcs->[1]/$src->[1], $pcs->[2]/$src->[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # bless object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # return object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | return($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # create inverse 'matf' object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # returns: (ref_to_object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | sub inv { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # get object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inv: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my ($inv, $sys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # make new empty object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $inv = ICC::Profile::matf->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # if matrix is not empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if (defined($self->[1][0][0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # verify matrix is square | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | (@{$self->[1]} == @{$self->[1][0]}) || croak('matrix must be square'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # invert matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $inv->[1] = $self->[1]->invert(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | # if offset is not empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if (defined($self->[2][0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # clone the parent matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $sys = Storable::dclone($self->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # for each matrix row | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | for my $i (0 .. $#{$sys}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # concatenate negative offsets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | push(@{$sys->[$i]}, -$self->[2][$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # solve for new offsets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $inv->[2] = $sys->solve->transpose->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # return object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | return($inv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # get/set reference to header hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # parameters: ([ref_to_new_hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # returns: (ref_to_hash) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | sub header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # if there are parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # if one parameter, a hash reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if (@_ == 1 && ref($_[0]) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | # set header to new hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $self->[0] = {%{shift()}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | croak('\'matf\' header attribute must be a hash reference'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # return reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | return($self->[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # get/set reference to matrix array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | # parameters: ([ref_to_new_array]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # returns: (ref_to_array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | sub matrix { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 2 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
matrix: called CC=7 SCAR=35.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | # if there are parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 2 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | # if one parameter, a 2-D array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if (@_ == 1 && ref($_[0]) eq 'ARRAY' && @{$_[0]} == grep {ref() eq 'ARRAY'} @{$_[0]}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
@_ == 1 and ref $_[0] eq "ARRAY" and @{$_[0];} == grep({ref $_ eq "ARRAY";} @{$_[0];})
@_ == 1 and ref $_[0] eq "ARRAY"
MC/DC0%0/3
@_ == 1 and ref $_[0] eq "ARRAY" and @{$_[0];} == grep({ref $_ eq "ARRAY";} @{$_[0];})
@_ == 1
ref $_[0] eq "ARRAY"
@{$_[0];} == grep({ref $_ eq "ARRAY";} @{$_[0];})
Truth table0%0/4
A and B and C
A= @_ == 1B= ref $_[0] eq "ARRAY"C= @{$_[0];} == grep({ref $_ eq "ARRAY";} @{$_[0];})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # set matrix to clone of array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $self->[1] = bless(Storable::dclone($_[0]), 'Math::Matrix'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # if one parameter, a Math::Matrix object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | ▶ | } elsif (@_ == 1 && UNIVERSAL::isa($_[0], 'Math::Matrix')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
@_ == 1 and UNIVERSAL::isa($_[0], "Math::Matrix")
MC/DC0%0/2
@_ == 1 and UNIVERSAL::isa($_[0], "Math::Matrix")
@_ == 1
UNIVERSAL::isa($_[0], "Math::Matrix")
Truth table0%0/3
A and B
A= @_ == 1B= UNIVERSAL::isa($_[0], "Math::Matrix")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # set matrix to object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $self->[1] = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | croak('\'matf\' matrix must be a 2-D array reference or Math::Matrix object'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | # return object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 2 | return($self->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # get/set reference to offset array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # parameters: ([ref_to_new_array]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # returns: (ref_to_array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | sub offset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 4 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offset: called CC=5 SCAR=28.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | # if there are parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 4 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | # if one parameter, an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | if (@_ == 1 && ref($_[0]) eq 'ARRAY' && @{$_[0]} == grep {! ref()} @{$_[0]}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
@_ == 1 and ref $_[0] eq "ARRAY" and @{$_[0];} == grep({not ref $_;} @{$_[0];})
@_ == 1 and ref $_[0] eq "ARRAY"
MC/DC0%0/3
@_ == 1 and ref $_[0] eq "ARRAY" and @{$_[0];} == grep({not ref $_;} @{$_[0];})
@_ == 1
ref $_[0] eq "ARRAY"
@{$_[0];} == grep({not ref $_;} @{$_[0];})
Truth table0%0/4
A and B and C
A= @_ == 1B= ref $_[0] eq "ARRAY"C= @{$_[0];} == grep({not ref $_;} @{$_[0];})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | # set offset to copy of array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | $self->[2] = [@{shift()}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | croak('\'matf\' offset must be an array reference'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # return reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 4 | return($self->[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # get/set equivalent matrix-based profile primaries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # see appendix F.3 of 'ICC1v43_2010-12.pdf' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # each matrix row contains an XYZ primary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | # parameters: ([Math::Matrix_object -or- ref_to_array]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # returns: (Math::Matrix_object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | sub primary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | my ($self, $pri) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
primary: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | # if primaries parameter is supplied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | if (defined($pri)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | # if 3x3 Math::Matrix object or array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | if ((UNIVERSAL::isa($pri, 'Math::Matrix') || ref($pri) eq 'ARRAY') && @{$pri} == 3 && @{$pri->[0]} == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
UNIVERSAL::isa($pri, "Math::Matrix") || ref $pri eq "ARRAY" and @{$pri;} == 3 and @{$pri->[0];} == 3
UNIVERSAL::isa($pri, "Math::Matrix") || ref $pri eq "ARRAY" and @{$pri;} == 3
UNIVERSAL::isa($pri, "Math::Matrix") or ref $pri eq "ARRAY"
MC/DC0%0/4
UNIVERSAL::isa($pri, "Math::Matrix") || ref $pri eq "ARRAY" and @{$pri;} == 3 and @{$pri->[0];} == 3
UNIVERSAL::isa($pri, "Math::Matrix")
ref $pri eq "ARRAY"
@{$pri;} == 3
@{$pri->[0];} == 3
Truth table0%0/7
A or B and C and D
A= UNIVERSAL::isa($pri, "Math::Matrix")B= ref $pri eq "ARRAY"C= @{$pri;} == 3D= @{$pri->[0];} == 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | # compute matrix object from primary tags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $self->[1] = Math::Matrix->new(@{$pri})->transpose->multiply_scalar(32768/65535); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | croak('invalid primary matrix parameter'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # if 'matf' matrix is defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | if (defined($self->[1])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | # compute primary tags from matrix object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $pri = $self->[1]->multiply_scalar(65535/32768)->transpose(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | croak('\'matf\' object has no matrix'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | # return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | return($pri); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # fit matf object to data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # uses LAPACK dgels function to perform a least-squares fit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | # fitting is done with or without offset, according to offset_flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | # input and output are 2D array references -or- Math::Matrix objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # parameters: (ref_to_input_array, ref_to_output_array, [offset_flag]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # returns: (dgels_info_value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | sub fit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | my ($self, $in, $out, $oflag) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fit: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | my ($info, $ab); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | # check if ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | state $lapack = defined($INC{'ICC/Support/Lapack.pm'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # verify ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | ($lapack) || croak('\'fit\' method requires ICC::Support::Lapack module'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | # resolve offset flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | $oflag = 0 if (! defined($oflag)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | # verify input array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | (ref($in) eq 'ARRAY' && ref($in->[0]) eq 'ARRAY' && ! ref($in->[0][0])) || UNIVERSAL::isa($in, 'Math::Matrix') || croak('fit input not a 2-D array reference'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
ref $in eq "ARRAY" and ref $in->[0] eq "ARRAY" and not ref $in->[0][0] or UNIVERSAL::isa($in, "Math::Matrix")
ref $in eq "ARRAY" and ref $in->[0] eq "ARRAY" and not ref $in->[0][0]
ref $in eq "ARRAY" and ref $in->[0] eq "ARRAY"
MC/DC0%0/4
ref $in eq "ARRAY" and ref $in->[0] eq "ARRAY" and not ref $in->[0][0] or UNIVERSAL::isa($in, "Math::Matrix")
ref $in eq "ARRAY"
ref $in->[0] eq "ARRAY"
not ref $in->[0][0]
UNIVERSAL::isa($in, "Math::Matrix")
Truth table0%0/7
A and B and not(C) or D
A= ref $in eq "ARRAY"B= ref $in->[0] eq "ARRAY"C= not ref $in->[0][0]D= UNIVERSAL::isa($in, "Math::Matrix")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | # verify output array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | (ref($out) eq 'ARRAY' && ref($out->[0]) eq 'ARRAY' && ! ref($out->[0][0])) || UNIVERSAL::isa($out, 'Math::Matrix') || croak('fit output not a 2-D array reference'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
ref $out eq "ARRAY" and ref $out->[0] eq "ARRAY" and not ref $out->[0][0] or UNIVERSAL::isa($out, "Math::Matrix")
ref $out eq "ARRAY" and ref $out->[0] eq "ARRAY" and not ref $out->[0][0]
ref $out eq "ARRAY" and ref $out->[0] eq "ARRAY"
MC/DC0%0/4
ref $out eq "ARRAY" and ref $out->[0] eq "ARRAY" and not ref $out->[0][0] or UNIVERSAL::isa($out, "Math::Matrix")
ref $out eq "ARRAY"
ref $out->[0] eq "ARRAY"
not ref $out->[0][0]
UNIVERSAL::isa($out, "Math::Matrix")
Truth table0%0/7
A and B and not(C) or D
A= ref $out eq "ARRAY"B= ref $out->[0] eq "ARRAY"C= not ref $out->[0][0]D= UNIVERSAL::isa($out, "Math::Matrix")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | # verify array dimensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | ($#{$in} == $#{$out}) || croak('\'fit\' input and output arrays have different number of rows'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | # fit the matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ($info, $ab) = ICC::Support::Lapack::matf_fit($in, $out, $oflag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | # check result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | carp('fit failed - bad parameter when calling dgels') if ($info < 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | carp('fit failed - A matrix not full rank') if ($info > 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | # initialize matrix object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | $self->[1] = Math::Matrix->new([]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | # for each input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | for my $i (0 .. $#{$in->[0]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | # for each output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | for my $j (0 .. $#{$out->[0]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # set matrix element (transposing) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $self->[1][$j][$i] = $ab->[$i][$j]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | # if offset flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | if ($oflag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | # set offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | $self->[2] = [@{$ab->[$#{$in->[0]} + 1]}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | # no offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | $self->[2] = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | # return info value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | return($info); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # transform data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | # supported input types: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | # parameters: (list, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # parameters: (vector, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | # parameters: (matrix, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | # parameters: (Math::Matrix_object, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # parameters: (structure, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | # returns: (same_type_as_input) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | sub transform { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # set hash value (0 or 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | my $h = ref($_[-1]) eq 'HASH' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transform: not called CC=12 SCAR=50.5
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | # if input a 'Math::Matrix' object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | if (@_ == $h + 2 && UNIVERSAL::isa($_[1], 'Math::Matrix')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
@_ == $h + 2 and UNIVERSAL::isa($_[1], "Math::Matrix")
MC/DC0%0/2
@_ == $h + 2 and UNIVERSAL::isa($_[1], "Math::Matrix")
@_ == $h + 2
UNIVERSAL::isa($_[1], "Math::Matrix")
Truth table0%0/3
A and B
A= @_ == $h + 2B= UNIVERSAL::isa($_[1], "Math::Matrix")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | # call matrix transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | &_trans2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | # if input an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | ▶ | } elsif (@_ == $h + 2 && ref($_[1]) eq 'ARRAY') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
@_ == $h + 2 and ref $_[1] eq "ARRAY"
MC/DC0%0/2
@_ == $h + 2 and ref $_[1] eq "ARRAY"
@_ == $h + 2
ref $_[1] eq "ARRAY"
Truth table0%0/3
A and B
A= @_ == $h + 2B= ref $_[1] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | # if array contains numbers (vector) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | if (! ref($_[1][0]) && @{$_[1]} == grep {Scalar::Util::looks_like_number($_)} @{$_[1]}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not ref $_[1][0] and @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
MC/DC0%0/2
not ref $_[1][0] and @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
not ref $_[1][0]
@{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
Truth table0%0/3
not(A) and B
A= not ref $_[1][0]B= @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # call vector transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | &_trans1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | # if array contains vectors (2-D array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | } elsif (ref($_[1][0]) eq 'ARRAY' && @{$_[1]} == grep {ref($_) eq 'ARRAY' && Scalar::Util::looks_like_number($_->[0])} @{$_[1]}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $_[1][0] eq "ARRAY" and @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
MC/DC0%0/2
ref $_[1][0] eq "ARRAY" and @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
ref $_[1][0] eq "ARRAY"
@{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
Truth table0%0/3
A and B
A= ref $_[1][0] eq "ARRAY"B= @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | # call matrix transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | &_trans2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | # call structure transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | &_trans3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # if input a list (of numbers) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | } elsif (@_ == $h + 1 + grep {Scalar::Util::looks_like_number($_)} @_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | # call list transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | &_trans0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | croak('invalid transform input'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | # inverse transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | # note: number of undefined output values must equal number of defined input values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | # note: input array contains the final calculated input values upon return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | # parameters: (ref_to_input_array, ref_to_output_array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | sub inverse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | my ($self, $in, $out) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inverse: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my ($i, $j, @si, @so); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my ($int, $info, $delta, $sys, $res, $mat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | # check if ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | state $lapack = defined($INC{'ICC/Support/Lapack.pm'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | # initialize indices | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | $i = $j = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | # build slice arrays while validating input and output arrays | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | ((grep {$i++; defined() && push(@si, $i)} @{$in}) == (grep {$j++; ! defined() && push(@so, $j)} @{$out})) || croak('wrong number of undefined values'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | # for each undefined output value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | for my $i (@so) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | # set to 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | $out->[$i] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | # if ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | if ($lapack) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | # compute initial transform values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $int = ICC::Support::Lapack::matf_vec_trans($out, $self->[1], $self->[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | # for each input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | for my $i (0 .. $#si) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | # for each output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | for my $j (0 .. $#so) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | # copy Jacobian value to system matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | $sys->[$i][$j] = $self->[1][$si[$i]][$so[$j]]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | # compute residual value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | $res->[$i][0] = $in->[$si[$i]] - $int->[$si[$i]]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | # solve for delta values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ($info, $delta) = ICC::Support::Lapack::solve($sys, $res); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | # report linear system error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | ($info) && print "matf inverse error $info: @{$in}\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | # for each output value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | for my $i (0 .. $#so) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # add delta value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | $out->[$so[$i]] += $delta->[$i][0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | # compute final transform values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | @{$in} = @{ICC::Support::Lapack::matf_vec_trans($out, $self->[1], $self->[2])}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | # compute initial transform values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | $int = [_trans0($self, @{$out})]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # for each input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | for my $i (0 .. $#si) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | # for each output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | for my $j (0 .. $#so) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | # copy Jacobian value to solution matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | $mat->[$i][$j] = $self->[1][$si[$i]][$so[$j]]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | # save residual value to solution matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | $mat->[$i][$#si + 1] = $in->[$si[$i]] - $int->[$si[$i]]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | # bless Matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | bless($mat, 'Math::Matrix'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # solve for delta values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | $delta = $mat->solve || print "matf inverse error: @{$in}\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$mat->solve || print("matf inverse error: @{$in;}\n")
MC/DC0%0/2
$mat->solve || print("matf inverse error: @{$in;}\n")
$mat->solve
print("matf inverse error: @{$in;}\n")
Truth table0%0/3
A || B
A= $mat->solveB= print("matf inverse error: @{$in;}\n")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | # for each output value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | for my $i (0 .. $#so) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | # add delta value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | $out->[$so[$i]] += $delta->[$i][0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | # compute final transform values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | @{$in} = _trans0($self, @{$out}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | # compute Jacobian matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | # note: input values only required for output values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | # parameters: ([input_vector]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | # returns: (ref_to_Jacobian_matrix, [output_vector]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | sub jacobian { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
jacobian: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | # if output values wanted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | # return Jacobian and output values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | return(bless(Storable::dclone($self->[1]), 'Math::Matrix'), _trans1($self, $_[0])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | # return Jacobian only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | return(bless(Storable::dclone($self->[1]), 'Math::Matrix')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | # invert data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | # requires the matrix element to be square | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | # supported input types: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | # parameters: (list, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | # parameters: (vector, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | # parameters: (matrix, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | # parameters: (Math::Matrix_object, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | # parameters: (structure, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | # returns: (same_type_as_input) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | sub invsqr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | # set hash value (0 or 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | my $h = ref($_[-1]) eq 'HASH' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invsqr: not called CC=12 SCAR=50.5
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | # if input a 'Math::Matrix' object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | if (@_ == $h + 2 && UNIVERSAL::isa($_[1], 'Math::Matrix')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
@_ == $h + 2 and UNIVERSAL::isa($_[1], "Math::Matrix")
MC/DC0%0/2
@_ == $h + 2 and UNIVERSAL::isa($_[1], "Math::Matrix")
@_ == $h + 2
UNIVERSAL::isa($_[1], "Math::Matrix")
Truth table0%0/3
A and B
A= @_ == $h + 2B= UNIVERSAL::isa($_[1], "Math::Matrix")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | # call matrix transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | &_invsqr2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | # if input an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | ▶ | } elsif (@_ == $h + 2 && ref($_[1]) eq 'ARRAY') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
@_ == $h + 2 and ref $_[1] eq "ARRAY"
MC/DC0%0/2
@_ == $h + 2 and ref $_[1] eq "ARRAY"
@_ == $h + 2
ref $_[1] eq "ARRAY"
Truth table0%0/3
A and B
A= @_ == $h + 2B= ref $_[1] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | # if array contains numbers (vector) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | ▶ | if (! ref($_[1][0]) && @{$_[1]} == grep {Scalar::Util::looks_like_number($_)} @{$_[1]}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not ref $_[1][0] and @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
MC/DC0%0/2
not ref $_[1][0] and @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
not ref $_[1][0]
@{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
Truth table0%0/3
not(A) and B
A= not ref $_[1][0]B= @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | # call vector transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | &_invsqr1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | # if array contains vectors (2-D array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | ▶ | } elsif (ref($_[1][0]) eq 'ARRAY' && @{$_[1]} == grep {ref($_) eq 'ARRAY' && Scalar::Util::looks_like_number($_->[0])} @{$_[1]}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $_[1][0] eq "ARRAY" and @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
MC/DC0%0/2
ref $_[1][0] eq "ARRAY" and @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
ref $_[1][0] eq "ARRAY"
@{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
Truth table0%0/3
A and B
A= ref $_[1][0] eq "ARRAY"B= @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | # call matrix transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | &_invsqr2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | # call structure transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | &_invsqr3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | # if input a list (of numbers) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | } elsif (@_ == $h + 1 + grep {Scalar::Util::looks_like_number($_)} @_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | # call list transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | &_invsqr0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | croak('invalid transform input'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | # create matf object from ICC profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | # parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | # returns: (ref_to_object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | sub new_fh { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | # get object class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | ▶ | my $class = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_fh: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | # create empty matf object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | my $self = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | {}, # header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | [], # matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | [] # offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | # verify 3 parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | ▶ | (@_ == 3) || croak('wrong number of parameters'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | # read matf data from profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | _readICCmatf($self, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | # bless object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | # return object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | return($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | # writes matf object to ICC profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | # parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | sub write_fh { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_fh: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | # verify 3 parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | ▶ | (@_ == 3) || croak('wrong number of parameters'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | # write matf data to profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | _writeICCmatf($self, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | # get tag size (for writing to profile) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | # returns: (clut_size) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | sub size { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | # get parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | # set header size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | my $size = 12; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | # add matrix and offset size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | $size += 4 * @{$self->[1]} * (@{$self->[1][0]} + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | # return size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | return($size); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | # get number of input channels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | # returns: (number) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | sub cin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 6 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | # return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 6 | return(scalar(@{$self->[1][0]})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | # get number of output channels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | # returns: (number) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | sub cout { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 6 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cout: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | # return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 6 | return(scalar(@{$self->[1]})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | # print object contents to string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | # format is an array structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | # parameter: ([format]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | # returns: (string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | sub sdump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | ▶ | my ($self, $p) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sdump: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | my ($fmt, $s, $rows, $off, $fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | # resolve parameter to an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | ▶ | $p = defined($p) ? ref($p) eq 'ARRAY' ? $p : [$p] : []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | # get format string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | ▶ | $fmt = defined($p->[0]) && ! ref($p->[0]) ? $p->[0] : 'm'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $p->[0] and not ref $p->[0]
MC/DC0%0/2
defined $p->[0] and not ref $p->[0]
defined $p->[0]
not ref $p->[0]
Truth table0%0/3
A and not(B)
A= defined $p->[0]B= not ref $p->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | # set string to object ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | $s = sprintf("'%s' object, (0x%x)\n", ref($self), $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | # get matrix rows | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | $rows = $#{$self->[1]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | # get offset size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | $off = $#{$self->[2]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | # if empty object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | ▶ | if ($rows < 0 && $off < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rows < 0 and $off < 0
MC/DC0%0/2
$rows < 0 and $off < 0
$rows < 0
$off < 0
Truth table0%0/3
A and B
A= $rows < 0B= $off < 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | # append string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | $s .= "<empty object>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | # if matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | ▶ | if ($rows >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | # append string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | $s .= "matrix values\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | # for each row | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | for my $i (0 .. $rows) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | # make number format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | $fn = ' %10.5f' x @{$self->[1][$i]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | # append matrix row | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | $s .= sprintf("$fn\n", @{$self->[1][$i]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | # if offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | ▶ | if ($off >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | # append string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | $s .= "offset values\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | # make number format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | $fmt = ' %10.5f' x @{$self->[2]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | # append offset values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | $s .= sprintf("$fmt\n", @{$self->[2]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | # return string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | return($s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | # recursive transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | # array structure is traversed until scalar arrays are found and transformed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | # parameters: (ref_to_object, subroutine_reference, input_array_reference, output_array_reference) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | sub _crawl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | ▶ | my ($self, $sub, $in, $out) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_crawl: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | # if input is a vector (reference to a numeric array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | if (@{$in} == grep {Scalar::Util::looks_like_number($_)} @{$in}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | # transform input vector and copy to output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | @{$out} = @{$sub->($self, $in)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | # for each input element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | for my $i (0 .. $#{$in}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | # if an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | ▶ | if (ref($in->[$i]) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | # transform next level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | _crawl($self, $sub, $in->[$i], $out->[$i] = []); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | croak('invalid input structure'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | # transform list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | # parameters: (object_reference, list, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | # returns: (list) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | sub _trans0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | ▶ | my ($self, $hash, @out); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trans0: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | $self = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | # get optional hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | ▶ | $hash = pop() if (ref($_[-1]) eq 'HASH'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | # validate number of input channels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | ▶ | (@_ == @{$self->[1][0]}) || croak('wrong number input channels'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | # set output to offset values or zeros | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | @out = defined($self->[2][0]) ? @{$self->[2]} : (0) x @{$self->[1]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | # for each output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | # add matrix value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | $out[$i] += ICC::Shared::dotProduct(\@_, $self->[1][$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | # return output data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | return(@out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | # transform vector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | # parameters: (object_reference, vector, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | # returns: (vector) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | sub _trans1 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trans1: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | # check if ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | state $lapack = defined($INC{'ICC/Support/Lapack.pm'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | # validate number of input channels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | ▶ | (@{$in} == @{$self->[1][0]}) || croak('wrong number input channels'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | # if ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | ▶ | if ($lapack) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | # call the BLAS dgemv function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | return(ICC::Support::Lapack::matf_vec_trans($in, $self->[1], $self->[2])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | # return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | return([_trans0($self, @{$in})]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | # transform matrix (2-D array -or- Math::Matrix object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | # parameters: (object_reference, matrix, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | # returns: (matrix) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | sub _trans2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trans2: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | my ($info, $out, $offset); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | # check if ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | state $lapack = defined($INC{'ICC/Support/Lapack.pm'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | # validate number of input channels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | ▶ | (@{$in->[0]} == @{$self->[1][0]}) || croak('wrong number input channels'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | # if ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | ▶ | if ($lapack) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | # compute output matrix using BLAS dgemm function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | $out = ICC::Support::Lapack::matf_mat_trans($in, $self->[1], $self->[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | # get offset vector (zeros if undefined) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | ▶ | $offset = defined($self->[2][0]) ? $self->[2] : [(0) x @{$in->[0]}]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | # make output array (from offset vector) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | $out = [map{Storable::dclone($offset)} (0 .. $#{$in})]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | # for each row | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | for my $i (0 .. $#{$in}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | # for each column | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 0 | for my $j (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | # add dot product | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | $out->[$i][$j] += ICC::Shared::dotProduct($in->[$i], $self->[1][$j]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | # return output matrix (Math::Matrix object or 2-D array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 0 | ▶ | return(UNIVERSAL::isa($in, 'Math::Matrix') ? bless($out, 'Math::Matrix') : $out); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | # transform structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | # parameters: (object_reference, structure, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | # returns: (structure) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | sub _trans3 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trans3: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | # transform the array structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | _crawl($self, \&_trans1, $in, my $out = []); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | # return output structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | return($out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | # invert list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | # parameters: (object_reference, list, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | # returns: (list) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | sub _invsqr0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | ▶ | my ($self, $hash, @out); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_invsqr0: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | $self = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | # get optional hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | ▶ | $hash = pop() if (ref($_[-1]) eq 'HASH'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | # validate number of input channels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | ▶ | (@_ == @{$self->[1][0]}) || croak('wrong number input channels'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | # return simple array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | return(@{_invsqr1($self, [@_])}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | # invert vector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | # parameters: (object_reference, vector, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | # returns: (vector) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | sub _invsqr1 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_invsqr1: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | # validate number of input channels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | ▶ | (@{$in} == @{$self->[1]}) || croak('wrong number input channels'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | # clone the 'matf' matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | my $sys = Storable::dclone($self->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | # for each input channel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 0 | for my $i (0 .. $#{$in}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | # concatenate input value (minus offset, if any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | ▶ | push(@{$sys->[$i]}, defined($self->[2][$i]) ? $in->[$i] - $self->[2][$i] : $in->[$i]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | # return output vector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | return([map {$_->[0]} @{$sys->solve()}]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | # invert matrix (Math::Matrix object -or- 2-D array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | # parameters: (object_reference, matrix, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | # returns: (output_matrix) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | sub _invsqr2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_invsqr2: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 0 | my ($info, $out, $sys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | # check if ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | state $lapack = defined($INC{'ICC/Support/Lapack.pm'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | # validate number of input channels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | ▶ | (@{$in->[0]} == @{$self->[1]}) || croak('wrong number input channels'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | # if ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | ▶ | if ($lapack) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | # compute output matrix using Lapack DGESV function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | ($info, $out) = ICC::Support::Lapack::matf_inv($in, $self->[1], $self->[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | # check for DGESV error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | ▶ | ($info) && croak("'ICC::Support::Lapack::matf_inv' error: $info"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | # return output matrix (Math::Matrix object or 2-D array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | ▶ | return(UNIVERSAL::isa($in, 'Math::Matrix') ? bless($out, 'Math::Matrix') : $out); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | # clone the 'matf' matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | $sys = Storable::dclone($self->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | # for each input channel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | for my $i (0 .. $#{$in->[0]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | # for each data sample | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | for my $j (0 .. $#{$in}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | # concatenate input value (minus offset, if any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | ▶ | push(@{$sys->[$i]}, defined($self->[2][$i]) ? $in->[$j][$i] - $self->[2][$i] : $in->[$j][$i]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | # compute output matrix using 'Math::Matrix' methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 0 | $out = $sys->solve->transpose(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | # return output matrix (Math::Matrix object or 2-D array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | ▶ | return(UNIVERSAL::isa($in, 'Math::Matrix') ? $out : [@{$out}]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | # invert structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | # parameters: (object_reference, structure, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | # returns: (structure) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | sub _invsqr3 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_invsqr3: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | # transform the array structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | _crawl($self, \&_invsqr1, $in, my $out = []); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | # return output structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | return($out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | # make new matf object from attribute hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | # hash keys are: ('header', 'matrix', 'offset') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | # object elements not specified in the hash are unchanged | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | # parameters: (ref_to_object, ref_to_attribute_hash) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | sub _new_from_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | ▶ | my ($self, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_from_hash: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | my ($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | # if 'header' key defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | ▶ | if (defined($hash->{'header'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | # if reference to hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | ▶ | if (ref($hash->{'header'}) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | # set object element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | $self->[0] = {%{$hash->{'header'}}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | # wrong data type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | croak('wrong \'header\' data type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | # if 'matrix' key defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | ▶ | if (defined($hash->{'matrix'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | # get value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | $value = $hash->{'matrix'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | # if a reference to a 2-D array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | ▶ | if (ref($value) eq 'ARRAY' && @{$value} == grep {ref() eq 'ARRAY'} @{$value}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
ref $value eq "ARRAY" and @{$value;} == grep({ref $_ eq "ARRAY";} @{$value;})
MC/DC0%0/2
ref $value eq "ARRAY" and @{$value;} == grep({ref $_ eq "ARRAY";} @{$value;})
ref $value eq "ARRAY"
@{$value;} == grep({ref $_ eq "ARRAY";} @{$value;})
Truth table0%0/3
A and B
A= ref $value eq "ARRAY"B= @{$value;} == grep({ref $_ eq "ARRAY";} @{$value;})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | # copy matrix to object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | $self->[1] = bless(Storable::dclone($value), 'Math::Matrix'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | # if a Math::Matrix object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | } elsif (UNIVERSAL::isa($value, 'Math::Matrix')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | # copy matrix to object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 0 | $self->[1] = Storable::dclone($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | # if a positive integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | ▶ | } elsif (Scalar::Util::looks_like_number($value) && $value == int($value) && $value > 0) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
&Scalar::Util::looks_like_number($value) and $value == int $value and $value > 0
&Scalar::Util::looks_like_number($value) and $value == int $value
MC/DC0%0/3
&Scalar::Util::looks_like_number($value) and $value == int $value and $value > 0
&Scalar::Util::looks_like_number($value)
$value == int $value
$value > 0
Truth table0%0/4
A and B and C
A= &Scalar::Util::looks_like_number($value)B= $value == int $valueC= $value > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | # set matrix to identity matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 0 | $self->[1] = Math::Matrix->new_identity($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | # wrong data type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | croak('wrong \'matrix\' data type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | # if 'offset' key defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | ▶ | if (defined($hash->{'offset'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | # get value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | $value = $hash->{'offset'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | # if a reference to an array of scalars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 0 | ▶ | if (ref($value) eq 'ARRAY' && @{$value} == grep {! ref()} @{$value}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $value eq "ARRAY" and @{$value;} == grep({not ref $_;} @{$value;})
MC/DC0%0/2
ref $value eq "ARRAY" and @{$value;} == grep({not ref $_;} @{$value;})
ref $value eq "ARRAY"
@{$value;} == grep({not ref $_;} @{$value;})
Truth table0%0/3
A and B
A= ref $value eq "ARRAY"B= @{$value;} == grep({not ref $_;} @{$value;})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | # copy offset to object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 0 | $self->[2] = [@{$value}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | # if a numeric value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | } elsif (Scalar::Util::looks_like_number($value)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | # if first 'matrix' row is defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 0 | ▶ | if (defined($self->[1])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | # set offset to constant | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | $self->[2] = [($value) x @{$self->[1]}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | # wrong data type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 0 | croak('unknown \'matrix\' size'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | # wrong data type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 0 | croak('wrong \'offset\' data type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | # read matf data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | # note: assumes file handle is positioned at start of matrix data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | # header information must be read separately by the calling function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | # setting offset flag enables reading of offset data following matrix data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | # number format is 2 (s15Fixed16Number) or 4 (floating point) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | # parameters: (ref_to_object, file_handle, input_channels, output_channels, offset_flag, format) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | sub _read_matf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 4 | ▶ | my ($self, $fh, $ci, $co, $oflag, $format) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_matf: called CC=7 SCAR=25.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 4 | my ($buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | # if s15Fixed16Number format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 4 | ▶ | if ($format == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | # for each output channel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 4 | for my $i (0 .. $co - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | # read into buffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 12 | read($fh, $buf, 4 * $ci); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | # unpack buffer and save | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | 12 | $self->[1][$i] = [ICC::Shared::s15f162v(unpack('N*', $buf))]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | # if offset data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 4 | ▶ | if ($oflag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | # read into buffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 2 | read($fh, $buf, 4 * $co); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | # unpack buffer and save | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 2 | $self->[2] = [ICC::Shared::s15f162v(unpack('N*', $buf))]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | # if floating point format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | } elsif ($format == 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | # for each output channel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 0 | for my $i (0 .. $co - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | # read into buffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | read($fh, $buf, 4 * $ci); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | # unpack buffer and save | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | 0 | $self->[1][$i] = [unpack('f>*', $buf)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | # if offset data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 0 | ▶ | if ($oflag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | # read into buffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | 0 | read($fh, $buf, 4 * $co); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | # unpack buffer and save | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | $self->[2] = [unpack('f>*', $buf)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | croak('unsupported format, must be 2 or 4'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | # bless matrix array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 4 | bless($self->[1], 'Math::Matrix'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | # read matf tag from ICC profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | sub _readICCmatf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 0 | ▶ | my ($self, $parent, $fh, $tag) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readICCmatf: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | 0 | my ($buf, $ci, $co); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | # save tag signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 0 | $self->[0]{'signature'} = $tag->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | # seek start of tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 0 | seek($fh, $tag->[1], 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | # read tag header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | read($fh, $buf, 12); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | # unpack header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 0 | ($ci, $co) = unpack('x8 n2', $buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | # set number of input channels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 0 | $self->[0]{'input_channels'} = $ci; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | # set number of output channels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | 0 | $self->[0]{'output_channels'} = $co; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | # read matrix w/offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | 0 | _read_matf($self, $fh, $ci, $co, 1, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | # write matf data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | # note: assumes file handle is positioned at start of matf data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | # header information must be written separately by the calling function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | # setting offset flag enables writing of offset data following matrix data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | # if offset data array is undefined or empty, zeros are written | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | # number format is 2 (s15Fixed16Number) or 4 (floating point) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | # parameters: (ref_to_object, file_handle, offset_flag, format) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | sub _write_matf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 2 | ▶ | my ($self, $fh, $oflag, $format) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_matf: called CC=11 SCAR=37.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | 2 | my ($buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | # if s15Fixed16Number format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | 2 | ▶ | if ($format == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | # for each matrix row | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 2 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | # write matrix values as s15Fixed16Numbers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | 6 | print $fh pack('N*', ICC::Shared::v2s15f16(@{$self->[1][$i]})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | # if offset data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 2 | ▶ | if ($oflag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | # write offset values as s15Fixed16Numbers (if offset array is undefined or empty, write zeros) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | 2 | ▶ | print $fh pack('N*', (defined($self->[2]) && @{$self->[2]} > 0) ? ICC::Shared::v2s15f16(@{$self->[2]}) : (0) x @{$self->[1][0]}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->[2] and @{$self->[2];} > 0
MC/DC0%0/2
defined $self->[2] and @{$self->[2];} > 0
defined $self->[2]
@{$self->[2];} > 0
Truth table33%1/3
A and B
A= defined $self->[2]B= @{$self->[2];} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | # if floating point format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | } elsif ($format == 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | # for each matrix row | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | # write matrix values as big-endian 32-bit floating point | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 0 | print $fh pack('f>*', @{$self->[1][$i]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | # if offset data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 0 | ▶ | if ($oflag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | # write offset values as big-endian 32-bit floating point (if offset array is undefined or empty, write zeros) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 0 | ▶ | print $fh pack('f>*', (defined($self->[2]) && @{$self->[2]} > 0) ? @{$self->[2]} : (0) x @{$self->[1][0]}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->[2] and @{$self->[2];} > 0
MC/DC0%0/2
defined $self->[2] and @{$self->[2];} > 0
defined $self->[2]
@{$self->[2];} > 0
Truth table0%0/3
A and B
A= defined $self->[2]B= @{$self->[2];} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 0 | croak('unsupported format, must be 2 or 4'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | # write matf tag to ICC profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | sub _writeICCmatf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | 0 | ▶ | my ($self, $parent, $fh, $tag) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_writeICCmatf: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | 0 | my ($ci, $co); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | # get number of input channels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 0 | $ci = @{$self->[1][0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | # get number of output channels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | 0 | $co = @{$self->[1]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | # validate number input channels (1 to 15) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | 0 | ▶ | ($ci > 0 && $ci < 16) || croak('unsupported number of input channels'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ci > 0 and $ci < 16
MC/DC0%0/2
$ci > 0 and $ci < 16
$ci > 0
$ci < 16
Truth table0%0/3
A and B
A= $ci > 0B= $ci < 16
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | # validate number output channels (1 to 15) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | 0 | ▶ | ($co > 0 && $co < 16) || croak('unsupported number of output channels'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$co > 0 and $co < 16
MC/DC0%0/2
$co > 0 and $co < 16
$co > 0
$co < 16
Truth table0%0/3
A and B
A= $co > 0B= $co < 16
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | # seek start of tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 0 | seek($fh, $tag->[1], 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | # write 'matf' header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 0 | print $fh pack('a4 x4 n2', 'matf', $ci, $co); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | # write matrix w/offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 0 | _write_matf($self, $fh, 1, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||