Skip to content

Instantly share code, notes, and snippets.

@Shimuuar
Created April 3, 2024 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shimuuar/5a1abd16ed23122047b6cd2781712171 to your computer and use it in GitHub Desktop.
Save Shimuuar/5a1abd16ed23122047b6cd2781712171 to your computer and use it in GitHub Desktop.
-- RHS size: {terms: 109, types: 51, coercions: 0, joins: 3/6}
$wvarianceNoInline :: forall {v :: * -> *}. (v Double -> Int) -> (v Double -> Int# -> Box Double) -> v Double -> Double#
$wvarianceNoInline
= \ (@(v_ :: * -> *))
(basicLen :: v_ Double -> Int)
(basicIndex :: v_ Double -> Int# -> Box Double)
(xs_s2g2 :: v_ Double) ->
case xs_s2g2 of vec { __DEFAULT ->
case basicLen vec of { I# len_i ->
let {
len_d :: Double#
len_d = int2Double# len_i } in
case >=# 0# len_i of {
__DEFAULT ->
case basicIndex vec 0# of { Box x_0 ->
case x_0 of { D# x_0U ->
join {
$j_s2eN :: Double# -> Double#
$j_s2eN (sum :: Double#)
= case /## sum len_d of mean { __DEFAULT ->
let {
x3_a2eI :: Double#
x3_a2eI = -## x_0U mean } in
joinrec {
$s$wfoldlM'_loop_s2gk :: Int# -> Double# -> Double#
$s$wfoldlM'_loop_s2gk (sc_s2gj :: Int#) (sc1_s2gi :: Double#)
= case >=# sc_s2gj len_i of {
__DEFAULT ->
case basicIndex vec sc_s2gj of { Box x4_X3 ->
case x4_X3 of { D# x5_X5 ->
let {
x6_X6 :: Double#
x6_X6 = -## x5_X5 mean } in
jump $s$wfoldlM'_loop_s2gk
(+# sc_s2gj 1#) (+## sc1_s2gi (*## x6_X6 x6_X6))
}
};
1# -> /## sc1_s2gi len_d
}; } in
jump $s$wfoldlM'_loop_s2gk 1# (*## x3_a2eI x3_a2eI)
} } in
joinrec {
$s$wfoldlM'_loop_sum :: Int# -> Double# -> Double#
$s$wfoldlM'_loop_sum (sc_s2go :: Int#) (sc1_s2gn :: Double#)
= case >=# sc_s2go len_i of {
__DEFAULT ->
case basicIndex vec sc_s2go of
{ Box x2_X2 ->
case x2_X2 of { D# y_a2dl ->
jump $s$wfoldlM'_loop_sum (+# sc_s2go 1#) (+## sc1_s2gn y_a2dl)
}
};
1# -> jump $j_s2eN sc1_s2gn
}; } in
jump $s$wfoldlM'_loop_sum 0# 0.0##
}
};
1# -> /## 0.0## len_d
}
}
}
-- RHS size: {terms: 14, types: 69, coercions: 0, joins: 0/0}
varianceNoInline :: forall (v :: * -> *). Vector v Double => v Double -> Double
varianceNoInline
= \ (@(v_ :: * -> *))
($dVector_s2fQ :: Vector v_ Double)
(xs_s2g2 :: v_ Double) ->
case $dVector_s2fQ of
{ C:Vector ww_s2fS ww1_s2fT ww2_s2fU ww3_s2fV ww4_s2fW ww5_s2fX
ww6_s2fY ww7_s2fZ ww8_s2g0 ->
case $wvarianceNoInline @v_ ww3_s2fV ww6_s2fY xs_s2g2
of ww9_s2g6
{ __DEFAULT ->
D# ww9_s2g6
}
}
-- RHS size: {terms: 114, types: 54, coercions: 0, joins: 3/6}
$wvarianceNoInline
:: forall {v :: * -> *}. Vector v Double => v Double -> Double#
$wvarianceNoInline
= \ (@(v_ :: * -> *)) ($dict :: Vector v_ Double)
(xs_sfO7 :: v_ Double) ->
case xs_sfO7 of vec { __DEFAULT ->
case basicLength @v_ @Double $dict vec of
{ I# ipv_i2TC ->
let {
n_sfOd :: Double#
n_sfOd = int2Double# ipv_i2TC } in
case >=# 0# ipv_i2TC of {
__DEFAULT ->
case basicUnsafeIndexM
@v_ @Double $dict vec lvl_rfOM
of
{ Box x_i2TI ->
case x_i2TI of { D# x1_acHG ->
join {
$j_sfMX :: Double# -> Double#
$j_sfMX (x2_afdZ :: Double#)
= case /## x2_afdZ n_sfOd of ds2_afe4 { __DEFAULT ->
let {
x3_acHO :: Double#
x3_acHO = -## x1_acHG ds2_afe4 } in
joinrec {
$s$wfoldlM'_loop_sfOz :: Int# -> Double# -> Double#
$s$wfoldlM'_loop_sfOz (sc_sfOy :: Int#) (sc1_sfOx :: Double#)
= case >=# sc_sfOy ipv_i2TC of {
__DEFAULT ->
case basicUnsafeIndexM @v_ @Double $dict vec (I# sc_sfOy) of
{ Box x4_X3 ->
case x4_X3 of { D# x5_X5 ->
let {
x6_X6 :: Double#
x6_X6 = -## x5_X5 ds2_afe4 } in
jump $s$wfoldlM'_loop_sfOz
(+# sc_sfOy 1#) (+## sc1_sfOx (*## x6_X6 x6_X6))
}
};
1# -> /## sc1_sfOx n_sfOd
}; } in
jump $s$wfoldlM'_loop_sfOz 1# (*## x3_acHO x3_acHO)
} } in
joinrec {
$s$wfoldlM'_loop_sfOE :: Int# -> Double# -> Double#
$s$wfoldlM'_loop_sfOE (sc_sfOD :: Int#) (sc1_sfOC :: Double#)
= case >=# sc_sfOD ipv_i2TC of {
__DEFAULT ->
case basicUnsafeIndexM @v_ @Double $dict vec (I# sc_sfOD) of
{ Box x2_X2 ->
case x2_X2 of { D# y_afku ->
jump $s$wfoldlM'_loop_sfOE (+# sc_sfOD 1#) (+## sc1_sfOC y_afku)
}
};
1# -> jump $j_sfMX sc1_sfOC
}; } in
jump $s$wfoldlM'_loop_sfOE 0# 0.0##
}
};
1# -> /## 0.0## n_sfOd
}
}
}
-- RHS size: {terms: 10, types: 9, coercions: 0, joins: 0/0}
varianceNoInline
:: forall (v :: * -> *). Vector v Double => v Double -> Double
varianceNoInline
= \ (@(v_ :: * -> *))
($dict :: Vector v_ Double)
(xs_sfO7 :: v_ Double) ->
case $wvarianceNoInline @v_ $dict xs_sfO7 of ww_sfOb
{ __DEFAULT ->
D# ww_sfOb
}
-- RHS size: {terms: 112, types: 54, coercions: 0, joins: 3/6}
$wvarianceNoInline
:: forall {v :: * -> *}. Vector v Double => v Double -> Double#
$wvarianceNoInline
= \ (@(v_ :: * -> *))
($dictVec :: Vector v_ Double)
(vec0 :: v_ Double) ->
case vec0 of vec { __DEFAULT ->
case basicLength @v_ @Double $dictVec vec of
{ I# len_i ->
let {
len_d :: Double#
len_d = int2Double# len_i } in
case >=# 0# len_i of {
__DEFAULT ->
case basicUnsafeIndexM# @v_ @Double $dictVec vec 0# of
{ Box x_0_boxed ->
case x_0_boxed of { D# x_0 ->
join {
$j_sfNx :: Double# -> Double#
$j_sfNx (sum :: Double#)
= case /## sum len_d of mean { __DEFAULT ->
let {
x3_acIn :: Double#
x3_acIn = -## x_0 mean } in
joinrec {
$s$wfoldlM'_loop_sfPd :: Int# -> Double# -> Double#
$s$wfoldlM'_loop_sfPd (sc_sfPc :: Int#) (sc1_sfPb :: Double#)
= case >=# sc_sfPc len_i of {
__DEFAULT ->
case basicUnsafeIndexM# @v_ @Double $dictVec vec sc_sfPc
of
{ Box x4_X3 ->
case x4_X3 of { D# x5_X5 ->
let {
x6_X6 :: Double#
x6_X6 = -## x5_X5 mean } in
jump $s$wfoldlM'_loop_sfPd
(+# sc_sfPc 1#) (+## sc1_sfPb (*## x6_X6 x6_X6))
}
};
1# -> /## sc1_sfPb len_d
}; } in
jump $s$wfoldlM'_loop_sfPd 1# (*## x3_acIn x3_acIn)
} } in
joinrec {
$s$wfoldlM'_loop_sum :: Int# -> Double# -> Double#
$s$wfoldlM'_loop_sum (sc_sfPh :: Int#) (sc1_sfPg :: Double#)
= case >=# sc_sfPh len_i of {
__DEFAULT ->
case basicUnsafeIndexM# @v_ @Double $dictVec vec sc_sfPh of
{ Box x2_X2 ->
case x2_X2 of { D# y_afl4 ->
jump $s$wfoldlM'_loop_sum (+# sc_sfPh 1#) (+## sc1_sfPg y_afl4)
}
};
1# -> jump $j_sfNx sc1_sfPg
}; } in
jump $s$wfoldlM'_loop_sum 0# 0.0##
}
};
1# -> /## 0.0## len_d
}
}
}
-- RHS size: {terms: 10, types: 9, coercions: 0, joins: 0/0}
varianceNoInline
:: forall (v :: * -> *). Vector v Double => v Double -> Double
varianceNoInline
= \ (@(v_ :: * -> *))
($dictVec :: Vector v_ Double)
(vec0 :: v_ Double) ->
case $wvarianceNoInline @v_ $dictVec vec0 of ww_sfOR
{ __DEFAULT ->
D# ww_sfOR
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment