[Jprogramming] Composition conjunctions

Erling Hellenäs erling at erlinghellenas.se
Mon Oct 2 14:11:37 UTC 2017


Hi all !

These measurements are with Jx j.dll on the latest Beta release.

    n=.500000
    v=.?~n
    $v
500000
    10{.v
50689 85238 136693 442735 25192 304048 139323 96663 216893 142946
    ts'-AtTacit-AtTacit-AtTacit-AtTacit- at - v'
0.1156 4.19917e6
    ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v'
0.108927 4.20006e6
    ts'-At-At-At-At-Atop- v'
3.30635 4.20416e6
    ts'-@:-@:-@:-@:- at - v'
0.115168 4.19712e6

For some reason my tacit code is on par with the built in code here. The 
performance of my tacit code is doubled!!! in this release compared to 
latest stable. There is no avx on this machine. I guess the Jx j.dll is 
compiled without it. The explicit code is even slower here.

The measurements from the latest stable, taken from below:

    n=.500000
    v=.?~n
    $v
500000
    10{.v
415593 299586 376558 161399 308885 477430 286004 354448 123594 75795
    ts'-AtTacit-AtTacit-AtTacit-AtTacit- at - v'
0.240852 1.32199e8
    ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v'
0.2369 1.322e8
    ts'-At-At-At-At-Atop- v'
2.96161 1.32204e8
    ts'-@:-@:-@:-@:- at - v'
0.158078 1.32197e8

Cheers,

Erling

On 2017-10-02 15:42, Erling Hellenäs wrote:
> Hi all !
>
> I tried to create explicit and tacit definitions of our composition 
> conjunctions. I think the result could possibly be used to clarify the 
> descriptions in NuVoc.
>
> Opinions are welcome, there are probably still some bugs or 
> misunderstandings of function, there could be interesting aspects to 
> discuss.
>
> The printout follows, then my project with definitions, tests and some 
> minor explanations.
>
> In the end of the printout there are some performance measurements. 
> The explicit versions are doing bad in those. The built in versions 
> are slightly faster, which could be expected.
>
> Cheers,
>
> Erling
>
> ====Printout=======================
>
>    ts=: 6!:2 , 7!:2@]       NB. Time and space
>
>    At=: 2 : 0
> NB. @:
> u v"_ y
> :
> u x v"_ y
> )
>
>    <At- 1 2
> ┌─────┐
> │_1 _2│
> └─────┘
>    NB. < _1_2
>    5 <At- 1 2
> ┌───┐
> │4 3│
> └───┘
>    NB. < 4 3
>
>    NB. @:
>    AtTacit=: 2 : '[: u v'
>
>
>    <AtTacit- 1 2
> ┌─────┐
> │_1 _2│
> └─────┘
>    NB. < _1_2
>    5 <AtTacit- 1 2
> ┌───┐
> │4 3│
> └───┘
>    NB. < 4 3
>
>    NB. @:
>    <AtTacit-
> [: < -
>
>    Atop=: 2 : 0
> NB. @
> u At v"v y
> :
> x u At v"v y
> )
>
>    <Atop- 1 2
> ┌──┬──┐
> │_1│_2│
> └──┴──┘
>    NB. _1;_2
>    5 <Atop- 1 2
> ┌─┬─┐
> │4│3│
> └─┴─┘
>    NB. 4;3
>
>    NB. @
>    AtopTacit=: 2 : '([: u v)"v'
>
>    <AtopTacit- 1 2
> ┌──┬──┐
> │_1│_2│
> └──┴──┘
>    NB. _1;_2
>    5 <AtopTacit- 1 2
> ┌─┬─┐
> │4│3│
> └─┴─┘
>    NB. 4;3
>
>    NB. @
>    <AtopTacit-
> ([: < -)"0 0 0
>    <AtopTacit[
> ([: < [)"_ _ _
>    <AtopTacit i.
> ([: < i.)"1 _ _
>
>    Appose=: 2 : 0
> NB. &:
> u v"_ y
> :
> (v"_ x) u v"_ y
> )
>
>    <Appose- 1 2
> ┌─────┐
> │_1 _2│
> └─────┘
>    NB. < _1 _2
>    5 ([:<<)Appose- 4 5
> ┌───┐
> │1 0│
> └───┘
>    NB. < 1 0
>
>    NB. &:
>    ApposeTacitMonadic=: 2 : '[: u [: v ]'
>    ApposeTacitDyadic=: 2 : '([: v [) u [: v ]'
>
>    <ApposeTacitMonadic- 1 2
> ┌─────┐
> │_1 _2│
> └─────┘
>    NB. < _1 _2
>    5 ([:<<)ApposeTacitDyadic- 4 5
> ┌───┐
> │1 0│
> └───┘
>    NB. < 1 0
>
>    NB. &:
>    <ApposeTacitMonadic-
> [: < [: - ]
>    ([:<<)ApposeTacitDyadic-
> ([: - [) ([: < <) [: - ]
>
>    Compose=: 2 : 0
> NB. &
> u Appose v"v y
> :
> x u Appose v"v y
> )
>
>    <Compose- 1 2
> ┌──┬──┐
> │_1│_2│
> └──┴──┘
>    NB. _1;_2
>    5 ([:<<)Compose- 4 5
> ┌─┬─┐
> │1│0│
> └─┴─┘
>    NB. 1;0
>
>    NB. &
>    ComposeTacitMonadic=: 2 : '([: u [: v ])"v'
>    ComposeTacitDyadic=: 2 : '(([: v [) u [: v ])"v'
>
>    <ComposeTacitMonadic- 1 2
> ┌──┬──┐
> │_1│_2│
> └──┴──┘
>    NB. _1;_2
>    5 ([:<<)ComposeTacitDyadic- 4 5
> ┌─┬─┐
> │1│0│
> └─┴─┘
>    NB. 1;0
>
>    NB. &
>    <ComposeTacitMonadic-
> ([: < [: - ])"0 0 0
>    ([:<<)ComposeTacitDyadic-
> (([: - [) ([: < <) [: - ])"0 0 0
>
>    UnderRankInfinite=: 2 : 0
> NB. &.:
> v"_^:_1 u v"_ y
> :
> v"_^:_1 (v"_ x) u v"_ y
> )
>
>    -UnderRankInfinite> 1 2;3 4
> ┌─────┐
> │_1 _2│
> │_3 _4│
> └─────┘
>    NB. <2 2 $ _1 _2 -3 -4
>    (5;6) -UnderRankInfinite> 1 2;3 4
> ┌───┐
> │4 3│
> │3 2│
> └───┘
>    NB. < 2 2 $ 4 3 3 2
>
>    NB. &.:
>    UnderRankInfiniteTacitMonadic=: 2 : '[: v^:_1 [: u [: v ]'
>    UnderRankInfiniteTacitDyadic=: 2 : '[: v^:_1 ([: v [) u [: v ]'
>
>    -UnderRankInfiniteTacitMonadic> 1 2;3 4
> ┌─────┐
> │_1 _2│
> │_3 _4│
> └─────┘
>    NB. <2 2 $ _1 _2 -3 -4
>    (5;6) -UnderRankInfiniteTacitDyadic> 1 2;3 4
> ┌───┐
> │4 3│
> │3 2│
> └───┘
>    NB. < 2 2 $ 4 3 3 2
>
>    NB. &.:
>    -UnderRankInfiniteTacitMonadic>
> [: >^:_1 [: - [: > ]
>    -UnderRankInfiniteTacitDyadic>
> [: >^:_1 ([: > [) - [: > ]
>
>    UnderRankV=: 2 : 0
> NB. &.
> u UnderRankInfinite v"v y
> :
> x u UnderRankInfinite v"v y
> )
>
>    -UnderRankV> 1 2; 3 4
> ┌─────┬─────┐
> │_1 _2│_3 _4│
> └─────┴─────┘
>    NB. _1 _2; _3 _4
>    (5;6) -UnderRankV> 1 2;3 4
> ┌───┬───┐
> │4 3│3 2│
> └───┴───┘
>    NB. 4 3;3 2
>
>    NB. &.
>    UnderRankVTacitMonadic=: 2 : '([: v^:_1 [: u [: v ])"v'
>    UnderRankVTacitDyadic=: 2 : '([: v^:_1 ([: v [) u [: v ])"v'
>
>    -UnderRankVTacitMonadic> 1 2; 3 4
> ┌─────┬─────┐
> │_1 _2│_3 _4│
> └─────┴─────┘
>    NB. _1 _2; _3 _4
>    (5;6) -UnderRankVTacitDyadic> 1 2;3 4
> ┌───┬───┐
> │4 3│3 2│
> └───┴───┘
>    NB. 4 3;3 2
>
>    NB. &.
>    -UnderRankVTacitMonadic>
> ([: >^:_1 [: - [: > ])"0 0 0
>    -UnderRankVTacitDyadic>
> ([: >^:_1 ([: > [) - [: > ])"0 0 0
>
>    n=.500000
>    v=.?~n
>    $v
> 500000
>    10{.v
> 415593 299586 376558 161399 308885 477430 286004 354448 123594 75795
>
>    ts'-AtTacit-AtTacit-AtTacit-AtTacit- at - v'
> 0.240852 1.32199e8
>    ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v'
> 0.2369 1.322e8
>    ts'-At-At-At-At-Atop- v'
> 2.96161 1.32204e8
>    ts'-@:-@:-@:-@:- at - v'
> 0.158078 1.32197e8
>
> ====================== Project =======================================
>
> ts=: 6!:2 , 7!:2@]       NB. Time and space
>
> At=: 2 : 0
> NB. @:
> u v"_ y
> :
> u x v"_ y
> )
>
> <At- 1 2
> NB. < _1_2
> 5 <At- 1 2
> NB. < 4 3
>
> NB. @:
> AtTacit=: 2 : '[: u v'
>
>
> <AtTacit- 1 2
> NB. < _1_2
> 5 <AtTacit- 1 2
> NB. < 4 3
>
> NB. @:
> <AtTacit-
>
> Atop=: 2 : 0
> NB. @
> u At v"v y
> :
> x u At v"v y
> )
>
> <Atop- 1 2
> NB. _1;_2
> 5 <Atop- 1 2
> NB. 4;3
>
> NB. @
> AtopTacit=: 2 : '([: u v)"v'
>
> <AtopTacit- 1 2
> NB. _1;_2
> 5 <AtopTacit- 1 2
> NB. 4;3
>
> NB. @
> <AtopTacit-
> <AtopTacit[
> <AtopTacit i.
>
> Appose=: 2 : 0
> NB. &:
> u v"_ y
> :
> (v"_ x) u v"_ y
> )
>
> <Appose- 1 2
> NB. < _1 _2
> 5 ([:<<)Appose- 4 5
> NB. < 1 0
>
> NB. &:
> ApposeTacitMonadic=: 2 : '[: u [: v ]'
> ApposeTacitDyadic=: 2 : '([: v [) u [: v ]'
>
> <ApposeTacitMonadic- 1 2
> NB. < _1 _2
> 5 ([:<<)ApposeTacitDyadic- 4 5
> NB. < 1 0
>
> NB. &:
> <ApposeTacitMonadic-
> ([:<<)ApposeTacitDyadic-
>
> Compose=: 2 : 0
> NB. &
> u Appose v"v y
> :
> x u Appose v"v y
> )
>
> <Compose- 1 2
> NB. _1;_2
> 5 ([:<<)Compose- 4 5
> NB. 1;0
>
> NB. &
> ComposeTacitMonadic=: 2 : '([: u [: v ])"v'
> ComposeTacitDyadic=: 2 : '(([: v [) u [: v ])"v'
>
> <ComposeTacitMonadic- 1 2
> NB. _1;_2
> 5 ([:<<)ComposeTacitDyadic- 4 5
> NB. 1;0
>
> NB. &
> <ComposeTacitMonadic-
> ([:<<)ComposeTacitDyadic-
>
> UnderRankInfinite=: 2 : 0
> NB. &.:
> v"_^:_1 u v"_ y
> :
> v"_^:_1 (v"_ x) u v"_ y
> )
>
> -UnderRankInfinite> 1 2;3 4
> NB. <2 2 $ _1 _2 -3 -4
> (5;6) -UnderRankInfinite> 1 2;3 4
> NB. < 2 2 $ 4 3 3 2
>
> NB. &.:
> UnderRankInfiniteTacitMonadic=: 2 : '[: v^:_1 [: u [: v ]'
> UnderRankInfiniteTacitDyadic=: 2 : '[: v^:_1 ([: v [) u [: v ]'
>
> -UnderRankInfiniteTacitMonadic> 1 2;3 4
> NB. <2 2 $ _1 _2 -3 -4
> (5;6) -UnderRankInfiniteTacitDyadic> 1 2;3 4
> NB. < 2 2 $ 4 3 3 2
>
> NB. &.:
> -UnderRankInfiniteTacitMonadic>
> -UnderRankInfiniteTacitDyadic>
>
> UnderRankV=: 2 : 0
> NB. &.
> u UnderRankInfinite v"v y
> :
> x u UnderRankInfinite v"v y
> )
>
> -UnderRankV> 1 2; 3 4
> NB. _1 _2; _3 _4
> (5;6) -UnderRankV> 1 2;3 4
> NB. 4 3;3 2
>
> NB. &.
> UnderRankVTacitMonadic=: 2 : '([: v^:_1 [: u [: v ])"v'
> UnderRankVTacitDyadic=: 2 : '([: v^:_1 ([: v [) u [: v ])"v'
>
> -UnderRankVTacitMonadic> 1 2; 3 4
> NB. _1 _2; _3 _4
> (5;6) -UnderRankVTacitDyadic> 1 2;3 4
> NB. 4 3;3 2
>
> NB. &.
> -UnderRankVTacitMonadic>
> -UnderRankVTacitDyadic>
>
> n=.500000
> v=.?~n
> $v
> 10{.v
>
> ts'-AtTacit-AtTacit-AtTacit-AtTacit- at - v'
> ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v'
> ts'-At-At-At-At-Atop- v'
> ts'-@:-@:-@:-@:- at - v'
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm




More information about the Programming mailing list