| 1 | package ICC::Support::nNET2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = 0.21; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # revised 2016-05-17 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Copyright © 2004-2018 by William B. Birkett | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # add development directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use lib 'lib'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # inherit from Shared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use parent qw(ICC::Shared); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # use POSIX math | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use POSIX (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # enable static variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use feature 'state'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # list of functions to export | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | our @EXPORT = qw(rbf_g rbf_iq rbf_mq rbf_imq rbf_phs rbf_tps); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # list of valid kernel types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | my @types = qw(CODE ICC::Support::geo1 ICC::Support::geo2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # create new nNET object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # hash keys are: 'header', 'kernel', 'hidden', 'weight', 'offset', 'init' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # 'header' value is a hash reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # 'kernel' value is an array reference of kernel objects -or- CODE references | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # 'hidden' value is an array reference of CODE references | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # 'weight' value is an array reference (2-D) -or- Math::Matrix object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # 'offset' value is an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # 'init' value is a CODE reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # parameters: ([ref_to_attribute_hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # returns: (ref_to_object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # get object class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=24.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # local variable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | my ($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # create empty nNET object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | my $self = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | {}, # object header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | [], # kernel array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | [], # hidden array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | [], # weight matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | [] # offset vector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # if there are parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # if one parameter, a hash reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # make new nNET object from attribute hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | _new_from_hash($self, shift()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # initialize object (if CODE reference defined) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | (defined($code = $self->[0]{'init'}) && &$code); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | croak('\'nNET\' parameter must be a hash reference'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # bless object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # return object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | return($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # initialize object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # calls 'init' CODE reference, if any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # used when retrieving an nNET object using Storable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # local variable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my ($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # initialize object (if CODE reference defined) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | (defined($code = $self->[0]{'init'}) && &$code); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # fit nNET object to data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # determines optimum 'weight' and 'offset' arrays | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # kernel and hidden nodes are not modified by this method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # uses LAPACK dgelsd function to perform a least-squares fit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # fitting is done with or without offset, according to offset_flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # input and output are 2D array references or Math::Matrix objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # parameters: (ref_to_input_array, ref_to_output_array, [offset_flag]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # returns: (dgelsd_info_value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | sub fit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my ($self, $in, $out, $oflag) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fit: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my ($info, $hidden, $ab); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # verify input array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | (ref($in) eq 'ARRAY' && ref($in->[0]) eq 'ARRAY' && ! ref($in->[0][0])) || (UNIVERSAL::isa($in, 'Math::Matrix')) or 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # verify output array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | (ref($out) eq 'ARRAY' && ref($out->[0]) eq 'ARRAY' && ! ref($out->[0][0])) || (UNIVERSAL::isa($out, 'Math::Matrix')) or 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # verify array dimensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | ($#{$in} == $#{$out}) or croak('fit input and output arrays have different number of rows'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # compute hidden array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $hidden = _hidden2($self, $in); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # fit matrix and offset (hidden values to output values) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | ($info, $ab) = ICC::Support::Lapack::nNET_fit($hidden, $out, defined($oflag) ? $oflag : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # check result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | carp('fit failed - bad parameter when calling dgelsd') if ($info < 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | carp('fit failed - SVD algorithm failed to converge') if ($info > 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # initialize matrix and offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | undef($self->[3]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | undef($self->[4]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # for each output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | for my $i (0 .. $#{$out->[0]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # for each input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | for my $j (0 .. $#{$hidden->[0]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # set matrix element (transposing) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $self->[3][$i][$j] = $ab->[$j][$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # if offset flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | if ($oflag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # set offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $self->[4] = [@{$ab->[$#{$self->[1]} + 1]}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # return info value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return($info); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # get/set reference to header hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # parameters: ([ref_to_new_hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # returns: (ref_to_hash) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | sub header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | my ($self, $header) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # if parameter supplied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if (defined($header)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # verify a hash reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | (ref($header) eq 'HASH') or croak('\'nNET2\' header wrong data type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # copy header hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->[0] = {%{$header}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # return hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | return($self->[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # get/set kernel array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # parameters: ([ref_to_array]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # returns: (ref_to_array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | sub kernel { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | my ($self, $kernel) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
kernel: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # if parameter supplied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if (defined($kernel)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # verify an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | (ref($kernel) eq 'ARRAY') or croak('\'nNET2\' kernel wrong data type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # initialize object array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $self->[1] = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # for each kernel element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | for my $i (0 .. $#{$kernel}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # if a valid kernel type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if (grep {ref($kernel->[$i]) eq $_} @types) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # copy kernel object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $self->[1][$i] = $kernel->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # wrong data type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | croak('\'nNET\' kernel element wrong data type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # return kernel array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | return($self->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # get/set hidden array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # parameters: ([ref_to_array]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # returns: (ref_to_array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | sub hidden { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | my ($self, $hidden) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hidden: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # if parameter supplied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if (defined($hidden)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | # verify an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | (ref($hidden) eq 'ARRAY') or croak('\'nNET2\' hidden wrong data type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # initialize object array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $self->[2] = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # for each hidden element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | for my $i (0 .. $#{$hidden}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # if a CODE reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if (ref($hidden->[$i]) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # copy hidden element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $self->[2][$i] = $hidden->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # wrong data type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | croak('\'nNET2\' hidden element wrong data type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # return hidden array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | return($self->[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # get/set reference to matrix array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # parameters: ([ref_to_new_array]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # returns: (ref_to_array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | sub matrix { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | my ($self, $matrix) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
matrix: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # if parameter supplied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | if (defined($matrix)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # verify a 2-D array reference or Math::Matrix object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | ((ref($matrix) eq 'ARRAY' && @{$matrix} == grep {ref() eq 'ARRAY'} @{$matrix}) || UNIVERSAL::isa($matrix, 'Math::Matrix')) or croak('\'nNET2\' matrix wrong data type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $matrix eq "ARRAY" and @{$matrix;} == grep({ref $_ eq "ARRAY";} @{$matrix;}) or UNIVERSAL::isa($matrix, "Math::Matrix")
ref $matrix eq "ARRAY" and @{$matrix;} == grep({ref $_ eq "ARRAY";} @{$matrix;})
MC/DC0%0/3
ref $matrix eq "ARRAY" and @{$matrix;} == grep({ref $_ eq "ARRAY";} @{$matrix;}) or UNIVERSAL::isa($matrix, "Math::Matrix")
ref $matrix eq "ARRAY"
@{$matrix;} == grep({ref $_ eq "ARRAY";} @{$matrix;})
UNIVERSAL::isa($matrix, "Math::Matrix")
Truth table0%0/5
A and B or C
A= ref $matrix eq "ARRAY"B= @{$matrix;} == grep({ref $_ eq "ARRAY";} @{$matrix;})C= UNIVERSAL::isa($matrix, "Math::Matrix")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # copy matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $self->[3] = Storable::dclone($matrix); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # return matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | return($self->[3]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # get/set reference to offset array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # parameters: ([ref_to_new_array]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # returns: (ref_to_array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | sub offset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | my ($self, $offset) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offset: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # if parameter supplied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if (defined($offset)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # verify a reference to array of scalars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | (ref($offset) eq 'ARRAY' && @{$offset} == grep {! ref()} @{$offset}) or croak('\'nNET2\' offset wrong data type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $offset eq "ARRAY" and @{$offset;} == grep({not ref $_;} @{$offset;})
MC/DC0%0/2
ref $offset eq "ARRAY" and @{$offset;} == grep({not ref $_;} @{$offset;})
ref $offset eq "ARRAY"
@{$offset;} == grep({not ref $_;} @{$offset;})
Truth table0%0/3
A and B
A= ref $offset eq "ARRAY"B= @{$offset;} == grep({not ref $_;} @{$offset;})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | # copy offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $self->[4] = [@{$offset}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # return offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | return($self->[4]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # add kernel objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # parameters: (ref_to_array_of_objects) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # returns: (ref_to_array_of_geo_indices) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | sub add_kernel { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | my ($self, $kernel) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_kernel: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my (@gx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # verify add_kernel parameter supplied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | (defined($kernel)) or carp('\'nNET2\' add_kernel parameter undefined'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | # wrap if not an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | $kernel = [$kernel] if (ref($kernel) ne 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # for each kernel element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | for my $i (0 .. $#{$kernel}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | # if a valid kernel type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | if (grep {ref($kernel->[$i]) eq $_} @types) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | # add kernel object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | push(@{$self->[1]}, $kernel->[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # add geo index (kernel index + 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | push(@gx, $#{$self->[1]} + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # wrong data type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | croak('\'nNET\' add_kernel element wrong data type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | # return index array ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | return(\@gx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # add hidden subroutines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # parameters: (ref_to_array_of_CODE_refs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # returns: (ref_to_array_of_hidden_indices) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | sub add_hidden { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | my ($self, $hidden) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_hidden: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my (@hx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # verify add_hidden parameter supplied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | (defined($hidden)) or carp('\'nNET2\' add_hidden parameter undefined'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | # wrap if not an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | $hidden = [$hidden] if (ref($hidden) ne 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # for each hidden element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | for my $i (0 .. $#{$hidden}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # if a CODE reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | if (ref($hidden->[$i]) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | # add hidden element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | push(@{$self->[2]}, $hidden->[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # add hidden index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | push(@hx, $#{$self->[2]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # wrong data type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | croak('\'nNET2\' add_hidden element wrong data type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # return index array ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | return(\@hx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | # transform data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | # supported input types: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | # parameters: (list, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # parameters: (vector, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # parameters: (matrix, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | # parameters: (Math::Matrix_object, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | # parameters: (structure, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | # returns: (same_type_as_input) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | sub transform { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # set hash value (0 or 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | my $h = ref($_[-1]) eq 'HASH' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transform: not called CC=12 SCAR=50.5
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # if input a 'Math::Matrix' object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # call matrix transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | &_trans2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # if input an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | ▶ | } 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | # if array contains numbers (vector) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 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];})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | # call vector transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | &_trans1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | # if array contains vectors (2-D array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 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];})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | # call matrix transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | &_trans2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # call structure transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | &_trans3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # if input a list (of numbers) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | } elsif (@_ == $h + 1 + grep {Scalar::Util::looks_like_number($_)} @_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | # call list transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | &_trans0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | croak('invalid transform input'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | # inverse transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | # note: number of undefined output values must equal number of defined input values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # note: the input and output vectors contain the final solution on return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # hash key 'init' specifies initial value vector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | # parameters: (input_vector, output_vector, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | # returns: (RMS_error_value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | sub inverse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | my ($self, $in, $out, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inverse: not called CC=15 SCAR=54.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | my ($i, $j, @si, @so, $init); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my ($int, $jac, $mat, $delta); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my ($max, $elim, $dlim, $accum, $error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | # initialize indices | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $i = $j = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # build slice arrays while validating input and output arrays | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | ((grep {$i++; defined() && push(@si, $i)} @{$in}) == (grep {$j++; ! defined() && push(@so, $j)} @{$out})) or croak('wrong number of undefined values'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # get init array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $init = $hash->{'init'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # for each undefined output value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | for my $i (@so) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | # set to supplied initial value or 0.5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | $out->[$i] = defined($init->[$i]) ? $init->[$i] : 0.5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # set maximum loop count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | $max = $hash->{'inv_max'} || 10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$hash->{'inv_max'} || 10
MC/DC0%0/1
$hash->{'inv_max'} || 10
$hash->{'inv_max'}
Truth table0%0/2
A
A= $hash->{'inv_max'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | # loop error limit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | $elim = $hash->{'inv_elim'} || 1E-6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$hash->{'inv_elim'} || 1e-06
MC/DC0%0/1
$hash->{'inv_elim'} || 1e-06
$hash->{'inv_elim'}
Truth table0%0/2
A
A= $hash->{'inv_elim'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | # set delta limit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | $dlim = $hash->{'inv_dlim'} || 0.5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$hash->{'inv_dlim'} || 0.5
MC/DC0%0/1
$hash->{'inv_dlim'} || 0.5
$hash->{'inv_dlim'}
Truth table0%0/2
A
A= $hash->{'inv_dlim'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | # create empty solution matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | $mat = Math::Matrix->new([]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # compute initial transform values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ($jac, $int) = jacobian($self, $out, $hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | # solution loop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | for (1 .. $max) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | # for each input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | for my $i (0 .. $#si) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # for each output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | for my $j (0 .. $#so) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # copy Jacobian value to solution matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | $mat->[$i][$j] = $jac->[$si[$i]][$so[$j]]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | # save residual value to solution matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | $mat->[$i][$#si + 1] = $in->[$si[$i]] - $int->[$si[$i]]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | # solve for delta values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | $delta = $mat->solve; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | # for each output value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | for my $i (0 .. $#so) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | # add delta (limited using hyperbolic tangent) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | $out->[$so[$i]] += POSIX::tanh($delta->[$i][0]/$dlim) * $dlim; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | # compute updated transform values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ($jac, $int) = jacobian($self, $out, $hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | # initialize error accumulator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | $accum = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | # for each input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | for my $i (0 .. $#si) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | # accumulate delta squared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | $accum += ($in->[$si[$i]] - $int->[$si[$i]])**2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # compute RMS error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | $error = sqrt($accum/@si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # if error less than limit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | last if ($error < $elim); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # update input vector with final values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | @{$in} = @{$int}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | # return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | return($error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | # compute Jacobian matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | # using numerical approximation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | # parameters: (input_vector, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | # returns: (Jacobian_matrix, [output_vector]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | sub jacobian { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
jacobian: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my ($out, $din, $dout, $delta, $jac); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # get output array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $out = _trans1($self, $in); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | # set delta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | $delta = 1E-9; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | # for each input channel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | for my $i (0 .. $#{$in}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | # copy input array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | @{$din} = @{$in}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | # add delta to input channel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $din->[$i] += $delta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | # compute new output values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | $dout = transform($self, $din); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | # for each output value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | for my $j (0 .. $#{$out}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | # compute Jacobian matrix element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | $jac->[$j][$i] = ($dout->[$j] - $out->[$j])/$delta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | # bless Jacobian matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | bless($jac, 'Math::Matrix'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | # if array wanted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | # return Jacobian and output array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | return($jac, $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | # return Jacobian | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | return($jac); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | # print object contents to string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | # format is an array structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | # parameter: ([format]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | # returns: (string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | sub sdump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | my ($self, $p) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sdump: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | my ($s, $fmt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | # resolve parameter to an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | $p = defined($p) ? ref($p) eq 'ARRAY' ? $p : [$p] : []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | # get format string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 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]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # set string to object ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | $s = sprintf("'%s' object, (0x%x)\n", ref($self), $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | # return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | return($s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | # radial basis function - Gaussian | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | # ϕ(r) = e^-(εr)² | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | # parameters: (radius, ε) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | # returns: (ϕ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | sub rbf_g { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | # return function value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | ▶ | return(exp(-($_[0] * $_[1])**2)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rbf_g: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # radial basis function - Inverse quadratic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | # ϕ(r) = 1/(1 + (εr)²) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | # parameters: (radius, ε) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | # returns: (ϕ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | sub rbf_iq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | # return function value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | ▶ | return(1/(1 + ($_[0] * $_[1])**2)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rbf_iq: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | # radial basis function - Multiquadric | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | # ϕ(r) = sqrt(1 + (εr)²) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | # parameters: (radius, ε) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | # returns: (ϕ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | sub rbf_mq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | # return function value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | return(sqrt(1 + ($_[0] * $_[1])**2)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rbf_mq: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | # radial basis function - Inverse multiquadric | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | # ϕ(r) = 1/sqrt(1 + (εr)²) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | # parameters: (radius, ε) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | # returns: (ϕ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | sub rbf_imq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | # return function value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | return(1/sqrt(1 + ($_[0] * $_[1])**2)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rbf_imq: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | # radial basis function - Polyharmonic spline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | # ϕ(r) = rᵏ, k = 1, 3, 5, ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | # ϕ(r) = rᵏln(r), k = 2, 4, 6, ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | # parameters: (radius, k) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | # returns: (ϕ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | sub rbf_phs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | # return function value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | ▶ | return($_[1] % 2 ? $_[0]**$_[1] : $_[0]**$_[1] * log($_[0])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rbf_phs: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | # radial basis function - Thin plate spline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | # ϕ(r) = r²ln(r) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | # parameters: (radius) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | # returns: (ϕ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | sub rbf_tps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | # return function value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | ▶ | return($_[0]**2 * log($_[0])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rbf_tps: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | # transform list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | # parameters: (object_reference, list, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | # returns: (list) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | sub _trans0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | ▶ | my ($self, $hash, @out); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trans0: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | $self = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | # get optional hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | $hash = pop() if (ref($_[-1]) eq 'HASH'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | # compute output using '_trans1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | @out = @{_trans1($self, \@_, $hash)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | # return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | return(@out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | # transform vector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | # parameters: (object_reference, vector, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | # returns: (vector) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | sub _trans1 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trans1: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | # check if ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | state $lapack = defined($INC{'ICC/Support/Lapack.pm'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | # if ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | if ($lapack) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | # call the BLAS dgemv function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | return(ICC::Support::Lapack::matf_vec_trans(_hidden($self, $in), $self->[3], $self->[4])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | croak('method not yet implemented'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | # transform matrix (2-D array -or- Math::Matrix object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | # parameters: (object_reference, matrix, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | # returns: (matrix) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | sub _trans2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trans2: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | my ($out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | # check if ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | state $lapack = defined($INC{'ICC/Support/Lapack.pm'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | # if ICC::Support::Lapack module is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | ▶ | if ($lapack) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | # call the BLAS dgemm function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | $out = ICC::Support::Lapack::matf_mat_trans(_hidden2($self, $in), $self->[3], $self->[4]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | croak('method not yet implemented'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | # return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | return(UNIVERSAL::isa($in, 'Math::Matrix') ? bless($out, 'Math::Matrix') : $out); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | # transform structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | # parameters: (object_reference, structure, [hash]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | # returns: (structure) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | sub _trans3 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trans3: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | # transform the array structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | _crawl($self, $in, my $out = [], $hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | # return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | return($out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | # recursive transform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | # array structure is traversed until scalar arrays are found and transformed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | # parameters: (ref_to_object, ref_to_input_array, ref_to_output_array, hash) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | sub _crawl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | ▶ | my ($self, $in, $out, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_crawl: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | # if input is a vector (reference to a scalar array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | ▶ | if (@{$in} == grep {! ref()} @{$in}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | # transform input vector and copy to output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | @{$out} = @{_trans1($self, $in, $hash)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | # for each input element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | for my $i (0 .. $#{$in}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | # if an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | ▶ | if (ref($in->[$i]) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | # transform next level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | _crawl($self, $in->[$i], $out->[$i] = [], $hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | croak('invalid transform input'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | # compute hidden node output vector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | # parameters: (ref_to_object, ref_to_input_vector) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | # returns: (ref_to_output_vector) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | sub _hidden { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | my ($self, $in) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hidden: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | my (@geo, @hidden); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | # init array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | @geo = ($in); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | # for each kernel node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | for my $node (@{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | # if a code reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | ▶ | if (ref($node) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | # call subroutine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | push(@geo, [&$node($in)]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | # else an object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | # call transform method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | push(@geo, [$node->transform($in)]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | # for each hidden node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | for my $node (@{$self->[2]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | # add hidden value(s) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | push(@hidden, &$node(\@geo)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | # return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | return([@hidden]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | # compute hidden node output matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | # parameters: (ref_to_object, ref_to_array_of_input_vectors) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | # returns: (ref_to_array_of_output_vectors) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | sub _hidden2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | ▶ | my ($self, $array) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hidden2: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | my (@geo, @hidden, @out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | # for each input vector | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | for my $in (@{$array}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | # init array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | @geo = ($in); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | # for each kernel node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | for my $node (@{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | # if a code reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | ▶ | if (ref($node) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | # call subroutine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | push(@geo, [&$node($in)]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | # else an object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | # call transform method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | push(@geo, [$node->transform($in)]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | # init array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | @hidden = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | # for each hidden node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | for my $node (@{$self->[2]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | # add hidden value(s) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | push(@hidden, &$node(\@geo)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | # add to output array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | push(@out, [@hidden]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | # return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | return([@out]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | # make new nNET object from attribute hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | # hash may contain pointers to header, kernel, matrix, offset or init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | # hash keys are: ('header', 'kernel', 'matrix', 'offset', 'init') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | # object elements not specified in the hash are unchanged | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | # parameters: (ref_to_object, ref_to_attribute_hash) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | sub _new_from_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | ▶ | my ($self, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_from_hash: not called CC=20 SCAR=60.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | # local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | my ($header, $kernel, $hidden, $matrix, $offset, $init); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | # get header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | ▶ | if ($header = $hash->{'header'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | # verify a hash reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | ▶ | (ref($header) eq 'HASH') or croak('\'nNET\' header wrong data type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | # copy header hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | $self->[0] = {%{$header}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | # get kernel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | if ($kernel = $hash->{'kernel'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | # verify an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | ▶ | (ref($kernel) eq 'ARRAY') or croak('\'nNET\' kernel wrong data type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | # for each kernel element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | for my $i (0 .. $#{$kernel}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | # if a valid kernel type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | if (grep {ref($kernel->[$i]) eq $_} @types) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | # copy kernel object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | $self->[1][$i] = $kernel->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | # wrong data type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | croak('\'nNET\' kernel element wrong data type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | # get hidden | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | ▶ | if ($hidden = $hash->{'hidden'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | # verify an array reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | ▶ | (ref($hidden) eq 'ARRAY') or croak('\'nNET\' hidden wrong data type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | # for each hidden element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | for my $i (0 .. $#{$hidden}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | # if a CODE reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | ▶ | if (ref($hidden->[$i]) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | # copy hidden element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | $self->[2][$i] = $hidden->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | # wrong data type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | croak('\'nNET\' hidden element wrong data type'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | # get matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | ▶ | if ($matrix = $hash->{'matrix'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | # verify a 2-D array reference or Math::Matrix object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | ▶ | ((ref($matrix) eq 'ARRAY' && @{$matrix} == grep {ref() eq 'ARRAY'} @{$matrix}) || UNIVERSAL::isa($matrix, 'Math::Matrix')) or croak('\'nNET\' matrix wrong data type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $matrix eq "ARRAY" and @{$matrix;} == grep({ref $_ eq "ARRAY";} @{$matrix;}) or UNIVERSAL::isa($matrix, "Math::Matrix")
ref $matrix eq "ARRAY" and @{$matrix;} == grep({ref $_ eq "ARRAY";} @{$matrix;})
MC/DC0%0/3
ref $matrix eq "ARRAY" and @{$matrix;} == grep({ref $_ eq "ARRAY";} @{$matrix;}) or UNIVERSAL::isa($matrix, "Math::Matrix")
ref $matrix eq "ARRAY"
@{$matrix;} == grep({ref $_ eq "ARRAY";} @{$matrix;})
UNIVERSAL::isa($matrix, "Math::Matrix")
Truth table0%0/5
A and B or C
A= ref $matrix eq "ARRAY"B= @{$matrix;} == grep({ref $_ eq "ARRAY";} @{$matrix;})C= UNIVERSAL::isa($matrix, "Math::Matrix")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | # copy matrix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | $self->[3] = Storable::dclone($matrix); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | # get offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | ▶ | if ($offset = $hash->{'offset'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | # verify a reference to array of scalars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | ▶ | (ref($offset) eq 'ARRAY' && @{$offset} == grep {! ref()} @{$offset}) or croak('\'nNET\' offset wrong data type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $offset eq "ARRAY" and @{$offset;} == grep({not ref $_;} @{$offset;})
MC/DC0%0/2
ref $offset eq "ARRAY" and @{$offset;} == grep({not ref $_;} @{$offset;})
ref $offset eq "ARRAY"
@{$offset;} == grep({not ref $_;} @{$offset;})
Truth table0%0/3
A and B
A= ref $offset eq "ARRAY"B= @{$offset;} == grep({not ref $_;} @{$offset;})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | # copy offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | $self->[4] = [@{$offset}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | # get init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | ▶ | if ($init = $hash->{'init'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | # verify a CODE reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | ▶ | (ref($init) eq 'CODE') or croak('\'nNET\' init wrong data type'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | # set init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | $self->[0]{'init'} = $init; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||