| 1 | package ICC::Profile::parf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = 0.2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # revised 2016-10-22 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Copyright © 2004-2018 by William B. Birkett | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # add development directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use lib 'lib'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # inherit from Shared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use parent qw(ICC::Shared); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # parameter count by function type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | our @Np = (4, 5, 5, 3, 4, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # create new parf tag object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # parameters: ([ref_to_array]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # returns: (ref_to_object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # get object class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my $class = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # create empty parf object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my $self = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | {}, # object header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | [] # parameter array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # if parameter supplied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # verify array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | (ref($_[0]) eq 'ARRAY') || croak('not an array reference'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # verify function type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | ($_[0][0] == int($_[0][0]) && defined($Np[$_[0][0]])) || croak('invalid function type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_[0][0] == int $_[0][0] and defined $ICC::Profile::parf::Np[$_[0][0]]
MC/DC0%0/2
$_[0][0] == int $_[0][0] and defined $ICC::Profile::parf::Np[$_[0][0]]
$_[0][0] == int $_[0][0]
defined $ICC::Profile::parf::Np[$_[0][0]]
Truth table0%0/3
A and B
A= $_[0][0] == int $_[0][0]B= defined $ICC::Profile::parf::Np[$_[0][0]]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # verify number of parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | ($#{$_[0]} == $Np[$_[0][0]]) || croak('wrong number of parameters'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # copy array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $self->[1] = [@{shift()}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # bless object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # return object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # create parf tag object from ICC profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # returns: (ref_to_object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | sub new_fh { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # get object class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | my $class = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_fh: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # create empty parf object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $self = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | {}, # object header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | [] # parameter array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # verify 3 parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | (@_ == 3) || croak('wrong number of parameters'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # read parf data from profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | _readICCparf($self, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # bless object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # return object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | return($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # writes parf tag object to ICC profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | sub write_fh { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # get tag reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_fh: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # verify 3 parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | (@_ == 3) || croak('wrong number of parameters'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # write parf data to profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | _writeICCparf($self, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # get tag size (for writing to profile) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # returns: (tag_size) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | sub size { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # return size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return(12 + 4 * $Np[$self->[1][0]]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # compute curve function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # parameters: (input_value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # returns: (output_value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | sub transform { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my ($self, $in) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transform: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my ($a, $type, $pow); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # get parameter array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $a = $self->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # get function type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $type = $a->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # function type 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ($type == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # return value Y = (aX + b)**γ + c | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | return(($a->[2] * $in + $a->[3])**$a->[1] + $a->[4]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # function type 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } elsif ($type == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # return value Y = a log10(bX**γ + c) + d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return($a->[2] * POSIX::log10($a->[3] * $in**$a->[1] + $a->[4]) + $a->[5]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # function type 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } elsif ($type == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # return value Y = ab**(cX+d) + e | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | return($a->[1] * $a->[2]**($a->[3] * $in + $a->[4]) + $a->[5]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # function type 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } elsif ($type == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # return value Y = (aX + b)/(cX + 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return(($a->[1] * $in + $a->[2])/($a->[3] * $in + 1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # function type 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } elsif ($type == 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # return value Y = (aX + b)/(cX**γ + 1)**(1/γ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | return(($a->[2] * $in + $a->[3])/($a->[4] * $in**$a->[1] + 1)**(1/$a->[1])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # function type 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } elsif ($type == 5) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # compute X**γ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $pow = $in**$a->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # return value Y = (aX**γ + b)/(cX**γ + 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | return(($a->[2] * $pow + $a->[3])/($a->[4] * $pow + 1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | croak('invalid parametric function type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # compute curve inverse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # parameters: (input_value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # returns: (output_value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | sub inverse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | my ($self, $in) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inverse: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my ($a, $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # get parameter array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $a = $self->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # get function type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $type = $a->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # function type 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if ($type == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # return value X = ((Y - c)**(1/γ) - b)/a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | return((($in - $a->[4])**(1/$a->[1]) - $a->[3])/$a->[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # function type 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } elsif ($type == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # return value X = ((10**(Y/a - d/a) - c)/b)**(1/γ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | return(((10**($in/$a->[2] - $a->[5]/$a->[2]) - $a->[4])/$a->[3])**(1/$a->[1])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # function type 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } elsif ($type == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # return value X = (log((Y - e)/a)/log(b) - d)/c | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | return((log(($in - $a->[5])/$a->[1])/log($a->[2]) - $a->[4])/$a->[3]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # function type 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } elsif ($type == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # return value X = (b - Y)/(cY - a) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | return(($a->[2] - $in)/($a->[3] * $in - $a->[1])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # function type 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } elsif ($type == 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | croak('inverse of function type 4 requires numerical solution'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # function type 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } elsif ($type == 5) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # return value X = ((b - Y)/(cY - a))**(1/γ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | return((($a->[3] - $in)/($a->[4] * $in - $a->[2]))**(1/$a->[1])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | croak('invalid parametric function type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | # compute curve derivative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # parameters: (input_value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | # returns: (derivative_value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | sub derivative { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | my ($self, $in) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
derivative: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my ($a, $type, $den); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # get parameter array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $a = $self->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # get function type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $type = $a->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # function type 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | if ($type == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # return dY/dX = aγ(aX + b)**(γ - 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | return($a->[1] == 1 ? $a->[2] : $a->[2] * $a->[1] * ($a->[2] * $in + $a->[3])**($a->[1] - 1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # function type 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } elsif ($type == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | # compute denominator = ln(10) (bX**γ + c) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $den = ICC::Shared::ln10 * ($a->[3] * $in**$a->[1] + $a->[4]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # return dY/dX = abγX**(γ - 1)/(ln(10) (bX**γ + c)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | return($den == 0 ? 'inf' : $a->[2] * $a->[3] * $a->[1] * $in**($a->[1] - 1)/$den); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # function type 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } elsif ($type == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # return dY/dX = ac ln(b) b**(cX+d) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | return($a->[1] * $a->[3] * log($a->[2]) * $a->[2]**($a->[3] * $in + $a->[4])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # function type 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } elsif ($type == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # compute denominator = (cX + 1)**2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $den = ($a->[3] * $in + 1)**2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # return value Y = (a - bc)/(cX + 1)**2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | return($den == 0 ? 'inf' : ($a->[1] - $a->[2] * $a->[3])/$den); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # function type 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } elsif ($type == 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # compute denominator = (cX**γ + 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $den = ($a->[4] * $in**$a->[1] + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # return value Y = (a - (aX + b) cX**(γ - 1)/((cX**γ + 1)))/(cX**γ + 1)**(1/γ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | return($den == 0 ? 'inf' : ($a->[2] - ($a->[2] * $in + $a->[3]) * $a->[4] * $in**($a->[1] - 1)/$den)/$den**(1/$a->[1])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # function type 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } elsif ($type == 5) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # compute denominator = (cX**γ + 1)**2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $den = ($a->[4] * $in**$a->[1] + 1)**2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # return value Y = γX**(γ - 1)(a - bc)/(cX**γ + 1)**2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | return($den == 0 ? 'inf' : $a->[1] * $in**($a->[1] - 1) * ($a->[2] - $a->[3] * $a->[4])/$den); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | croak('invalid parametric function type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # get/set array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # parameters: ([ref_to_array]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # returns: (ref_to_array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | sub array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
array: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my ($array, $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # if parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # get array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $array = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | # verify array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | (ref($array) eq 'ARRAY') || croak('not an array reference'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # get function type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | $type = $array->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | # verify function type (integer, 0 - 5) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | ($type == int($type) && $type >= 0 && $type <= 5) || croak('invalid function type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$type == int $type and $type >= 0 and $type <= 5
$type == int $type and $type >= 0
MC/DC0%0/3
$type == int $type and $type >= 0 and $type <= 5
$type == int $type
$type >= 0
$type <= 5
Truth table0%0/4
A and B and C
A= $type == int $typeB= $type >= 0C= $type <= 5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # verify number of parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | ($#{$array} == $Np[$type]) || croak('wrong number of parameters'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # set array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $self->[1] = $array; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # return array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | return($self->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | # print object contents to string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | # format is an array structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # parameter: ([format]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # returns: (string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | sub sdump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | my ($self, $p) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sdump: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my ($s, $fmt, $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # resolve parameter to an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | $p = defined($p) ? ref($p) eq 'ARRAY' ? $p : [$p] : []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # get format string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | $fmt = defined($p->[0]) && ! ref($p->[0]) ? $p->[0] : 'undef'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # set string to object ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | $s = sprintf("'%s' object, (0x%x)\n", ref($self), $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | # if object has parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | if (defined($type = $self->[1][0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | # if function type 0, 4, 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | if ($type == 0 || $type == 4 || $type == 5) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/6
$type == 0 or $type == 4 or $type == 5
$type == 0 or $type == 4
MC/DC0%0/3
$type == 0 or $type == 4 or $type == 5
$type == 0
$type == 4
$type == 5
Truth table0%0/4
A or B or C
A= $type == 0B= $type == 4C= $type == 5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | # append parameter string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | $s .= sprintf(" function type %d, gamma %.3f, a %.3f, b %.3f, c %.3f\n", @{$self->[1]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # if function type 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } elsif ($type == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # append parameter string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | $s .= sprintf(" function type %d, gamma %.3f, a %.3f, b %.3f, c %.3f, d %.3f\n", @{$self->[1]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # if function type 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } elsif ($type == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | # append parameter string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $s .= sprintf(" function type %d, gamma %.3f, a %.3f, b %.3f, c %.3f, d %.3f, e %.3f\n", @{$self->[1]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # if function type 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } elsif ($type == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # append parameter string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $s .= sprintf(" function type %d, a %.3f, b %.3f, c %.3f\n", @{$self->[1]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | # append error string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $s .= " invalid function type\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # append string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | $s .= " <empty object>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | return($s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # read parf tag from ICC profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | sub _readICCparf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | my ($self, $parent, $fh, $tag) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readICCparf: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | my ($buf, $fun, $cnt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # save tag signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | $self->[0]{'signature'} = $tag->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | # seek start of tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | seek($fh, $tag->[1], 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # read tag type signature and function type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | read($fh, $buf, 12); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | # unpack function type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | $fun = unpack('x8 n x2', $buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # get parameter count and verify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | defined($cnt = $Np[$fun]) || croak('invalid function type when reading \'parf\' tag'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # read parameter values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | read($fh, $buf, $cnt * 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # unpack the values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $self->[1] = [$fun, unpack('f>*', $buf)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | # write parf tag to ICC profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | sub _writeICCparf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | my ($self, $parent, $fh, $tag) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_writeICCparf: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | # verify object structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | ($self->[1][0] == int($self->[1][0]) && $self->[1][0] >= 0 && $self->[1][0] <= 2 && $Np[$self->[1][0]] == $#{$self->[1]}) || croak('invalid function data when writing \'parf\' tag'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$self->[1][0] == int $self->[1][0] and $self->[1][0] >= 0 and $self->[1][0] <= 2 and $ICC::Profile::parf::Np[$self->[1][0]] == $#{$$self[1];}
$self->[1][0] == int $self->[1][0] and $self->[1][0] >= 0 and $self->[1][0] <= 2
$self->[1][0] == int $self->[1][0] and $self->[1][0] >= 0
MC/DC0%0/4
$self->[1][0] == int $self->[1][0] and $self->[1][0] >= 0 and $self->[1][0] <= 2 and $ICC::Profile::parf::Np[$self->[1][0]] == $#{$$self[1];}
$self->[1][0] == int $self->[1][0]
$self->[1][0] >= 0
$self->[1][0] <= 2
$ICC::Profile::parf::Np[$self->[1][0]] == $#{$$self[1];}
Truth table0%0/5
A and B and C and D
A= $self->[1][0] == int $self->[1][0]B= $self->[1][0] >= 0C= $self->[1][0] <= 2D= $ICC::Profile::parf::Np[$self->[1][0]] == $#{$$self[1];}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | # seek start of tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | seek($fh, $tag->[1], 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # write tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | print $fh pack('a4 x4 n x2 f>*', 'parf', @{$self->[1]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||