| 1 | |||||||||||||||||||||||||||||||||||
| 2 | # map different scales | ||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||
| 4 | package App::GUI::Juliagraph::Compute::Mapping; | ||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use v5.12; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | 0 | ▶ | sub scales { | ||||||||||||||||||||||||||||||||
|
Subroutine
scales: not called CC=22 SCAR=62.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 9 | 0 | my( $scaling_type, $scale_length, $parts ) = @_; | |||||||||||||||||||||||||||||||||
| 10 | 0 | my (%mapping); | |||||||||||||||||||||||||||||||||
| 11 | 0 | my @iterator = 1 .. $parts; | |||||||||||||||||||||||||||||||||
| 12 | 0 | my $jumping_index = 0; | |||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | if ($scaling_type eq 'linear'){ | ||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||
| 14 | 0 | my $scale_max = $scale_length / $parts; | |||||||||||||||||||||||||||||||||
| 15 | 0 | for my $part_nr (@iterator) { | |||||||||||||||||||||||||||||||||
| 16 | 0 | my $next_scale_notch = round ($part_nr * $scale_max); | |||||||||||||||||||||||||||||||||
| 17 | 0 | $mapping{$_} = $part_nr-1 for $jumping_index .. $next_scale_notch; | |||||||||||||||||||||||||||||||||
| 18 | 0 | $jumping_index = $next_scale_notch + 1; | |||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||
| 20 | } elsif ($scaling_type eq 'square'){ | ||||||||||||||||||||||||||||||||||
| 21 | 0 | my $scale_max = $scale_length / ($parts ** 2); | |||||||||||||||||||||||||||||||||
| 22 | 0 | for my $part_nr ( @iterator) { | |||||||||||||||||||||||||||||||||
| 23 | 0 | my $next_scale_notch = round (($part_nr**2) * $scale_max); | |||||||||||||||||||||||||||||||||
| 24 | 0 | $mapping{$_} = $part_nr-1 for $jumping_index .. $next_scale_notch; | |||||||||||||||||||||||||||||||||
| 25 | 0 | $jumping_index = $next_scale_notch + 1; | |||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||
| 27 | } elsif ($scaling_type eq 'cube'){ | ||||||||||||||||||||||||||||||||||
| 28 | 0 | my $scale_max = $scale_length / ($parts ** 3); | |||||||||||||||||||||||||||||||||
| 29 | 0 | for my $part_nr ( @iterator) { | |||||||||||||||||||||||||||||||||
| 30 | 0 | my $next_scale_notch = round (($part_nr**3) * $scale_max); | |||||||||||||||||||||||||||||||||
| 31 | 0 | $mapping{$_} = $part_nr-1 for $jumping_index .. $next_scale_notch; | |||||||||||||||||||||||||||||||||
| 32 | 0 | $jumping_index = $next_scale_notch + 1; | |||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||
| 34 | } elsif ($scaling_type eq 'sqrt'){ | ||||||||||||||||||||||||||||||||||
| 35 | 0 | my $scale_max = $scale_length / sqrt ($parts); | |||||||||||||||||||||||||||||||||
| 36 | 0 | for my $part_nr ( @iterator) { | |||||||||||||||||||||||||||||||||
| 37 | 0 | my $next_scale_notch = round ((sqrt $part_nr) * $scale_max); | |||||||||||||||||||||||||||||||||
| 38 | 0 | $mapping{$_} = $part_nr-1 for $jumping_index .. $next_scale_notch; | |||||||||||||||||||||||||||||||||
| 39 | 0 | $jumping_index = $next_scale_notch + 1; | |||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||
| 41 | } elsif ($scaling_type eq 'cubert'){ | ||||||||||||||||||||||||||||||||||
| 42 | 0 | my $third = 1/3; | |||||||||||||||||||||||||||||||||
| 43 | 0 | my $scale_max = $scale_length /(($parts) ** $third); | |||||||||||||||||||||||||||||||||
| 44 | 0 | for my $part_nr (@iterator) { | |||||||||||||||||||||||||||||||||
| 45 | 0 | my $next_scale_notch = round (($part_nr ** $third) * $scale_max); | |||||||||||||||||||||||||||||||||
| 46 | 0 | $mapping{$_} = $part_nr-1 for $jumping_index .. $next_scale_notch; | |||||||||||||||||||||||||||||||||
| 47 | 0 | $jumping_index = $next_scale_notch + 1; | |||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||
| 49 | } elsif ($scaling_type eq 'log'){ | ||||||||||||||||||||||||||||||||||
| 50 | 0 | my $scale_max = $scale_length / log ($parts+1); | |||||||||||||||||||||||||||||||||
| 51 | 0 | for my $part_nr (@iterator) { | |||||||||||||||||||||||||||||||||
| 52 | 0 | my $next_scale_notch = round (log($part_nr+1) * $scale_max); | |||||||||||||||||||||||||||||||||
| 53 | 0 | $mapping{$_} = $part_nr-1 for $jumping_index .. $next_scale_notch; | |||||||||||||||||||||||||||||||||
| 54 | 0 | $jumping_index = $next_scale_notch + 1; | |||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||
| 56 | } elsif ($scaling_type eq 'exp'){ | ||||||||||||||||||||||||||||||||||
| 57 | 0 | my $scale_max = $scale_length / exp($parts); | |||||||||||||||||||||||||||||||||
| 58 | 0 | for my $part_nr ( @iterator) { | |||||||||||||||||||||||||||||||||
| 59 | 0 | my $next_scale_notch = round (exp($part_nr) * $scale_max); | |||||||||||||||||||||||||||||||||
| 60 | 0 | $mapping{$_} = $part_nr-1 for $jumping_index .. $next_scale_notch; | |||||||||||||||||||||||||||||||||
| 61 | 0 | $jumping_index = $next_scale_notch + 1; | |||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||
| 64 | 0 | return \%mapping; | |||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||
| 67 | 1 | my $half = 0.50000000000008; | |||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub round { | ||||||||||||||||||||||||||||||||
|
Subroutine
round: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | $_[0] >= 0 ? int ($_[0] + $half) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 70 | : int ($_[0] - $half) | ||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | 1 | 1; | |||||||||||||||||||||||||||||||||