on master help sign in
.ghc.environment.x86_64-linux-8.6.5deleted−17
since splitsnapshots
unifiedsplit
@@ -1,17 +0,0 @@
1−-- This is a GHC environment file written by cabal. This means you can
2−-- run ghc or ghci and get the environment of the project as a whole.
3−-- But you still need to use cabal repl $target to get the environment
4−-- of specific components (libs, exes, tests etc) because each one can
5−-- have its own source dirs, cpp flags etc.
6−--
7−clear-package-db
8−global-package-db
9−package-db /home/bolt/.cabal/store/ghc-8.6.5/package.db
10−package-db packagedb/ghc-8.6.5
11−package-id laop-0.1.0.0-inplace
12−package-id base-4.12.0.0
13−package-id ghc-prim-0.5.3
14−package-id rts
15−package-id integer-gmp-1.0.2.0
16−package-id deepseq-1.4.4.0
17−package-id array-0.5.3.0
.github/workflows/ci.ymlnew file+43
@@ -0,0 +1,43 @@
1+name: CI
2+
3+# Trigger the workflow on push or pull request, but only for the master branch
4+on:
5+ pull_request:
6+ push:
7+ branches: [master]
8+
9+jobs:
10+ build:
11+ name: ghc ${{ matrix.ghc }}
12+ runs-on: ubuntu-16.04
13+ strategy:
14+ matrix:
15+ cabal: ["3.0"]
16+ ghc:
17+ - "8.6.5"
18+ - "8.8.3"
19+
20+ steps:
21+ - uses: actions/checkout@v2
22+ if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'
23+
24+ - uses: actions/setup-haskell@v1
25+ name: Setup Haskell
26+ with:
27+ ghc-version: ${{ matrix.ghc }}
28+ cabal-version: ${{ matrix.cabal }}
29+
30+ - uses: actions/cache@v1
31+ name: Cache ~/.cabal/store
32+ with:
33+ path: ~/.cabal/store
34+ key: ${{ runner.os }}-${{ matrix.ghc }}-cabal
35+
36+ - name: Build
37+ run: |
38+ cabal v2-update
39+ cabal v2-build --enable-tests --enable-benchmarks
40+
41+ - name: Test
42+ run: |
43+ cabal v2-test --enable-tests
.gitignore+54−2
@@ -1,3 +1,55 @@
1+### Haskell
2+dist
3+dist-*
4+cabal-dev
5+*.o
6+*.hi
7+*.chi
8+*.chs.h
9+*.dyn_o
10+*.dyn_hi
11+*.prof
12+*.aux
13+*.hp
14+*.eventlog
15+.virtualenv
16+.hsenv
17+.hpc
18+.cabal-sandbox/
19+cabal.sandbox.config
20+cabal.config
21+cabal.project.local
22+.ghc.environment.*
23+.HTF/
24+# Stack
1.stack-work/
25.stack-work/
2−laop.cabal
26+stack.yaml.lock
27+
28+### IDE/support
29+# Vim
30+[._]*.s[a-v][a-z]
31+[._]*.sw[a-p]
32+[._]s[a-v][a-z]
33+[._]sw[a-p]
3−*~
34+*~
35+tags
36+
37+# IntellijIDEA
38+.idea/
39+.ideaHaskellLib/
40+*.iml
41+
42+# Atom
43+.haskell-ghc-mod.json
44+
45+# VS
46+.vscode/
47+
48+# Emacs
49+*#
50+.dir-locals.el
51+TAGS
52+
53+# other
54+.DS_Store
55+hackage.sh
.travis.ymlnew file+47
@@ -0,0 +1,47 @@
1+sudo: true
2+language: haskell
3+
4+git:
5+ depth: 5
6+
7+cabal: "3.0"
8+
9+cache:
10+ directories:
11+ - "$HOME/.cabal/store"
12+ - "$HOME/.stack"
13+ - "$TRAVIS_BUILD_DIR/.stack-work"
14+
15+matrix:
16+ include:
17+ - ghc: 8.6.5
18+ - ghc: 8.8.3
19+
20+ - ghc: 8.8.3
21+ env: STACK_YAML="$TRAVIS_BUILD_DIR/stack-8.8.3.yaml"
22+
23+ - ghc: 8.6.5
24+ env: STACK_YAML="$TRAVIS_BUILD_DIR/stack.yaml"
25+
26+
27+install:
28+ - |
29+ if [ -z "$STACK_YAML" ]; then
30+ cabal v2-update
31+ cabal v2-build --enable-tests --enable-benchmarks
32+ else
33+ curl -sSL https://get.haskellstack.org/ | sh
34+ stack --version
35+ stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks
36+ fi
37+
38+script:
39+ - |
40+ if [ -z "$STACK_YAML" ]; then
41+ cabal v2-test --enable-tests
42+ else
43+ stack test --system-ghc
44+ fi
45+
46+notifications:
47+ email: false
CHANGELOG.mdnew file+17
@@ -0,0 +1,17 @@
1+# Changelog
2+
3+`laop` uses [PVP Versioning][1].
4+The changelog is available [on GitHub][2].
5+
6+## 0.1.1.1
7+
8+* Bump base version to work with cabal
9+
10+## 0.1.1.0
11+
12+* Package is more organized and now has tests and benchmarks separated
13+* Repository is more organized and clean
14+* Added CI
15+
16+[1]: https://pvp.haskell.org
17+[2]: https://github.com/bolt12/laop2/releases
ChangeLog.mddeleted−3
@@ -1,3 +0,0 @@
1−# Changelog for laop
2−
3−## Unreleased changes
LICENSE+17−26
@@ -1,30 +1,21 @@
1−Copyright Armando Santos (c) 2019
1+MIT License
2
2
3−All rights reserved.
3+Copyright (c) 2020 Armando Santos
4
4
5−Redistribution and use in source and binary forms, with or without
5+Permission is hereby granted, free of charge, to any person obtaining a copy
6+of this software and associated documentation files (the "Software"), to deal
7+in the Software without restriction, including without limitation the rights
8+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+copies of the Software, and to permit persons to whom the Software is
6−modification, are permitted provided that the following conditions are met:
10+furnished to do so, subject to the following conditions:
7
11
8− * Redistributions of source code must retain the above copyright
12+The above copyright notice and this permission notice shall be included in all
9− notice, this list of conditions and the following disclaimer.
13+copies or substantial portions of the Software.
10
14
11− * Redistributions in binary form must reproduce the above
15+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12− copyright notice, this list of conditions and the following
13− disclaimer in the documentation and/or other materials provided
14− with the distribution.
15−
16− * Neither the name of Armando Santos nor the names of other
17− contributors may be used to endorse or promote products derived
18− from this software without specific prior written permission.
19−
20−THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21−"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22−LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
16+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23−A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
17+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24−OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25−SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26−LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27−DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28−THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29−(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
20+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30−OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21+SOFTWARE.
README.md+35−27
@@ -1,5 +1,11 @@
1# laop - Linear Algebra of Programming library
1# laop - Linear Algebra of Programming library
2
2
3+[![GitHub CI](https://github.com/bolt12/laop/workflows/CI/badge.svg)](https://github.com/bolt12/laop/actions)
4+[![Build status](https://img.shields.io/travis/bolt12/laop.svg?logo=travis)](https://travis-ci.org/bolt12/laop)
5+[![Hackage](https://img.shields.io/hackage/v/laop.svg?logo=haskell)](https://hackage.haskell.org/package/laop)
6+[![Stackage Lts](http://stackage.org/package/laop/badge/lts)](http://stackage.org/lts/package/laop)
7+[![Stackage Nightly](http://stackage.org/package/laop/badge/nightly)](http://stackage.org/nightly/package/laop)
8+
3The LAoP discipline generalises relations and functions treating them as
9The LAoP discipline generalises relations and functions treating them as
4Boolean matrices and in turn consider these as arrows.
10Boolean matrices and in turn consider these as arrows.
5
11
@@ -10,36 +16,38 @@ motivation behind the library, the underlying theory, and implementation details
10This module offers many of the combinators mentioned in the work of
16This module offers many of the combinators mentioned in the work of
11[Macedo (2012)](https://repositorium.sdum.uminho.pt/handle/1822/22894) and [Oliveira (2012)](https://pdfs.semanticscholar.org/ccf5/27fa9179081223bffe8067edd81948644fc0.pdf).
17[Macedo (2012)](https://repositorium.sdum.uminho.pt/handle/1822/22894) and [Oliveira (2012)](https://pdfs.semanticscholar.org/ccf5/27fa9179081223bffe8067edd81948644fc0.pdf).
12
18
13−See the candidate package in hackage [here](https://hackage.haskell.org/package/laop-0.1.0.0)
19+See the package in hackage [here](https://hackage.haskell.org/package/laop-0.1.1.0)
20+
21+A Functional Pearl has been written and can be regarded as the [reference document](https://github.com/bolt12/tymfgg-pearl) for this library.
14
22
15## Features
23## Features
16
24
17−This library offers:
25+This library offers 3 main matrix programming modules:
18−
26+
19−- An internal module representation that uses normal datatypes (`Void`, `()`, `Either`) for matrix dimensions and two
27+- One in which matrices are typed with type level natural numbers;
20− type families `FromNat` and `Count` to make it easier to work with these type of matrices.
28+- One in which matrices are typed with arbitrary generic data types;
21−- An interfacing module that uses generalised types for the dimensions and is just a newtype wrapper
29+- One in which matrices are regarded as relations, i.e. boolean matrices;
22− around the internal matrix data type.
30+
23−- An interfacing module that uses type level naturals for the dimensions and is just a newtype wrapper
31+There's also an experimental module that uses matrices to represent probability
24− around the internal matrix data type.
32+distributions.
25−- An interfacing module that restricts the matrix contents to being only 0's or 1's (True
33+
26− and False). This module is called 'Relation' and offers many of the combinators seen in
34+The most interesting feature is that matrices are represented as an inductive data type.
27− AoP and Relational Calculus/Algebra.
35+Given this formulation, matrix algorithms can be expressed in a much more elegant and
28−- A very simple Probabilistic Programming module and several functions and data types to
36+calculational style than the traditional vector of vectors representation. This data type
29− make it easier to deal with sample space.
37+guarantees that a matrix will always have valid dimensions. It can also express block matrix
30−
38+computations naturally, which leads to total, efficient and statically typed manipulation
31−Given this, this new matrix formulation compared to other libraries one has much more advantages, such as:
39+and transformation functions.
32−
40+
33−- Has an inductive definition enabling writing matrix manipulation functions in a much more elegant and calculational way;
41+Like matrix multiplication, other common operations, such as matrix transposition, benefit from a block-oriented structure that leads to a simple and natural divide-and-conquer algorithmic solution. Performance wise, this means that without much effort we can obtain optimal cache-oblivious algorithms.
34−- Statically typed dimensions;
42+
35−- Polymorphic data type dimensions;
43+Given this, this new matrix formulation compared to other libraries:
36−- Polymorphic matrix content;
44+
37−- Awesome dimension type inference;
45+- Is more compositional and polymorphic and does not have partial matrix manipulation functions (hence less chances for usage errors);
38−- Fast type natural conversion via `FromNat` type family;
46+- Our implementation of matrices enables simple manipulation of submatrices, making it particularly suitable for formal verification and equation reasoning, using the mathematical framework defined by the linear algebra of programming. Furthermore, the data type constructors ensure that the matrices of this kind are sound, i.e. malformed matrices with incorrect dimensions of the sort, can not be constructed.
39−- Matrix `Junc` and `Split`-ing in O(1);
47+
40−- Matrix composition takes advantage of divide-and-conquer and fusion laws.
48+## Known issues
41−
49+
42−Unfortunately, this approach does not solve the issue of type dimensions being in some way constrainted making it impossible to write Arrow instances, for example. Type inference isn't perfect, when it comes to infer the types of matrices which dimensions are computed using type level naturals multiplication, the compiler needs type annotations in order to succeed.
50+Unfortunately, due to the use of type-level programming features, this approach sometimes requires type dimensions to be constrainted, in some way, impossible to write idiomatic Arrow instances, for example. Type inference isn't perfect, when it comes to infer the types of matrices which dimensions are computed using type level naturals multiplication, the compiler needs type annotations in order to succeed. And not all kinds of programs can be modeled using matrices, namely programs that deal with arbitrary infinite data types such as lists or integers (although there are some workarounds).
43
51
44## Notes
52## Notes
45
53
Setup.hsdeleted−2
@@ -1,2 +0,0 @@
1−import Distribution.Simple
2−main = defaultMain
app/Main.hsdeleted−7
@@ -1,7 +0,0 @@
1−module Main where
2−
3−import Examples
4−import Benchmarks
5−
6−main :: IO ()
7−main = benchmark
app/Spreadsheets.hsdeleted−61
@@ -1,61 +0,0 @@
1−{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE GADTs #-}
3−{-# LANGUAGE FlexibleContexts #-}
4−{-# LANGUAGE DeriveGeneric #-}
5−module Spreadsheets
6− (
7− )
8− where
9−
10−import LAoP.Matrix.Type
11−import qualified LAoP.Matrix.Internal as I
12−import GHC.Generics
13−
14−data Student = Student1 | Student2 | Student3 | Student4
15− deriving (Eq, Show, Enum, Bounded, Generic)
16−
17−data Question = Question1 | Question2 | Question3 | Question4
18− deriving (Eq, Show, Enum, Bounded, Generic)
19−
20−data Results = Test | Exam | Final
21− deriving (Eq, Show, Enum, Bounded, Generic)
22−
23−test :: Matrix Float One Results
24−test = point Test
25−
26−exam :: Matrix Float One Results
27−exam = point Exam
28−
29−final :: Matrix Float One Results
30−final = point Final
31−
32−m :: Matrix Float Question Student
33−m = fromLists [[95, 90, 100, 40], [20, 90, 90, 0], [30, 20, 95, 0], [50, 80, 100, 30]]
34−
35−w :: Matrix Float Question One
36−w = fromLists [[0.2, 0.3, 0.2, 0.3]]
37−
38−xls :: Matrix Float Question One
39− -> Matrix Float Question Student
40− -> Matrix Float Student One
41− -> Matrix Float (Either Question Results) (Either One Student)
42−xls w m t = junc (split w m) (split zeros r)
43− where
44− rExam = m `comp` tr w
45− rTest = tr t
46− rFinal = rTest `maxPP` rExam
47− rAux = junc rTest (junc rExam rFinal)
48− r = tr (converter `comp` tr rAux)
49− converter = junc test (junc exam final)
50−
51−-- | Overloaded, point-wise 'max' function
52−maxPP_ :: Ord e => I.Matrix e a b -> I.Matrix e a b -> I.Matrix e a b
53−maxPP_ I.Empty I.Empty = I.Empty
54−maxPP_ (I.One a) (I.One b) = I.One (a `max` b)
55−maxPP_ (I.Junc a b) (I.Junc c d) = I.Junc (maxPP_ a c) (maxPP_ b d)
56−maxPP_ (I.Split a b) (I.Split c d) = I.Split (maxPP_ a c) (maxPP_ b d)
57−maxPP_ x@(I.Split _ _) y@(I.Junc _ _) = maxPP_ x (I.abideJS y)
58−maxPP_ x@(I.Junc _ _) y@(I.Split _ _) = maxPP_ (I.abideJS x) y
59−
60−maxPP :: Ord e => Matrix e a b -> Matrix e a b -> Matrix e a b
61−maxPP (M a) (M b) = M (maxPP_ a b)
appveyor.ymlnew file+34
@@ -0,0 +1,34 @@
1+clone_folder: "c:\\WORK"
2+clone_depth: 5
3+
4+# Do not build feature branch with open Pull Requests
5+skip_branch_with_pr: true
6+
7+platform:
8+ - x86_64
9+
10+cache:
11+ - "C:\\SR"
12+ - dist-newstyle
13+
14+environment:
15+ global:
16+ CABOPTS: --store-dir=C:\\SR
17+
18+ matrix:
19+ - GHCVER: 8.6.5
20+
21+install:
22+ - choco source add -n mistuke -s https://www.myget.org/F/mistuke/api/v2
23+ - choco install -y cabal --version 2.4.1.0
24+ - choco install -y ghc --version 8.6.3
25+ - refreshenv
26+
27+before_build:
28+ - cabal --version
29+ - ghc --version
30+ - cabal %CABOPTS% v2-update
31+
32+build_script:
33+ - cabal %CABOPTS% v2-build --enable-tests
34+ - cabal %CABOPTS% v2-test --enable-tests
app/Benchmarks.hs → benchmark/Main.hsrenamed+31−24
@@ -8,35 +8,36 @@
8{-# LANGUAGE AllowAmbiguousTypes #-}
8{-# LANGUAGE AllowAmbiguousTypes #-}
9{-# LANGUAGE ScopedTypeVariables #-}
9{-# LANGUAGE ScopedTypeVariables #-}
10
10
11−module Benchmarks
12− ( benchmark
13− )
14− where
11+module Main (main) where
15
12
16import LAoP.Dist.Internal
13import LAoP.Dist.Internal
17import LAoP.Utils
14import LAoP.Utils
18−import LAoP.Matrix.Type hiding (CountableN, Countable, FromListsN)
15+import LAoP.Matrix.Type hiding (CountableN, Countable, FLN)
19−import qualified LAoP.Matrix.Type as T (FromListsN)
16+import qualified LAoP.Matrix.Type as T (FLN)
20import Criterion.Main
17import Criterion.Main
21import Control.DeepSeq
18import Control.DeepSeq
22import Test.QuickCheck
19import Test.QuickCheck
23import GHC.TypeLits
20import GHC.TypeLits
24import Data.Proxy
21import Data.Proxy
22+import Prelude hiding (id, (.))
25
23
26selectM2 ::
24selectM2 ::
27 ( Num e,
25 ( Num e,
28− T.FromListsN e b b,
26+ T.FLN b b,
29 CountableN b
27 CountableN b
30 ) => Matrix e cols (Either a b) -> Matrix e a b -> Matrix e cols b
28 ) => Matrix e cols (Either a b) -> Matrix e a b -> Matrix e cols b
31−selectM2 m y = junc y identity `comp` m
29+selectM2 m y = join y iden `comp` m
32
30
33selectD2 ::
31selectD2 ::
34− ( FromListsN b b,
32+ ( FLN b b,
35 CountableN b
33 CountableN b
36 ) => Dist (Either a b) -> Matrix Prob a b -> Dist b
34 ) => Dist (Either a b) -> Matrix Prob a b -> Dist b
37−selectD2 (D d) m = D (junc m identity `comp` d)
35+selectD2 (D d) m = D (join m iden `comp` d)
36+
37+-- Composition with iden
38+compId m = comp iden m
38
39
39−randomDist :: forall a . (Countable a, FromListsN () a) => Gen (Dist a)
40+randomDist :: forall a . (Countable a, FLN () a) => Gen (Dist a)
40randomDist = do
41randomDist = do
41 let size = fromInteger (natVal (Proxy :: Proxy (Count a)))
42 let size = fromInteger (natVal (Proxy :: Proxy (Count a)))
42 l <- vectorOf size (arbitrary :: Gen Prob)
43 l <- vectorOf size (arbitrary :: Gen Prob)
@@ -45,7 +46,7 @@ randomDist = do
45 m = fromLists lr
46 m = fromLists lr
46 return (D m)
47 return (D m)
47
48
48−randomMatrix :: forall a b . (CountableDimensions a b, FromListsN a b) => Gen (Matrix Prob a b)
49+randomMatrix :: forall a b . (CountableDims a b, FLN a b) => Gen (Matrix Prob a b)
49randomMatrix = do
50randomMatrix = do
50 let cols = fromInteger (natVal (Proxy :: Proxy (Count a)))
51 let cols = fromInteger (natVal (Proxy :: Proxy (Count a)))
51 rows = fromInteger (natVal (Proxy :: Proxy (Count b)))
52 rows = fromInteger (natVal (Proxy :: Proxy (Count b)))
@@ -104,12 +105,14 @@ normalize3 as l = let s = sum l
104 probs = map (/ s) l
105 probs = map (/ s) l
105 in zip as probs
106 in zip as probs
106
107
107−randomDistF :: forall a b . (CoArbitrary a, Arbitrary b) => Gen (Dist' (a -> b))
108+randomDistF :: forall a b . (CountableDims a b, CoArbitrary a, Arbitrary b) => Gen (Dist' (a -> b))
108randomDistF = do
109randomDistF = do
110+ let a = fromInteger (natVal (Proxy :: Proxy (Count a)))
111+ b = fromInteger (natVal (Proxy :: Proxy (Count b)))
109− let size = 200
112+ size = a * b
110 l <- vectorOf size (arbitrary :: Gen Prob)
113 l <- vectorOf size (arbitrary :: Gen Prob)
111 l2 <- vectorOf size (arbitrary :: Gen (a -> b))
114 l2 <- vectorOf size (arbitrary :: Gen (a -> b))
112− let ln = normalize3 l2 (map P l)
115+ let !ln = normalize3 l2 (map P l)
113 return (D' ln)
116 return (D' ln)
114
117
115instance CoArbitrary (Natural a b)
118instance CoArbitrary (Natural a b)
@@ -134,15 +137,15 @@ setupEnv = do
134
137
135setupEnv2 = do
138setupEnv2 = do
136 m21 <- generate (resize 1 (randomMatrix @(Natural 0 100) @(Natural 0 100) ))
139 m21 <- generate (resize 1 (randomMatrix @(Natural 0 100) @(Natural 0 100) ))
137− m40 <- generate (resize 1 (randomMatrix @(Natural 0 300) @(Either (Natural 0 100) (Natural 0 100) )))
140+ m40 <- generate (resize 1 (randomMatrix @(Natural 0 100) @(Either (Natural 0 100) (Natural 0 100) )))
138− dist <- generate (resize 1 (randomDist @(Either (Natural 0 1000) (Natural 0 1000)) ))
141+ dist <- generate (resize 1 (randomDist @(Either (Natural 0 100) (Natural 0 100)) ))
139− dist2 <- generate (resize 1 (randomMatrix @(Natural 0 1000) @(Natural 0 1000) ))
142+ dist2 <- generate (resize 1 (randomMatrix @(Natural 0 100) @(Natural 0 100) ))
140− distList1 <- generate (resize 1 (randomDist2 @(Either (Natural 0 1000) (Natural 0 1000))))
143+ distList1 <- generate (resize 1 (randomDist2 @(Either (Natural 0 100) (Natural 0 100))))
141− distList2 <- generate (resize 1 (randomDistF @(Natural 0 1000) @(Natural 0 1000)))
144+ distList2 <- generate (resize 1 (randomDistF @(Natural 0 100) @(Natural 0 100)))
142 return (m21, m40, dist, dist2, distList1, distList2)
145 return (m21, m40, dist, dist2, distList1, distList2)
143
146
144−benchmark :: IO ()
147+main :: IO ()
145−benchmark = defaultMain [
148+main = defaultMain [
146 env setupEnv $ \ ~(m11, m12, m21, m22, m31, m32) -> bgroup "Matrix Composition" [
149 env setupEnv $ \ ~(m11, m12, m21, m22, m31, m32) -> bgroup "Matrix Composition" [
147 bgroup "10x10" [
150 bgroup "10x10" [
148 bench "WHNF - 10x10" $ whnf (comp m11) m12
151 bench "WHNF - 10x10" $ whnf (comp m11) m12
@@ -155,14 +158,18 @@ benchmark = defaultMain [
155 bgroup "200x200" [
158 bgroup "200x200" [
156 bench "WHNF - 200x200" $ whnf (comp m31) m32
159 bench "WHNF - 200x200" $ whnf (comp m31) m32
157 , bench "NF - 200x200" $ nf (comp m31) m32
160 , bench "NF - 200x200" $ nf (comp m31) m32
161+ ],
162+ bgroup "200x200 - RULES" [
163+ bench "No rules - 200x200" $ nf (comp m21) iden
164+ , bench "Rules - 200x200" $ nf compId m21
158 ] ],
165 ] ],
159 env setupEnv2 $ \ ~(m21, m40, dist, dist2, dl1, dl2) -> bgroup "Matrix vs List - `select`" [
166 env setupEnv2 $ \ ~(m21, m40, dist, dist2, dl1, dl2) -> bgroup "Matrix vs List - `select`" [
160− bgroup "Distribution" [
167+ bgroup "Distribution `select` - 100+100 / 100x100" [
161 bench "List Distribution - Applicative version" $ nf (select dl1) dl2
168 bench "List Distribution - Applicative version" $ nf (select dl1) dl2
162 , bench "Matrix Distribution - Applicative version" $ nf (selectD2 dist) dist2
169 , bench "Matrix Distribution - Applicative version" $ nf (selectD2 dist) dist2
163 , bench "Matrix Distribution - Selective version" $ nf (selectD dist) dist2
170 , bench "Matrix Distribution - Selective version" $ nf (selectD dist) dist2
164 ],
171 ],
165− bgroup "Matrix `select`" [
172+ bgroup "Matrix `select` - 100x(100+100) / 100x100" [
166 bench "Applicative version" $ nf (selectM2 m40) m21
173 bench "Applicative version" $ nf (selectM2 m40) m21
167 , bench "Selective version" $ nf (selectM m40) m21
174 , bench "Selective version" $ nf (selectM m40) m21
168 ] ] ]
175 ] ] ]
hackage.shdeleted−10
@@ -1,10 +0,0 @@
1−#!/bin/sh
2−set -e
3−
4−dir=$(mktemp -d dist-docs.XXXXXX)
5−trap 'rm -r "$dir"' EXIT
6−
7−# assumes cabal 2.4 or later
8−cabal v2-haddock --builddir="$dir" --haddock-for-hackage --enable-doc
9−
10−cabal upload -d $dir/*-docs.tar.gz --publish
laop-0.1.0.0-docs.tar.gzdeleted

Binary file not shown.

laop.cabalnew file+89
@@ -0,0 +1,89 @@
1+cabal-version: 2.4
2+name: laop
3+version: 0.1.1.1
4+synopsis: Matrix programming library
5+description: Matrix programming library that uses a type-safe inductive definition
6+ inspired by the Linear Algebra of Programming
7+homepage: https://github.com/bolt12/laop
8+bug-reports: https://github.com/bolt12/laop/issues
9+license: MIT
10+license-file: LICENSE
11+author: Armando Santos
12+maintainer: Armando Santos <armandoifsantos@gmail.com>
13+copyright: 2020 Armando Santos
14+category: Data
15+build-type: Simple
16+extra-doc-files: README.md
17+ CHANGELOG.md
18+tested-with: GHC == 8.6.5
19+ GHC == 8.8.3
20+
21+source-repository head
22+ type: git
23+ location: https://github.com/bolt12/laop.git
24+
25+common common-options
26+ build-depends: base >= 4.12.0.0 && < 5,
27+ deepseq
28+
29+ ghc-options: -Wall
30+ -Wcompat
31+ -Widentities
32+ -Wincomplete-uni-patterns
33+ -Wincomplete-record-updates
34+ if impl(ghc >= 8.0)
35+ ghc-options: -Wredundant-constraints
36+ if impl(ghc >= 8.2)
37+ ghc-options: -fhide-source-paths
38+ if impl(ghc >= 8.4)
39+ ghc-options: -Wmissing-export-lists
40+ -Wpartial-fields
41+ if impl(ghc >= 8.8)
42+ ghc-options: -Wmissing-deriving-strategies
43+
44+ default-language: Haskell2010
45+
46+library
47+ import: common-options
48+ hs-source-dirs: src
49+ exposed-modules: LAoP.Dist
50+ LAoP.Dist.Internal
51+ LAoP.Matrix.Internal
52+ LAoP.Matrix.Nat
53+ LAoP.Matrix.Type
54+ LAoP.Relation
55+ LAoP.Relation.Internal
56+ LAoP.Utils
57+ LAoP.Utils.Internal
58+
59+test-suite laop-test
60+ import: common-options
61+ type: exitcode-stdio-1.0
62+ hs-source-dirs: test
63+ other-modules: Examples.Readme
64+ main-is: Spec.hs
65+ build-depends: laop
66+ ghc-options: -threaded
67+ -rtsopts
68+ -with-rtsopts=-N
69+ -funfolding-use-threshold=16
70+ -fexcess-precision
71+ -optc-O3
72+ -optc-ffast-math
73+
74+benchmark laop-benchmark
75+ import: common-options
76+ type: exitcode-stdio-1.0
77+ hs-source-dirs: benchmark
78+ main-is: Main.hs
79+ build-depends: criterion
80+ , QuickCheck
81+ , deepseq
82+ , laop
83+ ghc-options: -threaded
84+ -rtsopts
85+ -with-rtsopts=-N
86+ -funfolding-use-threshold=16
87+ -fexcess-precision
88+ -optc-O3
89+ -optc-ffast-math
package.yamldeleted−57
@@ -1,57 +0,0 @@
1−name: laop
2−version: 0.1.0.3
3−github: "bolt12/laop"
4−license: BSD3
5−author: "Armando Santos"
6−maintainer: "armandoifsantos@gmail.com"
7−copyright: "MIT"
8−
9−extra-source-files:
10−- README.md
11−- ChangeLog.md
12−
13−# Metadata used when publishing your package
14−# synopsis: Short description of your package
15−category: Data
16−
17−# To avoid duplicated efforts in documentation and dealing with the
18−# complications of embedding Haddock markup inside cabal files, it is
19−# common to point users to the README.md file.
20−description: Please see the README on GitHub at <https://github.com/bolt12/laop#readme>
21−
22−dependencies:
23−- base >= 4.7 && < 5
24−- deepseq
25−
26−library:
27− source-dirs: src
28−
29−executables:
30− laop-exe:
31− main: Main.hs
32− source-dirs: app
33− ghc-options:
34− - -threaded
35− - -rtsopts
36− - -with-rtsopts=-N
37− - -funfolding-use-threshold=16
38− - -fexcess-precision # Good for doubles
39− - -optc-O3 # Good for doubles
40− - -optc-ffast-math # Good for doubles
41− - -O # Optimize
42− dependencies:
43− - laop
44− - criterion
45− - deepseq
46− - QuickCheck
47−
48−tests:
49− laop-test:
50− main: Spec.hs
51− source-dirs: test
52− ghc-options:
53− - -threaded
54− - -rtsopts
55− - -with-rtsopts=-N
56− dependencies:
57− - laop
report.htmldeleted−1169
@@ -1,1169 +0,0 @@
1−<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2−<html>
3− <head>
4− <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5− <title>criterion report</title>
6− <script language="javascript" type="text/javascript">
7− /*! jQuery v3.3.1 | (c) JS Foundation and other contributors | jquery.org/license */
8−!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return"function"==typeof t&&"number"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement("script");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[c.call(e)]||"object":typeof e}var b="3.3.1",w=function(e,t){return new w.fn.init(e,t)},T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;w.fn=w.prototype={jquery:"3.3.1",constructor:w,length:0,toArray:function(){return o.call(this)},get:function(e){return null==e?o.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=w.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return w.each(this,e)},map:function(e){return this.pushStack(w.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(o.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:s,sort:n.sort,splice:n.splice},w.extend=w.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||g(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)n=a[t],a!==(r=e[t])&&(l&&r&&(w.isPlainObject(r)||(i=Array.isArray(r)))?(i?(i=!1,o=n&&Array.isArray(n)?n:[]):o=n&&w.isPlainObject(n)?n:{},a[t]=w.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},w.extend({expando:"jQuery"+("3.3.1"+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==c.call(e))&&(!(t=i(e))||"function"==typeof(n=f.call(t,"constructor")&&t.constructor)&&p.call(n)===d)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e){m(e)},each:function(e,t){var n,r=0;if(C(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},trim:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(C(Object(e))?w.merge(n,"string"==typeof e?[e]:e):s.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:u.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r,i=[],o=0,a=e.length,s=!n;o<a;o++)(r=!t(e[o],o))!==s&&i.push(e[o]);return i},map:function(e,t,n){var r,i,o=0,s=[];if(C(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&s.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&s.push(i);return a.apply([],s)},guid:1,support:h}),"function"==typeof Symbol&&(w.fn[Symbol.iterator]=n[Symbol.iterator]),w.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function C(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!g(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}var E=function(e){var t,n,r,i,o,a,s,u,l,c,f,p,d,h,g,y,v,m,x,b="sizzle"+1*new Date,w=e.document,T=0,C=0,E=ae(),k=ae(),S=ae(),D=function(e,t){return e===t&&(f=!0),0},N={}.hasOwnProperty,A=[],j=A.pop,q=A.push,L=A.push,H=A.slice,O=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},P="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",I="\\["+M+"*("+R+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+R+"))|)"+M+"*\\]",W=":("+R+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+I+")*)|.*)\\)|)",$=new RegExp(M+"+","g"),B=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),F=new RegExp("^"+M+"*,"+M+"*"),_=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),z=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),X=new RegExp(W),U=new RegExp("^"+R+"$"),V={ID:new RegExp("^#("+R+")"),CLASS:new RegExp("^\\.("+R+")"),TAG:new RegExp("^("+R+"|[*])"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},G=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Q=/^[^{]+\{\s*\[native \w/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/[+~]/,Z=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ee=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},te=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ne=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},re=function(){p()},ie=me(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{L.apply(A=H.call(w.childNodes),w.childNodes),A[w.childNodes.length].nodeType}catch(e){L={apply:A.length?function(e,t){q.apply(e,H.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function oe(e,t,r,i){var o,s,l,c,f,h,v,m=t&&t.ownerDocument,T=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==T&&9!==T&&11!==T)return r;if(!i&&((t?t.ownerDocument||t:w)!==d&&p(t),t=t||d,g)){if(11!==T&&(f=J.exec(e)))if(o=f[1]){if(9===T){if(!(l=t.getElementById(o)))return r;if(l.id===o)return r.push(l),r}else if(m&&(l=m.getElementById(o))&&x(t,l)&&l.id===o)return r.push(l),r}else{if(f[2])return L.apply(r,t.getElementsByTagName(e)),r;if((o=f[3])&&n.getElementsByClassName&&t.getElementsByClassName)return L.apply(r,t.getElementsByClassName(o)),r}if(n.qsa&&!S[e+" "]&&(!y||!y.test(e))){if(1!==T)m=t,v=e;else if("object"!==t.nodeName.toLowerCase()){(c=t.getAttribute("id"))?c=c.replace(te,ne):t.setAttribute("id",c=b),s=(h=a(e)).length;while(s--)h[s]="#"+c+" "+ve(h[s]);v=h.join(","),m=K.test(e)&&ge(t.parentNode)||t}if(v)try{return L.apply(r,m.querySelectorAll(v)),r}catch(e){}finally{c===b&&t.removeAttribute("id")}}}return u(e.replace(B,"$1"),t,r,i)}function ae(){var e=[];function t(n,i){return e.push(n+" ")>r.cacheLength&&delete t[e.shift()],t[n+" "]=i}return t}function se(e){return e[b]=!0,e}function ue(e){var t=d.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var n=e.split("|"),i=n.length;while(i--)r.attrHandle[n[i]]=t}function ce(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function fe(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function pe(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function de(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&ie(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function he(e){return se(function(t){return t=+t,se(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function ge(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}n=oe.support={},o=oe.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},p=oe.setDocument=function(e){var t,i,a=e?e.ownerDocument||e:w;return a!==d&&9===a.nodeType&&a.documentElement?(d=a,h=d.documentElement,g=!o(d),w!==d&&(i=d.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",re,!1):i.attachEvent&&i.attachEvent("onunload",re)),n.attributes=ue(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=ue(function(e){return e.appendChild(d.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=Q.test(d.getElementsByClassName),n.getById=ue(function(e){return h.appendChild(e).id=b,!d.getElementsByName||!d.getElementsByName(b).length}),n.getById?(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){return e.getAttribute("id")===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n=t.getElementById(e);return n?[n]:[]}}):(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){var n="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&g)return t.getElementsByClassName(e)},v=[],y=[],(n.qsa=Q.test(d.querySelectorAll))&&(ue(function(e){h.appendChild(e).innerHTML="<a id='"+b+"'></a><select id='"+b+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&y.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||y.push("\\["+M+"*(?:value|"+P+")"),e.querySelectorAll("[id~="+b+"-]").length||y.push("~="),e.querySelectorAll(":checked").length||y.push(":checked"),e.querySelectorAll("a#"+b+"+*").length||y.push(".#.+[+~]")}),ue(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=d.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&y.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&y.push(":enabled",":disabled"),h.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&y.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),y.push(",.*:")})),(n.matchesSelector=Q.test(m=h.matches||h.webkitMatchesSelector||h.mozMatchesSelector||h.oMatchesSelector||h.msMatchesSelector))&&ue(function(e){n.disconnectedMatch=m.call(e,"*"),m.call(e,"[s!='']:x"),v.push("!=",W)}),y=y.length&&new RegExp(y.join("|")),v=v.length&&new RegExp(v.join("|")),t=Q.test(h.compareDocumentPosition),x=t||Q.test(h.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return f=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r||(1&(r=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!n.sortDetached&&t.compareDocumentPosition(e)===r?e===d||e.ownerDocument===w&&x(w,e)?-1:t===d||t.ownerDocument===w&&x(w,t)?1:c?O(c,e)-O(c,t):0:4&r?-1:1)}:function(e,t){if(e===t)return f=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===d?-1:t===d?1:i?-1:o?1:c?O(c,e)-O(c,t):0;if(i===o)return ce(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?ce(a[r],s[r]):a[r]===w?-1:s[r]===w?1:0},d):d},oe.matches=function(e,t){return oe(e,null,null,t)},oe.matchesSelector=function(e,t){if((e.ownerDocument||e)!==d&&p(e),t=t.replace(z,"='$1']"),n.matchesSelector&&g&&!S[t+" "]&&(!v||!v.test(t))&&(!y||!y.test(t)))try{var r=m.call(e,t);if(r||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return oe(t,d,null,[e]).length>0},oe.contains=function(e,t){return(e.ownerDocument||e)!==d&&p(e),x(e,t)},oe.attr=function(e,t){(e.ownerDocument||e)!==d&&p(e);var i=r.attrHandle[t.toLowerCase()],o=i&&N.call(r.attrHandle,t.toLowerCase())?i(e,t,!g):void 0;return void 0!==o?o:n.attributes||!g?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},oe.escape=function(e){return(e+"").replace(te,ne)},oe.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},oe.uniqueSort=function(e){var t,r=[],i=0,o=0;if(f=!n.detectDuplicates,c=!n.sortStable&&e.slice(0),e.sort(D),f){while(t=e[o++])t===e[o]&&(i=r.push(o));while(i--)e.splice(r[i],1)}return c=null,e},i=oe.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(3===o||4===o)return e.nodeValue}else while(t=e[r++])n+=i(t);return n},(r=oe.selectors={cacheLength:50,createPseudo:se,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Z,ee),e[3]=(e[3]||e[4]||e[5]||"").replace(Z,ee),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||oe.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&oe.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return V.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=a(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Z,ee).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&E(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=oe.attr(r,e);return null==i?"!="===t:!t||(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i.replace($," ")+" ").indexOf(n)>-1:"|="===t&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,d,h,g=o!==a?"nextSibling":"previousSibling",y=t.parentNode,v=s&&t.nodeName.toLowerCase(),m=!u&&!s,x=!1;if(y){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===v:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?y.firstChild:y.lastChild],a&&m){x=(d=(l=(c=(f=(p=y)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1])&&l[2],p=d&&y.childNodes[d];while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if(1===p.nodeType&&++x&&p===t){c[e]=[T,d,x];break}}else if(m&&(x=d=(l=(c=(f=(p=t)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1]),!1===x)while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===v:1===p.nodeType)&&++x&&(m&&((c=(f=p[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]=[T,x]),p===t))break;return(x-=i)===r||x%r==0&&x/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||oe.error("unsupported pseudo: "+e);return i[b]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?se(function(e,n){var r,o=i(e,t),a=o.length;while(a--)e[r=O(e,o[a])]=!(n[r]=o[a])}):function(e){return i(e,0,n)}):i}},pseudos:{not:se(function(e){var t=[],n=[],r=s(e.replace(B,"$1"));return r[b]?se(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:se(function(e){return function(t){return oe(e,t).length>0}}),contains:se(function(e){return e=e.replace(Z,ee),function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:se(function(e){return U.test(e||"")||oe.error("unsupported lang: "+e),e=e.replace(Z,ee).toLowerCase(),function(t){var n;do{if(n=g?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===h},focus:function(e){return e===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:de(!1),disabled:de(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!r.pseudos.empty(e)},header:function(e){return Y.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:he(function(){return[0]}),last:he(function(e,t){return[t-1]}),eq:he(function(e,t,n){return[n<0?n+t:n]}),even:he(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:he(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:he(function(e,t,n){for(var r=n<0?n+t:n;--r>=0;)e.push(r);return e}),gt:he(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}}).pseudos.nth=r.pseudos.eq;for(t in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})r.pseudos[t]=fe(t);for(t in{submit:!0,reset:!0})r.pseudos[t]=pe(t);function ye(){}ye.prototype=r.filters=r.pseudos,r.setFilters=new ye,a=oe.tokenize=function(e,t){var n,i,o,a,s,u,l,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,u=[],l=r.preFilter;while(s){n&&!(i=F.exec(s))||(i&&(s=s.slice(i[0].length)||s),u.push(o=[])),n=!1,(i=_.exec(s))&&(n=i.shift(),o.push({value:n,type:i[0].replace(B," ")}),s=s.slice(n.length));for(a in r.filter)!(i=V[a].exec(s))||l[a]&&!(i=l[a](i))||(n=i.shift(),o.push({value:n,type:a,matches:i}),s=s.slice(n.length));if(!n)break}return t?s.length:s?oe.error(e):k(e,u).slice(0)};function ve(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function me(e,t,n){var r=t.dir,i=t.next,o=i||r,a=n&&"parentNode"===o,s=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||a)return e(t,n,i);return!1}:function(t,n,u){var l,c,f,p=[T,s];if(u){while(t=t[r])if((1===t.nodeType||a)&&e(t,n,u))return!0}else while(t=t[r])if(1===t.nodeType||a)if(f=t[b]||(t[b]={}),c=f[t.uniqueID]||(f[t.uniqueID]={}),i&&i===t.nodeName.toLowerCase())t=t[r]||t;else{if((l=c[o])&&l[0]===T&&l[1]===s)return p[2]=l[2];if(c[o]=p,p[2]=e(t,n,u))return!0}return!1}}function xe(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function be(e,t,n){for(var r=0,i=t.length;r<i;r++)oe(e,t[r],n);return n}function we(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s<u;s++)(o=e[s])&&(n&&!n(o,r,i)||(a.push(o),l&&t.push(s)));return a}function Te(e,t,n,r,i,o){return r&&!r[b]&&(r=Te(r)),i&&!i[b]&&(i=Te(i,o)),se(function(o,a,s,u){var l,c,f,p=[],d=[],h=a.length,g=o||be(t||"*",s.nodeType?[s]:s,[]),y=!e||!o&&t?g:we(g,p,e,s,u),v=n?i||(o?e:h||r)?[]:a:y;if(n&&n(y,v,s,u),r){l=we(v,d),r(l,[],s,u),c=l.length;while(c--)(f=l[c])&&(v[d[c]]=!(y[d[c]]=f))}if(o){if(i||e){if(i){l=[],c=v.length;while(c--)(f=v[c])&&l.push(y[c]=f);i(null,v=[],l,u)}c=v.length;while(c--)(f=v[c])&&(l=i?O(o,f):p[c])>-1&&(o[l]=!(a[l]=f))}}else v=we(v===a?v.splice(h,v.length):v),i?i(null,a,v,u):L.apply(a,v)})}function Ce(e){for(var t,n,i,o=e.length,a=r.relative[e[0].type],s=a||r.relative[" "],u=a?1:0,c=me(function(e){return e===t},s,!0),f=me(function(e){return O(t,e)>-1},s,!0),p=[function(e,n,r){var i=!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):f(e,n,r));return t=null,i}];u<o;u++)if(n=r.relative[e[u].type])p=[me(xe(p),n)];else{if((n=r.filter[e[u].type].apply(null,e[u].matches))[b]){for(i=++u;i<o;i++)if(r.relative[e[i].type])break;return Te(u>1&&xe(p),u>1&&ve(e.slice(0,u-1).concat({value:" "===e[u-2].type?"*":""})).replace(B,"$1"),n,u<i&&Ce(e.slice(u,i)),i<o&&Ce(e=e.slice(i)),i<o&&ve(e))}p.push(n)}return xe(p)}function Ee(e,t){var n=t.length>0,i=e.length>0,o=function(o,a,s,u,c){var f,h,y,v=0,m="0",x=o&&[],b=[],w=l,C=o||i&&r.find.TAG("*",c),E=T+=null==w?1:Math.random()||.1,k=C.length;for(c&&(l=a===d||a||c);m!==k&&null!=(f=C[m]);m++){if(i&&f){h=0,a||f.ownerDocument===d||(p(f),s=!g);while(y=e[h++])if(y(f,a||d,s)){u.push(f);break}c&&(T=E)}n&&((f=!y&&f)&&v--,o&&x.push(f))}if(v+=m,n&&m!==v){h=0;while(y=t[h++])y(x,b,a,s);if(o){if(v>0)while(m--)x[m]||b[m]||(b[m]=j.call(u));b=we(b)}L.apply(u,b),c&&!o&&b.length>0&&v+t.length>1&&oe.uniqueSort(u)}return c&&(T=E,l=w),x};return n?se(o):o}return s=oe.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=a(e)),n=t.length;while(n--)(o=Ce(t[n]))[b]?r.push(o):i.push(o);(o=S(e,Ee(i,r))).selector=e}return o},u=oe.select=function(e,t,n,i){var o,u,l,c,f,p="function"==typeof e&&e,d=!i&&a(e=p.selector||e);if(n=n||[],1===d.length){if((u=d[0]=d[0].slice(0)).length>2&&"ID"===(l=u[0]).type&&9===t.nodeType&&g&&r.relative[u[1].type]){if(!(t=(r.find.ID(l.matches[0].replace(Z,ee),t)||[])[0]))return n;p&&(t=t.parentNode),e=e.slice(u.shift().value.length)}o=V.needsContext.test(e)?0:u.length;while(o--){if(l=u[o],r.relative[c=l.type])break;if((f=r.find[c])&&(i=f(l.matches[0].replace(Z,ee),K.test(u[0].type)&&ge(t.parentNode)||t))){if(u.splice(o,1),!(e=i.length&&ve(u)))return L.apply(n,i),n;break}}}return(p||s(e,d))(i,t,!g,n,!t||K.test(e)&&ge(t.parentNode)||t),n},n.sortStable=b.split("").sort(D).join("")===b,n.detectDuplicates=!!f,p(),n.sortDetached=ue(function(e){return 1&e.compareDocumentPosition(d.createElement("fieldset"))}),ue(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||le("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),n.attributes&&ue(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||le("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ue(function(e){return null==e.getAttribute("disabled")})||le(P,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),oe}(e);w.find=E,w.expr=E.selectors,w.expr[":"]=w.expr.pseudos,w.uniqueSort=w.unique=E.uniqueSort,w.text=E.getText,w.isXMLDoc=E.isXML,w.contains=E.contains,w.escapeSelector=E.escape;var k=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&w(e).is(n))break;r.push(e)}return r},S=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},D=w.expr.match.needsContext;function N(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var A=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,t,n){return g(t)?w.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?w.grep(e,function(e){return e===t!==n}):"string"!=typeof t?w.grep(e,function(e){return u.call(t,e)>-1!==n}):w.filter(t,e,n)}w.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?w.find.matchesSelector(r,e)?[r]:[]:w.find.matches(e,w.grep(t,function(e){return 1===e.nodeType}))},w.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(w(e).filter(function(){for(t=0;t<r;t++)if(w.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)w.find(e,i[t],n);return r>1?w.uniqueSort(n):n},filter:function(e){return this.pushStack(j(this,e||[],!1))},not:function(e){return this.pushStack(j(this,e||[],!0))},is:function(e){return!!j(this,"string"==typeof e&&D.test(e)?w(e):e||[],!1).length}});var q,L=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(w.fn.init=function(e,t,n){var i,o;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:L.exec(e))||!i[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof w?t[0]:t,w.merge(this,w.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:r,!0)),A.test(i[1])&&w.isPlainObject(t))for(i in t)g(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}return(o=r.getElementById(i[2]))&&(this[0]=o,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):g(e)?void 0!==n.ready?n.ready(e):e(w):w.makeArray(e,this)}).prototype=w.fn,q=w(r);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};w.fn.extend({has:function(e){var t=w(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(w.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&w(e);if(!D.test(e))for(;r<i;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?a.index(n)>-1:1===n.nodeType&&w.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?w.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?u.call(w(e),this[0]):u.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(w.uniqueSort(w.merge(this.get(),w(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}w.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return k(e,"parentNode")},parentsUntil:function(e,t,n){return k(e,"parentNode",n)},next:function(e){return P(e,"nextSibling")},prev:function(e){return P(e,"previousSibling")},nextAll:function(e){return k(e,"nextSibling")},prevAll:function(e){return k(e,"previousSibling")},nextUntil:function(e,t,n){return k(e,"nextSibling",n)},prevUntil:function(e,t,n){return k(e,"previousSibling",n)},siblings:function(e){return S((e.parentNode||{}).firstChild,e)},children:function(e){return S(e.firstChild)},contents:function(e){return N(e,"iframe")?e.contentDocument:(N(e,"template")&&(e=e.content||e),w.merge([],e.childNodes))}},function(e,t){w.fn[e]=function(n,r){var i=w.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=w.filter(r,i)),this.length>1&&(O[e]||w.uniqueSort(i),H.test(e)&&i.reverse()),this.pushStack(i)}});var M=/[^\x20\t\r\n\f]+/g;function R(e){var t={};return w.each(e.match(M)||[],function(e,n){t[n]=!0}),t}w.Callbacks=function(e){e="string"==typeof e?R(e):w.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1){n=a.shift();while(++s<o.length)!1===o[s].apply(n[0],n[1])&&e.stopOnFalse&&(s=o.length,n=!1)}e.memory||(n=!1),t=!1,i&&(o=n?[]:"")},l={add:function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){w.each(n,function(n,r){g(r)?e.unique&&l.has(r)||o.push(r):r&&r.length&&"string"!==x(r)&&t(r)})}(arguments),n&&!t&&u()),this},remove:function(){return w.each(arguments,function(e,t){var n;while((n=w.inArray(t,o,n))>-1)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?w.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=[e,(n=n||[]).slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l};function I(e){return e}function W(e){throw e}function $(e,t,n,r){var i;try{e&&g(i=e.promise)?i.call(e).done(t).fail(n):e&&g(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}w.extend({Deferred:function(t){var n=[["notify","progress",w.Callbacks("memory"),w.Callbacks("memory"),2],["resolve","done",w.Callbacks("once memory"),w.Callbacks("once memory"),0,"resolved"],["reject","fail",w.Callbacks("once memory"),w.Callbacks("once memory"),1,"rejected"]],r="pending",i={state:function(){return r},always:function(){return o.done(arguments).fail(arguments),this},"catch":function(e){return i.then(null,e)},pipe:function(){var e=arguments;return w.Deferred(function(t){w.each(n,function(n,r){var i=g(e[r[4]])&&e[r[4]];o[r[1]](function(){var e=i&&i.apply(this,arguments);e&&g(e.promise)?e.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(t,r,i){var o=0;function a(t,n,r,i){return function(){var s=this,u=arguments,l=function(){var e,l;if(!(t<o)){if((e=r.apply(s,u))===n.promise())throw new TypeError("Thenable self-resolution");l=e&&("object"==typeof e||"function"==typeof e)&&e.then,g(l)?i?l.call(e,a(o,n,I,i),a(o,n,W,i)):(o++,l.call(e,a(o,n,I,i),a(o,n,W,i),a(o,n,I,n.notifyWith))):(r!==I&&(s=void 0,u=[e]),(i||n.resolveWith)(s,u))}},c=i?l:function(){try{l()}catch(e){w.Deferred.exceptionHook&&w.Deferred.exceptionHook(e,c.stackTrace),t+1>=o&&(r!==W&&(s=void 0,u=[e]),n.rejectWith(s,u))}};t?c():(w.Deferred.getStackHook&&(c.stackTrace=w.Deferred.getStackHook()),e.setTimeout(c))}}return w.Deferred(function(e){n[0][3].add(a(0,e,g(i)?i:I,e.notifyWith)),n[1][3].add(a(0,e,g(t)?t:I)),n[2][3].add(a(0,e,g(r)?r:W))}).promise()},promise:function(e){return null!=e?w.extend(e,i):i}},o={};return w.each(n,function(e,t){var a=t[2],s=t[5];i[t[1]]=a.add,s&&a.add(function(){r=s},n[3-e][2].disable,n[3-e][3].disable,n[0][2].lock,n[0][3].lock),a.add(t[3].fire),o[t[0]]=function(){return o[t[0]+"With"](this===o?void 0:this,arguments),this},o[t[0]+"With"]=a.fireWith}),i.promise(o),t&&t.call(o,o),o},when:function(e){var t=arguments.length,n=t,r=Array(n),i=o.call(arguments),a=w.Deferred(),s=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?o.call(arguments):n,--t||a.resolveWith(r,i)}};if(t<=1&&($(e,a.done(s(n)).resolve,a.reject,!t),"pending"===a.state()||g(i[n]&&i[n].then)))return a.then();while(n--)$(i[n],s(n),a.reject);return a.promise()}});var B=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;w.Deferred.exceptionHook=function(t,n){e.console&&e.console.warn&&t&&B.test(t.name)&&e.console.warn("jQuery.Deferred exception: "+t.message,t.stack,n)},w.readyException=function(t){e.setTimeout(function(){throw t})};var F=w.Deferred();w.fn.ready=function(e){return F.then(e)["catch"](function(e){w.readyException(e)}),this},w.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--w.readyWait:w.isReady)||(w.isReady=!0,!0!==e&&--w.readyWait>0||F.resolveWith(r,[w]))}}),w.ready.then=F.then;function _(){r.removeEventListener("DOMContentLoaded",_),e.removeEventListener("load",_),w.ready()}"complete"===r.readyState||"loading"!==r.readyState&&!r.documentElement.doScroll?e.setTimeout(w.ready):(r.addEventListener("DOMContentLoaded",_),e.addEventListener("load",_));var z=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===x(n)){i=!0;for(s in n)z(e,t,s,n[s],!0,o,a)}else if(void 0!==r&&(i=!0,g(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(w(e),n)})),t))for(;s<u;s++)t(e[s],n,a?r:r.call(e[s],s,t(e[s],n)));return i?e:l?t.call(e):u?t(e[0],n):o},X=/^-ms-/,U=/-([a-z])/g;function V(e,t){return t.toUpperCase()}function G(e){return e.replace(X,"ms-").replace(U,V)}var Y=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};function Q(){this.expando=w.expando+Q.uid++}Q.uid=1,Q.prototype={cache:function(e){var t=e[this.expando];return t||(t={},Y(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[G(t)]=n;else for(r in t)i[G(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][G(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){n=(t=Array.isArray(t)?t.map(G):(t=G(t))in r?[t]:t.match(M)||[]).length;while(n--)delete r[t[n]]}(void 0===t||w.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!w.isEmptyObject(t)}};var J=new Q,K=new Q,Z=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,ee=/[A-Z]/g;function te(e){return"true"===e||"false"!==e&&("null"===e?null:e===+e+""?+e:Z.test(e)?JSON.parse(e):e)}function ne(e,t,n){var r;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(ee,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n=te(n)}catch(e){}K.set(e,t,n)}else n=void 0;return n}w.extend({hasData:function(e){return K.hasData(e)||J.hasData(e)},data:function(e,t,n){return K.access(e,t,n)},removeData:function(e,t){K.remove(e,t)},_data:function(e,t,n){return J.access(e,t,n)},_removeData:function(e,t){J.remove(e,t)}}),w.fn.extend({data:function(e,t){var n,r,i,o=this[0],a=o&&o.attributes;if(void 0===e){if(this.length&&(i=K.get(o),1===o.nodeType&&!J.get(o,"hasDataAttrs"))){n=a.length;while(n--)a[n]&&0===(r=a[n].name).indexOf("data-")&&(r=G(r.slice(5)),ne(o,r,i[r]));J.set(o,"hasDataAttrs",!0)}return i}return"object"==typeof e?this.each(function(){K.set(this,e)}):z(this,function(t){var n;if(o&&void 0===t){if(void 0!==(n=K.get(o,e)))return n;if(void 0!==(n=ne(o,e)))return n}else this.each(function(){K.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){K.remove(this,e)})}}),w.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=J.get(e,t),n&&(!r||Array.isArray(n)?r=J.access(e,t,w.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=w.queue(e,t),r=n.length,i=n.shift(),o=w._queueHooks(e,t),a=function(){w.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return J.get(e,n)||J.access(e,n,{empty:w.Callbacks("once memory").add(function(){J.remove(e,[t+"queue",n])})})}}),w.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length<n?w.queue(this[0],e):void 0===t?this:this.each(function(){var n=w.queue(this,e,t);w._queueHooks(this,e),"fx"===e&&"inprogress"!==n[0]&&w.dequeue(this,e)})},dequeue:function(e){return this.each(function(){w.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=w.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};"string"!=typeof e&&(t=e,e=void 0),e=e||"fx";while(a--)(n=J.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var re=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ie=new RegExp("^(?:([+-])=|)("+re+")([a-z%]*)$","i"),oe=["Top","Right","Bottom","Left"],ae=function(e,t){return"none"===(e=t||e).style.display||""===e.style.display&&w.contains(e.ownerDocument,e)&&"none"===w.css(e,"display")},se=function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i};function ue(e,t,n,r){var i,o,a=20,s=r?function(){return r.cur()}:function(){return w.css(e,t,"")},u=s(),l=n&&n[3]||(w.cssNumber[t]?"":"px"),c=(w.cssNumber[t]||"px"!==l&&+u)&&ie.exec(w.css(e,t));if(c&&c[3]!==l){u/=2,l=l||c[3],c=+u||1;while(a--)w.style(e,t,c+l),(1-o)*(1-(o=s()/u||.5))<=0&&(a=0),c/=o;c*=2,w.style(e,t,c+l),n=n||[]}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}var le={};function ce(e){var t,n=e.ownerDocument,r=e.nodeName,i=le[r];return i||(t=n.body.appendChild(n.createElement(r)),i=w.css(t,"display"),t.parentNode.removeChild(t),"none"===i&&(i="block"),le[r]=i,i)}function fe(e,t){for(var n,r,i=[],o=0,a=e.length;o<a;o++)(r=e[o]).style&&(n=r.style.display,t?("none"===n&&(i[o]=J.get(r,"display")||null,i[o]||(r.style.display="")),""===r.style.display&&ae(r)&&(i[o]=ce(r))):"none"!==n&&(i[o]="none",J.set(r,"display",n)));for(o=0;o<a;o++)null!=i[o]&&(e[o].style.display=i[o]);return e}w.fn.extend({show:function(){return fe(this,!0)},hide:function(){return fe(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){ae(this)?w(this).show():w(this).hide()})}});var pe=/^(?:checkbox|radio)$/i,de=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ge.optgroup=ge.option,ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td;function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&N(e,t)?w.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n<r;n++)J.set(e[n],"globalEval",!t||J.get(t[n],"globalEval"))}var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d<h;d++)if((o=e[d])||0===o)if("object"===x(o))w.merge(p,o.nodeType?[o]:o);else if(me.test(o)){a=a||f.appendChild(t.createElement("div")),s=(de.exec(o)||["",""])[1].toLowerCase(),u=ge[s]||ge._default,a.innerHTML=u[1]+w.htmlPrefilter(o)+u[2],c=u[0];while(c--)a=a.lastChild;w.merge(p,a.childNodes),(a=f.firstChild).textContent=""}else p.push(t.createTextNode(o));f.textContent="",d=0;while(o=p[d++])if(r&&w.inArray(o,r)>-1)i&&i.push(o);else if(l=w.contains(o.ownerDocument,o),a=ye(f.appendChild(o),"script"),l&&ve(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}!function(){var e=r.createDocumentFragment().appendChild(r.createElement("div")),t=r.createElement("input");t.setAttribute("type","radio"),t.setAttribute("checked","checked"),t.setAttribute("name","t"),e.appendChild(t),h.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML="<textarea>x</textarea>",h.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var be=r.documentElement,we=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ce=/^([^.]*)(?:\.(.+)|)/;function Ee(){return!0}function ke(){return!1}function Se(){try{return r.activeElement}catch(e){}}function De(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)De(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=ke;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return w().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=w.guid++)),e.each(function(){w.event.add(this,t,i,r,n)})}w.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.get(e);if(y){n.handler&&(n=(o=n).handler,i=o.selector),i&&w.find.matchesSelector(be,i),n.guid||(n.guid=w.guid++),(u=y.events)||(u=y.events={}),(a=y.handle)||(a=y.handle=function(t){return"undefined"!=typeof w&&w.event.triggered!==t.type?w.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||"").match(M)||[""]).length;while(l--)d=g=(s=Ce.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=w.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=w.event.special[d]||{},c=w.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&w.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(d,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),w.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.hasData(e)&&J.get(e);if(y&&(u=y.events)){l=(t=(t||"").match(M)||[""]).length;while(l--)if(s=Ce.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){f=w.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,y.handle)||w.removeEvent(e,d,y.handle),delete u[d])}else for(d in u)w.event.remove(e,d+t[l],n,r,!0);w.isEmptyObject(u)&&J.remove(e,"handle events")}},dispatch:function(e){var t=w.event.fix(e),n,r,i,o,a,s,u=new Array(arguments.length),l=(J.get(this,"events")||{})[t.type]||[],c=w.event.special[t.type]||{};for(u[0]=t,n=1;n<arguments.length;n++)u[n]=arguments[n];if(t.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,t)){s=w.event.handlers.call(this,t,l),n=0;while((o=s[n++])&&!t.isPropagationStopped()){t.currentTarget=o.elem,r=0;while((a=o.handlers[r++])&&!t.isImmediatePropagationStopped())t.rnamespace&&!t.rnamespace.test(a.namespace)||(t.handleObj=a,t.data=a.data,void 0!==(i=((w.event.special[a.origType]||{}).handle||a.handler).apply(o.elem,u))&&!1===(t.result=i)&&(t.preventDefault(),t.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,t),t.result}},handlers:function(e,t){var n,r,i,o,a,s=[],u=t.delegateCount,l=e.target;if(u&&l.nodeType&&!("click"===e.type&&e.button>=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n<u;n++)void 0===a[i=(r=t[n]).selector+" "]&&(a[i]=r.needsContext?w(i,this).index(l)>-1:w.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u<t.length&&s.push({elem:l,handlers:t.slice(u)}),s},addProp:function(e,t){Object.defineProperty(w.Event.prototype,e,{enumerable:!0,configurable:!0,get:g(t)?function(){if(this.originalEvent)return t(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[e]},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})},fix:function(e){return e[w.expando]?e:new w.Event(e)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==Se()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===Se()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&N(this,"input"))return this.click(),!1},_default:function(e){return N(e.target,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},w.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},w.Event=function(e,t){if(!(this instanceof w.Event))return new w.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?Ee:ke,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&w.extend(this,t),this.timeStamp=e&&e.timeStamp||Date.now(),this[w.expando]=!0},w.Event.prototype={constructor:w.Event,isDefaultPrevented:ke,isPropagationStopped:ke,isImmediatePropagationStopped:ke,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=Ee,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=Ee,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=Ee,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},w.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,"char":!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(e){var t=e.button;return null==e.which&&we.test(e.type)?null!=e.charCode?e.charCode:e.keyCode:!e.which&&void 0!==t&&Te.test(e.type)?1&t?1:2&t?3:4&t?2:0:e.which}},w.event.addProp),w.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,t){w.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return i&&(i===r||w.contains(r,i))||(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),w.fn.extend({on:function(e,t,n,r){return De(this,e,t,n,r)},one:function(e,t,n,r){return De(this,e,t,n,r,1)},off:function(e,t,n){var r,i;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,w(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof e){for(i in e)this.off(i,t,e[i]);return this}return!1!==t&&"function"!=typeof t||(n=t,t=void 0),!1===n&&(n=ke),this.each(function(){w.event.remove(this,e,n,t)})}});var Ne=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,Ae=/<script|<style|<link/i,je=/checked\s*(?:[^=]|=\s*.checked.)/i,qe=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function Le(e,t){return N(e,"table")&&N(11!==t.nodeType?t:t.firstChild,"tr")?w(e).children("tbody")[0]||e:e}function He(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Oe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Pe(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(J.hasData(e)&&(o=J.access(e),a=J.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n<r;n++)w.event.add(t,i,l[i][n])}K.hasData(e)&&(s=K.access(e),u=w.extend({},s),K.set(t,u))}}function Me(e,t){var n=t.nodeName.toLowerCase();"input"===n&&pe.test(e.type)?t.checked=e.checked:"input"!==n&&"textarea"!==n||(t.defaultValue=e.defaultValue)}function Re(e,t,n,r){t=a.apply([],t);var i,o,s,u,l,c,f=0,p=e.length,d=p-1,y=t[0],v=g(y);if(v||p>1&&"string"==typeof y&&!h.checkClone&&je.test(y))return e.each(function(i){var o=e.eq(i);v&&(t[0]=y.call(this,i,o.html())),Re(o,t,n,r)});if(p&&(i=xe(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(u=(s=w.map(ye(i,"script"),He)).length;f<p;f++)l=i,f!==d&&(l=w.clone(l,!0,!0),u&&w.merge(s,ye(l,"script"))),n.call(e[f],l,f);if(u)for(c=s[s.length-1].ownerDocument,w.map(s,Oe),f=0;f<u;f++)l=s[f],he.test(l.type||"")&&!J.access(l,"globalEval")&&w.contains(c,l)&&(l.src&&"module"!==(l.type||"").toLowerCase()?w._evalUrl&&w._evalUrl(l.src):m(l.textContent.replace(qe,""),c,l))}return e}function Ie(e,t,n){for(var r,i=t?w.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||w.cleanData(ye(r)),r.parentNode&&(n&&w.contains(r.ownerDocument,r)&&ve(ye(r,"script")),r.parentNode.removeChild(r));return e}w.extend({htmlPrefilter:function(e){return e.replace(Ne,"<$1></$2>")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=w.contains(e.ownerDocument,e);if(!(h.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||w.isXMLDoc(e)))for(a=ye(s),r=0,i=(o=ye(e)).length;r<i;r++)Me(o[r],a[r]);if(t)if(n)for(o=o||ye(e),a=a||ye(s),r=0,i=o.length;r<i;r++)Pe(o[r],a[r]);else Pe(e,s);return(a=ye(s,"script")).length>0&&ve(a,!u&&ye(e,"script")),s},cleanData:function(e){for(var t,n,r,i=w.event.special,o=0;void 0!==(n=e[o]);o++)if(Y(n)){if(t=n[J.expando]){if(t.events)for(r in t.events)i[r]?w.event.remove(n,r):w.removeEvent(n,r,t.handle);n[J.expando]=void 0}n[K.expando]&&(n[K.expando]=void 0)}}}),w.fn.extend({detach:function(e){return Ie(this,e,!0)},remove:function(e){return Ie(this,e)},text:function(e){return z(this,function(e){return void 0===e?w.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Re(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Le(this,e).appendChild(e)})},prepend:function(){return Re(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Le(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(w.cleanData(ye(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return w.clone(this,e,t)})},html:function(e){return z(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ae.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=w.htmlPrefilter(e);try{for(;n<r;n++)1===(t=this[n]||{}).nodeType&&(w.cleanData(ye(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=[];return Re(this,arguments,function(t){var n=this.parentNode;w.inArray(this,e)<0&&(w.cleanData(ye(this)),n&&n.replaceChild(t,this))},e)}}),w.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){w.fn[e]=function(e){for(var n,r=[],i=w(e),o=i.length-1,a=0;a<=o;a++)n=a===o?this:this.clone(!0),w(i[a])[t](n),s.apply(r,n.get());return this.pushStack(r)}});var We=new RegExp("^("+re+")(?!px)[a-z%]+$","i"),$e=function(t){var n=t.ownerDocument.defaultView;return n&&n.opener||(n=e),n.getComputedStyle(t)},Be=new RegExp(oe.join("|"),"i");!function(){function t(){if(c){l.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",c.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",be.appendChild(l).appendChild(c);var t=e.getComputedStyle(c);i="1%"!==t.top,u=12===n(t.marginLeft),c.style.right="60%",s=36===n(t.right),o=36===n(t.width),c.style.position="absolute",a=36===c.offsetWidth||"absolute",be.removeChild(l),c=null}}function n(e){return Math.round(parseFloat(e))}var i,o,a,s,u,l=r.createElement("div"),c=r.createElement("div");c.style&&(c.style.backgroundClip="content-box",c.cloneNode(!0).style.backgroundClip="",h.clearCloneStyle="content-box"===c.style.backgroundClip,w.extend(h,{boxSizingReliable:function(){return t(),o},pixelBoxStyles:function(){return t(),s},pixelPosition:function(){return t(),i},reliableMarginLeft:function(){return t(),u},scrollboxSize:function(){return t(),a}}))}();function Fe(e,t,n){var r,i,o,a,s=e.style;return(n=n||$e(e))&&(""!==(a=n.getPropertyValue(t)||n[t])||w.contains(e.ownerDocument,e)||(a=w.style(e,t)),!h.pixelBoxStyles()&&We.test(a)&&Be.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o)),void 0!==a?a+"":a}function _e(e,t){return{get:function(){if(!e())return(this.get=t).apply(this,arguments);delete this.get}}}var ze=/^(none|table(?!-c[ea]).+)/,Xe=/^--/,Ue={position:"absolute",visibility:"hidden",display:"block"},Ve={letterSpacing:"0",fontWeight:"400"},Ge=["Webkit","Moz","ms"],Ye=r.createElement("div").style;function Qe(e){if(e in Ye)return e;var t=e[0].toUpperCase()+e.slice(1),n=Ge.length;while(n--)if((e=Ge[n]+t)in Ye)return e}function Je(e){var t=w.cssProps[e];return t||(t=w.cssProps[e]=Qe(e)||e),t}function Ke(e,t,n){var r=ie.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function Ze(e,t,n,r,i,o){var a="width"===t?1:0,s=0,u=0;if(n===(r?"border":"content"))return 0;for(;a<4;a+=2)"margin"===n&&(u+=w.css(e,n+oe[a],!0,i)),r?("content"===n&&(u-=w.css(e,"padding"+oe[a],!0,i)),"margin"!==n&&(u-=w.css(e,"border"+oe[a]+"Width",!0,i))):(u+=w.css(e,"padding"+oe[a],!0,i),"padding"!==n?u+=w.css(e,"border"+oe[a]+"Width",!0,i):s+=w.css(e,"border"+oe[a]+"Width",!0,i));return!r&&o>=0&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))),u}function et(e,t,n){var r=$e(e),i=Fe(e,t,r),o="border-box"===w.css(e,"boxSizing",!1,r),a=o;if(We.test(i)){if(!n)return i;i="auto"}return a=a&&(h.boxSizingReliable()||i===e.style[t]),("auto"===i||!parseFloat(i)&&"inline"===w.css(e,"display",!1,r))&&(i=e["offset"+t[0].toUpperCase()+t.slice(1)],a=!0),(i=parseFloat(i)||0)+Ze(e,t,n||(o?"border":"content"),a,r,i)+"px"}w.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Fe(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=G(t),u=Xe.test(t),l=e.style;if(u||(t=Je(s)),a=w.cssHooks[t]||w.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"==(o=typeof n)&&(i=ie.exec(n))&&i[1]&&(n=ue(e,t,i),o="number"),null!=n&&n===n&&("number"===o&&(n+=i&&i[3]||(w.cssNumber[s]?"":"px")),h.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=G(t);return Xe.test(t)||(t=Je(s)),(a=w.cssHooks[t]||w.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Fe(e,t,r)),"normal"===i&&t in Ve&&(i=Ve[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),w.each(["height","width"],function(e,t){w.cssHooks[t]={get:function(e,n,r){if(n)return!ze.test(w.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?et(e,t,r):se(e,Ue,function(){return et(e,t,r)})},set:function(e,n,r){var i,o=$e(e),a="border-box"===w.css(e,"boxSizing",!1,o),s=r&&Ze(e,t,r,a,o);return a&&h.scrollboxSize()===o.position&&(s-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-Ze(e,t,"border",!1,o)-.5)),s&&(i=ie.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=w.css(e,t)),Ke(e,n,s)}}}),w.cssHooks.marginLeft=_e(h.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Fe(e,"marginLeft"))||e.getBoundingClientRect().left-se(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),w.each({margin:"",padding:"",border:"Width"},function(e,t){w.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+oe[r]+t]=o[r]||o[r-2]||o[0];return i}},"margin"!==e&&(w.cssHooks[e+t].set=Ke)}),w.fn.extend({css:function(e,t){return z(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=$e(e),i=t.length;a<i;a++)o[t[a]]=w.css(e,t[a],!1,r);return o}return void 0!==n?w.style(e,t,n):w.css(e,t)},e,t,arguments.length>1)}});function tt(e,t,n,r,i){return new tt.prototype.init(e,t,n,r,i)}w.Tween=tt,tt.prototype={constructor:tt,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||w.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(w.cssNumber[n]?"":"px")},cur:function(){var e=tt.propHooks[this.prop];return e&&e.get?e.get(this):tt.propHooks._default.get(this)},run:function(e){var t,n=tt.propHooks[this.prop];return this.options.duration?this.pos=t=w.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):tt.propHooks._default.set(this),this}},tt.prototype.init.prototype=tt.prototype,tt.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=w.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){w.fx.step[e.prop]?w.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[w.cssProps[e.prop]]&&!w.cssHooks[e.prop]?e.elem[e.prop]=e.now:w.style(e.elem,e.prop,e.now+e.unit)}}},tt.propHooks.scrollTop=tt.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},w.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},w.fx=tt.prototype.init,w.fx.step={};var nt,rt,it=/^(?:toggle|show|hide)$/,ot=/queueHooks$/;function at(){rt&&(!1===r.hidden&&e.requestAnimationFrame?e.requestAnimationFrame(at):e.setTimeout(at,w.fx.interval),w.fx.tick())}function st(){return e.setTimeout(function(){nt=void 0}),nt=Date.now()}function ut(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=oe[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function lt(e,t,n){for(var r,i=(pt.tweeners[t]||[]).concat(pt.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function ct(e,t,n){var r,i,o,a,s,u,l,c,f="width"in t||"height"in t,p=this,d={},h=e.style,g=e.nodeType&&ae(e),y=J.get(e,"fxshow");n.queue||(null==(a=w._queueHooks(e,"fx")).unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,p.always(function(){p.always(function(){a.unqueued--,w.queue(e,"fx").length||a.empty.fire()})}));for(r in t)if(i=t[r],it.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!y||void 0===y[r])continue;g=!0}d[r]=y&&y[r]||w.style(e,r)}if((u=!w.isEmptyObject(t))||!w.isEmptyObject(d)){f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],null==(l=y&&y.display)&&(l=J.get(e,"display")),"none"===(c=w.css(e,"display"))&&(l?c=l:(fe([e],!0),l=e.style.display||l,c=w.css(e,"display"),fe([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===w.css(e,"float")&&(u||(p.done(function(){h.display=l}),null==l&&(c=h.display,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",p.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1;for(r in d)u||(y?"hidden"in y&&(g=y.hidden):y=J.access(e,"fxshow",{display:l}),o&&(y.hidden=!g),g&&fe([e],!0),p.done(function(){g||fe([e]),J.remove(e,"fxshow");for(r in d)w.style(e,r,d[r])})),u=lt(g?y[r]:0,r,p),r in y||(y[r]=u.start,g&&(u.end=u.start,u.start=0))}}function ft(e,t){var n,r,i,o,a;for(n in e)if(r=G(n),i=t[r],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=w.cssHooks[r])&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}function pt(e,t,n){var r,i,o=0,a=pt.prefilters.length,s=w.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;for(var t=nt||st(),n=Math.max(0,l.startTime+l.duration-t),r=1-(n/l.duration||0),o=0,a=l.tweens.length;o<a;o++)l.tweens[o].run(r);return s.notifyWith(e,[l,r,n]),r<1&&a?n:(a||s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:w.extend({},t),opts:w.extend(!0,{specialEasing:{},easing:w.easing._default},n),originalProperties:t,originalOptions:n,startTime:nt||st(),duration:n.duration,tweens:[],createTween:function(t,n){var r=w.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;n<r;n++)l.tweens[n].run(1);return t?(s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l,t])):s.rejectWith(e,[l,t]),this}}),c=l.props;for(ft(c,l.opts.specialEasing);o<a;o++)if(r=pt.prefilters[o].call(l,e,c,l.opts))return g(r.stop)&&(w._queueHooks(l.elem,l.opts.queue).stop=r.stop.bind(r)),r;return w.map(c,lt,l),g(l.opts.start)&&l.opts.start.call(e,l),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always),w.fx.timer(w.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l}w.Animation=w.extend(pt,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return ue(n.elem,e,ie.exec(t),n),n}]},tweener:function(e,t){g(e)?(t=e,e=["*"]):e=e.match(M);for(var n,r=0,i=e.length;r<i;r++)n=e[r],pt.tweeners[n]=pt.tweeners[n]||[],pt.tweeners[n].unshift(t)},prefilters:[ct],prefilter:function(e,t){t?pt.prefilters.unshift(e):pt.prefilters.push(e)}}),w.speed=function(e,t,n){var r=e&&"object"==typeof e?w.extend({},e):{complete:n||!n&&t||g(e)&&e,duration:e,easing:n&&t||t&&!g(t)&&t};return w.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in w.fx.speeds?r.duration=w.fx.speeds[r.duration]:r.duration=w.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){g(r.old)&&r.old.call(this),r.queue&&w.dequeue(this,r.queue)},r},w.fn.extend({fadeTo:function(e,t,n,r){return this.filter(ae).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=w.isEmptyObject(e),o=w.speed(t,n,r),a=function(){var t=pt(this,w.extend({},e),o);(i||J.get(this,"finish"))&&t.stop(!0)};return a.finish=a,i||!1===o.queue?this.each(a):this.queue(o.queue,a)},stop:function(e,t,n){var r=function(e){var t=e.stop;delete e.stop,t(n)};return"string"!=typeof e&&(n=t,t=e,e=void 0),t&&!1!==e&&this.queue(e||"fx",[]),this.each(function(){var t=!0,i=null!=e&&e+"queueHooks",o=w.timers,a=J.get(this);if(i)a[i]&&a[i].stop&&r(a[i]);else for(i in a)a[i]&&a[i].stop&&ot.test(i)&&r(a[i]);for(i=o.length;i--;)o[i].elem!==this||null!=e&&o[i].queue!==e||(o[i].anim.stop(n),t=!1,o.splice(i,1));!t&&n||w.dequeue(this,e)})},finish:function(e){return!1!==e&&(e=e||"fx"),this.each(function(){var t,n=J.get(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=w.timers,a=r?r.length:0;for(n.finish=!0,w.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;t<a;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}}),w.each(["toggle","show","hide"],function(e,t){var n=w.fn[t];w.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ut(t,!0),e,r,i)}}),w.each({slideDown:ut("show"),slideUp:ut("hide"),slideToggle:ut("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){w.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),w.timers=[],w.fx.tick=function(){var e,t=0,n=w.timers;for(nt=Date.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||w.fx.stop(),nt=void 0},w.fx.timer=function(e){w.timers.push(e),w.fx.start()},w.fx.interval=13,w.fx.start=function(){rt||(rt=!0,at())},w.fx.stop=function(){rt=null},w.fx.speeds={slow:600,fast:200,_default:400},w.fn.delay=function(t,n){return t=w.fx?w.fx.speeds[t]||t:t,n=n||"fx",this.queue(n,function(n,r){var i=e.setTimeout(n,t);r.stop=function(){e.clearTimeout(i)}})},function(){var e=r.createElement("input"),t=r.createElement("select").appendChild(r.createElement("option"));e.type="checkbox",h.checkOn=""!==e.value,h.optSelected=t.selected,(e=r.createElement("input")).value="t",e.type="radio",h.radioValue="t"===e.value}();var dt,ht=w.expr.attrHandle;w.fn.extend({attr:function(e,t){return z(this,w.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){w.removeAttr(this,e)})}}),w.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?w.prop(e,t,n):(1===o&&w.isXMLDoc(e)||(i=w.attrHooks[t.toLowerCase()]||(w.expr.match.bool.test(t)?dt:void 0)),void 0!==n?null===n?void w.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=w.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!h.radioValue&&"radio"===t&&N(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(M);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),dt={set:function(e,t,n){return!1===t?w.removeAttr(e,n):e.setAttribute(n,n),n}},w.each(w.expr.match.bool.source.match(/\w+/g),function(e,t){var n=ht[t]||w.find.attr;ht[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=ht[a],ht[a]=i,i=null!=n(e,t,r)?a:null,ht[a]=o),i}});var gt=/^(?:input|select|textarea|button)$/i,yt=/^(?:a|area)$/i;w.fn.extend({prop:function(e,t){return z(this,w.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[w.propFix[e]||e]})}}),w.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&w.isXMLDoc(e)||(t=w.propFix[t]||t,i=w.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=w.find.attr(e,"tabindex");return t?parseInt(t,10):gt.test(e.nodeName)||yt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),h.optSelected||(w.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),w.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){w.propFix[this.toLowerCase()]=this});function vt(e){return(e.match(M)||[]).join(" ")}function mt(e){return e.getAttribute&&e.getAttribute("class")||""}function xt(e){return Array.isArray(e)?e:"string"==typeof e?e.match(M)||[]:[]}w.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).addClass(e.call(this,t,mt(this)))});if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).removeClass(e.call(this,t,mt(this)))});if(!arguments.length)return this.attr("class","");if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])while(r.indexOf(" "+o+" ")>-1)r=r.replace(" "+o+" "," ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=typeof e,r="string"===n||Array.isArray(e);return"boolean"==typeof t&&r?t?this.addClass(e):this.removeClass(e):g(e)?this.each(function(n){w(this).toggleClass(e.call(this,n,mt(this),t),t)}):this.each(function(){var t,i,o,a;if(r){i=0,o=w(this),a=xt(e);while(t=a[i++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else void 0!==e&&"boolean"!==n||((t=mt(this))&&J.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":J.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&(" "+vt(mt(n))+" ").indexOf(t)>-1)return!0;return!1}});var bt=/\r/g;w.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=g(e),this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,w(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=w.map(i,function(e){return null==e?"":e+""})),(t=w.valHooks[this.type]||w.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=w.valHooks[i.type]||w.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(bt,""):null==n?"":n}}}),w.extend({valHooks:{option:{get:function(e){var t=w.find.attr(e,"value");return null!=t?t:vt(w.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r<u;r++)if(((n=i[r]).selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!N(n.parentNode,"optgroup"))){if(t=w(n).val(),a)return t;s.push(t)}return s},set:function(e,t){var n,r,i=e.options,o=w.makeArray(t),a=i.length;while(a--)((r=i[a]).selected=w.inArray(w.valHooks.option.get(r),o)>-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),w.each(["radio","checkbox"],function(){w.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=w.inArray(w(e).val(),t)>-1}},h.checkOn||(w.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),h.focusin="onfocusin"in e;var wt=/^(?:focusinfocus|focusoutblur)$/,Tt=function(e){e.stopPropagation()};w.extend(w.event,{trigger:function(t,n,i,o){var a,s,u,l,c,p,d,h,v=[i||r],m=f.call(t,"type")?t.type:t,x=f.call(t,"namespace")?t.namespace.split("."):[];if(s=h=u=i=i||r,3!==i.nodeType&&8!==i.nodeType&&!wt.test(m+w.event.triggered)&&(m.indexOf(".")>-1&&(m=(x=m.split(".")).shift(),x.sort()),c=m.indexOf(":")<0&&"on"+m,t=t[w.expando]?t:new w.Event(m,"object"==typeof t&&t),t.isTrigger=o?2:3,t.namespace=x.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+x.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=i),n=null==n?[t]:w.makeArray(n,[t]),d=w.event.special[m]||{},o||!d.trigger||!1!==d.trigger.apply(i,n))){if(!o&&!d.noBubble&&!y(i)){for(l=d.delegateType||m,wt.test(l+m)||(s=s.parentNode);s;s=s.parentNode)v.push(s),u=s;u===(i.ownerDocument||r)&&v.push(u.defaultView||u.parentWindow||e)}a=0;while((s=v[a++])&&!t.isPropagationStopped())h=s,t.type=a>1?l:d.bindType||m,(p=(J.get(s,"events")||{})[t.type]&&J.get(s,"handle"))&&p.apply(s,n),(p=c&&s[c])&&p.apply&&Y(s)&&(t.result=p.apply(s,n),!1===t.result&&t.preventDefault());return t.type=m,o||t.isDefaultPrevented()||d._default&&!1!==d._default.apply(v.pop(),n)||!Y(i)||c&&g(i[m])&&!y(i)&&((u=i[c])&&(i[c]=null),w.event.triggered=m,t.isPropagationStopped()&&h.addEventListener(m,Tt),i[m](),t.isPropagationStopped()&&h.removeEventListener(m,Tt),w.event.triggered=void 0,u&&(i[c]=u)),t.result}},simulate:function(e,t,n){var r=w.extend(new w.Event,n,{type:e,isSimulated:!0});w.event.trigger(r,null,t)}}),w.fn.extend({trigger:function(e,t){return this.each(function(){w.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return w.event.trigger(e,t,n,!0)}}),h.focusin||w.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){w.event.simulate(t,e.target,w.event.fix(e))};w.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=J.access(r,t);i||r.addEventListener(e,n,!0),J.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=J.access(r,t)-1;i?J.access(r,t,i):(r.removeEventListener(e,n,!0),J.remove(r,t))}}});var Ct=e.location,Et=Date.now(),kt=/\?/;w.parseXML=function(t){var n;if(!t||"string"!=typeof t)return null;try{n=(new e.DOMParser).parseFromString(t,"text/xml")}catch(e){n=void 0}return n&&!n.getElementsByTagName("parsererror").length||w.error("Invalid XML: "+t),n};var St=/\[\]$/,Dt=/\r?\n/g,Nt=/^(?:submit|button|image|reset|file)$/i,At=/^(?:input|select|textarea|keygen)/i;function jt(e,t,n,r){var i;if(Array.isArray(t))w.each(t,function(t,i){n||St.test(e)?r(e,i):jt(e+"["+("object"==typeof i&&null!=i?t:"")+"]",i,n,r)});else if(n||"object"!==x(t))r(e,t);else for(i in t)jt(e+"["+i+"]",t[i],n,r)}w.param=function(e,t){var n,r=[],i=function(e,t){var n=g(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!w.isPlainObject(e))w.each(e,function(){i(this.name,this.value)});else for(n in e)jt(n,e[n],t,i);return r.join("&")},w.fn.extend({serialize:function(){return w.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=w.prop(this,"elements");return e?w.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!w(this).is(":disabled")&&At.test(this.nodeName)&&!Nt.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=w(this).val();return null==n?null:Array.isArray(n)?w.map(n,function(e){return{name:t.name,value:e.replace(Dt,"\r\n")}}):{name:t.name,value:n.replace(Dt,"\r\n")}}).get()}});var qt=/%20/g,Lt=/#.*$/,Ht=/([?&])_=[^&]*/,Ot=/^(.*?):[ \t]*([^\r\n]*)$/gm,Pt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mt=/^(?:GET|HEAD)$/,Rt=/^\/\//,It={},Wt={},$t="*/".concat("*"),Bt=r.createElement("a");Bt.href=Ct.href;function Ft(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(M)||[];if(g(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function _t(e,t,n,r){var i={},o=e===Wt;function a(s){var u;return i[s]=!0,w.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):void 0:(t.dataTypes.unshift(l),a(l),!1)}),u}return a(t.dataTypes[0])||!i["*"]&&a("*")}function zt(e,t){var n,r,i=w.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&w.extend(!0,e,r),e}function Xt(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function Ut(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}w.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:Pt.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":$t,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":w.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?zt(zt(e,w.ajaxSettings),t):zt(w.ajaxSettings,e)},ajaxPrefilter:Ft(It),ajaxTransport:Ft(Wt),ajax:function(t,n){"object"==typeof t&&(n=t,t=void 0),n=n||{};var i,o,a,s,u,l,c,f,p,d,h=w.ajaxSetup({},n),g=h.context||h,y=h.context&&(g.nodeType||g.jquery)?w(g):w.event,v=w.Deferred(),m=w.Callbacks("once memory"),x=h.statusCode||{},b={},T={},C="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(c){if(!s){s={};while(t=Ot.exec(a))s[t[1].toLowerCase()]=t[2]}t=s[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return c?a:null},setRequestHeader:function(e,t){return null==c&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,b[e]=t),this},overrideMimeType:function(e){return null==c&&(h.mimeType=e),this},statusCode:function(e){var t;if(e)if(c)E.always(e[E.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||C;return i&&i.abort(t),k(0,t),this}};if(v.promise(E),h.url=((t||h.url||Ct.href)+"").replace(Rt,Ct.protocol+"//"),h.type=n.method||n.type||h.method||h.type,h.dataTypes=(h.dataType||"*").toLowerCase().match(M)||[""],null==h.crossDomain){l=r.createElement("a");try{l.href=h.url,l.href=l.href,h.crossDomain=Bt.protocol+"//"+Bt.host!=l.protocol+"//"+l.host}catch(e){h.crossDomain=!0}}if(h.data&&h.processData&&"string"!=typeof h.data&&(h.data=w.param(h.data,h.traditional)),_t(It,h,n,E),c)return E;(f=w.event&&h.global)&&0==w.active++&&w.event.trigger("ajaxStart"),h.type=h.type.toUpperCase(),h.hasContent=!Mt.test(h.type),o=h.url.replace(Lt,""),h.hasContent?h.data&&h.processData&&0===(h.contentType||"").indexOf("application/x-www-form-urlencoded")&&(h.data=h.data.replace(qt,"+")):(d=h.url.slice(o.length),h.data&&(h.processData||"string"==typeof h.data)&&(o+=(kt.test(o)?"&":"?")+h.data,delete h.data),!1===h.cache&&(o=o.replace(Ht,"$1"),d=(kt.test(o)?"&":"?")+"_="+Et+++d),h.url=o+d),h.ifModified&&(w.lastModified[o]&&E.setRequestHeader("If-Modified-Since",w.lastModified[o]),w.etag[o]&&E.setRequestHeader("If-None-Match",w.etag[o])),(h.data&&h.hasContent&&!1!==h.contentType||n.contentType)&&E.setRequestHeader("Content-Type",h.contentType),E.setRequestHeader("Accept",h.dataTypes[0]&&h.accepts[h.dataTypes[0]]?h.accepts[h.dataTypes[0]]+("*"!==h.dataTypes[0]?", "+$t+"; q=0.01":""):h.accepts["*"]);for(p in h.headers)E.setRequestHeader(p,h.headers[p]);if(h.beforeSend&&(!1===h.beforeSend.call(g,E,h)||c))return E.abort();if(C="abort",m.add(h.complete),E.done(h.success),E.fail(h.error),i=_t(Wt,h,n,E)){if(E.readyState=1,f&&y.trigger("ajaxSend",[E,h]),c)return E;h.async&&h.timeout>0&&(u=e.setTimeout(function(){E.abort("timeout")},h.timeout));try{c=!1,i.send(b,k)}catch(e){if(c)throw e;k(-1,e)}}else k(-1,"No Transport");function k(t,n,r,s){var l,p,d,b,T,C=n;c||(c=!0,u&&e.clearTimeout(u),i=void 0,a=s||"",E.readyState=t>0?4:0,l=t>=200&&t<300||304===t,r&&(b=Xt(h,E,r)),b=Ut(h,b,E,l),l?(h.ifModified&&((T=E.getResponseHeader("Last-Modified"))&&(w.lastModified[o]=T),(T=E.getResponseHeader("etag"))&&(w.etag[o]=T)),204===t||"HEAD"===h.type?C="nocontent":304===t?C="notmodified":(C=b.state,p=b.data,l=!(d=b.error))):(d=C,!t&&C||(C="error",t<0&&(t=0))),E.status=t,E.statusText=(n||C)+"",l?v.resolveWith(g,[p,C,E]):v.rejectWith(g,[E,C,d]),E.statusCode(x),x=void 0,f&&y.trigger(l?"ajaxSuccess":"ajaxError",[E,h,l?p:d]),m.fireWith(g,[E,C]),f&&(y.trigger("ajaxComplete",[E,h]),--w.active||w.event.trigger("ajaxStop")))}return E},getJSON:function(e,t,n){return w.get(e,t,n,"json")},getScript:function(e,t){return w.get(e,void 0,t,"script")}}),w.each(["get","post"],function(e,t){w[t]=function(e,n,r,i){return g(n)&&(i=i||r,r=n,n=void 0),w.ajax(w.extend({url:e,type:t,dataType:i,data:n,success:r},w.isPlainObject(e)&&e))}}),w._evalUrl=function(e){return w.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},w.fn.extend({wrapAll:function(e){var t;return this[0]&&(g(e)&&(e=e.call(this[0])),t=w(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return g(e)?this.each(function(t){w(this).wrapInner(e.call(this,t))}):this.each(function(){var t=w(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=g(e);return this.each(function(n){w(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){w(this).replaceWith(this.childNodes)}),this}}),w.expr.pseudos.hidden=function(e){return!w.expr.pseudos.visible(e)},w.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},w.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(e){}};var Vt={0:200,1223:204},Gt=w.ajaxSettings.xhr();h.cors=!!Gt&&"withCredentials"in Gt,h.ajax=Gt=!!Gt,w.ajaxTransport(function(t){var n,r;if(h.cors||Gt&&!t.crossDomain)return{send:function(i,o){var a,s=t.xhr();if(s.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(a in t.xhrFields)s[a]=t.xhrFields[a];t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");for(a in i)s.setRequestHeader(a,i[a]);n=function(e){return function(){n&&(n=r=s.onload=s.onerror=s.onabort=s.ontimeout=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?o(0,"error"):o(s.status,s.statusText):o(Vt[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=n(),r=s.onerror=s.ontimeout=n("error"),void 0!==s.onabort?s.onabort=r:s.onreadystatechange=function(){4===s.readyState&&e.setTimeout(function(){n&&r()})},n=n("abort");try{s.send(t.hasContent&&t.data||null)}catch(e){if(n)throw e}},abort:function(){n&&n()}}}),w.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),w.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return w.globalEval(e),e}}}),w.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),w.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(i,o){t=w("<script>").prop({charset:e.scriptCharset,src:e.url}).on("load error",n=function(e){t.remove(),n=null,e&&o("error"===e.type?404:200,e.type)}),r.head.appendChild(t[0])},abort:function(){n&&n()}}}});var Yt=[],Qt=/(=)\?(?=&|$)|\?\?/;w.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Yt.pop()||w.expando+"_"+Et++;return this[e]=!0,e}}),w.ajaxPrefilter("json jsonp",function(t,n,r){var i,o,a,s=!1!==t.jsonp&&(Qt.test(t.url)?"url":"string"==typeof t.data&&0===(t.contentType||"").indexOf("application/x-www-form-urlencoded")&&Qt.test(t.data)&&"data");if(s||"jsonp"===t.dataTypes[0])return i=t.jsonpCallback=g(t.jsonpCallback)?t.jsonpCallback():t.jsonpCallback,s?t[s]=t[s].replace(Qt,"$1"+i):!1!==t.jsonp&&(t.url+=(kt.test(t.url)?"&":"?")+t.jsonp+"="+i),t.converters["script json"]=function(){return a||w.error(i+" was not called"),a[0]},t.dataTypes[0]="json",o=e[i],e[i]=function(){a=arguments},r.always(function(){void 0===o?w(e).removeProp(i):e[i]=o,t[i]&&(t.jsonpCallback=n.jsonpCallback,Yt.push(i)),a&&g(o)&&o(a[0]),a=o=void 0}),"script"}),h.createHTMLDocument=function(){var e=r.implementation.createHTMLDocument("").body;return e.innerHTML="<form></form><form></form>",2===e.childNodes.length}(),w.parseHTML=function(e,t,n){if("string"!=typeof e)return[];"boolean"==typeof t&&(n=t,t=!1);var i,o,a;return t||(h.createHTMLDocument?((i=(t=r.implementation.createHTMLDocument("")).createElement("base")).href=r.location.href,t.head.appendChild(i)):t=r),o=A.exec(e),a=!n&&[],o?[t.createElement(o[1])]:(o=xe([e],t,a),a&&a.length&&w(a).remove(),w.merge([],o.childNodes))},w.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return s>-1&&(r=vt(e.slice(s)),e=e.slice(0,s)),g(t)?(n=t,t=void 0):t&&"object"==typeof t&&(i="POST"),a.length>0&&w.ajax({url:e,type:i||"GET",dataType:"html",data:t}).done(function(e){o=arguments,a.html(r?w("<div>").append(w.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},w.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){w.fn[t]=function(e){return this.on(t,e)}}),w.expr.pseudos.animated=function(e){return w.grep(w.timers,function(t){return e===t.elem}).length},w.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l,c=w.css(e,"position"),f=w(e),p={};"static"===c&&(e.style.position="relative"),s=f.offset(),o=w.css(e,"top"),u=w.css(e,"left"),(l=("absolute"===c||"fixed"===c)&&(o+u).indexOf("auto")>-1)?(a=(r=f.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),g(t)&&(t=t.call(e,n,w.extend({},s))),null!=t.top&&(p.top=t.top-s.top+a),null!=t.left&&(p.left=t.left-s.left+i),"using"in t?t.using.call(e,p):f.css(p)}},w.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each(function(t){w.offset.setOffset(this,e,t)});var t,n,r=this[0];if(r)return r.getClientRects().length?(t=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:t.top+n.pageYOffset,left:t.left+n.pageXOffset}):{top:0,left:0}},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===w.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===w.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=w(e).offset()).top+=w.css(e,"borderTopWidth",!0),i.left+=w.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-w.css(r,"marginTop",!0),left:t.left-i.left-w.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===w.css(e,"position"))e=e.offsetParent;return e||be})}}),w.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var n="pageYOffset"===t;w.fn[e]=function(r){return z(this,function(e,r,i){var o;if(y(e)?o=e:9===e.nodeType&&(o=e.defaultView),void 0===i)return o?o[t]:e[r];o?o.scrollTo(n?o.pageXOffset:i,n?i:o.pageYOffset):e[r]=i},e,r,arguments.length)}}),w.each(["top","left"],function(e,t){w.cssHooks[t]=_e(h.pixelPosition,function(e,n){if(n)return n=Fe(e,t),We.test(n)?w(e).position()[t]+"px":n})}),w.each({Height:"height",Width:"width"},function(e,t){w.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){w.fn[r]=function(i,o){var a=arguments.length&&(n||"boolean"!=typeof i),s=n||(!0===i||!0===o?"margin":"border");return z(this,function(t,n,i){var o;return y(t)?0===r.indexOf("outer")?t["inner"+e]:t.document.documentElement["client"+e]:9===t.nodeType?(o=t.documentElement,Math.max(t.body["scroll"+e],o["scroll"+e],t.body["offset"+e],o["offset"+e],o["client"+e])):void 0===i?w.css(t,n,s):w.style(t,n,i,s)},t,a?i:void 0,a)}})}),w.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,t){w.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),w.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),w.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}}),w.proxy=function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),g(e))return r=o.call(arguments,2),i=function(){return e.apply(t||this,r.concat(o.call(arguments)))},i.guid=e.guid=e.guid||w.guid++,i},w.holdReady=function(e){e?w.readyWait++:w.ready(!0)},w.isArray=Array.isArray,w.parseJSON=JSON.parse,w.nodeName=N,w.isFunction=g,w.isWindow=y,w.camelCase=G,w.type=x,w.now=Date.now,w.isNumeric=function(e){var t=w.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},"function"==typeof define&&define.amd&&define("jquery",[],function(){return w});var Jt=e.jQuery,Kt=e.$;return w.noConflict=function(t){return e.$===w&&(e.$=Kt),t&&e.jQuery===w&&(e.jQuery=Jt),w},t||(e.jQuery=e.$=w),w});
9−
10− </script>
11− <script language="javascript" type="text/javascript">
12− /* Javascript plotting library for jQuery, version 0.8.3.
13−
14−Copyright (c) 2007-2014 IOLA and Ole Laursen.
15−Licensed under the MIT license.
16−
17−*/
18−(function($){$.color={};$.color.make=function(r,g,b,a){var o={};o.r=r||0;o.g=g||0;o.b=b||0;o.a=a!=null?a:1;o.add=function(c,d){for(var i=0;i<c.length;++i)o[c.charAt(i)]+=d;return o.normalize()};o.scale=function(c,f){for(var i=0;i<c.length;++i)o[c.charAt(i)]*=f;return o.normalize()};o.toString=function(){if(o.a>=1){return"rgb("+[o.r,o.g,o.b].join(",")+")"}else{return"rgba("+[o.r,o.g,o.b,o.a].join(",")+")"}};o.normalize=function(){function clamp(min,value,max){return value<min?min:value>max?max:value}o.r=clamp(0,parseInt(o.r),255);o.g=clamp(0,parseInt(o.g),255);o.b=clamp(0,parseInt(o.b),255);o.a=clamp(0,o.a,1);return o};o.clone=function(){return $.color.make(o.r,o.b,o.g,o.a)};return o.normalize()};$.color.extract=function(elem,css){var c;do{c=elem.css(css).toLowerCase();if(c!=""&&c!="transparent")break;elem=elem.parent()}while(elem.length&&!$.nodeName(elem.get(0),"body"));if(c=="rgba(0, 0, 0, 0)")c="transparent";return $.color.parse(c)};$.color.parse=function(str){var res,m=$.color.make;if(res=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10));if(res=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10),parseFloat(res[4]));if(res=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55);if(res=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55,parseFloat(res[4]));if(res=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str))return m(parseInt(res[1],16),parseInt(res[2],16),parseInt(res[3],16));if(res=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str))return m(parseInt(res[1]+res[1],16),parseInt(res[2]+res[2],16),parseInt(res[3]+res[3],16));var name=$.trim(str).toLowerCase();if(name=="transparent")return m(255,255,255,0);else{res=lookupColors[name]||[0,0,0];return m(res[0],res[1],res[2])}};var lookupColors={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);(function($){var hasOwnProperty=Object.prototype.hasOwnProperty;if(!$.fn.detach){$.fn.detach=function(){return this.each(function(){if(this.parentNode){this.parentNode.removeChild(this)}})}}function Canvas(cls,container){var element=container.children("."+cls)[0];if(element==null){element=document.createElement("canvas");element.className=cls;$(element).css({direction:"ltr",position:"absolute",left:0,top:0}).appendTo(container);if(!element.getContext){if(window.G_vmlCanvasManager){element=window.G_vmlCanvasManager.initElement(element)}else{throw new Error("Canvas is not available. If you're using IE with a fall-back such as Excanvas, then there's either a mistake in your conditional include, or the page has no DOCTYPE and is rendering in Quirks Mode.")}}}this.element=element;var context=this.context=element.getContext("2d");var devicePixelRatio=window.devicePixelRatio||1,backingStoreRatio=context.webkitBackingStorePixelRatio||context.mozBackingStorePixelRatio||context.msBackingStorePixelRatio||context.oBackingStorePixelRatio||context.backingStorePixelRatio||1;this.pixelRatio=devicePixelRatio/backingStoreRatio;this.resize(container.width(),container.height());this.textContainer=null;this.text={};this._textCache={}}Canvas.prototype.resize=function(width,height){if(width<=0||height<=0){throw new Error("Invalid dimensions for plot, width = "+width+", height = "+height)}var element=this.element,context=this.context,pixelRatio=this.pixelRatio;if(this.width!=width){element.width=width*pixelRatio;element.style.width=width+"px";this.width=width}if(this.height!=height){element.height=height*pixelRatio;element.style.height=height+"px";this.height=height}context.restore();context.save();context.scale(pixelRatio,pixelRatio)};Canvas.prototype.clear=function(){this.context.clearRect(0,0,this.width,this.height)};Canvas.prototype.render=function(){var cache=this._textCache;for(var layerKey in cache){if(hasOwnProperty.call(cache,layerKey)){var layer=this.getTextLayer(layerKey),layerCache=cache[layerKey];layer.hide();for(var styleKey in layerCache){if(hasOwnProperty.call(layerCache,styleKey)){var styleCache=layerCache[styleKey];for(var key in styleCache){if(hasOwnProperty.call(styleCache,key)){var positions=styleCache[key].positions;for(var i=0,position;position=positions[i];i++){if(position.active){if(!position.rendered){layer.append(position.element);position.rendered=true}}else{positions.splice(i--,1);if(position.rendered){position.element.detach()}}}if(positions.length==0){delete styleCache[key]}}}}}layer.show()}}};Canvas.prototype.getTextLayer=function(classes){var layer=this.text[classes];if(layer==null){if(this.textContainer==null){this.textContainer=$("<div class='flot-text'></div>").css({position:"absolute",top:0,left:0,bottom:0,right:0,"font-size":"smaller",color:"#545454"}).insertAfter(this.element)}layer=this.text[classes]=$("<div></div>").addClass(classes).css({position:"absolute",top:0,left:0,bottom:0,right:0}).appendTo(this.textContainer)}return layer};Canvas.prototype.getTextInfo=function(layer,text,font,angle,width){var textStyle,layerCache,styleCache,info;text=""+text;if(typeof font==="object"){textStyle=font.style+" "+font.variant+" "+font.weight+" "+font.size+"px/"+font.lineHeight+"px "+font.family}else{textStyle=font}layerCache=this._textCache[layer];if(layerCache==null){layerCache=this._textCache[layer]={}}styleCache=layerCache[textStyle];if(styleCache==null){styleCache=layerCache[textStyle]={}}info=styleCache[text];if(info==null){var element=$("<div></div>").html(text).css({position:"absolute","max-width":width,top:-9999}).appendTo(this.getTextLayer(layer));if(typeof font==="object"){element.css({font:textStyle,color:font.color})}else if(typeof font==="string"){element.addClass(font)}info=styleCache[text]={width:element.outerWidth(true),height:element.outerHeight(true),element:element,positions:[]};element.detach()}return info};Canvas.prototype.addText=function(layer,x,y,text,font,angle,width,halign,valign){var info=this.getTextInfo(layer,text,font,angle,width),positions=info.positions;if(halign=="center"){x-=info.width/2}else if(halign=="right"){x-=info.width}if(valign=="middle"){y-=info.height/2}else if(valign=="bottom"){y-=info.height}for(var i=0,position;position=positions[i];i++){if(position.x==x&&position.y==y){position.active=true;return}}position={active:true,rendered:false,element:positions.length?info.element.clone():info.element,x:x,y:y};positions.push(position);position.element.css({top:Math.round(y),left:Math.round(x),"text-align":halign})};Canvas.prototype.removeText=function(layer,x,y,text,font,angle){if(text==null){var layerCache=this._textCache[layer];if(layerCache!=null){for(var styleKey in layerCache){if(hasOwnProperty.call(layerCache,styleKey)){var styleCache=layerCache[styleKey];for(var key in styleCache){if(hasOwnProperty.call(styleCache,key)){var positions=styleCache[key].positions;for(var i=0,position;position=positions[i];i++){position.active=false}}}}}}}else{var positions=this.getTextInfo(layer,text,font,angle).positions;for(var i=0,position;position=positions[i];i++){if(position.x==x&&position.y==y){position.active=false}}}};function Plot(placeholder,data_,options_,plugins){var series=[],options={colors:["#edc240","#afd8f8","#cb4b4b","#4da74d","#9440ed"],legend:{show:true,noColumns:1,labelFormatter:null,labelBoxBorderColor:"#ccc",container:null,position:"ne",margin:5,backgroundColor:null,backgroundOpacity:.85,sorted:null},xaxis:{show:null,position:"bottom",mode:null,font:null,color:null,tickColor:null,transform:null,inverseTransform:null,min:null,max:null,autoscaleMargin:null,ticks:null,tickFormatter:null,labelWidth:null,labelHeight:null,reserveSpace:null,tickLength:null,alignTicksWithAxis:null,tickDecimals:null,tickSize:null,minTickSize:null},yaxis:{autoscaleMargin:.02,position:"left"},xaxes:[],yaxes:[],series:{points:{show:false,radius:3,lineWidth:2,fill:true,fillColor:"#ffffff",symbol:"circle"},lines:{lineWidth:2,fill:false,fillColor:null,steps:false},bars:{show:false,lineWidth:2,barWidth:1,fill:true,fillColor:null,align:"left",horizontal:false,zero:true},shadowSize:3,highlightColor:null},grid:{show:true,aboveData:false,color:"#545454",backgroundColor:null,borderColor:null,tickColor:null,margin:0,labelMargin:5,axisMargin:8,borderWidth:2,minBorderMargin:null,markings:null,markingsColor:"#f4f4f4",markingsLineWidth:2,clickable:false,hoverable:false,autoHighlight:true,mouseActiveRadius:10},interaction:{redrawOverlayInterval:1e3/60},hooks:{}},surface=null,overlay=null,eventHolder=null,ctx=null,octx=null,xaxes=[],yaxes=[],plotOffset={left:0,right:0,top:0,bottom:0},plotWidth=0,plotHeight=0,hooks={processOptions:[],processRawData:[],processDatapoints:[],processOffset:[],drawBackground:[],drawSeries:[],draw:[],bindEvents:[],drawOverlay:[],shutdown:[]},plot=this;plot.setData=setData;plot.setupGrid=setupGrid;plot.draw=draw;plot.getPlaceholder=function(){return placeholder};plot.getCanvas=function(){return surface.element};plot.getPlotOffset=function(){return plotOffset};plot.width=function(){return plotWidth};plot.height=function(){return plotHeight};plot.offset=function(){var o=eventHolder.offset();o.left+=plotOffset.left;o.top+=plotOffset.top;return o};plot.getData=function(){return series};plot.getAxes=function(){var res={},i;$.each(xaxes.concat(yaxes),function(_,axis){if(axis)res[axis.direction+(axis.n!=1?axis.n:"")+"axis"]=axis});return res};plot.getXAxes=function(){return xaxes};plot.getYAxes=function(){return yaxes};plot.c2p=canvasToAxisCoords;plot.p2c=axisToCanvasCoords;plot.getOptions=function(){return options};plot.highlight=highlight;plot.unhighlight=unhighlight;plot.triggerRedrawOverlay=triggerRedrawOverlay;plot.pointOffset=function(point){return{left:parseInt(xaxes[axisNumber(point,"x")-1].p2c(+point.x)+plotOffset.left,10),top:parseInt(yaxes[axisNumber(point,"y")-1].p2c(+point.y)+plotOffset.top,10)}};plot.shutdown=shutdown;plot.destroy=function(){shutdown();placeholder.removeData("plot").empty();series=[];options=null;surface=null;overlay=null;eventHolder=null;ctx=null;octx=null;xaxes=[];yaxes=[];hooks=null;highlights=[];plot=null};plot.resize=function(){var width=placeholder.width(),height=placeholder.height();surface.resize(width,height);overlay.resize(width,height)};plot.hooks=hooks;initPlugins(plot);parseOptions(options_);setupCanvases();setData(data_);setupGrid();draw();bindEvents();function executeHooks(hook,args){args=[plot].concat(args);for(var i=0;i<hook.length;++i)hook[i].apply(this,args)}function initPlugins(){var classes={Canvas:Canvas};for(var i=0;i<plugins.length;++i){var p=plugins[i];p.init(plot,classes);if(p.options)$.extend(true,options,p.options)}}function parseOptions(opts){$.extend(true,options,opts);if(opts&&opts.colors){options.colors=opts.colors}if(options.xaxis.color==null)options.xaxis.color=$.color.parse(options.grid.color).scale("a",.22).toString();if(options.yaxis.color==null)options.yaxis.color=$.color.parse(options.grid.color).scale("a",.22).toString();if(options.xaxis.tickColor==null)options.xaxis.tickColor=options.grid.tickColor||options.xaxis.color;if(options.yaxis.tickColor==null)options.yaxis.tickColor=options.grid.tickColor||options.yaxis.color;if(options.grid.borderColor==null)options.grid.borderColor=options.grid.color;if(options.grid.tickColor==null)options.grid.tickColor=$.color.parse(options.grid.color).scale("a",.22).toString();var i,axisOptions,axisCount,fontSize=placeholder.css("font-size"),fontSizeDefault=fontSize?+fontSize.replace("px",""):13,fontDefaults={style:placeholder.css("font-style"),size:Math.round(.8*fontSizeDefault),variant:placeholder.css("font-variant"),weight:placeholder.css("font-weight"),family:placeholder.css("font-family")};axisCount=options.xaxes.length||1;for(i=0;i<axisCount;++i){axisOptions=options.xaxes[i];if(axisOptions&&!axisOptions.tickColor){axisOptions.tickColor=axisOptions.color}axisOptions=$.extend(true,{},options.xaxis,axisOptions);options.xaxes[i]=axisOptions;if(axisOptions.font){axisOptions.font=$.extend({},fontDefaults,axisOptions.font);if(!axisOptions.font.color){axisOptions.font.color=axisOptions.color}if(!axisOptions.font.lineHeight){axisOptions.font.lineHeight=Math.round(axisOptions.font.size*1.15)}}}axisCount=options.yaxes.length||1;for(i=0;i<axisCount;++i){axisOptions=options.yaxes[i];if(axisOptions&&!axisOptions.tickColor){axisOptions.tickColor=axisOptions.color}axisOptions=$.extend(true,{},options.yaxis,axisOptions);options.yaxes[i]=axisOptions;if(axisOptions.font){axisOptions.font=$.extend({},fontDefaults,axisOptions.font);if(!axisOptions.font.color){axisOptions.font.color=axisOptions.color}if(!axisOptions.font.lineHeight){axisOptions.font.lineHeight=Math.round(axisOptions.font.size*1.15)}}}if(options.xaxis.noTicks&&options.xaxis.ticks==null)options.xaxis.ticks=options.xaxis.noTicks;if(options.yaxis.noTicks&&options.yaxis.ticks==null)options.yaxis.ticks=options.yaxis.noTicks;if(options.x2axis){options.xaxes[1]=$.extend(true,{},options.xaxis,options.x2axis);options.xaxes[1].position="top";if(options.x2axis.min==null){options.xaxes[1].min=null}if(options.x2axis.max==null){options.xaxes[1].max=null}}if(options.y2axis){options.yaxes[1]=$.extend(true,{},options.yaxis,options.y2axis);options.yaxes[1].position="right";if(options.y2axis.min==null){options.yaxes[1].min=null}if(options.y2axis.max==null){options.yaxes[1].max=null}}if(options.grid.coloredAreas)options.grid.markings=options.grid.coloredAreas;if(options.grid.coloredAreasColor)options.grid.markingsColor=options.grid.coloredAreasColor;if(options.lines)$.extend(true,options.series.lines,options.lines);if(options.points)$.extend(true,options.series.points,options.points);if(options.bars)$.extend(true,options.series.bars,options.bars);if(options.shadowSize!=null)options.series.shadowSize=options.shadowSize;if(options.highlightColor!=null)options.series.highlightColor=options.highlightColor;for(i=0;i<options.xaxes.length;++i)getOrCreateAxis(xaxes,i+1).options=options.xaxes[i];for(i=0;i<options.yaxes.length;++i)getOrCreateAxis(yaxes,i+1).options=options.yaxes[i];for(var n in hooks)if(options.hooks[n]&&options.hooks[n].length)hooks[n]=hooks[n].concat(options.hooks[n]);executeHooks(hooks.processOptions,[options])}function setData(d){series=parseData(d);fillInSeriesOptions();processData()}function parseData(d){var res=[];for(var i=0;i<d.length;++i){var s=$.extend(true,{},options.series);if(d[i].data!=null){s.data=d[i].data;delete d[i].data;$.extend(true,s,d[i]);d[i].data=s.data}else s.data=d[i];res.push(s)}return res}function axisNumber(obj,coord){var a=obj[coord+"axis"];if(typeof a=="object")a=a.n;if(typeof a!="number")a=1;return a}function allAxes(){return $.grep(xaxes.concat(yaxes),function(a){return a})}function canvasToAxisCoords(pos){var res={},i,axis;for(i=0;i<xaxes.length;++i){axis=xaxes[i];if(axis&&axis.used)res["x"+axis.n]=axis.c2p(pos.left)}for(i=0;i<yaxes.length;++i){axis=yaxes[i];if(axis&&axis.used)res["y"+axis.n]=axis.c2p(pos.top)}if(res.x1!==undefined)res.x=res.x1;if(res.y1!==undefined)res.y=res.y1;return res}function axisToCanvasCoords(pos){var res={},i,axis,key;for(i=0;i<xaxes.length;++i){axis=xaxes[i];if(axis&&axis.used){key="x"+axis.n;if(pos[key]==null&&axis.n==1)key="x";if(pos[key]!=null){res.left=axis.p2c(pos[key]);break}}}for(i=0;i<yaxes.length;++i){axis=yaxes[i];if(axis&&axis.used){key="y"+axis.n;if(pos[key]==null&&axis.n==1)key="y";if(pos[key]!=null){res.top=axis.p2c(pos[key]);break}}}return res}function getOrCreateAxis(axes,number){if(!axes[number-1])axes[number-1]={n:number,direction:axes==xaxes?"x":"y",options:$.extend(true,{},axes==xaxes?options.xaxis:options.yaxis)};return axes[number-1]}function fillInSeriesOptions(){var neededColors=series.length,maxIndex=-1,i;for(i=0;i<series.length;++i){var sc=series[i].color;if(sc!=null){neededColors--;if(typeof sc=="number"&&sc>maxIndex){maxIndex=sc}}}if(neededColors<=maxIndex){neededColors=maxIndex+1}var c,colors=[],colorPool=options.colors,colorPoolSize=colorPool.length,variation=0;for(i=0;i<neededColors;i++){c=$.color.parse(colorPool[i%colorPoolSize]||"#666");if(i%colorPoolSize==0&&i){if(variation>=0){if(variation<.5){variation=-variation-.2}else variation=0}else variation=-variation}colors[i]=c.scale("rgb",1+variation)}var colori=0,s;for(i=0;i<series.length;++i){s=series[i];if(s.color==null){s.color=colors[colori].toString();++colori}else if(typeof s.color=="number")s.color=colors[s.color].toString();if(s.lines.show==null){var v,show=true;for(v in s)if(s[v]&&s[v].show){show=false;break}if(show)s.lines.show=true}if(s.lines.zero==null){s.lines.zero=!!s.lines.fill}s.xaxis=getOrCreateAxis(xaxes,axisNumber(s,"x"));s.yaxis=getOrCreateAxis(yaxes,axisNumber(s,"y"))}}function processData(){var topSentry=Number.POSITIVE_INFINITY,bottomSentry=Number.NEGATIVE_INFINITY,fakeInfinity=Number.MAX_VALUE,i,j,k,m,length,s,points,ps,x,y,axis,val,f,p,data,format;function updateAxis(axis,min,max){if(min<axis.datamin&&min!=-fakeInfinity)axis.datamin=min;if(max>axis.datamax&&max!=fakeInfinity)axis.datamax=max}$.each(allAxes(),function(_,axis){axis.datamin=topSentry;axis.datamax=bottomSentry;axis.used=false});for(i=0;i<series.length;++i){s=series[i];s.datapoints={points:[]};executeHooks(hooks.processRawData,[s,s.data,s.datapoints])}for(i=0;i<series.length;++i){s=series[i];data=s.data;format=s.datapoints.format;if(!format){format=[];format.push({x:true,number:true,required:true});format.push({y:true,number:true,required:true});if(s.bars.show||s.lines.show&&s.lines.fill){var autoscale=!!(s.bars.show&&s.bars.zero||s.lines.show&&s.lines.zero);format.push({y:true,number:true,required:false,defaultValue:0,autoscale:autoscale});if(s.bars.horizontal){delete format[format.length-1].y;format[format.length-1].x=true}}s.datapoints.format=format}if(s.datapoints.pointsize!=null)continue;s.datapoints.pointsize=format.length;ps=s.datapoints.pointsize;points=s.datapoints.points;var insertSteps=s.lines.show&&s.lines.steps;s.xaxis.used=s.yaxis.used=true;for(j=k=0;j<data.length;++j,k+=ps){p=data[j];var nullify=p==null;if(!nullify){for(m=0;m<ps;++m){val=p[m];f=format[m];if(f){if(f.number&&val!=null){val=+val;if(isNaN(val))val=null;else if(val==Infinity)val=fakeInfinity;else if(val==-Infinity)val=-fakeInfinity}if(val==null){if(f.required)nullify=true;if(f.defaultValue!=null)val=f.defaultValue}}points[k+m]=val}}if(nullify){for(m=0;m<ps;++m){val=points[k+m];if(val!=null){f=format[m];if(f.autoscale!==false){if(f.x){updateAxis(s.xaxis,val,val)}if(f.y){updateAxis(s.yaxis,val,val)}}}points[k+m]=null}}else{if(insertSteps&&k>0&&points[k-ps]!=null&&points[k-ps]!=points[k]&&points[k-ps+1]!=points[k+1]){for(m=0;m<ps;++m)points[k+ps+m]=points[k+m];points[k+1]=points[k-ps+1];k+=ps}}}}for(i=0;i<series.length;++i){s=series[i];executeHooks(hooks.processDatapoints,[s,s.datapoints])}for(i=0;i<series.length;++i){s=series[i];points=s.datapoints.points;ps=s.datapoints.pointsize;format=s.datapoints.format;var xmin=topSentry,ymin=topSentry,xmax=bottomSentry,ymax=bottomSentry;for(j=0;j<points.length;j+=ps){if(points[j]==null)continue;for(m=0;m<ps;++m){val=points[j+m];f=format[m];if(!f||f.autoscale===false||val==fakeInfinity||val==-fakeInfinity)continue;if(f.x){if(val<xmin)xmin=val;if(val>xmax)xmax=val}if(f.y){if(val<ymin)ymin=val;if(val>ymax)ymax=val}}}if(s.bars.show){var delta;switch(s.bars.align){case"left":delta=0;break;case"right":delta=-s.bars.barWidth;break;default:delta=-s.bars.barWidth/2}if(s.bars.horizontal){ymin+=delta;ymax+=delta+s.bars.barWidth}else{xmin+=delta;xmax+=delta+s.bars.barWidth}}updateAxis(s.xaxis,xmin,xmax);updateAxis(s.yaxis,ymin,ymax)}$.each(allAxes(),function(_,axis){if(axis.datamin==topSentry)axis.datamin=null;if(axis.datamax==bottomSentry)axis.datamax=null})}function setupCanvases(){placeholder.css("padding",0).children().filter(function(){return!$(this).hasClass("flot-overlay")&&!$(this).hasClass("flot-base")}).remove();if(placeholder.css("position")=="static")placeholder.css("position","relative");surface=new Canvas("flot-base",placeholder);overlay=new Canvas("flot-overlay",placeholder);ctx=surface.context;octx=overlay.context;eventHolder=$(overlay.element).unbind();var existing=placeholder.data("plot");if(existing){existing.shutdown();overlay.clear()}placeholder.data("plot",plot)}function bindEvents(){if(options.grid.hoverable){eventHolder.mousemove(onMouseMove);eventHolder.bind("mouseleave",onMouseLeave)}if(options.grid.clickable)eventHolder.click(onClick);executeHooks(hooks.bindEvents,[eventHolder])}function shutdown(){if(redrawTimeout)clearTimeout(redrawTimeout);eventHolder.unbind("mousemove",onMouseMove);eventHolder.unbind("mouseleave",onMouseLeave);eventHolder.unbind("click",onClick);executeHooks(hooks.shutdown,[eventHolder])}function setTransformationHelpers(axis){function identity(x){return x}var s,m,t=axis.options.transform||identity,it=axis.options.inverseTransform;if(axis.direction=="x"){s=axis.scale=plotWidth/Math.abs(t(axis.max)-t(axis.min));m=Math.min(t(axis.max),t(axis.min))}else{s=axis.scale=plotHeight/Math.abs(t(axis.max)-t(axis.min));s=-s;m=Math.max(t(axis.max),t(axis.min))}if(t==identity)axis.p2c=function(p){return(p-m)*s};else axis.p2c=function(p){return(t(p)-m)*s};if(!it)axis.c2p=function(c){return m+c/s};else axis.c2p=function(c){return it(m+c/s)}}function measureTickLabels(axis){var opts=axis.options,ticks=axis.ticks||[],labelWidth=opts.labelWidth||0,labelHeight=opts.labelHeight||0,maxWidth=labelWidth||(axis.direction=="x"?Math.floor(surface.width/(ticks.length||1)):null),legacyStyles=axis.direction+"Axis "+axis.direction+axis.n+"Axis",layer="flot-"+axis.direction+"-axis flot-"+axis.direction+axis.n+"-axis "+legacyStyles,font=opts.font||"flot-tick-label tickLabel";for(var i=0;i<ticks.length;++i){var t=ticks[i];if(!t.label)continue;var info=surface.getTextInfo(layer,t.label,font,null,maxWidth);labelWidth=Math.max(labelWidth,info.width);labelHeight=Math.max(labelHeight,info.height)}axis.labelWidth=opts.labelWidth||labelWidth;axis.labelHeight=opts.labelHeight||labelHeight}function allocateAxisBoxFirstPhase(axis){var lw=axis.labelWidth,lh=axis.labelHeight,pos=axis.options.position,isXAxis=axis.direction==="x",tickLength=axis.options.tickLength,axisMargin=options.grid.axisMargin,padding=options.grid.labelMargin,innermost=true,outermost=true,first=true,found=false;$.each(isXAxis?xaxes:yaxes,function(i,a){if(a&&(a.show||a.reserveSpace)){if(a===axis){found=true}else if(a.options.position===pos){if(found){outermost=false}else{innermost=false}}if(!found){first=false}}});if(outermost){axisMargin=0}if(tickLength==null){tickLength=first?"full":5}if(!isNaN(+tickLength))padding+=+tickLength;if(isXAxis){lh+=padding;if(pos=="bottom"){plotOffset.bottom+=lh+axisMargin;axis.box={top:surface.height-plotOffset.bottom,height:lh}}else{axis.box={top:plotOffset.top+axisMargin,height:lh};plotOffset.top+=lh+axisMargin}}else{lw+=padding;if(pos=="left"){axis.box={left:plotOffset.left+axisMargin,width:lw};plotOffset.left+=lw+axisMargin}else{plotOffset.right+=lw+axisMargin;axis.box={left:surface.width-plotOffset.right,width:lw}}}axis.position=pos;axis.tickLength=tickLength;axis.box.padding=padding;axis.innermost=innermost}function allocateAxisBoxSecondPhase(axis){if(axis.direction=="x"){axis.box.left=plotOffset.left-axis.labelWidth/2;axis.box.width=surface.width-plotOffset.left-plotOffset.right+axis.labelWidth}else{axis.box.top=plotOffset.top-axis.labelHeight/2;axis.box.height=surface.height-plotOffset.bottom-plotOffset.top+axis.labelHeight}}function adjustLayoutForThingsStickingOut(){var minMargin=options.grid.minBorderMargin,axis,i;if(minMargin==null){minMargin=0;for(i=0;i<series.length;++i)minMargin=Math.max(minMargin,2*(series[i].points.radius+series[i].points.lineWidth/2))}var margins={left:minMargin,right:minMargin,top:minMargin,bottom:minMargin};$.each(allAxes(),function(_,axis){if(axis.reserveSpace&&axis.ticks&&axis.ticks.length){if(axis.direction==="x"){margins.left=Math.max(margins.left,axis.labelWidth/2);margins.right=Math.max(margins.right,axis.labelWidth/2)}else{margins.bottom=Math.max(margins.bottom,axis.labelHeight/2);margins.top=Math.max(margins.top,axis.labelHeight/2)}}});plotOffset.left=Math.ceil(Math.max(margins.left,plotOffset.left));plotOffset.right=Math.ceil(Math.max(margins.right,plotOffset.right));plotOffset.top=Math.ceil(Math.max(margins.top,plotOffset.top));plotOffset.bottom=Math.ceil(Math.max(margins.bottom,plotOffset.bottom))}function setupGrid(){var i,axes=allAxes(),showGrid=options.grid.show;for(var a in plotOffset){var margin=options.grid.margin||0;plotOffset[a]=typeof margin=="number"?margin:margin[a]||0}executeHooks(hooks.processOffset,[plotOffset]);for(var a in plotOffset){if(typeof options.grid.borderWidth=="object"){plotOffset[a]+=showGrid?options.grid.borderWidth[a]:0}else{plotOffset[a]+=showGrid?options.grid.borderWidth:0}}$.each(axes,function(_,axis){var axisOpts=axis.options;axis.show=axisOpts.show==null?axis.used:axisOpts.show;axis.reserveSpace=axisOpts.reserveSpace==null?axis.show:axisOpts.reserveSpace;setRange(axis)});if(showGrid){var allocatedAxes=$.grep(axes,function(axis){return axis.show||axis.reserveSpace});$.each(allocatedAxes,function(_,axis){setupTickGeneration(axis);setTicks(axis);snapRangeToTicks(axis,axis.ticks);measureTickLabels(axis)});for(i=allocatedAxes.length-1;i>=0;--i)allocateAxisBoxFirstPhase(allocatedAxes[i]);adjustLayoutForThingsStickingOut();$.each(allocatedAxes,function(_,axis){allocateAxisBoxSecondPhase(axis)})}plotWidth=surface.width-plotOffset.left-plotOffset.right;plotHeight=surface.height-plotOffset.bottom-plotOffset.top;$.each(axes,function(_,axis){setTransformationHelpers(axis)});if(showGrid){drawAxisLabels()}insertLegend()}function setRange(axis){var opts=axis.options,min=+(opts.min!=null?opts.min:axis.datamin),max=+(opts.max!=null?opts.max:axis.datamax),delta=max-min;if(delta==0){var widen=max==0?1:.01;if(opts.min==null)min-=widen;if(opts.max==null||opts.min!=null)max+=widen}else{var margin=opts.autoscaleMargin;if(margin!=null){if(opts.min==null){min-=delta*margin;if(min<0&&axis.datamin!=null&&axis.datamin>=0)min=0}if(opts.max==null){max+=delta*margin;if(max>0&&axis.datamax!=null&&axis.datamax<=0)max=0}}}axis.min=min;axis.max=max}function setupTickGeneration(axis){var opts=axis.options;var noTicks;if(typeof opts.ticks=="number"&&opts.ticks>0)noTicks=opts.ticks;else noTicks=.3*Math.sqrt(axis.direction=="x"?surface.width:surface.height);var delta=(axis.max-axis.min)/noTicks,dec=-Math.floor(Math.log(delta)/Math.LN10),maxDec=opts.tickDecimals;if(maxDec!=null&&dec>maxDec){dec=maxDec}var magn=Math.pow(10,-dec),norm=delta/magn,size;if(norm<1.5){size=1}else if(norm<3){size=2;if(norm>2.25&&(maxDec==null||dec+1<=maxDec)){size=2.5;++dec}}else if(norm<7.5){size=5}else{size=10}size*=magn;if(opts.minTickSize!=null&&size<opts.minTickSize){size=opts.minTickSize}axis.delta=delta;axis.tickDecimals=Math.max(0,maxDec!=null?maxDec:dec);axis.tickSize=opts.tickSize||size;if(opts.mode=="time"&&!axis.tickGenerator){throw new Error("Time mode requires the flot.time plugin.")}if(!axis.tickGenerator){axis.tickGenerator=function(axis){var ticks=[],start=floorInBase(axis.min,axis.tickSize),i=0,v=Number.NaN,prev;do{prev=v;v=start+i*axis.tickSize;ticks.push(v);++i}while(v<axis.max&&v!=prev);return ticks};axis.tickFormatter=function(value,axis){var factor=axis.tickDecimals?Math.pow(10,axis.tickDecimals):1;var formatted=""+Math.round(value*factor)/factor;if(axis.tickDecimals!=null){var decimal=formatted.indexOf(".");var precision=decimal==-1?0:formatted.length-decimal-1;if(precision<axis.tickDecimals){return(precision?formatted:formatted+".")+(""+factor).substr(1,axis.tickDecimals-precision)}}return formatted}}if($.isFunction(opts.tickFormatter))axis.tickFormatter=function(v,axis){return""+opts.tickFormatter(v,axis)};if(opts.alignTicksWithAxis!=null){var otherAxis=(axis.direction=="x"?xaxes:yaxes)[opts.alignTicksWithAxis-1];if(otherAxis&&otherAxis.used&&otherAxis!=axis){var niceTicks=axis.tickGenerator(axis);if(niceTicks.length>0){if(opts.min==null)axis.min=Math.min(axis.min,niceTicks[0]);if(opts.max==null&&niceTicks.length>1)axis.max=Math.max(axis.max,niceTicks[niceTicks.length-1])}axis.tickGenerator=function(axis){var ticks=[],v,i;for(i=0;i<otherAxis.ticks.length;++i){v=(otherAxis.ticks[i].v-otherAxis.min)/(otherAxis.max-otherAxis.min);v=axis.min+v*(axis.max-axis.min);ticks.push(v)}return ticks};if(!axis.mode&&opts.tickDecimals==null){var extraDec=Math.max(0,-Math.floor(Math.log(axis.delta)/Math.LN10)+1),ts=axis.tickGenerator(axis);if(!(ts.length>1&&/\..*0$/.test((ts[1]-ts[0]).toFixed(extraDec))))axis.tickDecimals=extraDec}}}}function setTicks(axis){var oticks=axis.options.ticks,ticks=[];if(oticks==null||typeof oticks=="number"&&oticks>0)ticks=axis.tickGenerator(axis);else if(oticks){if($.isFunction(oticks))ticks=oticks(axis);else ticks=oticks}var i,v;axis.ticks=[];for(i=0;i<ticks.length;++i){var label=null;var t=ticks[i];if(typeof t=="object"){v=+t[0];if(t.length>1)label=t[1]}else v=+t;if(label==null)label=axis.tickFormatter(v,axis);if(!isNaN(v))axis.ticks.push({v:v,label:label})}}function snapRangeToTicks(axis,ticks){if(axis.options.autoscaleMargin&&ticks.length>0){if(axis.options.min==null)axis.min=Math.min(axis.min,ticks[0].v);if(axis.options.max==null&&ticks.length>1)axis.max=Math.max(axis.max,ticks[ticks.length-1].v)}}function draw(){surface.clear();executeHooks(hooks.drawBackground,[ctx]);var grid=options.grid;if(grid.show&&grid.backgroundColor)drawBackground();if(grid.show&&!grid.aboveData){drawGrid()}for(var i=0;i<series.length;++i){executeHooks(hooks.drawSeries,[ctx,series[i]]);drawSeries(series[i])}executeHooks(hooks.draw,[ctx]);if(grid.show&&grid.aboveData){drawGrid()}surface.render();triggerRedrawOverlay()}function extractRange(ranges,coord){var axis,from,to,key,axes=allAxes();for(var i=0;i<axes.length;++i){axis=axes[i];if(axis.direction==coord){key=coord+axis.n+"axis";if(!ranges[key]&&axis.n==1)key=coord+"axis";if(ranges[key]){from=ranges[key].from;to=ranges[key].to;break}}}if(!ranges[key]){axis=coord=="x"?xaxes[0]:yaxes[0];from=ranges[coord+"1"];to=ranges[coord+"2"]}if(from!=null&&to!=null&&from>to){var tmp=from;from=to;to=tmp}return{from:from,to:to,axis:axis}}function drawBackground(){ctx.save();ctx.translate(plotOffset.left,plotOffset.top);ctx.fillStyle=getColorOrGradient(options.grid.backgroundColor,plotHeight,0,"rgba(255, 255, 255, 0)");ctx.fillRect(0,0,plotWidth,plotHeight);ctx.restore()}function drawGrid(){var i,axes,bw,bc;ctx.save();ctx.translate(plotOffset.left,plotOffset.top);var markings=options.grid.markings;if(markings){if($.isFunction(markings)){axes=plot.getAxes();axes.xmin=axes.xaxis.min;axes.xmax=axes.xaxis.max;axes.ymin=axes.yaxis.min;axes.ymax=axes.yaxis.max;markings=markings(axes)}for(i=0;i<markings.length;++i){var m=markings[i],xrange=extractRange(m,"x"),yrange=extractRange(m,"y");if(xrange.from==null)xrange.from=xrange.axis.min;if(xrange.to==null)xrange.to=xrange.axis.max;
19−if(yrange.from==null)yrange.from=yrange.axis.min;if(yrange.to==null)yrange.to=yrange.axis.max;if(xrange.to<xrange.axis.min||xrange.from>xrange.axis.max||yrange.to<yrange.axis.min||yrange.from>yrange.axis.max)continue;xrange.from=Math.max(xrange.from,xrange.axis.min);xrange.to=Math.min(xrange.to,xrange.axis.max);yrange.from=Math.max(yrange.from,yrange.axis.min);yrange.to=Math.min(yrange.to,yrange.axis.max);var xequal=xrange.from===xrange.to,yequal=yrange.from===yrange.to;if(xequal&&yequal){continue}xrange.from=Math.floor(xrange.axis.p2c(xrange.from));xrange.to=Math.floor(xrange.axis.p2c(xrange.to));yrange.from=Math.floor(yrange.axis.p2c(yrange.from));yrange.to=Math.floor(yrange.axis.p2c(yrange.to));if(xequal||yequal){var lineWidth=m.lineWidth||options.grid.markingsLineWidth,subPixel=lineWidth%2?.5:0;ctx.beginPath();ctx.strokeStyle=m.color||options.grid.markingsColor;ctx.lineWidth=lineWidth;if(xequal){ctx.moveTo(xrange.to+subPixel,yrange.from);ctx.lineTo(xrange.to+subPixel,yrange.to)}else{ctx.moveTo(xrange.from,yrange.to+subPixel);ctx.lineTo(xrange.to,yrange.to+subPixel)}ctx.stroke()}else{ctx.fillStyle=m.color||options.grid.markingsColor;ctx.fillRect(xrange.from,yrange.to,xrange.to-xrange.from,yrange.from-yrange.to)}}}axes=allAxes();bw=options.grid.borderWidth;for(var j=0;j<axes.length;++j){var axis=axes[j],box=axis.box,t=axis.tickLength,x,y,xoff,yoff;if(!axis.show||axis.ticks.length==0)continue;ctx.lineWidth=1;if(axis.direction=="x"){x=0;if(t=="full")y=axis.position=="top"?0:plotHeight;else y=box.top-plotOffset.top+(axis.position=="top"?box.height:0)}else{y=0;if(t=="full")x=axis.position=="left"?0:plotWidth;else x=box.left-plotOffset.left+(axis.position=="left"?box.width:0)}if(!axis.innermost){ctx.strokeStyle=axis.options.color;ctx.beginPath();xoff=yoff=0;if(axis.direction=="x")xoff=plotWidth+1;else yoff=plotHeight+1;if(ctx.lineWidth==1){if(axis.direction=="x"){y=Math.floor(y)+.5}else{x=Math.floor(x)+.5}}ctx.moveTo(x,y);ctx.lineTo(x+xoff,y+yoff);ctx.stroke()}ctx.strokeStyle=axis.options.tickColor;ctx.beginPath();for(i=0;i<axis.ticks.length;++i){var v=axis.ticks[i].v;xoff=yoff=0;if(isNaN(v)||v<axis.min||v>axis.max||t=="full"&&(typeof bw=="object"&&bw[axis.position]>0||bw>0)&&(v==axis.min||v==axis.max))continue;if(axis.direction=="x"){x=axis.p2c(v);yoff=t=="full"?-plotHeight:t;if(axis.position=="top")yoff=-yoff}else{y=axis.p2c(v);xoff=t=="full"?-plotWidth:t;if(axis.position=="left")xoff=-xoff}if(ctx.lineWidth==1){if(axis.direction=="x")x=Math.floor(x)+.5;else y=Math.floor(y)+.5}ctx.moveTo(x,y);ctx.lineTo(x+xoff,y+yoff)}ctx.stroke()}if(bw){bc=options.grid.borderColor;if(typeof bw=="object"||typeof bc=="object"){if(typeof bw!=="object"){bw={top:bw,right:bw,bottom:bw,left:bw}}if(typeof bc!=="object"){bc={top:bc,right:bc,bottom:bc,left:bc}}if(bw.top>0){ctx.strokeStyle=bc.top;ctx.lineWidth=bw.top;ctx.beginPath();ctx.moveTo(0-bw.left,0-bw.top/2);ctx.lineTo(plotWidth,0-bw.top/2);ctx.stroke()}if(bw.right>0){ctx.strokeStyle=bc.right;ctx.lineWidth=bw.right;ctx.beginPath();ctx.moveTo(plotWidth+bw.right/2,0-bw.top);ctx.lineTo(plotWidth+bw.right/2,plotHeight);ctx.stroke()}if(bw.bottom>0){ctx.strokeStyle=bc.bottom;ctx.lineWidth=bw.bottom;ctx.beginPath();ctx.moveTo(plotWidth+bw.right,plotHeight+bw.bottom/2);ctx.lineTo(0,plotHeight+bw.bottom/2);ctx.stroke()}if(bw.left>0){ctx.strokeStyle=bc.left;ctx.lineWidth=bw.left;ctx.beginPath();ctx.moveTo(0-bw.left/2,plotHeight+bw.bottom);ctx.lineTo(0-bw.left/2,0);ctx.stroke()}}else{ctx.lineWidth=bw;ctx.strokeStyle=options.grid.borderColor;ctx.strokeRect(-bw/2,-bw/2,plotWidth+bw,plotHeight+bw)}}ctx.restore()}function drawAxisLabels(){$.each(allAxes(),function(_,axis){var box=axis.box,legacyStyles=axis.direction+"Axis "+axis.direction+axis.n+"Axis",layer="flot-"+axis.direction+"-axis flot-"+axis.direction+axis.n+"-axis "+legacyStyles,font=axis.options.font||"flot-tick-label tickLabel",tick,x,y,halign,valign;surface.removeText(layer);if(!axis.show||axis.ticks.length==0)return;for(var i=0;i<axis.ticks.length;++i){tick=axis.ticks[i];if(!tick.label||tick.v<axis.min||tick.v>axis.max)continue;if(axis.direction=="x"){halign="center";x=plotOffset.left+axis.p2c(tick.v);if(axis.position=="bottom"){y=box.top+box.padding}else{y=box.top+box.height-box.padding;valign="bottom"}}else{valign="middle";y=plotOffset.top+axis.p2c(tick.v);if(axis.position=="left"){x=box.left+box.width-box.padding;halign="right"}else{x=box.left+box.padding}}surface.addText(layer,x,y,tick.label,font,null,null,halign,valign)}})}function drawSeries(series){if(series.lines.show)drawSeriesLines(series);if(series.bars.show)drawSeriesBars(series);if(series.points.show)drawSeriesPoints(series)}function drawSeriesLines(series){function plotLine(datapoints,xoffset,yoffset,axisx,axisy){var points=datapoints.points,ps=datapoints.pointsize,prevx=null,prevy=null;ctx.beginPath();for(var i=ps;i<points.length;i+=ps){var x1=points[i-ps],y1=points[i-ps+1],x2=points[i],y2=points[i+1];if(x1==null||x2==null)continue;if(y1<=y2&&y1<axisy.min){if(y2<axisy.min)continue;x1=(axisy.min-y1)/(y2-y1)*(x2-x1)+x1;y1=axisy.min}else if(y2<=y1&&y2<axisy.min){if(y1<axisy.min)continue;x2=(axisy.min-y1)/(y2-y1)*(x2-x1)+x1;y2=axisy.min}if(y1>=y2&&y1>axisy.max){if(y2>axisy.max)continue;x1=(axisy.max-y1)/(y2-y1)*(x2-x1)+x1;y1=axisy.max}else if(y2>=y1&&y2>axisy.max){if(y1>axisy.max)continue;x2=(axisy.max-y1)/(y2-y1)*(x2-x1)+x1;y2=axisy.max}if(x1<=x2&&x1<axisx.min){if(x2<axisx.min)continue;y1=(axisx.min-x1)/(x2-x1)*(y2-y1)+y1;x1=axisx.min}else if(x2<=x1&&x2<axisx.min){if(x1<axisx.min)continue;y2=(axisx.min-x1)/(x2-x1)*(y2-y1)+y1;x2=axisx.min}if(x1>=x2&&x1>axisx.max){if(x2>axisx.max)continue;y1=(axisx.max-x1)/(x2-x1)*(y2-y1)+y1;x1=axisx.max}else if(x2>=x1&&x2>axisx.max){if(x1>axisx.max)continue;y2=(axisx.max-x1)/(x2-x1)*(y2-y1)+y1;x2=axisx.max}if(x1!=prevx||y1!=prevy)ctx.moveTo(axisx.p2c(x1)+xoffset,axisy.p2c(y1)+yoffset);prevx=x2;prevy=y2;ctx.lineTo(axisx.p2c(x2)+xoffset,axisy.p2c(y2)+yoffset)}ctx.stroke()}function plotLineArea(datapoints,axisx,axisy){var points=datapoints.points,ps=datapoints.pointsize,bottom=Math.min(Math.max(0,axisy.min),axisy.max),i=0,top,areaOpen=false,ypos=1,segmentStart=0,segmentEnd=0;while(true){if(ps>0&&i>points.length+ps)break;i+=ps;var x1=points[i-ps],y1=points[i-ps+ypos],x2=points[i],y2=points[i+ypos];if(areaOpen){if(ps>0&&x1!=null&&x2==null){segmentEnd=i;ps=-ps;ypos=2;continue}if(ps<0&&i==segmentStart+ps){ctx.fill();areaOpen=false;ps=-ps;ypos=1;i=segmentStart=segmentEnd+ps;continue}}if(x1==null||x2==null)continue;if(x1<=x2&&x1<axisx.min){if(x2<axisx.min)continue;y1=(axisx.min-x1)/(x2-x1)*(y2-y1)+y1;x1=axisx.min}else if(x2<=x1&&x2<axisx.min){if(x1<axisx.min)continue;y2=(axisx.min-x1)/(x2-x1)*(y2-y1)+y1;x2=axisx.min}if(x1>=x2&&x1>axisx.max){if(x2>axisx.max)continue;y1=(axisx.max-x1)/(x2-x1)*(y2-y1)+y1;x1=axisx.max}else if(x2>=x1&&x2>axisx.max){if(x1>axisx.max)continue;y2=(axisx.max-x1)/(x2-x1)*(y2-y1)+y1;x2=axisx.max}if(!areaOpen){ctx.beginPath();ctx.moveTo(axisx.p2c(x1),axisy.p2c(bottom));areaOpen=true}if(y1>=axisy.max&&y2>=axisy.max){ctx.lineTo(axisx.p2c(x1),axisy.p2c(axisy.max));ctx.lineTo(axisx.p2c(x2),axisy.p2c(axisy.max));continue}else if(y1<=axisy.min&&y2<=axisy.min){ctx.lineTo(axisx.p2c(x1),axisy.p2c(axisy.min));ctx.lineTo(axisx.p2c(x2),axisy.p2c(axisy.min));continue}var x1old=x1,x2old=x2;if(y1<=y2&&y1<axisy.min&&y2>=axisy.min){x1=(axisy.min-y1)/(y2-y1)*(x2-x1)+x1;y1=axisy.min}else if(y2<=y1&&y2<axisy.min&&y1>=axisy.min){x2=(axisy.min-y1)/(y2-y1)*(x2-x1)+x1;y2=axisy.min}if(y1>=y2&&y1>axisy.max&&y2<=axisy.max){x1=(axisy.max-y1)/(y2-y1)*(x2-x1)+x1;y1=axisy.max}else if(y2>=y1&&y2>axisy.max&&y1<=axisy.max){x2=(axisy.max-y1)/(y2-y1)*(x2-x1)+x1;y2=axisy.max}if(x1!=x1old){ctx.lineTo(axisx.p2c(x1old),axisy.p2c(y1))}ctx.lineTo(axisx.p2c(x1),axisy.p2c(y1));ctx.lineTo(axisx.p2c(x2),axisy.p2c(y2));if(x2!=x2old){ctx.lineTo(axisx.p2c(x2),axisy.p2c(y2));ctx.lineTo(axisx.p2c(x2old),axisy.p2c(y2))}}}ctx.save();ctx.translate(plotOffset.left,plotOffset.top);ctx.lineJoin="round";var lw=series.lines.lineWidth,sw=series.shadowSize;if(lw>0&&sw>0){ctx.lineWidth=sw;ctx.strokeStyle="rgba(0,0,0,0.1)";var angle=Math.PI/18;plotLine(series.datapoints,Math.sin(angle)*(lw/2+sw/2),Math.cos(angle)*(lw/2+sw/2),series.xaxis,series.yaxis);ctx.lineWidth=sw/2;plotLine(series.datapoints,Math.sin(angle)*(lw/2+sw/4),Math.cos(angle)*(lw/2+sw/4),series.xaxis,series.yaxis)}ctx.lineWidth=lw;ctx.strokeStyle=series.color;var fillStyle=getFillStyle(series.lines,series.color,0,plotHeight);if(fillStyle){ctx.fillStyle=fillStyle;plotLineArea(series.datapoints,series.xaxis,series.yaxis)}if(lw>0)plotLine(series.datapoints,0,0,series.xaxis,series.yaxis);ctx.restore()}function drawSeriesPoints(series){function plotPoints(datapoints,radius,fillStyle,offset,shadow,axisx,axisy,symbol){var points=datapoints.points,ps=datapoints.pointsize;for(var i=0;i<points.length;i+=ps){var x=points[i],y=points[i+1];if(x==null||x<axisx.min||x>axisx.max||y<axisy.min||y>axisy.max)continue;ctx.beginPath();x=axisx.p2c(x);y=axisy.p2c(y)+offset;if(symbol=="circle")ctx.arc(x,y,radius,0,shadow?Math.PI:Math.PI*2,false);else symbol(ctx,x,y,radius,shadow);ctx.closePath();if(fillStyle){ctx.fillStyle=fillStyle;ctx.fill()}ctx.stroke()}}ctx.save();ctx.translate(plotOffset.left,plotOffset.top);var lw=series.points.lineWidth,sw=series.shadowSize,radius=series.points.radius,symbol=series.points.symbol;if(lw==0)lw=1e-4;if(lw>0&&sw>0){var w=sw/2;ctx.lineWidth=w;ctx.strokeStyle="rgba(0,0,0,0.1)";plotPoints(series.datapoints,radius,null,w+w/2,true,series.xaxis,series.yaxis,symbol);ctx.strokeStyle="rgba(0,0,0,0.2)";plotPoints(series.datapoints,radius,null,w/2,true,series.xaxis,series.yaxis,symbol)}ctx.lineWidth=lw;ctx.strokeStyle=series.color;plotPoints(series.datapoints,radius,getFillStyle(series.points,series.color),0,false,series.xaxis,series.yaxis,symbol);ctx.restore()}function drawBar(x,y,b,barLeft,barRight,fillStyleCallback,axisx,axisy,c,horizontal,lineWidth){var left,right,bottom,top,drawLeft,drawRight,drawTop,drawBottom,tmp;if(horizontal){drawBottom=drawRight=drawTop=true;drawLeft=false;left=b;right=x;top=y+barLeft;bottom=y+barRight;if(right<left){tmp=right;right=left;left=tmp;drawLeft=true;drawRight=false}}else{drawLeft=drawRight=drawTop=true;drawBottom=false;left=x+barLeft;right=x+barRight;bottom=b;top=y;if(top<bottom){tmp=top;top=bottom;bottom=tmp;drawBottom=true;drawTop=false}}if(right<axisx.min||left>axisx.max||top<axisy.min||bottom>axisy.max)return;if(left<axisx.min){left=axisx.min;drawLeft=false}if(right>axisx.max){right=axisx.max;drawRight=false}if(bottom<axisy.min){bottom=axisy.min;drawBottom=false}if(top>axisy.max){top=axisy.max;drawTop=false}left=axisx.p2c(left);bottom=axisy.p2c(bottom);right=axisx.p2c(right);top=axisy.p2c(top);if(fillStyleCallback){c.fillStyle=fillStyleCallback(bottom,top);c.fillRect(left,top,right-left,bottom-top)}if(lineWidth>0&&(drawLeft||drawRight||drawTop||drawBottom)){c.beginPath();c.moveTo(left,bottom);if(drawLeft)c.lineTo(left,top);else c.moveTo(left,top);if(drawTop)c.lineTo(right,top);else c.moveTo(right,top);if(drawRight)c.lineTo(right,bottom);else c.moveTo(right,bottom);if(drawBottom)c.lineTo(left,bottom);else c.moveTo(left,bottom);c.stroke()}}function drawSeriesBars(series){function plotBars(datapoints,barLeft,barRight,fillStyleCallback,axisx,axisy){var points=datapoints.points,ps=datapoints.pointsize;for(var i=0;i<points.length;i+=ps){if(points[i]==null)continue;drawBar(points[i],points[i+1],points[i+2],barLeft,barRight,fillStyleCallback,axisx,axisy,ctx,series.bars.horizontal,series.bars.lineWidth)}}ctx.save();ctx.translate(plotOffset.left,plotOffset.top);ctx.lineWidth=series.bars.lineWidth;ctx.strokeStyle=series.color;var barLeft;switch(series.bars.align){case"left":barLeft=0;break;case"right":barLeft=-series.bars.barWidth;break;default:barLeft=-series.bars.barWidth/2}var fillStyleCallback=series.bars.fill?function(bottom,top){return getFillStyle(series.bars,series.color,bottom,top)}:null;plotBars(series.datapoints,barLeft,barLeft+series.bars.barWidth,fillStyleCallback,series.xaxis,series.yaxis);ctx.restore()}function getFillStyle(filloptions,seriesColor,bottom,top){var fill=filloptions.fill;if(!fill)return null;if(filloptions.fillColor)return getColorOrGradient(filloptions.fillColor,bottom,top,seriesColor);var c=$.color.parse(seriesColor);c.a=typeof fill=="number"?fill:.4;c.normalize();return c.toString()}function insertLegend(){if(options.legend.container!=null){$(options.legend.container).html("")}else{placeholder.find(".legend").remove()}if(!options.legend.show){return}var fragments=[],entries=[],rowStarted=false,lf=options.legend.labelFormatter,s,label;for(var i=0;i<series.length;++i){s=series[i];if(s.label){label=lf?lf(s.label,s):s.label;if(label){entries.push({label:label,color:s.color})}}}if(options.legend.sorted){if($.isFunction(options.legend.sorted)){entries.sort(options.legend.sorted)}else if(options.legend.sorted=="reverse"){entries.reverse()}else{var ascending=options.legend.sorted!="descending";entries.sort(function(a,b){return a.label==b.label?0:a.label<b.label!=ascending?1:-1})}}for(var i=0;i<entries.length;++i){var entry=entries[i];if(i%options.legend.noColumns==0){if(rowStarted)fragments.push("</tr>");fragments.push("<tr>");rowStarted=true}fragments.push('<td class="legendColorBox"><div style="border:1px solid '+options.legend.labelBoxBorderColor+';padding:1px"><div style="width:4px;height:0;border:5px solid '+entry.color+';overflow:hidden"></div></div></td>'+'<td class="legendLabel">'+entry.label+"</td>")}if(rowStarted)fragments.push("</tr>");if(fragments.length==0)return;var table='<table style="font-size:smaller;color:'+options.grid.color+'">'+fragments.join("")+"</table>";if(options.legend.container!=null)$(options.legend.container).html(table);else{var pos="",p=options.legend.position,m=options.legend.margin;if(m[0]==null)m=[m,m];if(p.charAt(0)=="n")pos+="top:"+(m[1]+plotOffset.top)+"px;";else if(p.charAt(0)=="s")pos+="bottom:"+(m[1]+plotOffset.bottom)+"px;";if(p.charAt(1)=="e")pos+="right:"+(m[0]+plotOffset.right)+"px;";else if(p.charAt(1)=="w")pos+="left:"+(m[0]+plotOffset.left)+"px;";var legend=$('<div class="legend">'+table.replace('style="','style="position:absolute;'+pos+";")+"</div>").appendTo(placeholder);if(options.legend.backgroundOpacity!=0){var c=options.legend.backgroundColor;if(c==null){c=options.grid.backgroundColor;if(c&&typeof c=="string")c=$.color.parse(c);else c=$.color.extract(legend,"background-color");c.a=1;c=c.toString()}var div=legend.children();$('<div style="position:absolute;width:'+div.width()+"px;height:"+div.height()+"px;"+pos+"background-color:"+c+';"> </div>').prependTo(legend).css("opacity",options.legend.backgroundOpacity)}}}var highlights=[],redrawTimeout=null;function findNearbyItem(mouseX,mouseY,seriesFilter){var maxDistance=options.grid.mouseActiveRadius,smallestDistance=maxDistance*maxDistance+1,item=null,foundPoint=false,i,j,ps;for(i=series.length-1;i>=0;--i){if(!seriesFilter(series[i]))continue;var s=series[i],axisx=s.xaxis,axisy=s.yaxis,points=s.datapoints.points,mx=axisx.c2p(mouseX),my=axisy.c2p(mouseY),maxx=maxDistance/axisx.scale,maxy=maxDistance/axisy.scale;ps=s.datapoints.pointsize;if(axisx.options.inverseTransform)maxx=Number.MAX_VALUE;if(axisy.options.inverseTransform)maxy=Number.MAX_VALUE;if(s.lines.show||s.points.show){for(j=0;j<points.length;j+=ps){var x=points[j],y=points[j+1];if(x==null)continue;if(x-mx>maxx||x-mx<-maxx||y-my>maxy||y-my<-maxy)continue;var dx=Math.abs(axisx.p2c(x)-mouseX),dy=Math.abs(axisy.p2c(y)-mouseY),dist=dx*dx+dy*dy;if(dist<smallestDistance){smallestDistance=dist;item=[i,j/ps]}}}if(s.bars.show&&!item){var barLeft,barRight;switch(s.bars.align){case"left":barLeft=0;break;case"right":barLeft=-s.bars.barWidth;break;default:barLeft=-s.bars.barWidth/2}barRight=barLeft+s.bars.barWidth;for(j=0;j<points.length;j+=ps){var x=points[j],y=points[j+1],b=points[j+2];if(x==null)continue;if(series[i].bars.horizontal?mx<=Math.max(b,x)&&mx>=Math.min(b,x)&&my>=y+barLeft&&my<=y+barRight:mx>=x+barLeft&&mx<=x+barRight&&my>=Math.min(b,y)&&my<=Math.max(b,y))item=[i,j/ps]}}}if(item){i=item[0];j=item[1];ps=series[i].datapoints.pointsize;return{datapoint:series[i].datapoints.points.slice(j*ps,(j+1)*ps),dataIndex:j,series:series[i],seriesIndex:i}}return null}function onMouseMove(e){if(options.grid.hoverable)triggerClickHoverEvent("plothover",e,function(s){return s["hoverable"]!=false})}function onMouseLeave(e){if(options.grid.hoverable)triggerClickHoverEvent("plothover",e,function(s){return false})}function onClick(e){triggerClickHoverEvent("plotclick",e,function(s){return s["clickable"]!=false})}function triggerClickHoverEvent(eventname,event,seriesFilter){var offset=eventHolder.offset(),canvasX=event.pageX-offset.left-plotOffset.left,canvasY=event.pageY-offset.top-plotOffset.top,pos=canvasToAxisCoords({left:canvasX,top:canvasY});pos.pageX=event.pageX;pos.pageY=event.pageY;var item=findNearbyItem(canvasX,canvasY,seriesFilter);if(item){item.pageX=parseInt(item.series.xaxis.p2c(item.datapoint[0])+offset.left+plotOffset.left,10);item.pageY=parseInt(item.series.yaxis.p2c(item.datapoint[1])+offset.top+plotOffset.top,10)}if(options.grid.autoHighlight){for(var i=0;i<highlights.length;++i){var h=highlights[i];if(h.auto==eventname&&!(item&&h.series==item.series&&h.point[0]==item.datapoint[0]&&h.point[1]==item.datapoint[1]))unhighlight(h.series,h.point)}if(item)highlight(item.series,item.datapoint,eventname)}placeholder.trigger(eventname,[pos,item])}function triggerRedrawOverlay(){var t=options.interaction.redrawOverlayInterval;if(t==-1){drawOverlay();return}if(!redrawTimeout)redrawTimeout=setTimeout(drawOverlay,t)}function drawOverlay(){redrawTimeout=null;octx.save();overlay.clear();octx.translate(plotOffset.left,plotOffset.top);var i,hi;for(i=0;i<highlights.length;++i){hi=highlights[i];if(hi.series.bars.show)drawBarHighlight(hi.series,hi.point);else drawPointHighlight(hi.series,hi.point)}octx.restore();executeHooks(hooks.drawOverlay,[octx])}function highlight(s,point,auto){if(typeof s=="number")s=series[s];if(typeof point=="number"){var ps=s.datapoints.pointsize;point=s.datapoints.points.slice(ps*point,ps*(point+1))}var i=indexOfHighlight(s,point);if(i==-1){highlights.push({series:s,point:point,auto:auto});triggerRedrawOverlay()}else if(!auto)highlights[i].auto=false}function unhighlight(s,point){if(s==null&&point==null){highlights=[];triggerRedrawOverlay();return}if(typeof s=="number")s=series[s];if(typeof point=="number"){var ps=s.datapoints.pointsize;point=s.datapoints.points.slice(ps*point,ps*(point+1))}var i=indexOfHighlight(s,point);if(i!=-1){highlights.splice(i,1);triggerRedrawOverlay()}}function indexOfHighlight(s,p){for(var i=0;i<highlights.length;++i){var h=highlights[i];if(h.series==s&&h.point[0]==p[0]&&h.point[1]==p[1])return i}return-1}function drawPointHighlight(series,point){var x=point[0],y=point[1],axisx=series.xaxis,axisy=series.yaxis,highlightColor=typeof series.highlightColor==="string"?series.highlightColor:$.color.parse(series.color).scale("a",.5).toString();if(x<axisx.min||x>axisx.max||y<axisy.min||y>axisy.max)return;var pointRadius=series.points.radius+series.points.lineWidth/2;octx.lineWidth=pointRadius;octx.strokeStyle=highlightColor;var radius=1.5*pointRadius;x=axisx.p2c(x);y=axisy.p2c(y);octx.beginPath();if(series.points.symbol=="circle")octx.arc(x,y,radius,0,2*Math.PI,false);else series.points.symbol(octx,x,y,radius,false);octx.closePath();octx.stroke()}function drawBarHighlight(series,point){var highlightColor=typeof series.highlightColor==="string"?series.highlightColor:$.color.parse(series.color).scale("a",.5).toString(),fillStyle=highlightColor,barLeft;switch(series.bars.align){case"left":barLeft=0;break;case"right":barLeft=-series.bars.barWidth;break;default:barLeft=-series.bars.barWidth/2}octx.lineWidth=series.bars.lineWidth;octx.strokeStyle=highlightColor;drawBar(point[0],point[1],point[2]||0,barLeft,barLeft+series.bars.barWidth,function(){return fillStyle},series.xaxis,series.yaxis,octx,series.bars.horizontal,series.bars.lineWidth)}function getColorOrGradient(spec,bottom,top,defaultColor){if(typeof spec=="string")return spec;else{var gradient=ctx.createLinearGradient(0,top,0,bottom);for(var i=0,l=spec.colors.length;i<l;++i){var c=spec.colors[i];if(typeof c!="string"){var co=$.color.parse(defaultColor);if(c.brightness!=null)co=co.scale("rgb",c.brightness);if(c.opacity!=null)co.a*=c.opacity;c=co.toString()}gradient.addColorStop(i/(l-1),c)}return gradient}}}$.plot=function(placeholder,data,options){var plot=new Plot($(placeholder),data,options,$.plot.plugins);return plot};$.plot.version="0.8.3";$.plot.plugins=[];$.fn.plot=function(data,options){return this.each(function(){$.plot(this,data,options)})};function floorInBase(n,base){return base*Math.floor(n/base)}})(jQuery);
20− </script>
21− <script language="javascript" type="text/javascript">
22− /* Javascript plotting library for jQuery, version 0.8.3.
23−
24−Copyright (c) 2007-2014 IOLA and Ole Laursen.
25−Licensed under the MIT license.
26−
27−*/
28−(function($){var options={series:{points:{errorbars:null,xerr:{err:"x",show:null,asymmetric:null,upperCap:null,lowerCap:null,color:null,radius:null},yerr:{err:"y",show:null,asymmetric:null,upperCap:null,lowerCap:null,color:null,radius:null}}}};function processRawData(plot,series,data,datapoints){if(!series.points.errorbars)return;var format=[{x:true,number:true,required:true},{y:true,number:true,required:true}];var errors=series.points.errorbars;if(errors=="x"||errors=="xy"){if(series.points.xerr.asymmetric){format.push({x:true,number:true,required:true});format.push({x:true,number:true,required:true})}else format.push({x:true,number:true,required:true})}if(errors=="y"||errors=="xy"){if(series.points.yerr.asymmetric){format.push({y:true,number:true,required:true});format.push({y:true,number:true,required:true})}else format.push({y:true,number:true,required:true})}datapoints.format=format}function parseErrors(series,i){var points=series.datapoints.points;var exl=null,exu=null,eyl=null,eyu=null;var xerr=series.points.xerr,yerr=series.points.yerr;var eb=series.points.errorbars;if(eb=="x"||eb=="xy"){if(xerr.asymmetric){exl=points[i+2];exu=points[i+3];if(eb=="xy")if(yerr.asymmetric){eyl=points[i+4];eyu=points[i+5]}else eyl=points[i+4]}else{exl=points[i+2];if(eb=="xy")if(yerr.asymmetric){eyl=points[i+3];eyu=points[i+4]}else eyl=points[i+3]}}else if(eb=="y")if(yerr.asymmetric){eyl=points[i+2];eyu=points[i+3]}else eyl=points[i+2];if(exu==null)exu=exl;if(eyu==null)eyu=eyl;var errRanges=[exl,exu,eyl,eyu];if(!xerr.show){errRanges[0]=null;errRanges[1]=null}if(!yerr.show){errRanges[2]=null;errRanges[3]=null}return errRanges}function drawSeriesErrors(plot,ctx,s){var points=s.datapoints.points,ps=s.datapoints.pointsize,ax=[s.xaxis,s.yaxis],radius=s.points.radius,err=[s.points.xerr,s.points.yerr];var invertX=false;if(ax[0].p2c(ax[0].max)<ax[0].p2c(ax[0].min)){invertX=true;var tmp=err[0].lowerCap;err[0].lowerCap=err[0].upperCap;err[0].upperCap=tmp}var invertY=false;if(ax[1].p2c(ax[1].min)<ax[1].p2c(ax[1].max)){invertY=true;var tmp=err[1].lowerCap;err[1].lowerCap=err[1].upperCap;err[1].upperCap=tmp}for(var i=0;i<s.datapoints.points.length;i+=ps){var errRanges=parseErrors(s,i);for(var e=0;e<err.length;e++){var minmax=[ax[e].min,ax[e].max];if(errRanges[e*err.length]){var x=points[i],y=points[i+1];var upper=[x,y][e]+errRanges[e*err.length+1],lower=[x,y][e]-errRanges[e*err.length];if(err[e].err=="x")if(y>ax[1].max||y<ax[1].min||upper<ax[0].min||lower>ax[0].max)continue;if(err[e].err=="y")if(x>ax[0].max||x<ax[0].min||upper<ax[1].min||lower>ax[1].max)continue;var drawUpper=true,drawLower=true;if(upper>minmax[1]){drawUpper=false;upper=minmax[1]}if(lower<minmax[0]){drawLower=false;lower=minmax[0]}if(err[e].err=="x"&&invertX||err[e].err=="y"&&invertY){var tmp=lower;lower=upper;upper=tmp;tmp=drawLower;drawLower=drawUpper;drawUpper=tmp;tmp=minmax[0];minmax[0]=minmax[1];minmax[1]=tmp}x=ax[0].p2c(x),y=ax[1].p2c(y),upper=ax[e].p2c(upper);lower=ax[e].p2c(lower);minmax[0]=ax[e].p2c(minmax[0]);minmax[1]=ax[e].p2c(minmax[1]);var lw=err[e].lineWidth?err[e].lineWidth:s.points.lineWidth,sw=s.points.shadowSize!=null?s.points.shadowSize:s.shadowSize;if(lw>0&&sw>0){var w=sw/2;ctx.lineWidth=w;ctx.strokeStyle="rgba(0,0,0,0.1)";drawError(ctx,err[e],x,y,upper,lower,drawUpper,drawLower,radius,w+w/2,minmax);ctx.strokeStyle="rgba(0,0,0,0.2)";drawError(ctx,err[e],x,y,upper,lower,drawUpper,drawLower,radius,w/2,minmax)}ctx.strokeStyle=err[e].color?err[e].color:s.color;ctx.lineWidth=lw;drawError(ctx,err[e],x,y,upper,lower,drawUpper,drawLower,radius,0,minmax)}}}}function drawError(ctx,err,x,y,upper,lower,drawUpper,drawLower,radius,offset,minmax){y+=offset;upper+=offset;lower+=offset;if(err.err=="x"){if(upper>x+radius)drawPath(ctx,[[upper,y],[Math.max(x+radius,minmax[0]),y]]);else drawUpper=false;if(lower<x-radius)drawPath(ctx,[[Math.min(x-radius,minmax[1]),y],[lower,y]]);else drawLower=false}else{if(upper<y-radius)drawPath(ctx,[[x,upper],[x,Math.min(y-radius,minmax[0])]]);else drawUpper=false;if(lower>y+radius)drawPath(ctx,[[x,Math.max(y+radius,minmax[1])],[x,lower]]);else drawLower=false}radius=err.radius!=null?err.radius:radius;if(drawUpper){if(err.upperCap=="-"){if(err.err=="x")drawPath(ctx,[[upper,y-radius],[upper,y+radius]]);else drawPath(ctx,[[x-radius,upper],[x+radius,upper]])}else if($.isFunction(err.upperCap)){if(err.err=="x")err.upperCap(ctx,upper,y,radius);else err.upperCap(ctx,x,upper,radius)}}if(drawLower){if(err.lowerCap=="-"){if(err.err=="x")drawPath(ctx,[[lower,y-radius],[lower,y+radius]]);else drawPath(ctx,[[x-radius,lower],[x+radius,lower]])}else if($.isFunction(err.lowerCap)){if(err.err=="x")err.lowerCap(ctx,lower,y,radius);else err.lowerCap(ctx,x,lower,radius)}}}function drawPath(ctx,pts){ctx.beginPath();ctx.moveTo(pts[0][0],pts[0][1]);for(var p=1;p<pts.length;p++)ctx.lineTo(pts[p][0],pts[p][1]);ctx.stroke()}function draw(plot,ctx){var plotOffset=plot.getPlotOffset();ctx.save();ctx.translate(plotOffset.left,plotOffset.top);$.each(plot.getData(),function(i,s){if(s.points.errorbars&&(s.points.xerr.show||s.points.yerr.show))drawSeriesErrors(plot,ctx,s)});ctx.restore()}function init(plot){plot.hooks.processRawData.push(processRawData);plot.hooks.draw.push(draw)}$.plot.plugins.push({init:init,options:options,name:"errorbars",version:"1.0"})})(jQuery);
29− </script>
30− <script language="javascript" type="text/javascript">
31− /* Javascript plotting library for jQuery, version 0.8.3.
32−
33−Copyright (c) 2007-2014 IOLA and Ole Laursen.
34−Licensed under the MIT license.
35−
36−*/
37−(function(a){function e(h){var k,j=this,l=h.data||{};if(l.elem)j=h.dragTarget=l.elem,h.dragProxy=d.proxy||j,h.cursorOffsetX=l.pageX-l.left,h.cursorOffsetY=l.pageY-l.top,h.offsetX=h.pageX-h.cursorOffsetX,h.offsetY=h.pageY-h.cursorOffsetY;else if(d.dragging||l.which>0&&h.which!=l.which||a(h.target).is(l.not))return;switch(h.type){case"mousedown":return a.extend(l,a(j).offset(),{elem:j,target:h.target,pageX:h.pageX,pageY:h.pageY}),b.add(document,"mousemove mouseup",e,l),i(j,!1),d.dragging=null,!1;case!d.dragging&&"mousemove":if(g(h.pageX-l.pageX)+g(h.pageY-l.pageY)<l.distance)break;h.target=l.target,k=f(h,"dragstart",j),k!==!1&&(d.dragging=j,d.proxy=h.dragProxy=a(k||j)[0]);case"mousemove":if(d.dragging){if(k=f(h,"drag",j),c.drop&&(c.drop.allowed=k!==!1,c.drop.handler(h)),k!==!1)break;h.type="mouseup"}case"mouseup":b.remove(document,"mousemove mouseup",e),d.dragging&&(c.drop&&c.drop.handler(h),f(h,"dragend",j)),i(j,!0),d.dragging=d.proxy=l.elem=!1}return!0}function f(b,c,d){b.type=c;var e=a.event.dispatch.call(d,b);return e===!1?!1:e||b.result}function g(a){return Math.pow(a,2)}function h(){return d.dragging===!1}function i(a,b){a&&(a.unselectable=b?"off":"on",a.onselectstart=function(){return b},a.style&&(a.style.MozUserSelect=b?"":"none"))}a.fn.drag=function(a,b,c){return b&&this.bind("dragstart",a),c&&this.bind("dragend",c),a?this.bind("drag",b?b:a):this.trigger("drag")};var b=a.event,c=b.special,d=c.drag={not:":input",distance:0,which:1,dragging:!1,setup:function(c){c=a.extend({distance:d.distance,which:d.which,not:d.not},c||{}),c.distance=g(c.distance),b.add(this,"mousedown",e,c),this.attachEvent&&this.attachEvent("ondragstart",h)},teardown:function(){b.remove(this,"mousedown",e),this===d.dragging&&(d.dragging=d.proxy=!1),i(this,!0),this.detachEvent&&this.detachEvent("ondragstart",h)}};c.dragstart=c.dragend={setup:function(){},teardown:function(){}}})(jQuery);(function(d){function e(a){var b=a||window.event,c=[].slice.call(arguments,1),f=0,e=0,g=0,a=d.event.fix(b);a.type="mousewheel";b.wheelDelta&&(f=b.wheelDelta/120);b.detail&&(f=-b.detail/3);g=f;void 0!==b.axis&&b.axis===b.HORIZONTAL_AXIS&&(g=0,e=-1*f);void 0!==b.wheelDeltaY&&(g=b.wheelDeltaY/120);void 0!==b.wheelDeltaX&&(e=-1*b.wheelDeltaX/120);c.unshift(a,f,e,g);return(d.event.dispatch||d.event.handle).apply(this,c)}var c=["DOMMouseScroll","mousewheel"];if(d.event.fixHooks)for(var h=c.length;h;)d.event.fixHooks[c[--h]]=d.event.mouseHooks;d.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=c.length;a;)this.addEventListener(c[--a],e,!1);else this.onmousewheel=e},teardown:function(){if(this.removeEventListener)for(var a=c.length;a;)this.removeEventListener(c[--a],e,!1);else this.onmousewheel=null}};d.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);(function($){var options={xaxis:{zoomRange:null,panRange:null},zoom:{interactive:false,trigger:"dblclick",amount:1.5},pan:{interactive:false,cursor:"move",frameRate:20}};function init(plot){function onZoomClick(e,zoomOut){var c=plot.offset();c.left=e.pageX-c.left;c.top=e.pageY-c.top;if(zoomOut)plot.zoomOut({center:c});else plot.zoom({center:c})}function onMouseWheel(e,delta){e.preventDefault();onZoomClick(e,delta<0);return false}var prevCursor="default",prevPageX=0,prevPageY=0,panTimeout=null;function onDragStart(e){if(e.which!=1)return false;var c=plot.getPlaceholder().css("cursor");if(c)prevCursor=c;plot.getPlaceholder().css("cursor",plot.getOptions().pan.cursor);prevPageX=e.pageX;prevPageY=e.pageY}function onDrag(e){var frameRate=plot.getOptions().pan.frameRate;if(panTimeout||!frameRate)return;panTimeout=setTimeout(function(){plot.pan({left:prevPageX-e.pageX,top:prevPageY-e.pageY});prevPageX=e.pageX;prevPageY=e.pageY;panTimeout=null},1/frameRate*1e3)}function onDragEnd(e){if(panTimeout){clearTimeout(panTimeout);panTimeout=null}plot.getPlaceholder().css("cursor",prevCursor);plot.pan({left:prevPageX-e.pageX,top:prevPageY-e.pageY})}function bindEvents(plot,eventHolder){var o=plot.getOptions();if(o.zoom.interactive){eventHolder[o.zoom.trigger](onZoomClick);eventHolder.mousewheel(onMouseWheel)}if(o.pan.interactive){eventHolder.bind("dragstart",{distance:10},onDragStart);eventHolder.bind("drag",onDrag);eventHolder.bind("dragend",onDragEnd)}}plot.zoomOut=function(args){if(!args)args={};if(!args.amount)args.amount=plot.getOptions().zoom.amount;args.amount=1/args.amount;plot.zoom(args)};plot.zoom=function(args){if(!args)args={};var c=args.center,amount=args.amount||plot.getOptions().zoom.amount,w=plot.width(),h=plot.height();if(!c)c={left:w/2,top:h/2};var xf=c.left/w,yf=c.top/h,minmax={x:{min:c.left-xf*w/amount,max:c.left+(1-xf)*w/amount},y:{min:c.top-yf*h/amount,max:c.top+(1-yf)*h/amount}};$.each(plot.getAxes(),function(_,axis){var opts=axis.options,min=minmax[axis.direction].min,max=minmax[axis.direction].max,zr=opts.zoomRange,pr=opts.panRange;if(zr===false)return;min=axis.c2p(min);max=axis.c2p(max);if(min>max){var tmp=min;min=max;max=tmp}if(pr){if(pr[0]!=null&&min<pr[0]){min=pr[0]}if(pr[1]!=null&&max>pr[1]){max=pr[1]}}var range=max-min;if(zr&&(zr[0]!=null&&range<zr[0]&&amount>1||zr[1]!=null&&range>zr[1]&&amount<1))return;opts.min=min;opts.max=max});plot.setupGrid();plot.draw();if(!args.preventEvent)plot.getPlaceholder().trigger("plotzoom",[plot,args])};plot.pan=function(args){var delta={x:+args.left,y:+args.top};if(isNaN(delta.x))delta.x=0;if(isNaN(delta.y))delta.y=0;$.each(plot.getAxes(),function(_,axis){var opts=axis.options,min,max,d=delta[axis.direction];min=axis.c2p(axis.p2c(axis.min)+d),max=axis.c2p(axis.p2c(axis.max)+d);var pr=opts.panRange;if(pr===false)return;if(pr){if(pr[0]!=null&&pr[0]>min){d=pr[0]-min;min+=d;max+=d}if(pr[1]!=null&&pr[1]<max){d=pr[1]-max;min+=d;max+=d}}opts.min=min;opts.max=max});plot.setupGrid();plot.draw();if(!args.preventEvent)plot.getPlaceholder().trigger("plotpan",[plot,args])};function shutdown(plot,eventHolder){eventHolder.unbind(plot.getOptions().zoom.trigger,onZoomClick);eventHolder.unbind("mousewheel",onMouseWheel);eventHolder.unbind("dragstart",onDragStart);eventHolder.unbind("drag",onDrag);eventHolder.unbind("dragend",onDragEnd);if(panTimeout)clearTimeout(panTimeout)}plot.hooks.bindEvents.push(bindEvents);plot.hooks.shutdown.push(shutdown)}$.plot.plugins.push({init:init,options:options,name:"navigate",version:"1.3"})})(jQuery);
38− </script>
39− <script language="javascript" type="text/javascript">
40− (function ($) {
41− $.zip = function(a,b) {
42− var x = Math.min(a.length,b.length);
43− var c = new Array(x);
44− for (var i = 0; i < x; i++)
45− c[i] = [a[i],b[i]];
46− return c;
47− };
48−
49− $.mean = function(ary) {
50− var m = 0, i = 0;
51−
52− while (i < ary.length) {
53− var j = i++;
54− m += (ary[j] - m) / i;
55− }
56−
57− return m;
58− };
59−
60− $.timeUnits = function(secs) {
61− if (secs < 0) return $.timeUnits(-secs);
62− else if (secs >= 1e9) return [1e-9, "Gs"];
63− else if (secs >= 1e6) return [1e-6, "Ms"];
64− else if (secs >= 1) return [1, "s"];
65− else if (secs >= 1e-3) return [1e3, "ms"];
66− else if (secs >= 1e-6) return [1e6, "\u03bcs"];
67− else if (secs >= 1e-9) return [1e9, "ns"];
68− else if (secs >= 1e-12) return [1e12, "ps"];
69− return [1, "s"];
70− };
71−
72− $.scaleTimes = function(ary) {
73− var s = $.timeUnits($.mean(ary));
74− return [$.scaleBy(s[0], ary), s[0]];
75− };
76−
77− $.prepareTime = function(secs) {
78− var units = $.timeUnits(secs);
79− var scaled = secs * units[0];
80− var s = scaled.toPrecision(3);
81− var t = scaled.toString();
82− return [t.length < s.length ? t : s, units[1]];
83− };
84−
85− $.scaleBy = function(x, ary) {
86− var nary = new Array(ary.length);
87− for (var i = 0; i < ary.length; i++)
88− nary[i] = ary[i] * x;
89− return nary;
90− };
91−
92− $.renderTime = function(secs) {
93− var x = $.prepareTime(secs);
94− return x[0] + ' ' + x[1];
95− };
96−
97− $.unitFormatter = function(scale) {
98− var labelname;
99− return function(secs,axis) {
100− var x = $.prepareTime(secs / scale);
101− if (labelname === x[1])
102− return x[0];
103− else {
104− labelname = x[1];
105− return x[0] + ' ' + x[1];
106− }
107− };
108− };
109−
110− $.addTooltip = function(name, renderText) {
111− function showTooltip(x, y, contents) {
112− $('<div id="tooltip">' + contents + '</div>').css( {
113− position: 'absolute',
114− display: 'none',
115− top: y + 5,
116− left: x + 5,
117− border: '1px solid #fdd',
118− padding: '2px',
119− 'background-color': '#fee',
120− opacity: 0.80
121− }).appendTo("body").fadeIn(200);
122− };
123− var pp = null;
124− $(name).bind("plothover", function (event, pos, item) {
125− $("#x").text(pos.x.toFixed(2));
126− $("#y").text(pos.y.toFixed(2));
127−
128− if (item) {
129− if (pp != item.dataIndex) {
130− pp = item.dataIndex;
131−
132− $("#tooltip").remove();
133− var x = item.datapoint[0],
134− y = item.datapoint[1];
135−
136− showTooltip(item.pageX, item.pageY, renderText(x,y));
137− }
138− }
139− else {
140− $("#tooltip").remove();
141− pp = null;
142− }
143− });
144− };
145−})(jQuery);
146−
147− </script>
148− <style type="text/css">
149− html, body {
150− height: 100%;
151− margin: 0;
152−}
153−
154−#wrap {
155− min-height: 100%;
156−}
157−
158−#main {
159− overflow: auto;
160− padding-bottom: 180px; /* must be same height as the footer */
161−}
162−
163−#footer {
164− position: relative;
165− margin-top: -180px; /* negative value of footer height */
166− height: 180px;
167− clear: both;
168− background: #888;
169− margin: 40px 0 0;
170− color: white;
171− font-size: larger;
172− font-weight: 300;
173−}
174−
175−body:before {
176− /* Opera fix */
177− content: "";
178− height: 100%;
179− float: left;
180− width: 0;
181− margin-top: -32767px;
182−}
183−
184−body {
185− font: 14px Helvetica Neue;
186− text-rendering: optimizeLegibility;
187− margin-top: 1em;
188−}
189−
190−a:link {
191− color: steelblue;
192− text-decoration: none;
193−}
194−
195−a:visited {
196− color: #4a743b;
197− text-decoration: none;
198−}
199−
200−#footer a {
201− color: white;
202− text-decoration: underline;
203−}
204−
205−.hover {
206− color: steelblue;
207− text-decoration: none;
208−}
209−
210−.body {
211− width: 960px;
212− margin: auto;
213−}
214−
215−.footfirst {
216− position: relative;
217− top: 30px;
218−}
219−
220−th {
221− font-weight: 500;
222− opacity: 0.8;
223−}
224−
225−th.cibound {
226− opacity: 0.4;
227−}
228−
229−.confinterval {
230− opacity: 0.5;
231−}
232−
233−h1 {
234− font-size: 36px;
235− font-weight: 300;
236− margin-bottom: .3em;
237−}
238−
239−h2 {
240− font-size: 30px;
241− font-weight: 300;
242− margin-bottom: .3em;
243−}
244−
245−.meanlegend {
246− color: #404040;
247− background-color: #ffffff;
248− opacity: 0.6;
249− font-size: smaller;
250−}
251−
252− </style>
253− <!--[if !IE 7]>
254− <style type="text/css">
255− #wrap {display:table;height:100%}
256− </style>
257− <![endif]-->
258− </head>
259− <body>
260− <div id="wrap">
261− <div id="main" class="body">
262− <h1>criterion performance measurements</h1>
263−
264−<h2>overview</h2>
265−
266−<p><a href="#grokularation">want to understand this report?</a></p>
267−
268−<div id="overview" class="ovchart" style="width:900px;height:100px;"></div>
269−
270−<h2><a name="b0">Matrix Composition/10x10/WHNF - 10x10</a></h2>
271− <table width="100%">
272− <tbody>
273− <tr>
274− <td><div id="kde0" class="kdechart"
275− style="width:450px;height:278px;"></div></td>
276− <td><div id="time0" class="timechart"
277− style="width:450px;height:278px;"></div></td>
278−<!--
279− <td><div id="cycle0" class="cyclechart"
280− style="width:300px;height:278px;"></div></td>
281−-->
282− </tr>
283− </tbody>
284− </table>
285−
286− <table>
287− <thead class="analysis">
288− <th></th>
289− <th class="cibound"
290− title="0.95 confidence level">lower bound</th>
291− <th>estimate</th>
292− <th class="cibound"
293− title="0.95 confidence level">upper bound</th>
294− </thead>
295− <tbody>
296− <tr>
297− <td>OLS regression</td>
298− <td><span class="confinterval olstimelb0">xxx</span></td>
299− <td><span class="olstimept0">xxx</span></td>
300− <td><span class="confinterval olstimeub0">xxx</span></td>
301− </tr>
302− <tr>
303− <td>R&#xb2; goodness-of-fit</td>
304− <td><span class="confinterval olsr2lb0">xxx</span></td>
305− <td><span class="olsr2pt0">xxx</span></td>
306− <td><span class="confinterval olsr2ub0">xxx</span></td>
307− </tr>
308− <tr>
309− <td>Mean execution time</td>
310− <td><span class="confinterval citime">1.2049433368049536e-4</span></td>
311− <td><span class="time">1.2273010647022493e-4</span></td>
312− <td><span class="confinterval citime">1.2778054268834733e-4</span></td>
313− </tr>
314− <tr>
315− <td>Standard deviation</td>
316− <td><span class="confinterval citime">5.116451922891949e-6</span></td>
317− <td><span class="time">1.0291105469156734e-5</span></td>
318− <td><span class="confinterval citime">1.899929874113666e-5</span></td>
319− </tr>
320− </tbody>
321− </table>
322−
323− <span class="outliers">
324− <p>Outlying measurements have severe
325− (<span class="percent">0.749671001723266</span>%)
326− effect on estimated standard deviation.</p>
327− </span>
328−<h2><a name="b1">Matrix Composition/10x10/NF - 10x10</a></h2>
329− <table width="100%">
330− <tbody>
331− <tr>
332− <td><div id="kde1" class="kdechart"
333− style="width:450px;height:278px;"></div></td>
334− <td><div id="time1" class="timechart"
335− style="width:450px;height:278px;"></div></td>
336−<!--
337− <td><div id="cycle1" class="cyclechart"
338− style="width:300px;height:278px;"></div></td>
339−-->
340− </tr>
341− </tbody>
342− </table>
343−
344− <table>
345− <thead class="analysis">
346− <th></th>
347− <th class="cibound"
348− title="0.95 confidence level">lower bound</th>
349− <th>estimate</th>
350− <th class="cibound"
351− title="0.95 confidence level">upper bound</th>
352− </thead>
353− <tbody>
354− <tr>
355− <td>OLS regression</td>
356− <td><span class="confinterval olstimelb1">xxx</span></td>
357− <td><span class="olstimept1">xxx</span></td>
358− <td><span class="confinterval olstimeub1">xxx</span></td>
359− </tr>
360− <tr>
361− <td>R&#xb2; goodness-of-fit</td>
362− <td><span class="confinterval olsr2lb1">xxx</span></td>
363− <td><span class="olsr2pt1">xxx</span></td>
364− <td><span class="confinterval olsr2ub1">xxx</span></td>
365− </tr>
366− <tr>
367− <td>Mean execution time</td>
368− <td><span class="confinterval citime">1.219807334985906e-4</span></td>
369− <td><span class="time">1.2343493665093922e-4</span></td>
370− <td><span class="confinterval citime">1.2633720476730494e-4</span></td>
371− </tr>
372− <tr>
373− <td>Standard deviation</td>
374− <td><span class="confinterval citime">4.876323665872892e-6</span></td>
375− <td><span class="time">7.497583796499309e-6</span></td>
376− <td><span class="confinterval citime">1.2305448428855409e-5</span></td>
377− </tr>
378− </tbody>
379− </table>
380−
381− <span class="outliers">
382− <p>Outlying measurements have severe
383− (<span class="percent">0.6135229039528359</span>%)
384− effect on estimated standard deviation.</p>
385− </span>
386−<h2><a name="b2">Matrix Composition/100x100/WHNF - 100x100</a></h2>
387− <table width="100%">
388− <tbody>
389− <tr>
390− <td><div id="kde2" class="kdechart"
391− style="width:450px;height:278px;"></div></td>
392− <td><div id="time2" class="timechart"
393− style="width:450px;height:278px;"></div></td>
394−<!--
395− <td><div id="cycle2" class="cyclechart"
396− style="width:300px;height:278px;"></div></td>
397−-->
398− </tr>
399− </tbody>
400− </table>
401−
402− <table>
403− <thead class="analysis">
404− <th></th>
405− <th class="cibound"
406− title="0.95 confidence level">lower bound</th>
407− <th>estimate</th>
408− <th class="cibound"
409− title="0.95 confidence level">upper bound</th>
410− </thead>
411− <tbody>
412− <tr>
413− <td>OLS regression</td>
414− <td><span class="confinterval olstimelb2">xxx</span></td>
415− <td><span class="olstimept2">xxx</span></td>
416− <td><span class="confinterval olstimeub2">xxx</span></td>
417− </tr>
418− <tr>
419− <td>R&#xb2; goodness-of-fit</td>
420− <td><span class="confinterval olsr2lb2">xxx</span></td>
421− <td><span class="olsr2pt2">xxx</span></td>
422− <td><span class="confinterval olsr2ub2">xxx</span></td>
423− </tr>
424− <tr>
425− <td>Mean execution time</td>
426− <td><span class="confinterval citime">0.10670925100021122</span></td>
427− <td><span class="time">0.11259088430757033</span></td>
428− <td><span class="confinterval citime">0.12810259287901513</span></td>
429− </tr>
430− <tr>
431− <td>Standard deviation</td>
432− <td><span class="confinterval citime">2.794985106828957e-3</span></td>
433− <td><span class="time">1.4513815882466386e-2</span></td>
434− <td><span class="confinterval citime">2.275626878296965e-2</span></td>
435− </tr>
436− </tbody>
437− </table>
438−
439− <span class="outliers">
440− <p>Outlying measurements have moderate
441− (<span class="percent">0.3584714096581915</span>%)
442− effect on estimated standard deviation.</p>
443− </span>
444−<h2><a name="b3">Matrix Composition/100x100/NF - 100x100</a></h2>
445− <table width="100%">
446− <tbody>
447− <tr>
448− <td><div id="kde3" class="kdechart"
449− style="width:450px;height:278px;"></div></td>
450− <td><div id="time3" class="timechart"
451− style="width:450px;height:278px;"></div></td>
452−<!--
453− <td><div id="cycle3" class="cyclechart"
454− style="width:300px;height:278px;"></div></td>
455−-->
456− </tr>
457− </tbody>
458− </table>
459−
460− <table>
461− <thead class="analysis">
462− <th></th>
463− <th class="cibound"
464− title="0.95 confidence level">lower bound</th>
465− <th>estimate</th>
466− <th class="cibound"
467− title="0.95 confidence level">upper bound</th>
468− </thead>
469− <tbody>
470− <tr>
471− <td>OLS regression</td>
472− <td><span class="confinterval olstimelb3">xxx</span></td>
473− <td><span class="olstimept3">xxx</span></td>
474− <td><span class="confinterval olstimeub3">xxx</span></td>
475− </tr>
476− <tr>
477− <td>R&#xb2; goodness-of-fit</td>
478− <td><span class="confinterval olsr2lb3">xxx</span></td>
479− <td><span class="olsr2pt3">xxx</span></td>
480− <td><span class="confinterval olsr2ub3">xxx</span></td>
481− </tr>
482− <tr>
483− <td>Mean execution time</td>
484− <td><span class="confinterval citime">0.10572328594183394</span></td>
485− <td><span class="time">0.11065191628694417</span></td>
486− <td><span class="confinterval citime">0.1190700679846183</span></td>
487− </tr>
488− <tr>
489− <td>Standard deviation</td>
490− <td><span class="confinterval citime">1.5396112567768426e-3</span></td>
491− <td><span class="time">9.633081000847341e-3</span></td>
492− <td><span class="confinterval citime">1.3776160319998043e-2</span></td>
493− </tr>
494− </tbody>
495− </table>
496−
497− <span class="outliers">
498− <p>Outlying measurements have moderate
499− (<span class="percent">0.2338936359506027</span>%)
500− effect on estimated standard deviation.</p>
501− </span>
502−<h2><a name="b4">Matrix Composition/200x200/WHNF - 200x200</a></h2>
503− <table width="100%">
504− <tbody>
505− <tr>
506− <td><div id="kde4" class="kdechart"
507− style="width:450px;height:278px;"></div></td>
508− <td><div id="time4" class="timechart"
509− style="width:450px;height:278px;"></div></td>
510−<!--
511− <td><div id="cycle4" class="cyclechart"
512− style="width:300px;height:278px;"></div></td>
513−-->
514− </tr>
515− </tbody>
516− </table>
517−
518− <table>
519− <thead class="analysis">
520− <th></th>
521− <th class="cibound"
522− title="0.95 confidence level">lower bound</th>
523− <th>estimate</th>
524− <th class="cibound"
525− title="0.95 confidence level">upper bound</th>
526− </thead>
527− <tbody>
528− <tr>
529− <td>OLS regression</td>
530− <td><span class="confinterval olstimelb4">xxx</span></td>
531− <td><span class="olstimept4">xxx</span></td>
532− <td><span class="confinterval olstimeub4">xxx</span></td>
533− </tr>
534− <tr>
535− <td>R&#xb2; goodness-of-fit</td>
536− <td><span class="confinterval olsr2lb4">xxx</span></td>
537− <td><span class="olsr2pt4">xxx</span></td>
538− <td><span class="confinterval olsr2ub4">xxx</span></td>
539− </tr>
540− <tr>
541− <td>Mean execution time</td>
542− <td><span class="confinterval citime">0.9554592040840362</span></td>
543− <td><span class="time">0.9644028123334465</span></td>
544− <td><span class="confinterval citime">0.9742178227493241</span></td>
545− </tr>
546− <tr>
547− <td>Standard deviation</td>
548− <td><span class="confinterval citime">4.795288999957847e-3</span></td>
549− <td><span class="time">1.0832350628490363e-2</span></td>
550− <td><span class="confinterval citime">1.511725573135899e-2</span></td>
551− </tr>
552− </tbody>
553− </table>
554−
555− <span class="outliers">
556− <p>Outlying measurements have moderate
557− (<span class="percent">0.18749999999999994</span>%)
558− effect on estimated standard deviation.</p>
559− </span>
560−<h2><a name="b5">Matrix Composition/200x200/NF - 200x200</a></h2>
561− <table width="100%">
562− <tbody>
563− <tr>
564− <td><div id="kde5" class="kdechart"
565− style="width:450px;height:278px;"></div></td>
566− <td><div id="time5" class="timechart"
567− style="width:450px;height:278px;"></div></td>
568−<!--
569− <td><div id="cycle5" class="cyclechart"
570− style="width:300px;height:278px;"></div></td>
571−-->
572− </tr>
573− </tbody>
574− </table>
575−
576− <table>
577− <thead class="analysis">
578− <th></th>
579− <th class="cibound"
580− title="0.95 confidence level">lower bound</th>
581− <th>estimate</th>
582− <th class="cibound"
583− title="0.95 confidence level">upper bound</th>
584− </thead>
585− <tbody>
586− <tr>
587− <td>OLS regression</td>
588− <td><span class="confinterval olstimelb5">xxx</span></td>
589− <td><span class="olstimept5">xxx</span></td>
590− <td><span class="confinterval olstimeub5">xxx</span></td>
591− </tr>
592− <tr>
593− <td>R&#xb2; goodness-of-fit</td>
594− <td><span class="confinterval olsr2lb5">xxx</span></td>
595− <td><span class="olsr2pt5">xxx</span></td>
596− <td><span class="confinterval olsr2ub5">xxx</span></td>
597− </tr>
598− <tr>
599− <td>Mean execution time</td>
600− <td><span class="confinterval citime">0.9654473458749635</span></td>
601− <td><span class="time">0.980254961521041</span></td>
602− <td><span class="confinterval citime">0.9994299113750458</span></td>
603− </tr>
604− <tr>
605− <td>Standard deviation</td>
606− <td><span class="confinterval citime">2.345238647867079e-4</span></td>
607− <td><span class="time">2.1335106928918192e-2</span></td>
608− <td><span class="confinterval citime">2.623796574056436e-2</span></td>
609− </tr>
610− </tbody>
611− </table>
612−
613− <span class="outliers">
614− <p>Outlying measurements have moderate
615− (<span class="percent">0.1875</span>%)
616− effect on estimated standard deviation.</p>
617− </span>
618−<h2><a name="b6">Matrix vs List - `select`/Distribution/List Distribution - Applicative version</a></h2>
619− <table width="100%">
620− <tbody>
621− <tr>
622− <td><div id="kde6" class="kdechart"
623− style="width:450px;height:278px;"></div></td>
624− <td><div id="time6" class="timechart"
625− style="width:450px;height:278px;"></div></td>
626−<!--
627− <td><div id="cycle6" class="cyclechart"
628− style="width:300px;height:278px;"></div></td>
629−-->
630− </tr>
631− </tbody>
632− </table>
633−
634− <table>
635− <thead class="analysis">
636− <th></th>
637− <th class="cibound"
638− title="0.95 confidence level">lower bound</th>
639− <th>estimate</th>
640− <th class="cibound"
641− title="0.95 confidence level">upper bound</th>
642− </thead>
643− <tbody>
644− <tr>
645− <td>OLS regression</td>
646− <td><span class="confinterval olstimelb6">xxx</span></td>
647− <td><span class="olstimept6">xxx</span></td>
648− <td><span class="confinterval olstimeub6">xxx</span></td>
649− </tr>
650− <tr>
651− <td>R&#xb2; goodness-of-fit</td>
652− <td><span class="confinterval olsr2lb6">xxx</span></td>
653− <td><span class="olsr2pt6">xxx</span></td>
654− <td><span class="confinterval olsr2ub6">xxx</span></td>
655− </tr>
656− <tr>
657− <td>Mean execution time</td>
658− <td><span class="confinterval citime">0.43770282037348807</span></td>
659− <td><span class="time">0.4467186700617276</span></td>
660− <td><span class="confinterval citime">0.46234597762486374</span></td>
661− </tr>
662− <tr>
663− <td>Standard deviation</td>
664− <td><span class="confinterval citime">1.3631004574408759e-3</span></td>
665− <td><span class="time">1.5029085673470916e-2</span></td>
666− <td><span class="confinterval citime">1.8726410685291874e-2</span></td>
667− </tr>
668− </tbody>
669− </table>
670−
671− <span class="outliers">
672− <p>Outlying measurements have moderate
673− (<span class="percent">0.1875</span>%)
674− effect on estimated standard deviation.</p>
675− </span>
676−<h2><a name="b7">Matrix vs List - `select`/Distribution/Matrix Distribution - Applicative version</a></h2>
677− <table width="100%">
678− <tbody>
679− <tr>
680− <td><div id="kde7" class="kdechart"
681− style="width:450px;height:278px;"></div></td>
682− <td><div id="time7" class="timechart"
683− style="width:450px;height:278px;"></div></td>
684−<!--
685− <td><div id="cycle7" class="cyclechart"
686− style="width:300px;height:278px;"></div></td>
687−-->
688− </tr>
689− </tbody>
690− </table>
691−
692− <table>
693− <thead class="analysis">
694− <th></th>
695− <th class="cibound"
696− title="0.95 confidence level">lower bound</th>
697− <th>estimate</th>
698− <th class="cibound"
699− title="0.95 confidence level">upper bound</th>
700− </thead>
701− <tbody>
702− <tr>
703− <td>OLS regression</td>
704− <td><span class="confinterval olstimelb7">xxx</span></td>
705− <td><span class="olstimept7">xxx</span></td>
706− <td><span class="confinterval olstimeub7">xxx</span></td>
707− </tr>
708− <tr>
709− <td>R&#xb2; goodness-of-fit</td>
710− <td><span class="confinterval olsr2lb7">xxx</span></td>
711− <td><span class="olsr2pt7">xxx</span></td>
712− <td><span class="confinterval olsr2ub7">xxx</span></td>
713− </tr>
714− <tr>
715− <td>Mean execution time</td>
716− <td><span class="confinterval citime">0.176601423499556</span></td>
717− <td><span class="time">0.1820171075632162</span></td>
718− <td><span class="confinterval citime">0.18602406437478045</span></td>
719− </tr>
720− <tr>
721− <td>Standard deviation</td>
722− <td><span class="confinterval citime">4.2476576439371165e-3</span></td>
723− <td><span class="time">6.298418696687028e-3</span></td>
724− <td><span class="confinterval citime">8.492295568985392e-3</span></td>
725− </tr>
726− </tbody>
727− </table>
728−
729− <span class="outliers">
730− <p>Outlying measurements have moderate
731− (<span class="percent">0.1388888888888888</span>%)
732− effect on estimated standard deviation.</p>
733− </span>
734−<h2><a name="b8">Matrix vs List - `select`/Distribution/Matrix Distribution - Selective version</a></h2>
735− <table width="100%">
736− <tbody>
737− <tr>
738− <td><div id="kde8" class="kdechart"
739− style="width:450px;height:278px;"></div></td>
740− <td><div id="time8" class="timechart"
741− style="width:450px;height:278px;"></div></td>
742−<!--
743− <td><div id="cycle8" class="cyclechart"
744− style="width:300px;height:278px;"></div></td>
745−-->
746− </tr>
747− </tbody>
748− </table>
749−
750− <table>
751− <thead class="analysis">
752− <th></th>
753− <th class="cibound"
754− title="0.95 confidence level">lower bound</th>
755− <th>estimate</th>
756− <th class="cibound"
757− title="0.95 confidence level">upper bound</th>
758− </thead>
759− <tbody>
760− <tr>
761− <td>OLS regression</td>
762− <td><span class="confinterval olstimelb8">xxx</span></td>
763− <td><span class="olstimept8">xxx</span></td>
764− <td><span class="confinterval olstimeub8">xxx</span></td>
765− </tr>
766− <tr>
767− <td>R&#xb2; goodness-of-fit</td>
768− <td><span class="confinterval olsr2lb8">xxx</span></td>
769− <td><span class="olsr2pt8">xxx</span></td>
770− <td><span class="confinterval olsr2ub8">xxx</span></td>
771− </tr>
772− <tr>
773− <td>Mean execution time</td>
774− <td><span class="confinterval citime">8.933987364670819e-2</span></td>
775− <td><span class="time">9.136040249002575e-2</span></td>
776− <td><span class="confinterval citime">9.678633084819704e-2</span></td>
777− </tr>
778− <tr>
779− <td>Standard deviation</td>
780− <td><span class="confinterval citime">1.4344054494409147e-3</span></td>
781− <td><span class="time">5.3416383323926005e-3</span></td>
782− <td><span class="confinterval citime">9.301990711614968e-3</span></td>
783− </tr>
784− </tbody>
785− </table>
786−
787− <span class="outliers">
788− <p>Outlying measurements have moderate
789− (<span class="percent">0.18171701654949143</span>%)
790− effect on estimated standard deviation.</p>
791− </span>
792−<h2><a name="b9">Matrix vs List - `select`/Matrix `select`/Applicative version</a></h2>
793− <table width="100%">
794− <tbody>
795− <tr>
796− <td><div id="kde9" class="kdechart"
797− style="width:450px;height:278px;"></div></td>
798− <td><div id="time9" class="timechart"
799− style="width:450px;height:278px;"></div></td>
800−<!--
801− <td><div id="cycle9" class="cyclechart"
802− style="width:300px;height:278px;"></div></td>
803−-->
804− </tr>
805− </tbody>
806− </table>
807−
808− <table>
809− <thead class="analysis">
810− <th></th>
811− <th class="cibound"
812− title="0.95 confidence level">lower bound</th>
813− <th>estimate</th>
814− <th class="cibound"
815− title="0.95 confidence level">upper bound</th>
816− </thead>
817− <tbody>
818− <tr>
819− <td>OLS regression</td>
820− <td><span class="confinterval olstimelb9">xxx</span></td>
821− <td><span class="olstimept9">xxx</span></td>
822− <td><span class="confinterval olstimeub9">xxx</span></td>
823− </tr>
824− <tr>
825− <td>R&#xb2; goodness-of-fit</td>
826− <td><span class="confinterval olsr2lb9">xxx</span></td>
827− <td><span class="olsr2pt9">xxx</span></td>
828− <td><span class="confinterval olsr2ub9">xxx</span></td>
829− </tr>
830− <tr>
831− <td>Mean execution time</td>
832− <td><span class="confinterval citime">0.7791034777492314</span></td>
833− <td><span class="time">0.840422457165308</span></td>
834− <td><span class="confinterval citime">0.8923891394988459</span></td>
835− </tr>
836− <tr>
837− <td>Standard deviation</td>
838− <td><span class="confinterval citime">2.769907342949611e-2</span></td>
839− <td><span class="time">6.898641320796234e-2</span></td>
840− <td><span class="confinterval citime">9.23128387071436e-2</span></td>
841− </tr>
842− </tbody>
843− </table>
844−
845− <span class="outliers">
846− <p>Outlying measurements have moderate
847− (<span class="percent">0.21376667254855866</span>%)
848− effect on estimated standard deviation.</p>
849− </span>
850−<h2><a name="b10">Matrix vs List - `select`/Matrix `select`/Selective version</a></h2>
851− <table width="100%">
852− <tbody>
853− <tr>
854− <td><div id="kde10" class="kdechart"
855− style="width:450px;height:278px;"></div></td>
856− <td><div id="time10" class="timechart"
857− style="width:450px;height:278px;"></div></td>
858−<!--
859− <td><div id="cycle10" class="cyclechart"
860− style="width:300px;height:278px;"></div></td>
861−-->
862− </tr>
863− </tbody>
864− </table>
865−
866− <table>
867− <thead class="analysis">
868− <th></th>
869− <th class="cibound"
870− title="0.95 confidence level">lower bound</th>
871− <th>estimate</th>
872− <th class="cibound"
873− title="0.95 confidence level">upper bound</th>
874− </thead>
875− <tbody>
876− <tr>
877− <td>OLS regression</td>
878− <td><span class="confinterval olstimelb10">xxx</span></td>
879− <td><span class="olstimept10">xxx</span></td>
880− <td><span class="confinterval olstimeub10">xxx</span></td>
881− </tr>
882− <tr>
883− <td>R&#xb2; goodness-of-fit</td>
884− <td><span class="confinterval olsr2lb10">xxx</span></td>
885− <td><span class="olsr2pt10">xxx</span></td>
886− <td><span class="confinterval olsr2ub10">xxx</span></td>
887− </tr>
888− <tr>
889− <td>Mean execution time</td>
890− <td><span class="confinterval citime">0.41360511700137675</span></td>
891− <td><span class="time">0.42580509562564356</span></td>
892− <td><span class="confinterval citime">0.43034074300067005</span></td>
893− </tr>
894− <tr>
895− <td>Standard deviation</td>
896− <td><span class="confinterval citime">1.588963214600777e-4</span></td>
897− <td><span class="time">8.497480607539406e-3</span></td>
898− <td><span class="confinterval citime">1.0474628931683076e-2</span></td>
899− </tr>
900− </tbody>
901− </table>
902−
903− <span class="outliers">
904− <p>Outlying measurements have moderate
905− (<span class="percent">0.1875</span>%)
906− effect on estimated standard deviation.</p>
907− </span>
908−
909− <h2><a name="grokularation">understanding this report</a></h2>
910−
911− <p>In this report, each function benchmarked by criterion is assigned
912− a section of its own. The charts in each section are active; if
913− you hover your mouse over data points and annotations, you will see
914− more details.</p>
915−
916− <ul>
917− <li>The chart on the left is a
918− <a href="http://en.wikipedia.org/wiki/Kernel_density_estimation">kernel
919− density estimate</a> (also known as a KDE) of time
920− measurements. This graphs the probability of any given time
921− measurement occurring. A spike indicates that a measurement of a
922− particular time occurred; its height indicates how often that
923− measurement was repeated.</li>
924−
925− <li>The chart on the right is the raw data from which the kernel
926− density estimate is built. The <i>x</i> axis indicates the
927− number of loop iterations, while the <i>y</i> axis shows measured
928− execution time for the given number of loop iterations. The
929− line behind the values is the linear regression prediction of
930− execution time for a given number of iterations. Ideally, all
931− measurements will be on (or very near) this line.</li>
932− </ul>
933−
934− <p>Under the charts is a small table.
935− The first two rows are the results of a linear regression run
936− on the measurements displayed in the right-hand chart.</p>
937−
938− <ul>
939− <li><i>OLS regression</i> indicates the
940− time estimated for a single loop iteration using an ordinary
941− least-squares regression model. This number is more accurate
942− than the <i>mean</i> estimate below it, as it more effectively
943− eliminates measurement overhead and other constant factors.</li>
944− <li><i>R&#xb2; goodness-of-fit</i> is a measure of how
945− accurately the linear regression model fits the observed
946− measurements. If the measurements are not too noisy, R&#xb2;
947− should lie between 0.99 and 1, indicating an excellent fit. If
948− the number is below 0.99, something is confounding the accuracy
949− of the linear model.</li>
950− <li><i>Mean execution time</i> and <i>standard deviation</i> are
951− statistics calculated from execution time
952− divided by number of iterations.</li>
953− </ul>
954−
955− <p>We use a statistical technique called
956− the <a href="http://en.wikipedia.org/wiki/Bootstrapping_(statistics)">bootstrap</a>
957− to provide confidence intervals on our estimates. The
958− bootstrap-derived upper and lower bounds on estimates let you see
959− how accurate we believe those estimates to be. (Hover the mouse
960− over the table headers to see the confidence levels.)</p>
961−
962− <p>A noisy benchmarking environment can cause some or many
963− measurements to fall far from the mean. These outlying
964− measurements can have a significant inflationary effect on the
965− estimate of the standard deviation. We calculate and display an
966− estimate of the extent to which the standard deviation has been
967− inflated by outliers.</p>
968−
969−<script type="text/javascript">
970−$(function () {
971− function mangulate(rpt) {
972− var measured = function(key) {
973− var idx = rpt.reportKeys.indexOf(key);
974− return rpt.reportMeasured.map(function(r) { return r[idx]; });
975− };
976− var lowerBound = function(est) {
977− return est.estPoint - est.estError.confIntLDX;
978− };
979− var upperBound = function(est) {
980− return est.estPoint + est.estError.confIntUDX;
981− };
982− var number = rpt.reportNumber;
983− var name = rpt.reportName;
984− var mean = rpt.reportAnalysis.anMean.estPoint;
985− var iters = measured("iters");
986− var times = measured("time");
987− var kdetimes = rpt.reportKDEs[0].kdeValues;
988− var kdepdf = rpt.reportKDEs[0].kdePDF;
989−
990− var meanSecs = mean;
991− var units = $.timeUnits(mean);
992− var rgrs = rpt.reportAnalysis.anRegress[0];
993− var scale = units[0];
994− var olsTime = rgrs.regCoeffs.iters;
995− $(".olstimept" + number).text(function() {
996− return $.renderTime(olsTime.estPoint);
997− });
998− $(".olstimelb" + number).text(function() {
999− return $.renderTime(lowerBound(olsTime));
1000− });
1001− $(".olstimeub" + number).text(function() {
1002− return $.renderTime(upperBound(olsTime));
1003− });
1004− $(".olsr2pt" + number).text(function() {
1005− return rgrs.regRSquare.estPoint.toFixed(3);
1006− });
1007− $(".olsr2lb" + number).text(function() {
1008− return lowerBound(rgrs.regRSquare).toFixed(3);
1009− });
1010− $(".olsr2ub" + number).text(function() {
1011− return upperBound(rgrs.regRSquare).toFixed(3);
1012− });
1013− mean *= scale;
1014− kdetimes = $.scaleBy(scale, kdetimes);
1015− var kq = $("#kde" + number);
1016− var k = $.plot(kq,
1017− [{ label: name + " time densities",
1018− data: $.zip(kdetimes, kdepdf),
1019− }],
1020− { xaxis: { tickFormatter: $.unitFormatter(scale) },
1021− yaxis: { ticks: false },
1022− grid: { borderColor: "#777",
1023− hoverable: true, markings: [ { color: '#6fd3fb',
1024− lineWidth: 1.5, xaxis: { from: mean, to: mean } } ] },
1025− });
1026− var o = k.pointOffset({ x: mean, y: 0});
1027− kq.append('<div class="meanlegend" title="' + $.renderTime(meanSecs) +
1028− '" style="position:absolute;left:' + (o.left + 4) +
1029− 'px;bottom:139px;">mean</div>');
1030− $.addTooltip("#kde" + number,
1031− function(secs) { return $.renderTime(secs / scale); });
1032− var timepairs = new Array(times.length);
1033− var lastiter = iters[iters.length-1];
1034− var olspairs = [[0,0], [lastiter, lastiter * scale * olsTime.estPoint]];
1035− for (var i = 0; i < times.length; i++)
1036− timepairs[i] = [iters[i],times[i]*scale];
1037− iterFormatter = function() {
1038− var denom = 0;
1039− return function(iters) {
1040− if (iters == 0)
1041− return '';
1042− if (denom > 0)
1043− return (iters / denom).toFixed();
1044− var power;
1045− if (iters >= 1e9) {
1046− denom = '1e9'; power = '&#x2079;';
1047− }
1048− if (iters >= 1e6) {
1049− denom = '1e6'; power = '&#x2076;';
1050− }
1051− else if (iters >= 1e3) {
1052− denom = '1e3'; power = '&#xb3;';
1053− }
1054− else denom = 1;
1055− if (denom > 1) {
1056− iters = (iters / denom).toFixed();
1057− iters += '&times;10' + power + ' iters';
1058− } else {
1059− iters += ' iters';
1060− }
1061− return iters;
1062− };
1063− };
1064− $.plot($("#time" + number),
1065− [{ label: "regression", data: olspairs,
1066− lines: { show: true } },
1067− { label: name + " times", data: timepairs,
1068− points: { show: true } }],
1069− { grid: { borderColor: "#777", hoverable: true },
1070− xaxis: { tickFormatter: iterFormatter() },
1071− yaxis: { tickFormatter: $.unitFormatter(scale) } });
1072− $.addTooltip("#time" + number,
1073− function(iters,secs) {
1074− return ($.renderTime(secs / scale) + ' / ' +
1075− iters.toLocaleString() + ' iters');
1076− });
1077− if (0) {
1078− var cyclepairs = new Array(cycles.length);
1079− for (var i = 0; i < cycles.length; i++)
1080− cyclepairs[i] = [cycles[i],i];
1081− $.plot($("#cycle" + number),
1082− [{ label: name + " cycles",
1083− data: cyclepairs }],
1084− { points: { show: true },
1085− grid: { borderColor: "#777", hoverable: true },
1086− xaxis: { tickFormatter:
1087− function(cycles,axis) { return cycles + ' cycles'; }},
1088− yaxis: { ticks: false },
1089− });
1090− $.addTooltip("#cycles" + number, function(x,y) { return x + ' cycles'; });
1091− }
1092− };
1093− var reports = [{"reportAnalysis":{"anMean":{"estError":{"confIntLDX":2.235772789729569e-6,"confIntUDX":5.050436218122402e-6,"confIntCL":5.0e-2},"estPoint":1.2273010647022493e-4},"anRegress":[{"regRSquare":{"estError":{"confIntLDX":4.603195549745642e-3,"confIntUDX":3.151074582740332e-3,"confIntCL":5.0e-2},"estPoint":0.9952994091484983},"regResponder":"time","regCoeffs":{"y":{"estError":{"confIntLDX":5.775442544255838e-4,"confIntUDX":6.386415462507714e-4,"confIntCL":5.0e-2},"estPoint":2.1075018355648414e-4},"iters":{"estError":{"confIntLDX":2.03492324435964e-6,"confIntUDX":2.4138639206128557e-6,"confIntCL":5.0e-2},"estPoint":1.2144680095789925e-4}}}],"anStdDev":{"estError":{"confIntLDX":5.174653546264785e-6,"confIntUDX":8.708193271979925e-6,"confIntCL":5.0e-2},"estPoint":1.0291105469156734e-5},"anOutlierVar":{"ovFraction":0.749671001723266,"ovDesc":"severe","ovEffect":"Severe"}},"reportKDEs":[{"kdeValues":[1.1076181752825612e-4,1.1125294900708996e-4,1.1174408048592381e-4,1.1223521196475766e-4,1.1272634344359151e-4,1.1321747492242536e-4,1.1370860640125919e-4,1.1419973788009304e-4,1.1469086935892689e-4,1.1518200083776074e-4,1.1567313231659459e-4,1.1616426379542843e-4,1.1665539527426228e-4,1.1714652675309613e-4,1.1763765823192998e-4,1.1812878971076383e-4,1.1861992118959768e-4,1.1911105266843152e-4,1.1960218414726537e-4,1.2009331562609921e-4,1.2058444710493306e-4,1.210755785837669e-4,1.2156671006260075e-4,1.220578415414346e-4,1.2254897302026846e-4,1.2304010449910228e-4,1.2353123597793613e-4,1.2402236745676998e-4,1.2451349893560383e-4,1.2500463041443768e-4,1.2549576189327153e-4,1.2598689337210537e-4,1.2647802485093922e-4,1.2696915632977307e-4,1.2746028780860692e-4,1.2795141928744077e-4,1.2844255076627462e-4,1.2893368224510846e-4,1.294248137239423e-4,1.2991594520277616e-4,1.3040707668161e-4,1.3089820816044386e-4,1.313893396392777e-4,1.3188047111811155e-4,1.323716025969454e-4,1.3286273407577925e-4,1.3335386555461307e-4,1.3384499703344695e-4,1.3433612851228077e-4,1.3482725999111462e-4,1.3531839146994847e-4,1.3580952294878231e-4,1.3630065442761616e-4,1.3679178590645e-4,1.3728291738528386e-4,1.377740488641177e-4,1.3826518034295156e-4,1.387563118217854e-4,1.3924744330061925e-4,1.397385747794531e-4,1.4022970625828695e-4,1.407208377371208e-4,1.4121196921595465e-4,1.417031006947885e-4,1.4219423217362234e-4,1.426853636524562e-4,1.4317649513129004e-4,1.4366762661012386e-4,1.4415875808895774e-4,1.4464988956779156e-4,1.4514102104662543e-4,1.4563215252545925e-4,1.4612328400429313e-4,1.4661441548312695e-4,1.471055469619608e-4,1.4759667844079465e-4,1.480878099196285e-4,1.4857894139846234e-4,1.490700728772962e-4,1.4956120435613004e-4,1.500523358349639e-4,1.5054346731379774e-4,1.5103459879263159e-4,1.5152573027146543e-4,1.5201686175029928e-4,1.5250799322913313e-4,1.5299912470796698e-4,1.5349025618680083e-4,1.5398138766563468e-4,1.5447251914446852e-4,1.5496365062330237e-4,1.5545478210213622e-4,1.5594591358097004e-4,1.5643704505980392e-4,1.5692817653863774e-4,1.5741930801747161e-4,1.5791043949630544e-4,1.5840157097513928e-4,1.5889270245397313e-4,1.5938383393280698e-4,1.5987496541164083e-4,1.6036609689047468e-4,1.6085722836930853e-4,1.6134835984814237e-4,1.6183949132697622e-4,1.6233062280581007e-4,1.6282175428464392e-4,1.6331288576347777e-4,1.6380401724231162e-4,1.6429514872114546e-4,1.647862801999793e-4,1.6527741167881316e-4,1.65768543157647e-4,1.6625967463648086e-4,1.667508061153147e-4,1.6724193759414853e-4,1.677330690729824e-4,1.6822420055181622e-4,1.687153320306501e-4,1.6920646350948392e-4,1.6969759498831777e-4,1.7018872646715162e-4,1.7067985794598547e-4,1.711709894248193e-4,1.7166212090365316e-4,1.72153252382487e-4,1.7264438386132086e-4,1.731355153401547e-4],"kdeType":"time","kdePDF":[149.0086108306232,352.819638259101,933.3368091982317,2283.8712131319635,5071.285621527163,10211.606198442887,18671.3884014897,31059.365200198306,47124.613711119266,65442.772888226944,83593.66261697494,98903.58588627068,109436.9762337601,114666.06030366918,115386.1830722336,112943.10641959068,108332.04188499475,101806.4480879783,93210.67536127573,82667.70213990522,71001.91576286507,59555.588106109266,49591.62931879758,41782.94356700146,36137.35883395918,32299.002147309875,29894.51013393432,28652.820841558234,28290.461558643303,28355.05212220221,28216.498837651743,27246.041785664478,25075.291413102557,21779.905742724426,17888.069375547628,14212.547543186447,11581.637377351133,10567.488737673493,11291.8371971626,13362.083099493088,15969.768862056777,18149.111443268437,19124.606530678335,18601.976325516636,16847.961261347606,14504.199192032198,12238.286419026983,10435.70219696887,9099.631953220094,7979.815692613306,6807.687579993162,5473.899209724927,4058.4285468160706,2739.0200204913604,1671.090553898817,918.3706926860627,453.7964939353254,201.43382716674054,80.2845837336287,28.724986593847763,9.224963229231177,2.6590154878972077,0.6878843668034824,0.1597135292548994,3.328099243838994e-2,6.224111855376767e-3,1.044682113066755e-3,1.573679488289265e-4,2.1275150935448044e-5,2.581462593274605e-6,2.81270084552891e-7,2.992636378448279e-8,2.985739057347651e-8,2.8132615309861217e-7,2.5813842753059786e-6,2.1275170514940203e-5,1.5736767271358826e-4,1.044679510774252e-3,6.224081715265558e-3,3.328068146139688e-2,0.15971063923767828,0.6878602291744721,2.6588342636127456,9.22373990687873,28.717560464848,80.24403429088562,201.23461176399334,452.91564238276766,914.8642875240184,1658.5201191901306,2698.419882988605,3940.243188241877,5163.702823999855,6073.292084343236,6410.793839605764,6073.292084370521,5163.7028242809565,3940.2431908232834,2698.4199042637756,1658.5202765578283,914.8653322035457,452.92186646451853,201.26789244549747,80.40374493016246,29.405420694086548,11.882574170511056,11.882574170546656,29.40542069406519,80.40374493019094,201.26789244549747,452.9218664645434,914.8653322035403,1658.5202765578317,2698.4199042637792,3940.2431908234794,5163.702824283381,6073.292084397967,6410.793839886886,6073.292086924587,5163.702845275035,3940.243345609539,2698.4209276681368,1658.5263432718502,914.8975682055101,453.0753530220308,201.92247199321704,82.90286855451862,37.94130037176945]}],"reportKeys":["time","cpuTime","cycles","iters","allocated","numGcs","bytesCopied","mutatorWallSeconds","mutatorCpuSeconds","gcWallSeconds","gcCpuSeconds"],"reportNumber":0,"reportName":"Matrix Composition/10x10/WHNF - 10x10","reportOutliers":{"highSevere":2,"highMild":1,"lowMild":0,"samplesSeen":42,"lowSevere":0},"reportMeasured":[[1.41502998303622e-4,1.4056600000000863e-4,336015,1,null,null,null,null,null,null,null],[2.362099985475652e-4,2.3618400000002815e-4,565425,2,null,null,null,null,null,null,null],[3.406250034458935e-4,3.4048899999994386e-4,815058,3,null,null,null,null,null,null,null],[4.4664699817076325e-4,4.465419999999387e-4,1069218,4,null,null,null,null,null,null,null],[5.530180060304701e-4,5.530780000000401e-4,1324494,5,null,null,null,null,null,null,null],[6.676310003967956e-4,6.677240000000362e-4,1598976,6,null,null,null,null,null,null,null],[7.909730047686026e-4,7.902950000000519e-4,1892628,7,null,null,null,null,null,null,null],[9.45047999266535e-4,9.80444999999941e-4,2262672,8,null,null,null,null,null,null,null],[1.0548410064075142e-3,1.0892930000000467e-3,2525751,9,null,null,null,null,null,null,null],[1.1775550010497682e-3,1.2119440000000203e-3,2819430,10,null,null,null,null,null,null,null],[1.2797349991160445e-3,1.3134850000000586e-3,3063987,11,null,null,null,null,null,null,null],[1.4121580024948344e-3,1.4885249999999628e-3,3381264,12,null,null,null,null,null,null,null],[1.4963189969421364e-3,1.5313629999998968e-3,3582432,13,null,null,null,null,null,null,null],[1.6700890046195127e-3,1.6895869999999924e-3,3998988,14,null,null,null,null,null,null,null],[2.345401997445151e-3,1.8430430000000442e-3,5621913,15,null,null,null,null,null,null,null],[1.9354920004843734e-3,2.0413910000000035e-3,4633884,16,null,null,null,null,null,null,null],[2.0820930003537796e-3,2.187492000000013e-3,4985640,17,null,null,null,null,null,null,null],[2.1143609992577694e-3,2.210159999999961e-3,5062437,18,null,null,null,null,null,null,null],[2.1964269981253892e-3,2.2970150000000134e-3,5257953,19,null,null,null,null,null,null,null],[3.07219000387704e-3,3.1699299999999875e-3,7356204,20,null,null,null,null,null,null,null],[2.5107210021815263e-3,2.5748899999999963e-3,6011712,21,null,null,null,null,null,null,null],[2.4919329953263514e-3,2.5781660000000484e-3,5965623,22,null,null,null,null,null,null,null],[2.6854679963435046e-3,2.8288119999999584e-3,6428943,23,null,null,null,null,null,null,null],[2.878932995372452e-3,3.0408470000000687e-3,6891876,25,null,null,null,null,null,null,null],[3.0059790005907416e-3,3.154805000000094e-3,7196166,26,null,null,null,null,null,null,null],[3.128623000520747e-3,3.2809280000000163e-3,7489692,27,null,null,null,null,null,null,null],[3.2382770004915074e-3,3.388013000000023e-3,7752285,28,null,null,null,null,null,null,null],[3.484123997623101e-3,3.648979999999913e-3,8340903,30,null,null,null,null,null,null,null],[3.607118000218179e-3,3.8020669999999646e-3,8635788,31,null,null,null,null,null,null,null],[3.8642810031888075e-3,4.072343000000034e-3,9250992,33,null,null,null,null,null,null,null],[4.018284998892341e-3,4.217909000000075e-3,9619983,35,null,null,null,null,null,null,null],[4.141488003369886e-3,4.338748999999975e-3,9914985,36,null,null,null,null,null,null,null],[4.393203002109658e-3,4.600482000000072e-3,10517472,38,null,null,null,null,null,null,null],[4.630319999705534e-3,4.878507000000032e-3,11084886,40,null,null,null,null,null,null,null],[8.762030003708787e-3,9.005680000000016e-3,20976399,42,null,null,null,null,null,null,null],[5.057479997049086e-3,5.3363110000000935e-3,12107619,44,null,null,null,null,null,null,null],[5.50251999811735e-3,5.771895999999943e-3,13186350,47,null,null,null,null,null,null,null],[5.701294001482893e-3,6.007044999999933e-3,13649130,49,null,null,null,null,null,null,null],[5.977244996756781e-3,6.290282000000036e-3,14309370,52,null,null,null,null,null,null,null],[6.254870997508988e-3,6.601774999999921e-3,14974245,54,null,null,null,null,null,null,null],[6.604505004361272e-3,6.962506999999896e-3,15811164,57,null,null,null,null,null,null,null],[6.950718001462519e-3,7.3164909999998695e-3,16641045,60,null,null,null,null,null,null,null],[7.315648996154778e-3,7.713982999999924e-3,17513676,63,null,null,null,null,null,null,null],[7.661581999855116e-3,8.063939999999992e-3,18343035,66,null,null,null,null,null,null,null],[8.010308003576938e-3,8.472471000000148e-3,19176327,69,null,null,null,null,null,null,null],[8.521909003320616e-3,8.987615999999976e-3,20401200,73,null,null,null,null,null,null,null],[8.803935001196805e-3,9.257416999999935e-3,21076632,76,null,null,null,null,null,null,null],[9.360375996038783e-3,9.848305999999862e-3,22410603,80,null,null,null,null,null,null,null],[9.745210998516995e-3,1.026105799999999e-2,23330070,84,null,null,null,null,null,null,null],[1.0333010999602266e-2,1.0878233999999987e-2,24737139,89,null,null,null,null,null,null,null],[1.07537459989544e-2,1.1355315000000088e-2,25744077,93,null,null,null,null,null,null,null],[1.1541995001607575e-2,1.1965769999999987e-2,27631800,98,null,null,null,null,null,null,null],[1.2016369997581933e-2,1.2656972000000044e-2,28767258,103,null,null,null,null,null,null,null],[1.7552835000969935e-2,1.8254000999999853e-2,42022782,108,null,null,null,null,null,null,null],[1.31761849988834e-2,1.3858938999999904e-2,31543668,113,null,null,null,null,null,null,null],[1.3902623002650216e-2,1.4626205999999975e-2,33282918,119,null,null,null,null,null,null,null],[1.4507255997159518e-2,1.5299275000000057e-2,34729830,125,null,null,null,null,null,null,null],[1.5493021004658658e-2,1.6324045000000176e-2,37090719,131,null,null,null,null,null,null,null],[1.6024388001824263e-2,1.691538200000009e-2,38362950,138,null,null,null,null,null,null,null],[1.667637299397029e-2,1.7572445999999964e-2,39923550,144,null,null,null,null,null,null,null],[1.7731493004248478e-2,1.8635105999999846e-2,42449670,152,null,null,null,null,null,null,null],[1.9657346994790714e-2,2.0646646000000102e-2,47060793,159,null,null,null,null,null,null,null],[2.9878050998377148e-2,3.0179080999999996e-2,71538579,167,null,null,null,null,null,null,null],[2.1138580996193923e-2,2.2224663999999894e-2,50606847,176,null,null,null,null,null,null,null],[2.1534591003728565e-2,2.2666092999999776e-2,51552882,185,null,null,null,null,null,null,null],[2.2510647999297362e-2,2.3726236999999983e-2,53889228,194,null,null,null,null,null,null,null],[2.3668089001148473e-2,2.4961487999999976e-2,56661471,204,null,null,null,null,null,null,null],[2.529948399751447e-2,2.6630806000000007e-2,60567183,214,null,null,null,null,null,null,null],[2.6003293998655863e-2,2.7433453999999857e-2,62250777,224,null,null,null,null,null,null,null],[2.7303563001623843e-2,2.876849199999998e-2,65364066,236,null,null,null,null,null,null,null],[2.8714883999782614e-2,3.0318263999999928e-2,68742405,247,null,null,null,null,null,null,null],[3.0325185995025095e-2,3.1931839999999934e-2,72597888,260,null,null,null,null,null,null,null],[3.166261300066253e-2,3.336618299999983e-2,75799143,273,null,null,null,null,null,null,null],[3.334555199398892e-2,3.5129930999999726e-2,79828983,287,null,null,null,null,null,null,null],[3.5059573005128186e-2,3.696401600000021e-2,83930976,301,null,null,null,null,null,null,null],[4.169976800039876e-2,4.3746365000000065e-2,99828648,316,null,null,null,null,null,null,null],[3.971754999656696e-2,4.1796272999999884e-2,95083992,332,null,null,null,null,null,null,null],[4.079809299582848e-2,4.295217500000015e-2,97669476,348,null,null,null,null,null,null,null],[4.2441222998604644e-2,4.4746217000000144e-2,101602926,366,null,null,null,null,null,null,null],[4.459141299594194e-2,4.694254100000017e-2,106751070,384,null,null,null,null,null,null,null],[6.767889599723276e-2,6.276207300000003e-2,162031086,403,null,null,null,null,null,null,null],[5.07917360009742e-2,5.226953400000012e-2,121592349,424,null,null,null,null,null,null,null],[5.585068299842533e-2,5.8676618000000236e-2,133705134,445,null,null,null,null,null,null,null],[5.5968647997360677e-2,5.893469799999984e-2,133987338,467,null,null,null,null,null,null,null],[5.7817046996206045e-2,6.0939965999999846e-2,138411801,490,null,null,null,null,null,null,null],[6.51829819980776e-2,6.839699899999996e-2,156045861,515,null,null,null,null,null,null,null],[6.396372999734012e-2,6.7316017e-2,153127251,541,null,null,null,null,null,null,null],[7.437762000336079e-2,7.79969730000003e-2,178057566,568,null,null,null,null,null,null,null],[9.358713399706176e-2,9.091706499999974e-2,224045334,596,null,null,null,null,null,null,null],[7.335239199892385e-2,7.722593899999985e-2,175603527,626,null,null,null,null,null,null,null],[8.351861799746985e-2,8.689436400000039e-2,199940580,657,null,null,null,null,null,null,null],[8.562173500104109e-2,8.9852461e-2,204975549,690,null,null,null,null,null,null,null],[8.65185200018459e-2,9.079655300000011e-2,207122067,725,null,null,null,null,null,null,null],[8.876320799754467e-2,9.344290400000022e-2,212495445,761,null,null,null,null,null,null,null],[9.478703800414223e-2,9.952854899999952e-2,226916325,799,null,null,null,null,null,null,null],[0.10140306799439713,0.10650213499999994,242754678,839,null,null,null,null,null,null,null],[0.10245546399528394,0.10804485900000005,245273661,881,null,null,null,null,null,null,null],[0.11371724900527624,0.11950934200000018,272234457,925,null,null,null,null,null,null,null],[0.12763928800268332,0.13292975799999995,305564940,972,null,null,null,null,null,null,null],[0.11954174700076692,0.12572876400000021,286178049,1020,null,null,null,null,null,null,null],[0.12499914900399745,0.13189083099999976,299242287,1071,null,null,null,null,null,null,null],[0.13762259500072105,0.14477940200000017,329462631,1125,null,null,null,null,null,null,null],[0.13975769900571322,0.14683190700000015,334573137,1181,null,null,null,null,null,null,null],[0.1484065830009058,0.15622573100000015,355278348,1240,null,null,null,null,null,null,null],[0.15658681900094962,0.16489036000000024,374861052,1302,null,null,null,null,null,null,null],[0.15897915600362467,0.16764394399999993,380588517,1367,null,null,null,null,null,null,null],[0.1938851440063445,0.20246384100000014,464156802,1436,null,null,null,null,null,null,null],[0.18895987699943362,0.1982726070000007,452360502,1507,null,null,null,null,null,null,null],[0.1858109989989316,0.19581696000000015,444822471,1583,null,null,null,null,null,null,null],[0.198649491998367,0.20912437500000003,475557255,1662,null,null,null,null,null,null,null],[0.20933402300579473,0.22035859300000027,501135768,1745,null,null,null,null,null,null,null],[0.22448949299723608,0.23549453399999987,537415857,1832,null,null,null,null,null,null,null],[0.2300747080007568,0.24231689099999976,550786347,1924,null,null,null,null,null,null,null]]},{"reportAnalysis":{"anMean":{"estError":{"confIntLDX":1.4542031523486252e-6,"confIntUDX":2.9022681163657184e-6,"confIntCL":5.0e-2},"estPoint":1.2343493665093922e-4},"anRegress":[{"regRSquare":{"estError":{"confIntLDX":2.5065091503295722e-3,"confIntUDX":1.6772641534086308e-3,"confIntCL":5.0e-2},"estPoint":0.9973765207473525},"regResponder":"time","regCoeffs":{"y":{"estError":{"confIntLDX":3.80953616475421e-4,"confIntUDX":4.066530759472799e-4,"confIntCL":5.0e-2},"estPoint":1.7585120627625008e-4},"iters":{"estError":{"confIntLDX":1.289159406965459e-6,"confIntUDX":1.7876156643326948e-6,"confIntCL":5.0e-2},"estPoint":1.2235810949311643e-4}}}],"anStdDev":{"estError":{"confIntLDX":2.621260130626417e-6,"confIntUDX":4.8078646323561e-6,"confIntCL":5.0e-2},"estPoint":7.497583796499309e-6},"anOutlierVar":{"ovFraction":0.6135229039528359,"ovDesc":"severe","ovEffect":"Severe"}},"reportKDEs":[{"kdeValues":[1.1423300311603713e-4,1.1459568470559156e-4,1.1495836629514601e-4,1.1532104788470044e-4,1.1568372947425487e-4,1.1604641106380931e-4,1.1640909265336374e-4,1.1677177424291817e-4,1.1713445583247262e-4,1.1749713742202705e-4,1.1785981901158148e-4,1.1822250060113592e-4,1.1858518219069035e-4,1.1894786378024478e-4,1.1931054536979921e-4,1.1967322695935366e-4,1.2003590854890809e-4,1.2039859013846252e-4,1.2076127172801696e-4,1.211239533175714e-4,1.2148663490712582e-4,1.2184931649668027e-4,1.222119980862347e-4,1.2257467967578914e-4,1.2293736126534356e-4,1.23300042854898e-4,1.2366272444445245e-4,1.2402540603400686e-4,1.243880876235613e-4,1.2475076921311575e-4,1.2511345080267017e-4,1.2547613239222461e-4,1.2583881398177906e-4,1.2620149557133347e-4,1.2656417716088792e-4,1.2692685875044236e-4,1.2728954033999678e-4,1.2765222192955122e-4,1.2801490351910564e-4,1.2837758510866008e-4,1.2874026669821453e-4,1.2910294828776897e-4,1.294656298773234e-4,1.2982831146687783e-4,1.3019099305643225e-4,1.305536746459867e-4,1.3091635623554114e-4,1.3127903782509556e-4,1.3164171941465e-4,1.3200440100420444e-4,1.3236708259375886e-4,1.327297641833133e-4,1.3309244577286775e-4,1.3345512736242217e-4,1.338178089519766e-4,1.3418049054153105e-4,1.3454317213108547e-4,1.3490585372063991e-4,1.3526853531019436e-4,1.3563121689974878e-4,1.3599389848930322e-4,1.3635658007885766e-4,1.3671926166841208e-4,1.3708194325796652e-4,1.3744462484752097e-4,1.3780730643707538e-4,1.3816998802662983e-4,1.3853266961618427e-4,1.388953512057387e-4,1.3925803279529313e-4,1.3962071438484758e-4,1.39983395974402e-4,1.4034607756395644e-4,1.4070875915351086e-4,1.410714407430653e-4,1.4143412233261974e-4,1.417968039221742e-4,1.421594855117286e-4,1.4252216710128305e-4,1.4288484869083747e-4,1.432475302803919e-4,1.4361021186994635e-4,1.439728934595008e-4,1.4433557504905521e-4,1.4469825663860966e-4,1.4506093822816408e-4,1.4542361981771852e-4,1.4578630140727296e-4,1.461489829968274e-4,1.4651166458638182e-4,1.4687434617593627e-4,1.4723702776549069e-4,1.4759970935504513e-4,1.4796239094459957e-4,1.48325072534154e-4,1.4868775412370843e-4,1.4905043571326288e-4,1.494131173028173e-4,1.4977579889237174e-4,1.5013848048192618e-4,1.505011620714806e-4,1.5086384366103504e-4,1.512265252505895e-4,1.515892068401439e-4,1.5195188842969835e-4,1.523145700192528e-4,1.526772516088072e-4,1.5303993319836165e-4,1.5340261478791607e-4,1.5376529637747051e-4,1.5412797796702496e-4,1.544906595565794e-4,1.5485334114613382e-4,1.5521602273568826e-4,1.5557870432524268e-4,1.5594138591479712e-4,1.5630406750435157e-4,1.56666749093906e-4,1.5702943068346043e-4,1.5739211227301487e-4,1.577547938625693e-4,1.5811747545212373e-4,1.5848015704167818e-4,1.5884283863123262e-4,1.5920552022078704e-4,1.5956820181034148e-4,1.599308833998959e-4,1.6029356498945034e-4],"kdeType":"time","kdePDF":[-3.5394508362485313,10.862690447417558,-18.959978623055576,28.494801126896874,-40.390261392815724,56.061212475715266,-71.39551569097834,352.2637455792894,3603.077350858721,24635.117536157115,90635.51700472171,238010.91496936217,361559.4414346629,275909.6680404166,132760.28283216164,100042.58628848022,91629.89049306743,72897.53387447628,81901.41769151995,93102.63397413121,93636.88668507154,77675.55457125537,55280.071757729216,53961.23130898681,71858.02140758738,58024.87865469867,22518.8161134113,10142.019093530524,31537.735389210127,53079.04970960072,34513.169193547685,22323.199086235927,30338.287761555024,34530.775145689186,45263.64528358992,42318.523487668914,18853.476085310627,3467.30223223632,477.9199613625321,3465.0276446029816,18852.495330043737,42077.69645293178,42046.747810199224,18884.0632207055,3425.9885714567085,275.34825846076797,-35.04745204680679,48.92320830829724,-49.842879100856905,546.0893544301637,6349.441128996066,31383.883305150383,52742.75093164599,31631.26627394791,9547.251322937676,16215.145623650997,26343.45443125955,15718.91725748031,3154.7033238220956,288.1410486334607,-36.30324355186315,32.77564223591137,-26.086795817960443,21.385148773612116,-17.997110662603742,15.51826069778252,-13.690388050045724,12.348924870349386,-11.390009079570376,10.751258424975825,-10.401399038705229,10.336015709991583,-10.578399614273856,11.185922603915389,-12.263916432295993,13.99078514305115,-16.65842241351194,20.77555725848079,-20.944161306675042,268.247937097079,3180.9145556201015,15683.564996633353,26379.993458319685,15683.18895656808,3181.6716141991506,267.09972379272745,-19.389128126819358,18.79192054027415,-14.217428333786499,11.055529792826022,-8.787740218553107,7.110236771679364,-5.829736375854765,4.821992867165114,-4.0051337638797495,3.3235166947284753,-2.737974059449925,2.2197981675131606,-1.7469054457680873,1.3012676782272947,-0.8670628071652875,0.42919443049126244,2.8074732485287884e-2,-0.5226013328215029,1.0762064845419805,-1.7172381474386211,2.4843979951533908,-3.432744405186314,4.64343243478093,-6.2398377965533625,8.41419527831051,-11.469070255964091,15.921441175306992,-16.379624463176224,263.93212444501853,3185.0189942821034,15679.636945398746,26383.77880670813,15679.512875460092,3185.2727326767385,263.5371250079479,-15.824937531640664,15.180415648433826,-10.504702574663881,7.175960065663912,-4.658985178843138,2.6259529852188472,-0.8486843355416659]}],"reportKeys":["time","cpuTime","cycles","iters","allocated","numGcs","bytesCopied","mutatorWallSeconds","mutatorCpuSeconds","gcWallSeconds","gcCpuSeconds"],"reportNumber":1,"reportName":"Matrix Composition/10x10/NF - 10x10","reportOutliers":{"highSevere":2,"highMild":1,"lowMild":0,"samplesSeen":43,"lowSevere":0},"reportMeasured":[[1.4932500198483467e-4,1.4821999999981017e-4,353322,1,null,null,null,null,null,null,null],[2.5513699802104384e-4,2.5517500000038496e-4,610947,2,null,null,null,null,null,null,null],[3.7785199674544856e-4,3.781050000002395e-4,904698,3,null,null,null,null,null,null,null],[4.4769400119548663e-4,4.477839999994515e-4,1071999,4,null,null,null,null,null,null,null],[5.637039939756505e-4,5.636750000004298e-4,1349892,5,null,null,null,null,null,null,null],[6.714720002491958e-4,6.714610000004839e-4,1607760,6,null,null,null,null,null,null,null],[8.300860063172877e-4,8.314020000002031e-4,1993626,7,null,null,null,null,null,null,null],[1.0278120025759563e-3,1.0799869999997824e-3,2458746,8,null,null,null,null,null,null,null],[1.0642689958331175e-3,1.1177860000000095e-3,2549025,9,null,null,null,null,null,null,null],[1.2541040050564334e-3,1.3104049999999035e-3,2999691,10,null,null,null,null,null,null,null],[1.3255529993330128e-3,1.3531880000003937e-3,3173391,11,null,null,null,null,null,null,null],[1.4517589952447452e-3,1.4816870000000648e-3,3476331,12,null,null,null,null,null,null,null],[1.494432995968964e-3,1.5456149999995006e-3,3577833,13,null,null,null,null,null,null,null],[1.6483680010423996e-3,1.6912970000007022e-3,3946221,14,null,null,null,null,null,null,null],[1.736160003929399e-3,1.794030000000113e-3,4156542,15,null,null,null,null,null,null,null],[1.9210350001230836e-3,2.0203240000000733e-3,4599900,16,null,null,null,null,null,null,null],[2.0501059989328496e-3,2.1547479999997066e-3,4908168,17,null,null,null,null,null,null,null],[2.101440004480537e-3,2.199612000000073e-3,5030586,18,null,null,null,null,null,null,null],[2.2499270053231157e-3,2.3486210000003283e-3,5386275,19,null,null,null,null,null,null,null],[2.504643998690881e-3,2.5583170000000877e-3,5996196,20,null,null,null,null,null,null,null],[2.476497000316158e-3,2.5622820000004154e-3,5929569,21,null,null,null,null,null,null,null],[2.5332099976367317e-3,2.6318989999998266e-3,6064623,22,null,null,null,null,null,null,null],[2.744555000390392e-3,2.8926700000004857e-3,6570324,23,null,null,null,null,null,null,null],[2.9408150003291667e-3,3.08741199999929e-3,7040790,25,null,null,null,null,null,null,null],[3.1001269962871447e-3,3.24810000000042e-3,7421877,26,null,null,null,null,null,null,null],[3.2160670016310178e-3,3.3683910000004147e-3,7699518,27,null,null,null,null,null,null,null],[3.2880750004551373e-3,3.4394999999998177e-3,7871607,28,null,null,null,null,null,null,null],[3.5113630001433194e-3,3.649972000000723e-3,8405883,30,null,null,null,null,null,null,null],[3.7346509998315014e-3,3.8741940000006636e-3,8940870,31,null,null,null,null,null,null,null],[3.966600001149345e-3,4.175853999999646e-3,9496755,33,null,null,null,null,null,null,null],[4.142883997701574e-3,4.3459800000000826e-3,9918171,35,null,null,null,null,null,null,null],[4.266716001438908e-3,4.4679309999997585e-3,10214730,36,null,null,null,null,null,null,null],[4.439928001374938e-3,4.6499730000002515e-3,10629711,38,null,null,null,null,null,null,null],[4.727261999505572e-3,4.97174499999975e-3,11316933,40,null,null,null,null,null,null,null],[1.0230411004158668e-2,1.034602399999951e-2,24493293,42,null,null,null,null,null,null,null],[5.243473002337851e-3,5.510458999999912e-3,12553272,44,null,null,null,null,null,null,null],[5.519143996934872e-3,5.821183999999313e-3,13212819,47,null,null,null,null,null,null,null],[5.93575799575774e-3,6.216111000000524e-3,14211828,49,null,null,null,null,null,null,null],[6.1224480014061555e-3,6.416256999999703e-3,14656869,52,null,null,null,null,null,null,null],[6.399097001121845e-3,6.755957000000201e-3,15319350,54,null,null,null,null,null,null,null],[6.733016998623498e-3,7.087233000000026e-3,16118496,57,null,null,null,null,null,null,null],[7.1909779944689944e-3,7.45002699999997e-3,17215857,60,null,null,null,null,null,null,null],[7.450376004271675e-3,7.853078999999319e-3,17836299,63,null,null,null,null,null,null,null],[7.7949810001882724e-3,8.185831999999671e-3,18660906,66,null,null,null,null,null,null,null],[9.353321001981385e-3,9.337908000000006e-3,22393908,69,null,null,null,null,null,null,null],[8.634425998025108e-3,9.095827999999528e-3,20670813,73,null,null,null,null,null,null,null],[8.943900997110177e-3,9.400845000000047e-3,21411585,76,null,null,null,null,null,null,null],[9.448657001485117e-3,9.956708999999897e-3,22619727,80,null,null,null,null,null,null,null],[9.90277700475417e-3,1.0414231000000385e-2,23706720,84,null,null,null,null,null,null,null],[1.0538628994254395e-2,1.1096752000000265e-2,25229034,89,null,null,null,null,null,null,null],[1.1007904999132734e-2,1.1611873999999744e-2,26353080,93,null,null,null,null,null,null,null],[1.1577616001886781e-2,1.21352770000005e-2,27716760,98,null,null,null,null,null,null,null],[1.2319139997998718e-2,1.2924219000000292e-2,29506149,103,null,null,null,null,null,null,null],[1.274762800312601e-2,1.3458108000000024e-2,30517308,108,null,null,null,null,null,null,null],[1.3301412996952422e-2,1.3993478999999809e-2,31843035,113,null,null,null,null,null,null,null],[1.414484000270022e-2,1.4903552999999903e-2,33862563,119,null,null,null,null,null,null,null],[1.4842431999568362e-2,1.559154699999965e-2,35532945,125,null,null,null,null,null,null,null],[1.5504126000450924e-2,1.6357744999999646e-2,37116900,131,null,null,null,null,null,null,null],[2.5331542994535994e-2,2.5495935000000358e-2,60767874,138,null,null,null,null,null,null,null],[1.7105140002968255e-2,1.800301599999976e-2,40949325,144,null,null,null,null,null,null,null],[1.7937529999471735e-2,1.8903858999999912e-2,42941511,152,null,null,null,null,null,null,null],[1.876754599652486e-2,1.9739299000000265e-2,44928234,159,null,null,null,null,null,null,null],[1.9850952994602267e-2,2.088010999999934e-2,47522871,167,null,null,null,null,null,null,null],[2.0836928000790067e-2,2.1962044000000347e-2,49883697,176,null,null,null,null,null,null,null],[2.187214299920015e-2,2.303325499999964e-2,52361388,185,null,null,null,null,null,null,null],[2.2959041001740843e-2,2.4223719000000088e-2,54963189,194,null,null,null,null,null,null,null],[2.4192680000851396e-2,2.5413712999999838e-2,57916089,204,null,null,null,null,null,null,null],[2.5268892997701187e-2,2.6565198000000123e-2,60492537,214,null,null,null,null,null,null,null],[2.6736995998362545e-2,2.815821599999957e-2,64007730,224,null,null,null,null,null,null,null],[2.7934457000810653e-2,2.9414156000000524e-2,66874293,236,null,null,null,null,null,null,null],[3.5516555995855015e-2,3.713295599999977e-2,85027410,247,null,null,null,null,null,null,null],[3.1418719998328015e-2,3.30293450000001e-2,75220218,260,null,null,null,null,null,null,null],[3.254012099932879e-2,3.412264099999973e-2,77900013,273,null,null,null,null,null,null,null],[3.3886486999108456e-2,3.567773400000007e-2,81122949,287,null,null,null,null,null,null,null],[3.571407200070098e-2,3.758417499999922e-2,85498704,301,null,null,null,null,null,null,null],[3.824832999816863e-2,4.027858599999945e-2,91566054,316,null,null,null,null,null,null,null],[3.982343200186733e-2,4.192039300000072e-2,95337270,332,null,null,null,null,null,null,null],[4.114346800633939e-2,4.338167600000009e-2,98495001,348,null,null,null,null,null,null,null],[4.734826000640169e-2,4.9641049999999964e-2,113350878,366,null,null,null,null,null,null,null],[4.556502599734813e-2,4.800343099999971e-2,109081395,384,null,null,null,null,null,null,null],[4.931539300014265e-2,5.183552500000044e-2,118060974,403,null,null,null,null,null,null,null],[5.038301500462694e-2,5.3073839999999706e-2,120614166,424,null,null,null,null,null,null,null],[5.9178078998229466e-2,6.200529200000027e-2,141671007,445,null,null,null,null,null,null,null],[5.594699700304773e-2,5.897956699999973e-2,133935462,467,null,null,null,null,null,null,null],[5.837397600407712e-2,6.149012599999981e-2,139745619,490,null,null,null,null,null,null,null],[6.1100022998289205e-2,6.439140099999996e-2,146271600,515,null,null,null,null,null,null,null],[8.464225499483291e-2,8.739413699999954e-2,202631049,541,null,null,null,null,null,null,null],[7.338703500136035e-2,7.699107000000005e-2,175686102,568,null,null,null,null,null,null,null],[7.078000100591453e-2,7.448658400000063e-2,169445493,596,null,null,null,null,null,null,null],[7.938942300097551e-2,8.331468500000039e-2,190056222,626,null,null,null,null,null,null,null],[7.88895549994777e-2,8.302613399999892e-2,188858682,657,null,null,null,null,null,null,null],[8.18964420031989e-2,8.622726199999953e-2,196057008,690,null,null,null,null,null,null,null],[8.709968499897514e-2,9.152815799999914e-2,208513575,725,null,null,null,null,null,null,null],[9.490640000149142e-2,9.955062499999912e-2,227202741,761,null,null,null,null,null,null,null],[9.500613600539509e-2,9.998236900000101e-2,227440539,799,null,null,null,null,null,null,null],[0.1115685949989711,0.11681128300000054,267090732,839,null,null,null,null,null,null,null],[0.10490332599874819,0.1104693999999995,251134182,881,null,null,null,null,null,null,null],[0.11756071599666029,0.1234587979999997,281435922,925,null,null,null,null,null,null,null],[0.11552017900248757,0.12160548299999974,276551307,972,null,null,null,null,null,null,null],[0.12752244099829113,0.13402601999999852,305283078,1020,null,null,null,null,null,null,null],[0.12762748500244925,0.134427917,305536032,1071,null,null,null,null,null,null,null],[0.15119220600172412,0.15828207299999875,361946961,1125,null,null,null,null,null,null,null],[0.1403742050024448,0.14790094699999834,336048714,1181,null,null,null,null,null,null,null],[0.1523946259985678,0.1604037389999995,364825782,1240,null,null,null,null,null,null,null],[0.16407274499943014,0.1722229740000003,392798151,1302,null,null,null,null,null,null,null],[0.1618594160026987,0.17054831099999923,387483264,1367,null,null,null,null,null,null,null],[0.17720409100002144,0.18634311699999984,424217916,1436,null,null,null,null,null,null,null],[0.18326528699981282,0.19273580800000012,438727950,1507,null,null,null,null,null,null,null],[0.18768726399866864,0.19784945600000015,449314227,1583,null,null,null,null,null,null,null],[0.2022033899993403,0.21270864299999914,484064856,1662,null,null,null,null,null,null,null],[0.21465565099788364,0.22577739299999955,513874638,1745,null,null,null,null,null,null,null],[0.2236361500035855,0.23529569299999942,535372992,1832,null,null,null,null,null,null,null],[0.2334192160051316,0.24556724600000024,558793935,1924,null,null,null,null,null,null,null]]},{"reportAnalysis":{"anMean":{"estError":{"confIntLDX":5.881633307359108e-3,"confIntUDX":1.5511708571444793e-2,"confIntCL":5.0e-2},"estPoint":0.11259088430757033},"anRegress":[{"regRSquare":{"estError":{"confIntLDX":9.98088874695926e-2,"confIntUDX":8.51072092049483e-2,"confIntCL":5.0e-2},"estPoint":0.9147200107567641},"regResponder":"time","regCoeffs":{"y":{"estError":{"confIntLDX":0.1706339729016186,"confIntUDX":5.3739295125957175e-2,"confIntCL":5.0e-2},"estPoint":-3.75295245352645e-2},"iters":{"estError":{"confIntLDX":1.9053781817703896e-2,"confIntUDX":4.141938483096186e-2,"confIntCL":5.0e-2},"estPoint":0.12354784586941162}}}],"anStdDev":{"estError":{"confIntLDX":1.1718830775637429e-2,"confIntUDX":8.242452900503265e-3,"confIntCL":5.0e-2},"estPoint":1.4513815882466386e-2},"anOutlierVar":{"ovFraction":0.3584714096581915,"ovDesc":"moderate","ovEffect":"Moderate"}},"reportKDEs":[{"kdeValues":[9.99294621154106e-2,0.1003398919628745,0.1007503218103384,0.1011607516578023,0.1015711815052662,0.10198161135273011,0.10239204120019402,0.10280247104765791,0.10321290089512182,0.10362333074258571,0.10403376059004962,0.10444419043751352,0.10485462028497743,0.10526505013244133,0.10567547997990523,0.10608590982736914,0.10649633967483303,0.10690676952229694,0.10731719936976084,0.10772762921722474,0.10813805906468865,0.10854848891215255,0.10895891875961645,0.10936934860708035,0.10977977845454426,0.11019020830200815,0.11060063814947206,0.11101106799693597,0.11142149784439986,0.11183192769186377,0.11224235753932768,0.11265278738679158,0.11306321723425548,0.11347364708171938,0.11388407692918329,0.11429450677664718,0.11470493662411109,0.115115366471575,0.11552579631903889,0.1159362261665028,0.1163466560139667,0.1167570858614306,0.1171675157088945,0.11757794555635841,0.11798837540382232,0.11839880525128621,0.11880923509875012,0.11921966494621401,0.11963009479367792,0.12004052464114182,0.12045095448860572,0.12086138433606963,0.12127181418353353,0.12168224403099744,0.12209267387846134,0.12250310372592524,0.12291353357338913,0.12332396342085304,0.12373439326831695,0.12414482311578084,0.12455525296324475,0.12496568281070866,0.12537611265817256,0.12578654250563645,0.12619697235310037,0.12660740220056427,0.12701783204802816,0.12742826189549206,0.12783869174295598,0.12824912159041987,0.12865955143788377,0.1290699812853477,0.12948041113281158,0.12989084098027548,0.1303012708277394,0.1307117006752033,0.1311221305226672,0.1315325603701311,0.131942990217595,0.1323534200650589,0.1327638499125228,0.1331742797599867,0.1335847096074506,0.1339951394549145,0.1344055693023784,0.13481599914984232,0.13522642899730622,0.13563685884477011,0.13604728869223404,0.13645771853969793,0.13686814838716183,0.13727857823462575,0.13768900808208964,0.13809943792955354,0.13850986777701743,0.13892029762448135,0.13933072747194525,0.13974115731940914,0.14015158716687304,0.14056201701433696,0.14097244686180085,0.14138287670926475,0.14179330655672867,0.14220373640419257,0.14261416625165646,0.14302459609912038,0.14343502594658428,0.14384545579404817,0.1442558856415121,0.144666315488976,0.14507674533643988,0.14548717518390378,0.14589760503136767,0.1463080348788316,0.1467184647262955,0.14712889457375938,0.1475393244212233,0.1479497542686872,0.1483601841161511,0.14877061396361502,0.1491810438110789,0.1495914736585428,0.15000190350600673,0.15041233335347062,0.15082276320093452,0.15123319304839844,0.15164362289586233,0.15205405274332623],"kdeType":"time","kdePDF":[53.41327340090232,53.374000320910405,53.29543295511724,53.177530684937395,53.02023702691307,52.82348485998291,52.587203220890245,52.31132552316886,51.995799024898325,51.64059534389723,51.24572179676792,50.81123332066281,50.33724472414917,49.82394300632284,49.27159948146201,48.68058145000017,48.05136316528996,47.384535859277186,46.680816608446975,45.94105584379128,45.16624333454185,44.35751250441628,43.51614297047961,42.64356122774188,41.74133943658286,40.811192304310396,39.85497208591787,38.87466176174828,37.87236648066915,36.85030338595375,35.81078996684674,34.756231101349506,33.68910497474729,32.6119480735712,31.527339465872444,30.437884585817248,29.346198743692398,28.254890581545876,27.16654569003508,26.083710593866446,25.008877301770642,23.94446860263085,22.892824272540715,21.856188338650043,20.83669752507952,19.836370984416668,18.857101395769465,17.90064748750797,16.96862802006164,16.06251724187547,15.183641810195114,14.333179148095466,13.512157190343949,12.721455453559717,11.961807350858919,11.233803657933843,10.537897026375711,9.874407431097579,9.243528431936337,8.645334124912196,8.079786656118104,7.5467441707358365,7.045969071089927,6.577136460841355,6.1398426572096625,5.733613659347715,5.357913468474649,5.012152163934849,4.695693648783417,4.4078629886330845,4.147953278128503,3.915231980380282,3.7089466958026294,3.528330327910006,3.3726056245708413,3.2409890838673268,3.132694223925548,3.0469342257633256,2.982923967236263,2.939881474477684,2.9170288247339857,2.9135925411536814,2.928803525831608,2.961896582225392,3.012109581912577,3.0786823335522016,3.160855213844332,3.2578676212745554,3.3689563135009437,3.4933536884388765,3.6302860674571886,3.7789720366846606,3.9386208992908536,4.108431287828462,4.287589981373407,4.475270967361636,4.670634782775672,4.872828163771927,5.08098402704572,5.294221800295825,5.511648113160326,5.73235785403551,5.9554355923413,6.179957360135687,6.404992781579421,6.6296075336718285,6.852866116979473,7.073834910805321,7.291585483441664,7.505198124840991,7.713765566253037,7.916396849120491,8.112221303811529,8.300392597584462,8.480092810525296,8.650536498047698,8.81097469888299,8.960698848278728,9.099044557346284,9.22539522110806,9.339185419766524,9.439904080005617,9.527097365712027,9.600371270325486,9.6593938860675,9.703897328515769,9.733679298363752,9.748604265695777]}],"reportKeys":["time","cpuTime","cycles","iters","allocated","numGcs","bytesCopied","mutatorWallSeconds","mutatorCpuSeconds","gcWallSeconds","gcCpuSeconds"],"reportNumber":2,"reportName":"Matrix Composition/100x100/WHNF - 100x100","reportOutliers":{"highSevere":1,"highMild":0,"lowMild":0,"samplesSeen":8,"lowSevere":0},"reportMeasured":[[0.10952575400006026,0.1186222499999996,262197657,1,null,null,null,null,null,null,null],[0.2116565169999376,0.2307575169999989,506694942,2,null,null,null,null,null,null,null],[0.3128195340032107,0.341316462,748872756,3,null,null,null,null,null,null,null],[0.4559952859999612,0.4866446780000011,1091626920,4,null,null,null,null,null,null,null],[0.5352202980066068,0.5887010579999998,1281286728,5,null,null,null,null,null,null,null],[0.6314304600018659,0.694465791999999,1511606574,6,null,null,null,null,null,null,null],[1.0339723580036662,1.0897260549999999,2475266436,7,null,null,null,null,null,null,null],[0.8568660480013932,0.9402999449999996,2051286066,8,null,null,null,null,null,null,null]]},{"reportAnalysis":{"anMean":{"estError":{"confIntLDX":4.9286303451102215e-3,"confIntUDX":8.41815169767414e-3,"confIntCL":5.0e-2},"estPoint":0.11065191628694417},"anRegress":[{"regRSquare":{"estError":{"confIntLDX":7.787227678319963e-2,"confIntUDX":3.333559363586569e-2,"confIntCL":5.0e-2},"estPoint":0.9665090250785888},"regResponder":"time","regCoeffs":{"y":{"estError":{"confIntLDX":8.683451167775696e-2,"confIntUDX":5.0946042513026674e-2,"confIntCL":5.0e-2},"estPoint":-1.765151471304904e-2},"iters":{"estError":{"confIntLDX":1.1968879096965784e-2,"confIntUDX":2.2702741634266305e-2,"confIntCL":5.0e-2},"estPoint":0.11662004971384737}}}],"anStdDev":{"estError":{"confIntLDX":8.093469744070499e-3,"confIntUDX":4.1430793191507016e-3,"confIntCL":5.0e-2},"estPoint":9.633081000847341e-3},"anOutlierVar":{"ovFraction":0.2338936359506027,"ovDesc":"moderate","ovEffect":"Moderate"}},"reportKDEs":[{"kdeValues":[0.10140944396747122,0.10166479735643624,0.10192015074540127,0.1021755041343663,0.10243085752333132,0.10268621091229635,0.10294156430126138,0.1031969176902264,0.10345227107919143,0.10370762446815646,0.10396297785712148,0.10421833124608651,0.10447368463505154,0.10472903802401656,0.10498439141298159,0.10523974480194662,0.10549509819091166,0.10575045157987667,0.10600580496884171,0.10626115835780674,0.10651651174677176,0.10677186513573679,0.10702721852470182,0.10728257191366684,0.10753792530263187,0.1077932786915969,0.10804863208056192,0.10830398546952695,0.10855933885849198,0.108814692247457,0.10907004563642203,0.10932539902538706,0.10958075241435208,0.10983610580331711,0.11009145919228214,0.11034681258124716,0.11060216597021219,0.11085751935917722,0.11111287274814224,0.11136822613710727,0.1116235795260723,0.11187893291503732,0.11213428630400235,0.11238963969296738,0.1126449930819324,0.11290034647089743,0.11315569985986246,0.1134110532488275,0.11366640663779251,0.11392176002675755,0.11417711341572256,0.1144324668046876,0.11468782019365263,0.11494317358261766,0.11519852697158268,0.11545388036054771,0.11570923374951274,0.11596458713847776,0.11621994052744279,0.11647529391640782,0.11673064730537284,0.11698600069433787,0.1172413540833029,0.11749670747226792,0.11775206086123295,0.11800741425019798,0.118262767639163,0.11851812102812803,0.11877347441709306,0.11902882780605809,0.11928418119502311,0.11953953458398814,0.11979488797295317,0.12005024136191819,0.12030559475088322,0.12056094813984825,0.12081630152881329,0.1210716549177783,0.12132700830674334,0.12158236169570835,0.12183771508467339,0.1220930684736384,0.12234842186260345,0.12260377525156846,0.1228591286405335,0.12311448202949853,0.12336983541846355,0.12362518880742858,0.1238805421963936,0.12413589558535863,0.12439124897432366,0.12464660236328869,0.12490195575225371,0.12515730914121875,0.12541266253018377,0.12566801591914878,0.12592336930811382,0.12617872269707886,0.12643407608604387,0.12668942947500889,0.12694478286397393,0.12720013625293897,0.12745548964190398,0.12771084303086902,0.12796619641983403,0.12822154980879907,0.1284769031977641,0.12873225658672913,0.12898760997569414,0.12924296336465918,0.1294983167536242,0.12975367014258923,0.13000902353155425,0.1302643769205193,0.1305197303094843,0.13077508369844934,0.13103043708741435,0.1312857904763794,0.1315411438653444,0.13179649725430945,0.13205185064327446,0.1323072040322395,0.1325625574212045,0.13281791081016955,0.13307326419913457,0.1333286175880996,0.13358397097706465,0.13383932436602966],"kdeType":"time","kdePDF":[69.48805059048384,69.43807062439615,69.3382166071889,69.18870019208772,68.9898384147122,68.74205315324173,68.44587039755461,68.1019193182425,67.71093112462144,67.27373769939157,66.79126999649186,66.26455618799139,65.69471954559044,65.0829760424944,64.43063166208553,63.73907940095895,63.0097959555001,62.24433808324937,61.44433863279984,60.61150223887123,59.74760068245534,58.854467919485174,57.93399478528461,56.988123386044236,56.01884119267568,55.02817485654918,54.01818377074647,52.99095340448753,51.948588442244834,50.89320576267032,49.826927295761465,48.75187279962142,47.670152600664764,46.583860343139115,45.495065795323484,44.40580776070231,43.3180871427625,42.23386021181548,41.15503212138862,40.08345072027646,39.020900704291094,37.9690981491406,36.929685462708704,35.90422679136765,34.894203910854756,33.901012627760046,32.92595971284356,31.970260382316674,31.035036337926645,30.121314371274643,29.230025532323527,28.362004856611748,27.517991640330973,26.698630247246818,25.90447142648266,25.135974115541327,24.393507698635727,23.67735468652302,22.98771378060232,22.324703281114026,21.688364796871806,21.078667212118603,20.495510864813856,19.938731889964828,19.408106681482995,18.903356426494252,18.424151667016407,17.97011684544038,17.540834792256717,17.135851116943027,16.754678465804826,16.396800613816197,16.06167636106403,15.748743208227177,15.457420789539775,15.187114045860174,14.937216124710993,14.707110998434985,14.496175795846261,14.303782846911195,14.12930144399459,13.97209932702438,13.831543903496016,13.707003217534249,13.597846685198126,13.503445615844274,13.423173541607227,13.356406378914409,13.302522447393306,13.26090237256072,13.230928899288795,13.211986643238971,13.203461807238938,13.204741888975134,13.2152154053931,13.234271657873146,13.261300560599361,13.295692552603555,13.33683861177169,13.384130386689842,13.436960459615088,13.494722751126563,13.556813074183,13.622629842427132,13.691574934675385,13.763054714652748,13.836481202218403,13.911273389611754,13.986858693669843,14.062674532553501,14.138170013306478,14.212807714578332,14.286065547099886,14.357438673019272,14.426441464012319,14.492609477176966,14.555501427121769,14.614701132362063,14.669819414150151,14.720495926177108,14.766400894193756,14.807236745489092,14.842739609328396,14.8726806708656,14.896867362693756,14.915144380050666,14.92739450773888,14.933539249013116]}],"reportKeys":["time","cpuTime","cycles","iters","allocated","numGcs","bytesCopied","mutatorWallSeconds","mutatorCpuSeconds","gcWallSeconds","gcCpuSeconds"],"reportNumber":3,"reportName":"Matrix Composition/100x100/NF - 100x100","reportOutliers":{"highSevere":1,"highMild":1,"lowMild":0,"samplesSeen":8,"lowSevere":0},"reportMeasured":[[0.10411193400068441,0.11379232699999875,249236955,1,null,null,null,null,null,null,null],[0.21443264200206613,0.23332820599999948,513343440,2,null,null,null,null,null,null,null],[0.3171869650032022,0.3457035150000003,759331287,3,null,null,null,null,null,null,null],[0.4201904179935809,0.4585033939999974,1005915258,4,null,null,null,null,null,null,null],[0.5365279010002268,0.5894183349999977,1284421554,5,null,null,null,null,null,null,null],[0.7868210059968987,0.8382854229999985,1883606868,6,null,null,null,null,null,null,null],[0.8365401619957993,0.8956148559999981,2002627116,7,null,null,null,null,null,null,null],[0.8412986440016539,0.9244983859999998,2014019406,8,null,null,null,null,null,null,null]]},{"reportAnalysis":{"anMean":{"estError":{"confIntLDX":8.943608249410318e-3,"confIntUDX":9.815010415877623e-3,"confIntCL":5.0e-2},"estPoint":0.9644028123334465},"anRegress":[{"regRSquare":{"estError":{"confIntLDX":1.285112229145735e-4,"confIntUDX":1.3020207609359957e-4,"confIntCL":5.0e-2},"estPoint":0.9998697979239064},"regResponder":"time","regCoeffs":{"y":{"estError":{"confIntLDX":0.11413710799390062,"confIntUDX":2.3595975995702966e-2,"confIntCL":5.0e-2},"estPoint":-4.277713199553259e-2},"iters":{"estError":{"confIntLDX":1.4253654897038892e-2,"confIntUDX":3.1977604098215595e-2,"confIntCL":5.0e-2},"estPoint":0.9856170978979197}}}],"anStdDev":{"estError":{"confIntLDX":6.037061628532516e-3,"confIntUDX":4.284905102868627e-3,"confIntCL":5.0e-2},"estPoint":1.0832350628490363e-2},"anOutlierVar":{"ovFraction":0.18749999999999994,"ovDesc":"moderate","ovEffect":"Moderate"}},"reportKDEs":[{"kdeValues":[0.9495639015012785,0.949811308005194,0.9500587145091095,0.950306121013025,0.9505535275169406,0.9508009340208561,0.9510483405247716,0.951295747028687,0.9515431535326025,0.9517905600365181,0.9520379665404336,0.9522853730443491,0.9525327795482647,0.9527801860521802,0.9530275925560957,0.9532749990600112,0.9535224055639268,0.9537698120678423,0.9540172185717578,0.9542646250756733,0.9545120315795887,0.9547594380835043,0.9550068445874198,0.9552542510913353,0.9555016575952509,0.9557490640991664,0.9559964706030819,0.9562438771069974,0.956491283610913,0.9567386901148285,0.956986096618744,0.9572335031226595,0.957480909626575,0.9577283161304905,0.957975722634406,0.9582231291383215,0.958470535642237,0.9587179421461526,0.9589653486500681,0.9592127551539836,0.9594601616578992,0.9597075681618147,0.9599549746657302,0.9602023811696457,0.9604497876735613,0.9606971941774767,0.9609446006813922,0.9611920071853077,0.9614394136892233,0.9616868201931388,0.9619342266970543,0.9621816332009698,0.9624290397048854,0.9626764462088009,0.9629238527127164,0.9631712592166319,0.9634186657205475,0.963666072224463,0.9639134787283784,0.9641608852322939,0.9644082917362095,0.964655698240125,0.9649031047440405,0.965150511247956,0.9653979177518716,0.9656453242557871,0.9658927307597026,0.9661401372636181,0.9663875437675337,0.9666349502714492,0.9668823567753646,0.9671297632792801,0.9673771697831957,0.9676245762871112,0.9678719827910267,0.9681193892949422,0.9683667957988578,0.9686142023027733,0.9688616088066888,0.9691090153106043,0.9693564218145199,0.9696038283184354,0.9698512348223509,0.9700986413262663,0.9703460478301819,0.9705934543340974,0.9708408608380129,0.9710882673419284,0.971335673845844,0.9715830803497595,0.971830486853675,0.9720778933575905,0.9723252998615061,0.9725727063654216,0.9728201128693371,0.9730675193732526,0.9733149258771681,0.9735623323810836,0.9738097388849991,0.9740571453889146,0.9743045518928302,0.9745519583967457,0.9747993649006612,0.9750467714045767,0.9752941779084923,0.9755415844124078,0.9757889909163233,0.9760363974202388,0.9762838039241544,0.9765312104280698,0.9767786169319853,0.9770260234359008,0.9772734299398164,0.9775208364437319,0.9777682429476474,0.9780156494515629,0.9782630559554785,0.978510462459394,0.9787578689633095,0.979005275467225,0.9792526819711406,0.979500088475056,0.9797474949789715,0.979994901482887,0.9802423079868026,0.9804897144907181,0.9807371209946336,0.9809845274985491],"kdeType":"time","kdePDF":[34.223414039644574,34.22204006108001,34.219292616827865,34.215172733854246,34.20968195563045,34.20282234573638,34.19459649262699,34.18500751552881,34.174059071426484,34.161755363091075,34.14810114809473,34.133101748749084,34.1167630628982,34.09909157549006,34.080094370844776,34.05977914553202,34.03815422176484,34.015228561212474,33.991011779130325,33.965514158701644,33.9387466654824,33.91072096183783,33.88144942125762,33.85094514243464,33.819221962991776,33.78629447274089,33.752178026358195,33.71688875536154,33.68044357927642,33.64286021587992,33.60415719041416,33.56435384366477,33.52347033880302,33.4815276668956,33.43854765099019,33.39455294869105,33.349567053144675,33.303614292361864,33.25671982680966,33.20890964521381,33.160210558520006,33.11065019197023,33.06025697525849,33.00906013073941,32.95708965967085,32.90437632648173,32.850951641064015,32.79684783909812,32.74209786042897,32.68673532551983,32.6307945100194,32.574310317487125,32.51731825032981,32.45985437901164,32.401955309607615,32.343658149778605,32.28500047325355,32.226020282912025,32.16675597256676,32.107246287552336,32.04753028423183,31.98764728853928,31.927636853679285,31.86753871711077,31.807392756944328,31.747238947886103,31.68711731686322,31.627067898467743,31.56713069035638,31.507345608744302,31.44775244413032,31.388390817389798,31.329300136369948,31.270519553119588,31.21208792188205,31.154043757976677,31.096425197689225,31.039269959287047,30.982615305268645,30.926498005951725,30.870954304496344,30.81601988345327,30.761729832919322,30.70811862037402,30.655220062262796,30.603067297383806,30.55169276212589,30.501128167596356,30.451404478667417,30.402551894960993,30.354599833781545,30.3075769149974,30.261510947861076,30.216428919749887,30.172356986798643,30.12932046638722,30.087343831436794,30.04645070646017,30.00666386530316,29.96800523050647,29.93049587421001,29.89415602051469,29.859005049210637,29.825061500774755,29.792343082535623,29.760866675899074,29.73064834452406,29.701703343335012,29.674046128254833,29.647690366540385,29.62264894760171,29.598933994185774,29.576556873805846,29.555528210298913,29.535857895395367,29.51755510018772,29.500628286388473,29.485085217271042,29.470932968192535,29.458177936601977,29.446825851443755,29.436881781872135,29.428350145199882,29.42123471401087,29.41553862237479,29.411264371110125,29.40841383204967,29.40698825127215]}],"reportKeys":["time","cpuTime","cycles","iters","allocated","numGcs","bytesCopied","mutatorWallSeconds","mutatorCpuSeconds","gcWallSeconds","gcCpuSeconds"],"reportNumber":4,"reportName":"Matrix Composition/200x200/WHNF - 200x200","reportOutliers":{"highSevere":0,"highMild":0,"lowMild":0,"samplesSeen":4,"lowSevere":0},"reportMeasured":[[0.952182287001051,1.0526491169999979,2279462697,1,null,null,null,null,null,null,null],[1.9235457300019334,2.1374558310000005,4604850279,2,null,null,null,null,null,null,null],[2.895869865998975,3.2140532490000027,6932533185,3,null,null,null,null,null,null,null],[3.9134645679951063,4.339293682000001,9368588223,4,null,null,null,null,null,null,null]]},{"reportAnalysis":{"anMean":{"estError":{"confIntLDX":1.4807615646077465e-2,"confIntUDX":1.9174949854004808e-2,"confIntCL":5.0e-2},"estPoint":0.980254961521041},"anRegress":[{"regRSquare":{"estError":{"confIntLDX":null,"confIntUDX":3.192046223169376e-4,"confIntCL":5.0e-2},"estPoint":0.9996807953776831},"regResponder":"time","regCoeffs":{"y":{"estError":{"confIntLDX":0.12856153400571943,"confIntUDX":0.12444246400627135,"confIntCL":5.0e-2},"estPoint":4.5851696999309875e-2},"iters":{"estError":{"confIntLDX":3.517554090139974e-2,"confIntUDX":5.121866010231624e-2,"confIntCL":5.0e-2},"estPoint":0.9557867079005508}}}],"anStdDev":{"estError":{"confIntLDX":2.1100583064131484e-2,"confIntUDX":4.9028588116461665e-3,"confIntCL":5.0e-2},"estPoint":2.1335106928918192e-2},"anOutlierVar":{"ovFraction":0.1875,"ovDesc":"moderate","ovEffect":"Moderate"}},"reportKDEs":[{"kdeValues":[0.9606996932752736,0.9611290994776349,0.9615585056799963,0.9619879118823577,0.962417318084719,0.9628467242870803,0.9632761304894417,0.963705536691803,0.9641349428941643,0.9645643490965257,0.9649937552988871,0.9654231615012484,0.9658525677036097,0.966281973905971,0.9667113801083325,0.9671407863106938,0.9675701925130551,0.9679995987154165,0.9684290049177778,0.9688584111201392,0.9692878173225005,0.9697172235248619,0.9701466297272232,0.9705760359295845,0.9710054421319458,0.9714348483343073,0.9718642545366686,0.9722936607390299,0.9727230669413913,0.9731524731437526,0.973581879346114,0.9740112855484753,0.9744406917508367,0.974870097953198,0.9752995041555593,0.9757289103579206,0.9761583165602821,0.9765877227626434,0.9770171289650047,0.977446535167366,0.9778759413697274,0.9783053475720888,0.9787347537744501,0.9791641599768115,0.9795935661791728,0.9800229723815341,0.9804523785838954,0.9808817847862569,0.9813111909886182,0.9817405971909795,0.9821700033933408,0.9825994095957022,0.9830288157980636,0.9834582220004249,0.9838876282027862,0.9843170344051476,0.9847464406075089,0.9851758468098702,0.9856052530122317,0.986034659214593,0.9864640654169543,0.9868934716193156,0.987322877821677,0.9877522840240384,0.9881816902263997,0.988611096428761,0.9890405026311224,0.9894699088334837,0.989899315035845,0.9903287212382064,0.9907581274405678,0.9911875336429291,0.9916169398452904,0.9920463460476519,0.9924757522500132,0.9929051584523745,0.9933345646547358,0.9937639708570972,0.9941933770594585,0.9946227832618199,0.9950521894641812,0.9954815956665426,0.9959110018689039,0.9963404080712652,0.9967698142736265,0.997199220475988,0.9976286266783493,0.9980580328807106,0.998487439083072,0.9989168452854333,0.9993462514877947,0.999775657690156,1.0002050638925173,1.0006344700948786,1.0010638762972401,1.0014932824996015,1.0019226887019628,1.002352094904324,1.0027815011066854,1.0032109073090467,1.003640313511408,1.0040697197137693,1.0044991259161309,1.0049285321184922,1.0053579383208535,1.0057873445232148,1.0062167507255761,1.0066461569279375,1.0070755631302988,1.0075049693326603,1.0079343755350216,1.008363781737383,1.0087931879397443,1.0092225941421056,1.009652000344467,1.0100814065468282,1.0105108127491897,1.010940218951551,1.0113696251539124,1.0117990313562737,1.012228437558635,1.0126578437609963,1.0130872499633576,1.013516656165719,1.0139460623680805,1.0143754685704418,1.0148048747728031,1.0152342809751644],"kdeType":"time","kdePDF":[25.10113267935344,25.095649993942963,25.084691284818486,25.068269863440708,25.04640566719559,25.019125223699206,24.986461603322667,24.94845436003791,24.905149460710593,24.856599202990253,24.80286212197282,24.744002885833773,24.68009218065442,24.611206584685853,24.537428432318467,24.45884566804602,24.375551690734888,24.28764518852948,24.19522996474471,24.098414755115268,23.997313036790075,23.89204282947705,23.78272648916058,23.66949049482895,23.55246522866418,23.431784750159938,23.307586564645998,23.180011386709285,23.049202899011934,22.915307507016138,22.778474090134036,22.638853749827696,22.49659955519041,22.35186628654532,22.204810177600674,22.05558865670396,21.904360087737654,21.751283511200054,21.596518386012658,21.440224332593967,21.28256087773499,21.123687201807837,20.9637618888319,20.802942679915674,20.641386230582974,20.479247872483924,20.316681379979048,20.153838742074402,19.990869940171425,19.827922732082595,19.66514244274769,19.502671762070687,19.340650550279125,19.17921565119128,19.018500713756076,18.858636022212764,18.699748335195142,18.541960734085606,18.385392480900656,18.230158885968457,18.076371185634265,17.924136430207113,17.77355738233537,17.624732425975406,17.477755486090857,17.33271595919583,17.189698654828106,17.048783748013662,16.91004674275605,16.77355844655929,16.639384955964903,16.507587653058863,16.37822321287622,16.251343621606534,16.126996205475653,16.005223670155164,15.886064150523904,15.769551270582248,15.65571421329409,15.54457780010861,15.436162579889118,15.33048492695481,15.22755714791781,15.127387596977835,15.02998079931489,14.935337582202166,14.84345521344114,14.754327546704442,14.667945173354065,14.584295580288043,14.503363313352908,14.42513014584709,14.349575251627089,14.276675382318233,14.20640504812135,14.138736701698976,14.073640924616969,14.011086615812308,13.951041181552927,13.893470726352907,13.838340244304378,13.785613810287625,13.735254770521873,13.687225931921953,13.64148974973019,13.598008512898023,13.556744526699095,13.517660292063338,13.480718681131503,13.445883108540258,13.413117697960331,13.382387443423555,13.353658364989592,13.326897658318797,13.302073837735131,13.279156872381026,13.258118315085568,13.238931423587648,13.22157127377716,13.206014864639467,13.192241214611526,13.180231449081935,13.169968878791881,13.161439068919103,13.15462989865309,13.149531611095941,13.146136853350436,13.144440706683849]}],"reportKeys":["time","cpuTime","cycles","iters","allocated","numGcs","bytesCopied","mutatorWallSeconds","mutatorCpuSeconds","gcWallSeconds","gcCpuSeconds"],"reportNumber":5,"reportName":"Matrix Composition/200x200/NF - 200x200","reportOutliers":{"highSevere":0,"highMild":0,"lowMild":0,"samplesSeen":4,"lowSevere":0},"reportMeasured":[[1.0106897320001735,1.1114506120000058,2419530687,1,null,null,null,null,null,null,null],[1.931300898999325,2.1467453059999997,4623422013,2,null,null,null,null,null,null,null],[2.93830626700219,3.2560128309999996,7034127723,3,null,null,null,null,null,null,null],[3.860976969001058,4.287151803,9242947080,4,null,null,null,null,null,null,null]]},{"reportAnalysis":{"anMean":{"estError":{"confIntLDX":9.015849688239541e-3,"confIntUDX":1.5627307563136128e-2,"confIntCL":5.0e-2},"estPoint":0.4467186700617276},"anRegress":[{"regRSquare":{"estError":{"confIntLDX":4.758039038510686e-3,"confIntUDX":2.764331786034191e-3,"confIntCL":5.0e-2},"estPoint":0.9972356682139658},"regResponder":"time","regCoeffs":{"y":{"estError":{"confIntLDX":9.494432500287157e-2,"confIntUDX":0.1238789349990784,"confIntCL":5.0e-2},"estPoint":3.479605399843541e-2},"iters":{"estError":{"confIntLDX":4.1503871999154895e-2,"confIntUDX":6.790775800182047e-2,"confIntCL":5.0e-2},"estPoint":0.4311238130001579}}}],"anStdDev":{"estError":{"confIntLDX":1.366598521603004e-2,"confIntUDX":3.6973250118209587e-3,"confIntCL":5.0e-2},"estPoint":1.5029085673470916e-2},"anOutlierVar":{"ovFraction":0.1875,"ovDesc":"moderate","ovEffect":"Moderate"}},"reportKDEs":[{"kdeValues":[0.4332788312744015,0.43358530461062506,0.4338917779468486,0.43419825128307216,0.4345047246192957,0.43481119795551926,0.4351176712917428,0.43542414462796636,0.43573061796418994,0.43603709130041346,0.43634356463663704,0.43665003797286056,0.43695651130908414,0.43726298464530766,0.43756945798153124,0.4378759313177548,0.43818240465397834,0.4384888779902019,0.43879535132642544,0.439101824662649,0.4394082979988726,0.4397147713350961,0.4400212446713197,0.4403277180075432,0.4406341913437668,0.4409406646799903,0.4412471380162139,0.4415536113524375,0.441860084688661,0.4421665580248846,0.4424730313611081,0.4427795046973317,0.4430859780335552,0.4433924513697788,0.44369892470600236,0.4440053980422259,0.44431187137844946,0.444618344714673,0.44492481805089656,0.4452312913871201,0.44553776472334367,0.44584423805956724,0.44615071139579077,0.44645718473201434,0.44676365806823787,0.44707013140446145,0.44737660474068497,0.44768307807690855,0.4479895514131321,0.44829602474935565,0.4486024980855792,0.44890897142180275,0.4492154447580263,0.4495219180942499,0.44982839143047343,0.450134864766697,0.45044133810292053,0.4507478114391441,0.45105428477536763,0.4513607581115912,0.45166723144781473,0.4519737047840383,0.4522801781202619,0.4525866514564854,0.452893124792709,0.4531995981289325,0.4535060714651561,0.45381254480137967,0.4541190181376032,0.45442549147382677,0.4547319648100503,0.45503843814627387,0.4553449114824974,0.455651384818721,0.45595785815494455,0.4562643314911681,0.45657080482739165,0.4568772781636152,0.45718375149983875,0.4574902248360623,0.45779669817228585,0.45810317150850943,0.45840964484473296,0.45871611818095653,0.45902259151718006,0.45932906485340363,0.45963553818962716,0.45994201152585074,0.4602484848620743,0.46055495819829784,0.4608614315345214,0.46116790487074494,0.4614743782069685,0.46178085154319204,0.4620873248794156,0.4623937982156392,0.4627002715518627,0.4630067448880863,0.4633132182243098,0.4636196915605334,0.463926164896757,0.4642326382329805,0.4645391115692041,0.4648455849054276,0.4651520582416512,0.4654585315778747,0.4657650049140983,0.4660714782503218,0.4663779515865454,0.46668442492276896,0.4669908982589925,0.46729737159521606,0.4676038449314396,0.46791031826766316,0.46821679160388674,0.46852326494011026,0.46882973827633384,0.46913621161255736,0.46944268494878094,0.4697491582850045,0.47005563162122804,0.4703621049574516,0.47066857829367514,0.4709750516298987,0.47128152496612224,0.4715879983023458,0.47189447163856935,0.4722009449747929],"kdeType":"time","kdePDF":[36.46854517553605,36.45971767372291,36.44207355382525,36.41563456367283,36.3804332759831,36.33651302964449,36.283927851620675,36.222742359640456,36.15303164587927,36.07488114187756,35.98838646498195,35.8936532466331,35.79079694286365,35.67994262740633,35.56122476784969,35.434786985314595,35.300781798159505,35.15937035025631,35.010722124411366,34.855014641537664,34.69243314621433,34.523170279298405,34.34742573828139,34.16540592610894,33.97732358920643,33.78339744547609,33.58385180305245,33.378916170622375,33.16882486013375,32.9538165827328,32.73413403878412,32.51002350283988,32.28173440443492,32.04951890559307,31.81363147593622,31.574328466292737,31.331867681703603,31.086507954726187,30.838508719932882,30.588129590499722,30.33562993777316,30.081268474697108,29.825302843971503,29.567989211803315,29.30958186809636,29.05033283391213,28.790491477014864,28.530304136296838,28.27001375585665,28.00985952948244,27.75007655626531,27.490895508043966,27.232542309351132,26.975237830505332,26.7191975944576,26.464631497972842,26.21174354768879,25.960731611562633,25.711787186176306,25.465095180335997,25.220833715360136,24.979173942412597,24.740279877194656,24.504308252269997,24.2714083872524,24.041722077045094,23.81538349827503,23.592519134023714,23.37324771690989,23.157680190537235,22.945919689273417,22.738061536285027,22.534193259705937,22.334394626775335,22.138737695735287,21.9472868852372,21.760099060961196,21.57722363911318,21.398702706420636,21.22457115621037,21.05485684010984,20.889580734877892,20.7287571238315,20.572393792301696,20.420492236515557,20.273047885270344,20.13005033373293,19.99148358866988,19.857326324384037,19.727552148609558,19.602129877591093,19.481023819552934,19.364194065742108,19.25159678821275,19.143184543502375,19.03890658133765,18.938709157495424,18.842535849935953,18.750327877318064,18.662024419001714,18.57756293564096,18.496879489470626,18.41990906339224,18.346585877969627,18.276843705451856,18.21061617995021,18.147837102908213,18.088440743016992,18.032362129745273,17.979537339670983,17.929903774822627,17.88340043226078,17.839968164155188,17.799549927639326,17.762091023752976,17.727539324813964,17.69584548959215,17.66696316569274,17.640849178591633,17.617463706801914,17.596770442689678,17.57873673849627,17.563333737165376,17.55053648761491,17.540324044136796,17.532679549651053,17.527590302585594,17.52504780719747]}],"reportKeys":["time","cpuTime","cycles","iters","allocated","numGcs","bytesCopied","mutatorWallSeconds","mutatorCpuSeconds","gcWallSeconds","gcCpuSeconds"],"reportNumber":6,"reportName":"Matrix vs List - `select`/Distribution/List Distribution - Applicative version","reportOutliers":{"highSevere":0,"highMild":1,"lowMild":0,"samplesSeen":4,"lowSevere":0},"reportMeasured":[[0.43888329999754205,0.45220941800000247,1050657993,1,null,null,null,null,null,null,null],[0.9379148709995206,0.9577447980000002,2245311828,2,null,null,null,null,null,null,null],[1.327534812000522,1.3796596260000058,3178022445,3,null,null,null,null,null,null,null],[1.7460893629977363,1.8098142550000063,4180030308,4,null,null,null,null,null,null,null]]},{"reportAnalysis":{"anMean":{"estError":{"confIntLDX":5.41568406366022e-3,"confIntUDX":4.0069568115642384e-3,"confIntCL":5.0e-2},"estPoint":0.1820171075632162},"anRegress":[{"regRSquare":{"estError":{"confIntLDX":3.2668297220008746e-3,"confIntUDX":1.8052266832877528e-3,"confIntCL":5.0e-2},"estPoint":0.9981947733167122},"regResponder":"time","regCoeffs":{"y":{"estError":{"confIntLDX":2.771141228973966e-2,"confIntUDX":4.332394757997368e-2,"confIntCL":5.0e-2},"estPoint":-2.4105218600501112e-2},"iters":{"estError":{"confIntLDX":1.633759716891567e-2,"confIntUDX":7.047138326795099e-3,"confIntCL":5.0e-2},"estPoint":0.1912007901711539}}}],"anStdDev":{"estError":{"confIntLDX":2.050761052749911e-3,"confIntUDX":2.1938768722983646e-3,"confIntCL":5.0e-2},"estPoint":6.298418696687028e-3},"anOutlierVar":{"ovFraction":0.1388888888888888,"ovDesc":"moderate","ovEffect":"Moderate"}},"reportKDEs":[{"kdeValues":[0.17291204636918944,0.17306166772034354,0.17321128907149763,0.17336091042265173,0.17351053177380582,0.17366015312495992,0.17380977447611398,0.17395939582726808,0.17410901717842217,0.17425863852957627,0.17440825988073036,0.17455788123188445,0.17470750258303855,0.17485712393419264,0.17500674528534674,0.17515636663650083,0.17530598798765493,0.17545560933880902,0.1756052306899631,0.17575485204111718,0.17590447339227128,0.17605409474342537,0.17620371609457947,0.17635333744573356,0.17650295879688765,0.17665258014804175,0.17680220149919584,0.17695182285034994,0.17710144420150403,0.1772510655526581,0.1774006869038122,0.1775503082549663,0.17769992960612038,0.17784955095727448,0.17799917230842857,0.17814879365958267,0.17829841501073676,0.17844803636189085,0.17859765771304495,0.17874727906419904,0.17889690041535314,0.1790465217665072,0.1791961431176613,0.1793457644688154,0.1794953858199695,0.17964500717112358,0.17979462852227768,0.17994424987343177,0.18009387122458587,0.18024349257573996,0.18039311392689406,0.18054273527804815,0.18069235662920222,0.1808419779803563,0.1809915993315104,0.1811412206826645,0.1812908420338186,0.1814404633849727,0.18159008473612678,0.18173970608728088,0.18188932743843497,0.18203894878958907,0.18218857014074316,0.18233819149189723,0.18248781284305132,0.18263743419420542,0.1827870555453595,0.1829366768965136,0.1830862982476677,0.1832359195988218,0.1833855409499759,0.18353516230112998,0.18368478365228408,0.18383440500343817,0.18398402635459227,0.18413364770574636,0.18428326905690043,0.18443289040805452,0.18458251175920862,0.1847321331103627,0.1848817544615168,0.1850313758126709,0.185180997163825,0.1853306185149791,0.18548023986613318,0.18562986121728728,0.18577948256844135,0.18592910391959544,0.18607872527074953,0.18622834662190363,0.18637796797305772,0.18652758932421182,0.1866772106753659,0.18682683202652,0.1869764533776741,0.1871260747288282,0.1872756960799823,0.18742531743113638,0.18757493878229048,0.18772456013344455,0.18787418148459864,0.18802380283575273,0.18817342418690683,0.18832304553806092,0.18847266688921502,0.1886222882403691,0.1887719095915232,0.1889215309426773,0.1890711522938314,0.18922077364498546,0.18937039499613956,0.18952001634729365,0.18966963769844775,0.18981925904960184,0.18996888040075594,0.19011850175191003,0.19026812310306412,0.19041774445421822,0.1905673658053723,0.1907169871565264,0.1908666085076805,0.1910162298588346,0.19116585120998866,0.19131547256114276,0.19146509391229685,0.19161471526345095,0.19176433661460504,0.19191395796575914],"kdeType":"time","kdePDF":[54.480122582990404,54.477642268031175,54.47268757227488,54.46527034338099,54.45540830126605,54.44312497646677,54.428449628373436,54.41141714368722,54.39206791554063,54.370447703802604,54.34660747717066,54.32060323772968,54.29249582873082,54.26235072641433,54.23023781676622,54.19623115816067,54.160408730896876,54.122852174691424,54.08364651523391,54.04287988095558,54.000643211195985,53.9570299569833,53.91213577566827,53.866058220669615,53.81889642760148,53.77075079805944,53.721722682342005,53.67191406237824,53.621427236120994,53.570364504646754,53.518827863180476,53.46691869723419,53.4147374850143,53.36238350721232,53.30995456525018,53.2575467090012,53.20525397495495,53.15316813573613,53.10137846182666,53.04997149627505,52.99903084310936,52.94863697009987,52.898867026444066,52.84979467587278,52.80148994559917,52.75401909145577,52.707444479485865,52.66182448417835,52.61721340345573,52.57366139044837,52.531214402010434,52.4899141638582,52.44979815213696,52.41089959115135,52.373247466924184,52.33686655618247,52.301777470304856,52.26799671370519,52.23553675606903,52.20440611780773,52.17460946804463,52.1461477344044,52.119018223834665,52.093214753654564,52.06872779199286,52.04554460675214,52.023649422214234,52.00302358238543,51.98364572016781,51.965491931437306,51.94853595310609,51.932749344250496,51.91810166939328,51.904560683040785,51.892092514592896,51.88066185276439,51.87023212868158,51.86076569684707,51.85222401319861,51.84456780952423,51.837757263535146,51.83175216394102,51.82651206991666,51.821996464397685,51.818164900691556,51.814977141942606,51.812393293042206,51.810373924629566,51.808880188883755,51.807873926862655,51.80731776720081,51.80717521603326,51.80741073806795,51.80798982878352,51.80887907778282,51.810046223384646,51.811460198586346,51.8130911685791,51.814910560043565,51.81689108249841,51.819006742015034,51.82123284765137,51.823546010992644,51.8259241392205,51.82834642216024,51.83079331378294,51.833246508660615,51.835688913892,51.83810461703126,51.840478850563564,51.8427979534783,51.84504933049563,51.84722140950075,51.849303597737574,51.85128623730564,51.853160560493045,51.854918645464046,51.85655337280191,51.85805838338652,51.859428038062205,51.86065737952405,51.86174209682131,51.862678492843976,51.86346345512432,51.86409443024778,51.86456940212986,51.86488687437471,51.86504585689003]}],"reportKeys":["time","cpuTime","cycles","iters","allocated","numGcs","bytesCopied","mutatorWallSeconds","mutatorCpuSeconds","gcWallSeconds","gcCpuSeconds"],"reportNumber":7,"reportName":"Matrix vs List - `select`/Distribution/Matrix Distribution - Applicative version","reportOutliers":{"highSevere":0,"highMild":0,"lowMild":0,"samplesSeen":6,"lowSevere":0},"reportMeasured":[[0.17499620899616275,0.18208193499999936,418926708,1,null,null,null,null,null,null,null],[0.3489910780044738,0.36185200299999565,835467444,2,null,null,null,null,null,null,null],[0.5583885179948993,0.5746514829999967,1336749615,3,null,null,null,null,null,null,null],[0.7381117810000433,0.7604308450000019,1766995479,4,null,null,null,null,null,null,null],[0.9081149039993761,0.9381683330000072,2173973742,5,null,null,null,null,null,null,null],[1.14198279199627,1.1733856529999969,2733837057,6,null,null,null,null,null,null,null]]},{"reportAnalysis":{"anMean":{"estError":{"confIntLDX":2.0205288433175622e-3,"confIntUDX":5.425928358171295e-3,"confIntCL":5.0e-2},"estPoint":9.136040249002575e-2},"anRegress":[{"regRSquare":{"estError":{"confIntLDX":8.798266809115773e-4,"confIntUDX":6.731593911780687e-4,"confIntCL":5.0e-2},"estPoint":0.9992000703771193},"regResponder":"time","regCoeffs":{"y":{"estError":{"confIntLDX":1.4123799216399956e-2,"confIntUDX":1.3411080953009356e-2,"confIntCL":5.0e-2},"estPoint":6.3332808650250465e-3},"iters":{"estError":{"confIntLDX":1.5692309832214119e-3,"confIntUDX":2.331796105880496e-3,"confIntCL":5.0e-2},"estPoint":8.906482042454605e-2}}}],"anStdDev":{"estError":{"confIntLDX":3.907232882951686e-3,"confIntUDX":3.960352379222367e-3,"confIntCL":5.0e-2},"estPoint":5.3416383323926005e-3},"anOutlierVar":{"ovFraction":0.18171701654949143,"ovDesc":"moderate","ovEffect":"Moderate"}},"reportKDEs":[{"kdeValues":[8.433224143276069e-2,8.451795836818864e-2,8.470367530361658e-2,8.488939223904453e-2,8.507510917447247e-2,8.526082610990043e-2,8.544654304532838e-2,8.563225998075633e-2,8.581797691618427e-2,8.600369385161222e-2,8.618941078704016e-2,8.637512772246811e-2,8.656084465789605e-2,8.6746561593324e-2,8.693227852875196e-2,8.71179954641799e-2,8.730371239960785e-2,8.74894293350358e-2,8.767514627046374e-2,8.786086320589169e-2,8.804658014131964e-2,8.823229707674758e-2,8.841801401217553e-2,8.860373094760349e-2,8.878944788303143e-2,8.897516481845938e-2,8.916088175388732e-2,8.934659868931527e-2,8.953231562474322e-2,8.971803256017116e-2,8.990374949559911e-2,9.008946643102705e-2,9.027518336645501e-2,9.046090030188296e-2,9.06466172373109e-2,9.083233417273885e-2,9.10180511081668e-2,9.120376804359474e-2,9.138948497902269e-2,9.157520191445064e-2,9.176091884987858e-2,9.194663578530654e-2,9.213235272073449e-2,9.231806965616243e-2,9.250378659159038e-2,9.268950352701832e-2,9.287522046244627e-2,9.306093739787422e-2,9.324665433330216e-2,9.343237126873011e-2,9.361808820415807e-2,9.380380513958601e-2,9.398952207501396e-2,9.41752390104419e-2,9.436095594586985e-2,9.45466728812978e-2,9.473238981672574e-2,9.491810675215369e-2,9.510382368758163e-2,9.52895406230096e-2,9.547525755843753e-2,9.566097449386549e-2,9.584669142929343e-2,9.603240836472138e-2,9.621812530014932e-2,9.640384223557727e-2,9.658955917100522e-2,9.677527610643316e-2,9.696099304186112e-2,9.714670997728905e-2,9.733242691271701e-2,9.751814384814496e-2,9.77038607835729e-2,9.788957771900085e-2,9.80752946544288e-2,9.826101158985674e-2,9.844672852528469e-2,9.863244546071263e-2,9.881816239614058e-2,9.900387933156854e-2,9.918959626699649e-2,9.937531320242443e-2,9.956103013785238e-2,9.974674707328032e-2,9.993246400870827e-2,0.10011818094413621,0.10030389787956417,0.1004896148149921,0.10067533175042007,0.10086104868584801,0.10104676562127596,0.1012324825567039,0.10141819949213185,0.1016039164275598,0.10178963336298774,0.1019753502984157,0.10216106723384363,0.10234678416927159,0.10253250110469954,0.10271821804012748,0.10290393497555543,0.10308965191098338,0.10327536884641132,0.10346108578183927,0.10364680271726723,0.10383251965269516,0.10401823658812312,0.10420395352355107,0.10438967045897901,0.10457538739440696,0.1047611043298349,0.10494682126526285,0.1051325382006908,0.10531825513611874,0.10550397207154669,0.10568968900697465,0.10587540594240259,0.10606112287783054,0.10624683981325848,0.10643255674868643,0.10661827368411438,0.10680399061954232,0.10698970755497027,0.10717542449039821,0.10736114142582617,0.10754685836125412,0.10773257529668206,0.10791829223211001],"kdeType":"time","kdePDF":[28.61250324725837,28.965475705818537,29.6711180881012,30.72915421407188,32.139934126951474,33.90519589919426,36.0288420454396,38.51756245725569,41.38113537066191,44.63225844612554,48.285801922560225,52.357431220192545,56.861611801404,61.80907790275574,67.20391185293,73.04043536247394,79.30015274911678,85.94900453536243,92.93518624366445,100.18776170572214,107.61625502988474,115.1113444716799,122.54670996338109,129.78200972875135,136.66688602033736,143.04583088204222,148.76368443504592,153.67149393424504,157.6324340464639,160.5274786790462,162.26052247530276,162.76267516359684,161.99549289999285,159.95296546555448,156.66214386541975,152.18236606110207,146.6031151808083,140.04062005619073,132.63337754834214,124.53683515608762,115.91751663283551,106.94689946590303,97.79535907508914,88.62648001861673,79.59200060705824,70.82760701002918,62.44973047048248,54.55343185569543,47.21138714200333,40.47392107711598,34.369979026280994,28.908882592468707,24.08268528933713,19.868931087235378,16.233620326365422,13.13420233021828,10.522439176922529,8.347017099226123,6.555817371052692,5.097794026032673,3.924438586382712,2.9908401035697594,2.256370944630141,1.6850443750169168,1.245599226497989,0.9113704491297688,0.6600031286381005,0.47306278172363814,0.3355876268303147,0.23562018149128958,0.16374690259647626,0.11266639077402732,7.679942607779647e-2,5.1948079206538954e-2,3.5006460011462064e-2,2.3722292775606217e-2,1.6506317376603432e-2,1.2285319587828124e-2,1.0394177319460367e-2,1.0502453390894588e-2,1.2571560939279998e-2,1.6839185179135376e-2,2.382829662012615e-2,3.4378589253215956e-2,4.9698396445911154e-2,7.143497300127939e-2,0.10176040523575197,0.14346927702733744,0.20008257884193745,0.27595025891172104,0.3763424153900673,0.5075166357577844,0.6767467152506328,0.8922963225060618,1.1633205803911675,1.4996794641949296,1.9116498190229518,2.409527980918658,3.0031225754780126,3.7011469158338905,4.51053204995288,5.435694077030212,6.477801684391419,7.6341005001342745,8.897358223232542,10.255497032678003,11.691476195811736,13.183477275861227,14.705426738308907,16.22786674943732,17.719156089268527,19.14695171243862,20.47989055938473,21.689364062849844,22.751257702499817,23.647517797154094,24.36740953963004,24.908344993850882,25.276186981395814,25.48497270662733,25.556046574502023,25.51664093344636,25.39799183892937,25.233119692243253,25.05443747192796,24.8913688099761,24.76816217038567,24.702075136121977]}],"reportKeys":["time","cpuTime","cycles","iters","allocated","numGcs","bytesCopied","mutatorWallSeconds","mutatorCpuSeconds","gcWallSeconds","gcCpuSeconds"],"reportNumber":8,"reportName":"Matrix vs List - `select`/Distribution/Matrix Distribution - Selective version","reportOutliers":{"highSevere":1,"highMild":0,"lowMild":1,"samplesSeen":10,"lowSevere":0},"reportMeasured":[[0.1059527879988309,9.925472799999113e-2,253644102,1,null,null,null,null,null,null,null],[0.17740705399774015,0.18492871200000138,424704078,2,null,null,null,null,null,null,null],[0.2588932369981194,0.26972392700000114,619779645,3,null,null,null,null,null,null,null],[0.36431109700060915,0.37902938700000277,872142111,4,null,null,null,null,null,null,null],[0.45272927999758394,0.470623130000007,1083807486,5,null,null,null,null,null,null,null],[0.5497448730020551,0.5678201149999893,1316043675,6,null,null,null,null,null,null,null],[0.6330941910055117,0.6574168850000035,1515592188,7,null,null,null,null,null,null,null],[0.7227680840005632,0.7520511409999955,1730264562,8,null,null,null,null,null,null,null],[0.8022976110005402,0.8358020179999954,1920654288,9,null,null,null,null,null,null,null],[0.8946997169987299,0.9324800819999979,2141857287,10,null,null,null,null,null,null,null]]},{"reportAnalysis":{"anMean":{"estError":{"confIntLDX":6.131897941607656e-2,"confIntUDX":5.196668233353796e-2,"confIntCL":5.0e-2},"estPoint":0.840422457165308},"anRegress":[{"regRSquare":{"estError":{"confIntLDX":5.9381428532159775e-2,"confIntUDX":2.294389387055773e-2,"confIntCL":5.0e-2},"estPoint":0.9770561061294423},"regResponder":"time","regCoeffs":{"y":{"estError":{"confIntLDX":1.0511536234880774,"confIntUDX":0.9328142274935034,"confIntCL":5.0e-2},"estPoint":2.6528933496595238e-2},"iters":{"estError":{"confIntLDX":0.37904266079713156,"confIntUDX":0.2822799561967303,"confIntCL":5.0e-2},"estPoint":0.829012787800456}}}],"anStdDev":{"estError":{"confIntLDX":4.128733977846623e-2,"confIntUDX":2.3326425499181264e-2,"confIntCL":5.0e-2},"estPoint":6.898641320796234e-2},"anOutlierVar":{"ovFraction":0.21376667254855866,"ovDesc":"moderate","ovEffect":"Moderate"}},"reportKDEs":[{"kdeValues":[0.7537621279835245,0.755272904615005,0.7567836812464854,0.7582944578779659,0.7598052345094464,0.7613160111409268,0.7628267877724073,0.7643375644038878,0.7658483410353683,0.7673591176668487,0.7688698942983292,0.7703806709298097,0.7718914475612901,0.7734022241927707,0.7749130008242512,0.7764237774557317,0.7779345540872121,0.7794453307186926,0.7809561073501731,0.7824668839816535,0.783977660613134,0.7854884372446145,0.786999213876095,0.7885099905075754,0.7900207671390559,0.7915315437705364,0.7930423204020168,0.7945530970334973,0.7960638736649778,0.7975746502964582,0.7990854269279387,0.8005962035594192,0.8021069801908997,0.8036177568223801,0.8051285334538606,0.8066393100853411,0.8081500867168215,0.809660863348302,0.8111716399797826,0.812682416611263,0.8141931932427435,0.815703969874224,0.8172147465057045,0.8187255231371849,0.8202362997686654,0.8217470764001459,0.8232578530316264,0.8247686296631068,0.8262794062945873,0.8277901829260678,0.8293009595575482,0.8308117361890287,0.8323225128205092,0.8338332894519896,0.8353440660834701,0.8368548427149506,0.8383656193464311,0.8398763959779115,0.841387172609392,0.8428979492408725,0.8444087258723529,0.8459195025038334,0.8474302791353139,0.8489410557667945,0.8504518323982748,0.8519626090297554,0.8534733856612359,0.8549841622927163,0.8564949389241968,0.8580057155556773,0.8595164921871578,0.8610272688186382,0.8625380454501187,0.8640488220815992,0.8655595987130796,0.8670703753445601,0.8685811519760406,0.870091928607521,0.8716027052390015,0.873113481870482,0.8746242585019625,0.8761350351334429,0.8776458117649234,0.8791565883964039,0.8806673650278843,0.8821781416593648,0.8836889182908453,0.8851996949223258,0.8867104715538063,0.8882212481852867,0.8897320248167673,0.8912428014482476,0.8927535780797282,0.8942643547112087,0.8957751313426892,0.8972859079741696,0.8987966846056501,0.9003074612371306,0.901818237868611,0.9033290145000915,0.904839791131572,0.9063505677630525,0.9078613443945329,0.9093721210260134,0.9108828976574939,0.9123936742889743,0.9139044509204548,0.9154152275519353,0.9169260041834157,0.9184367808148962,0.9199475574463767,0.9214583340778572,0.9229691107093376,0.9244798873408182,0.9259906639722986,0.9275014406037791,0.9290122172352595,0.9305229938667401,0.9320337704982204,0.933544547129701,0.9350553237611815,0.936566100392662,0.9380768770241424,0.9395876536556229,0.9410984302871034,0.9426092069185839,0.9441199835500643,0.9456307601815448],"kdeType":"time","kdePDF":[5.931830864080185,5.9312882355711505,5.930203550272949,5.928577950784472,5.926413148903177,5.92371142310742,5.920475615205276,5.916709126154669,5.912415911060959,5.907600473359214,5.902267858189765,5.8964236449767204,5.890073939220441,5.8832253635160745,5.8758850478116065,5.8680606189199205,5.859760189300709,5.850992345129202,5.841766133669881,5.832091049974525,5.821977022925173,5.8114344006436385,5.800473935290502,5.789106767277529,5.777344408918675,5.765198727545904,5.752681928117116,5.739806535344642,5.726585375373649,5.7130315570409795,5.699158452745799,5.68497967896445,5.670509076442794,5.6557606901002,5.640748748680164,5.625487644183332,5.609991911119415,5.594276205615181,5.578355284416318,5.5622439838215065,5.545957198587568,5.5295098608449464,5.5129169190631515,5.496193317106078,5.479353973417283,5.462413760375472,5.445387483860411,5.428289863069523,5.4111355106251535,5.393938913012377,5.376714411386799,5.359476182791414,5.342238221821014,5.325014322772076,5.307818062315189,5.290662782726442,5.273561575712988,5.25652726686724,5.239572400782698,5.222709226863449,5.205949685857713,5.189305397144643,5.172787646801725,5.156407376478748,5.140175173102279,5.124101259432949,5.108195485495731,5.092467320901533,5.076925848076124,5.0615797564104055,5.046437337343626,5.031506480388941,5.016794670108193,5.002308984040492,4.988056091586532,4.974042253848204,4.960273324420339,4.946754751129006,4.933491578707985,4.92048845240261,4.907749622487409,4.895278949681469,4.883079911442767,4.871155609120269,4.859508775939894,4.848141785798152,4.837056662834655,4.82625509175247,4.815738428852864,4.8055077137488915,4.795563681720026,4.785906776668116,4.776537164632917,4.767454747823749,4.758659179122007,4.750149877007854,4.741926040862821,4.733986666598921,4.726330562563647,4.7189563656692854,4.711862557694163,4.705047481702778,4.698509358531303,4.692246303284595,4.686256341790787,4.680537426959468,4.675087454989799,4.66990428137519,4.664985736651845,4.660329641839159,4.655933823520922,4.651796128517384,4.647914438099521,4.644286681698258,4.640910850063072,4.637785007826115,4.634907305429954,4.632275990379116,4.62988941777776,4.627746060118282,4.625844516287986,4.624183519763674,4.622761945966601,4.621578818753145,4.620633316019324,4.619924774400369,4.619452693049478,4.619216736483095]}],"reportKeys":["time","cpuTime","cycles","iters","allocated","numGcs","bytesCopied","mutatorWallSeconds","mutatorCpuSeconds","gcWallSeconds","gcCpuSeconds"],"reportNumber":9,"reportName":"Matrix vs List - `select`/Matrix `select`/Applicative version","reportOutliers":{"highSevere":0,"highMild":0,"lowMild":0,"samplesSeen":4,"lowSevere":0},"reportMeasured":[[0.807160368996847,0.8949543830000124,1932304023,1,null,null,null,null,null,null,null],[1.859283414996753,2.003846456000005,4451023062,2,null,null,null,null,null,null,null],[2.3092535420000786,2.5852589090000038,5528220390,3,null,null,null,null,null,null,null],[3.4205462859972613,3.7581170509999993,8188588566,4,null,null,null,null,null,null,null]]},{"reportAnalysis":{"anMean":{"estError":{"confIntLDX":1.2199978624266805e-2,"confIntUDX":4.535647375026486e-3,"confIntCL":5.0e-2},"estPoint":0.42580509562564356},"anRegress":[{"regRSquare":{"estError":{"confIntLDX":5.585570063327383e-3,"confIntUDX":2.1599977168095252e-3,"confIntCL":5.0e-2},"estPoint":0.9978400022831905},"regResponder":"time","regCoeffs":{"y":{"estError":{"confIntLDX":0.20960627148088262,"confIntUDX":0.11365774149817366,"confIntCL":5.0e-2},"estPoint":-4.802204497535666e-3},"iters":{"estError":{"confIntLDX":5.0260523098403176e-2,"confIntUDX":5.749414789461399e-2,"confIntCL":5.0e-2},"estPoint":0.4275804610995688}}}],"anStdDev":{"estError":{"confIntLDX":8.338584286079328e-3,"confIntUDX":1.97714832414367e-3,"confIntCL":5.0e-2},"estPoint":8.497480607539406e-3},"anOutlierVar":{"ovFraction":0.1875,"ovDesc":"moderate","ovEffect":"Moderate"}},"reportKDEs":[{"kdeValues":[0.41179085805136617,0.41196228409388685,0.41213371013640754,0.4123051361789282,0.4124765622214489,0.4126479882639696,0.4128194143064903,0.41299084034901096,0.41316226639153164,0.4133336924340523,0.413505118476573,0.41367654451909375,0.41384797056161443,0.4140193966041351,0.4141908226466558,0.4143622486891765,0.41453367473169717,0.41470510077421785,0.41487652681673853,0.4150479528592592,0.4152193789017799,0.4153908049443006,0.41556223098682127,0.41573365702934195,0.41590508307186264,0.4160765091143833,0.416247935156904,0.4164193611994247,0.41659078724194537,0.41676221328446605,0.41693363932698674,0.4171050653695074,0.41727649141202816,0.41744791745454884,0.41761934349706953,0.4177907695395902,0.4179621955821109,0.4181336216246316,0.41830504766715226,0.41847647370967295,0.41864789975219363,0.4188193257947143,0.418990751837235,0.4191621778797557,0.41933360392227637,0.41950502996479705,0.41967645600731773,0.4198478820498384,0.4200193080923591,0.4201907341348798,0.42036216017740047,0.42053358621992115,0.42070501226244184,0.4208764383049626,0.42104786434748326,0.42121929039000394,0.4213907164325246,0.4215621424750453,0.421733568517566,0.4219049945600867,0.42207642060260736,0.42224784664512804,0.42241927268764873,0.4225906987301694,0.4227621247726901,0.4229335508152108,0.42310497685773146,0.42327640290025215,0.42344782894277283,0.4236192549852935,0.4237906810278142,0.4239621070703349,0.42413353311285557,0.42430495915537625,0.424476385197897,0.42464781124041767,0.42481923728293836,0.42499066332545904,0.4251620893679797,0.4253335154105004,0.4255049414530211,0.4256763674955418,0.42584779353806246,0.42601921958058314,0.4261906456231038,0.4263620716656245,0.4265334977081452,0.4267049237506659,0.42687634979318656,0.42704777583570724,0.4272192018782279,0.4273906279207486,0.4275620539632693,0.42773348000579,0.42790490604831066,0.4280763320908314,0.4282477581333521,0.42841918417587277,0.42859061021839345,0.42876203626091414,0.4289334623034348,0.4291048883459555,0.4292763143884762,0.42944774043099687,0.42961916647351756,0.42979059251603824,0.4299620185585589,0.4301334446010796,0.4303048706436003,0.430476296686121,0.43064772272864166,0.43081914877116234,0.430990574813683,0.4311620008562037,0.4313334268987244,0.4315048529412451,0.4316762789837658,0.4318477050262865,0.4320191310688072,0.43219055711132787,0.43236198315384855,0.43253340919636923,0.4327048352388899,0.4328762612814106,0.4330476873239313,0.43321911336645197,0.43339053940897265,0.43356196545149334],"kdeType":"time","kdePDF":[32.7931096273945,32.79740737292799,32.80600909628127,32.81892723642228,32.83618038786267,32.85779322412929,32.883796396058905,32.91422640520001,32.94912545267487,32.98854126392419,33.03252688982321,33.08114048472497,33.13444506205001,33.192508228105616,33.25540189487725,33.323201972595264,33.39598804293495,33.47384301376365,33.55685275639934,33.645105726395165,33.738692568909855,33.83770570976836,33.9422389333563,34.05238694853074,34.1682449437624,34.28990813275628,34.41747129182485,34.55102829031207,34.69067161538687,34.836491892542334,34.9885774031497,35.14701360042658,35.311882625185056,35.48326282272779,35.6612282622598,35.84584826017841,36.03718690859664,36.23530261044275,36.44024762246459,36.65206760744769,36.87080119693574,37.09647956571473,37.32912601929623,37.568755595600884,37.815374682011495,38.068980648924615,38.329561500892225,38.59709554639867,38.87155108727606,39.152886128709234,39.44104811073486,39.73597366208289,40.0375883771573,40.345806616893086,40.66053133417171,40.98165392441319,41.30905410190607,41.642599802369254,41.98214711218034,42.32754022463619,42.67861142354959,43.0351810944166,43.39705776332519,43.764038163706246,44.13590733096386,44.51243872495131,44.89339438019622,45.27852508370774,45.667570580136655,46.0602598039899,46.456311138540656,46.85543270100725,47.257322653515864,47.66166953929689,48.06815264350846,48.47644237801908,48.88620068942779,49.297081489542165,49.70873110748458,50.120788762543064,50.532887056837254,50.94465248681999,51.35570597259415,51.76566340397867,52.174136202222016,52.58073189622065,52.985054712069136,53.386706174734044,53.78528572061755,54.180391319748125,54.571620106314995,54.95856901624064,55.34083543047019,55.71801782264063,56.08971640978288,56.45553380470016,56.81507566866209,57.16795136305043,57.513774598594125,57.85216408083451,58.182744150468736,58.5051454172283,58.81900538596377,59.12396907362066,59.41968961581095,59.70582886170596,59.982057955999366,60.24805790671721,60.5035201376801,60.74814702445511,60.98165241266955,61.203762117595176,61.41421440395113,61.61276044491508,61.79916475937569,61.97320562650543,62.13467547678023,62.28338125862219,62.419144779892655,62.541803023516145,62.65120843656995,62.74722919222999,62.82974942402112,62.89866943187798,62.95390585958196,62.99539184320062,63.02307713021631,63.036928169093066]}],"reportKeys":["time","cpuTime","cycles","iters","allocated","numGcs","bytesCopied","mutatorWallSeconds","mutatorCpuSeconds","gcWallSeconds","gcCpuSeconds"],"reportNumber":10,"reportName":"Matrix vs List - `select`/Matrix `select`/Selective version","reportOutliers":{"highSevere":0,"highMild":0,"lowMild":0,"samplesSeen":4,"lowSevere":0},"reportMeasured":[[0.4263950690001366,0.4721681639999957,1020771981,1,null,null,null,null,null,null,null],[0.8634954130029655,0.9556901610000068,2067165855,2,null,null,null,null,null,null,null],[1.2408153510041302,1.3790502979999957,2970447003,3,null,null,null,null,null,null,null],[1.7258899599983124,1.914545817000004,4131682137,4,null,null,null,null,null,null,null]]}];
1094− reports.map(mangulate);
1095−
1096− var benches = ["Matrix Composition/10x10/WHNF - 10x10","Matrix Composition/10x10/NF - 10x10","Matrix Composition/100x100/WHNF - 100x100","Matrix Composition/100x100/NF - 100x100","Matrix Composition/200x200/WHNF - 200x200","Matrix Composition/200x200/NF - 200x200","Matrix vs List - `select`/Distribution/List Distribution - Applicative version","Matrix vs List - `select`/Distribution/Matrix Distribution - Applicative version","Matrix vs List - `select`/Distribution/Matrix Distribution - Selective version","Matrix vs List - `select`/Matrix `select`/Applicative version","Matrix vs List - `select`/Matrix `select`/Selective version",];
1097− var ylabels = [[-0,"<a href=\"#b0\">Matrix Composition/10x10/WHNF - 10x10</a>"],[-1,"<a href=\"#b1\">Matrix Composition/10x10/NF - 10x10</a>"],[-2,"<a href=\"#b2\">Matrix Composition/100x100/WHNF - 100x100</a>"],[-3,"<a href=\"#b3\">Matrix Composition/100x100/NF - 100x100</a>"],[-4,"<a href=\"#b4\">Matrix Composition/200x200/WHNF - 200x200</a>"],[-5,"<a href=\"#b5\">Matrix Composition/200x200/NF - 200x200</a>"],[-6,"<a href=\"#b6\">Matrix vs List - `select`/Distribution/List Distribution - Applicative version</a>"],[-7,"<a href=\"#b7\">Matrix vs List - `select`/Distribution/Matrix Distribution - Applicative version</a>"],[-8,"<a href=\"#b8\">Matrix vs List - `select`/Distribution/Matrix Distribution - Selective version</a>"],[-9,"<a href=\"#b9\">Matrix vs List - `select`/Matrix `select`/Applicative version</a>"],[-10,"<a href=\"#b10\">Matrix vs List - `select`/Matrix `select`/Selective version</a>"],];
1098− var means = $.scaleTimes([1.2273010647022493e-4,1.2343493665093922e-4,0.11259088430757033,0.11065191628694417,0.9644028123334465,0.980254961521041,0.4467186700617276,0.1820171075632162,9.136040249002575e-2,0.840422457165308,0.42580509562564356,]);
1099− var stddevs = [1.0291105469156734e-5,7.497583796499309e-6,1.4513815882466386e-2,9.633081000847341e-3,1.0832350628490363e-2,2.1335106928918192e-2,1.5029085673470916e-2,6.298418696687028e-3,5.3416383323926005e-3,6.898641320796234e-2,8.497480607539406e-3,];
1100− stddevs = $.scaleBy(means[1], stddevs);
1101− var xs = [];
1102− var prev = null;
1103− var colors = ["#edc240","#afd8f8","#cb4b4b","#4da74d","#9440ed"];
1104− var max_time = 0;
1105− for (var i = 0; i < means[0].length; i++) {
1106− var name = benches[i].split(/\//);
1107− name.pop();
1108− name = name.join('/');
1109− if (name != prev) {
1110− var color = colors[xs.length / 2 % colors.length];
1111− xs.push({ data: [[means[0][i], -i]], label: name, color: color,
1112− bars: { show: true, horizontal: true, barWidth: 0.75,
1113− align: "center" } });
1114− xs.push({ data: [[means[0][i], -i, stddevs[i]]], color: color,
1115− lines: { show: false },
1116− points: { radius: 0, errorbars: "x",
1117− xerr: { show: true, radius: 5,
1118− lowerCap: "-", upperCap: "-" } } });
1119− prev = name;
1120− } else {
1121− xs[xs.length - 2].data.push([means[0][i], -i]);
1122− xs[xs.length - 1].data.push([means[0][i], -i, stddevs[i]]);
1123− }
1124− max_time = Math.max(max_time, means[0][i] + stddevs[i]);
1125− }
1126− var oq = $("#overview");
1127− var max_x = max_time * 1.02;
1128− o = $.plot(oq, xs, { grid: { borderColor: "#777", hoverable: true },
1129− legend: { show: xs.length > 1 },
1130− xaxis: { max: max_x, zoomRange: [false, max_x], panRange: [0, max_x] },
1131− yaxis: { ticks: ylabels, tickColor: '#ffffff', zoomRange: false, panRange: false },
1132− zoom: { interactive: true, amount: 1.05 },
1133− pan: { interactive: true } });
1134− if (benches.length > 3)
1135− o.getPlaceholder().height(28*benches.length);
1136− o.resize();
1137− o.setupGrid();
1138− o.draw();
1139− $.addTooltip("#overview", function(x,y) { return $.renderTime(x / means[1]); });
1140−});
1141−$(document).ready(function () {
1142− $(".time").text(function(_, text) {
1143− return $.renderTime(text);
1144− });
1145− $(".citime").text(function(_, text) {
1146− return $.renderTime(text);
1147− });
1148− $(".percent").text(function(_, text) {
1149− return (text*100).toFixed(1);
1150− });
1151− });
1152−</script>
1153−
1154− </div>
1155− </div>
1156− <div id="footer">
1157− <div class="body">
1158− <div class="footfirst">
1159− <h2>colophon</h2>
1160− <p>This report was created using the
1161− <a href="http://hackage.haskell.org/package/criterion">criterion</a>
1162− benchmark execution and performance analysis tool.</p>
1163− <p>Criterion is developed and maintained
1164− by <a href="http://www.serpentine.com/blog/">Bryan O'Sullivan</a>.</p>
1165− </div>
1166− </div>
1167− </div>
1168− </body>
1169−</html>
report.pdfdeleted

Binary file not shown.

src/LAoP/Dist.hs+4−2
@@ -39,8 +39,8 @@ module LAoP.Dist
39 -- * Constraint type synonyms
39 -- * Constraint type synonyms
40 Countable,
40 Countable,
41 CountableN,
41 CountableN,
42− CountableDimensionsN,
42+ CountableDimsN,
43− FromListsN,
43+ FLN,
44 Liftable,
44 Liftable,
45 TrivialP,
45 TrivialP,
46
46
@@ -53,6 +53,8 @@ module LAoP.Dist
53
53
54 -- * Selective equivalent functions
54 -- * Selective equivalent functions
55 selectD,
55 selectD,
56+ branchD,
57+ ifD,
56
58
57 -- * Monad equivalent functions
59 -- * Monad equivalent functions
58 returnD,
60 returnD,
src/LAoP/Dist/Internal.hs+67−28
@@ -16,8 +16,8 @@ module LAoP.Dist.Internal
16
16
17 Countable,
17 Countable,
18 CountableN,
18 CountableN,
19− CountableDimensionsN,
19+ CountableDimsN,
20− FromListsN,
20+ FLN,
21 Liftable,
21 Liftable,
22 TrivialP,
22 TrivialP,
23
23
@@ -25,6 +25,8 @@ module LAoP.Dist.Internal
25 unitD,
25 unitD,
26 multD,
26 multD,
27 selectD,
27 selectD,
28+ branchD,
29+ ifD,
28 returnD,
30 returnD,
29 bindD,
31 bindD,
30 (??),
32 (??),
@@ -41,13 +43,15 @@ module LAoP.Dist.Internal
41 )
43 )
42 where
44 where
43
45
44−import LAoP.Matrix.Type hiding (TrivialP, Countable, CountableDimensions, CountableN, CountableDimensionsN, Liftable, FromListsN)
46+import LAoP.Matrix.Type hiding (TrivialP, Countable, CountableDims, CountableN, CountableDimsN, Liftable, FLN)
47+import Prelude hiding (id, (.))
45import qualified LAoP.Matrix.Internal as I
48import qualified LAoP.Matrix.Internal as I
46import LAoP.Utils
49import LAoP.Utils
47import GHC.TypeLits
50import GHC.TypeLits
48import Data.Proxy
51import Data.Proxy
49import Data.List (sortBy)
52import Data.List (sortBy)
50import Control.DeepSeq
53import Control.DeepSeq
54+import Data.Bool
51
55
52-- | Type synonym for probability value
56-- | Type synonym for probability value
53type Prob = Double
57type Prob = Double
@@ -58,18 +62,18 @@ newtype Dist a = D (Matrix Prob () a)
58 deriving (Show, Num, Eq, Ord, NFData) via (Matrix Prob () a)
62 deriving (Show, Num, Eq, Ord, NFData) via (Matrix Prob () a)
59
63
60-- | Constraint type synonyms to keep the type signatures less convoluted
64-- | Constraint type synonyms to keep the type signatures less convoluted
61−type Countable a = KnownNat (I.Count a)
65+type Countable a = KnownNat (I.Count a)
62−type CountableN a = KnownNat (I.Count (I.Normalize a))
66+type CountableN a = KnownNat (I.Count (I.Normalize a))
63−type CountableDimensionsN a b = (CountableN a, CountableN b)
67+type CountableDimsN a b = (CountableN a, CountableN b)
64−type FromListsN a b = I.FromLists Prob (I.Normalize a) (I.Normalize b)
68+type FLN a b = I.FL (I.Normalize a) (I.Normalize b)
65−type Liftable a b = (Bounded a, Bounded b, Enum a, Enum b, Eq b, Num Prob, Ord Prob)
69+type Liftable a b = (Bounded a, Bounded b, Enum a, Enum b, Eq b, Num Prob, Ord Prob)
66−type TrivialP a b = Normalize (a, b) ~ Normalize (Normalize a, Normalize b)
70+type TrivialP a b = Normalize (a, b) ~ Normalize (Normalize a, Normalize b)
67
71
68-- | Functor instance
72-- | Functor instance
69fmapD ::
73fmapD ::
70 ( Liftable a b,
74 ( Liftable a b,
71− CountableDimensionsN a b,
75+ CountableDimsN a b,
72− FromListsN b a
76+ FLN b a
73 )
77 )
74 =>
78 =>
75 (a -> b) -> Dist a -> Dist b
79 (a -> b) -> Dist a -> Dist b
@@ -81,23 +85,58 @@ unitD = D (one 1)
81
85
82-- | Applicative/Monoidal instance 'mult' function
86-- | Applicative/Monoidal instance 'mult' function
83multD ::
87multD ::
84− ( CountableDimensionsN a b,
88+ ( CountableDimsN a b,
85 CountableN (a, b),
89 CountableN (a, b),
86− FromListsN (a, b) a,
90+ FLN (a, b) a,
87− FromListsN (a, b) b,
91+ FLN (a, b) b,
88 TrivialP a b
92 TrivialP a b
89 ) => Dist a -> Dist b -> Dist (a, b)
93 ) => Dist a -> Dist b -> Dist (a, b)
90−multD (D a) (D b) = D (khatri a b)
94+multD (D a) (D b) = D (kr a b)
91
95
92-- | Selective instance function
96-- | Selective instance function
93selectD ::
97selectD ::
94− ( FromListsN b b,
98+ ( FLN b b,
95 CountableN b
99 CountableN b
96 ) => Dist (Either a b) -> Matrix Prob a b -> Dist b
100 ) => Dist (Either a b) -> Matrix Prob a b -> Dist b
97selectD (D d) m = D (selectM d m)
101selectD (D d) m = D (selectM d m)
98
102
103+-- | Chooses which of the two given effectful
104+-- functions to apply to a given argument;
105+branchD ::
106+ ( Num e,
107+ CountableDimsN a b,
108+ CountableDimsN c (Either b c),
109+ FLN c b,
110+ FLN a b,
111+ FLN a a,
112+ FLN b b,
113+ FLN c c,
114+ FLN b a,
115+ FLN b c,
116+ FLN (Either b c) b,
117+ FLN (Either b c) c
118+ )
119+ => Dist (Either a b) -> Matrix Prob a c -> Matrix Prob b c -> Dist c
120+branchD x l r = f x `selectD` g l `selectD` r
121+ where
122+ f (D m) = D (fork (tr i1) (i1 `comp` tr i2) `comp` m)
123+ g m = i2 `comp` m
124+
125+-- | Branch on a Boolean value, skipping unnecessary computations.
126+ifD ::
127+ ( CountableDimsN a (Either () a),
128+ FLN a a,
129+ FLN a (),
130+ FLN () a,
131+ FLN (Either () a) a
132+ )
133+ => Dist Bool -> Dist a -> Dist a -> Dist a
134+ifD x (D t) (D e) = branchD x' t e
135+ where
136+ x' = bool (Right ()) (Left ()) `fmapD` x
137+
99-- | Monad instance 'return' function
138-- | Monad instance 'return' function
100−returnD :: forall a . (Enum a, FromListsN () a, Countable a) => a -> Dist a
139+returnD :: forall a . (Enum a, FLN () a, Countable a) => a -> Dist a
101returnD a = D (col l)
140returnD a = D (col l)
102 where
141 where
103 i = fromInteger $ natVal (Proxy :: Proxy (Count a))
142 i = fromInteger $ natVal (Proxy :: Proxy (Count a))
@@ -112,7 +151,7 @@ bindD (D d) m = D (m `comp` d)
112(??) ::
151(??) ::
113 ( Enum a,
152 ( Enum a,
114 Countable a,
153 Countable a,
115− FromListsN () a
154+ FLN () a
116 ) => (a -> Bool) -> Dist a -> Prob
155 ) => (a -> Bool) -> Dist a -> Prob
117(??) p d =
156(??) p d =
118 let l = toValues d
157 let l = toValues d
@@ -122,11 +161,11 @@ bindD (D d) m = D (m `comp` d)
122-- Distribution Construction
161-- Distribution Construction
123
162
124-- | Constructs a Bernoulli distribution
163-- | Constructs a Bernoulli distribution
125−choose :: (FromListsN () a) => Prob -> Dist a
164+choose :: (FLN () a) => Prob -> Dist a
126choose prob = D (col [prob, 1 - prob])
165choose prob = D (col [prob, 1 - prob])
127
166
128-- | Creates a distribution given a shape function
167-- | Creates a distribution given a shape function
129−shape :: (FromListsN () a) => (Prob -> Prob) -> [a] -> Dist a
168+shape :: (FLN () a) => (Prob -> Prob) -> [a] -> Dist a
130shape _ [] = error "Probability.shape: empty list"
169shape _ [] = error "Probability.shape: empty list"
131shape f xs =
170shape f xs =
132 let incr = 1 / fromIntegral (length xs - 1)
171 let incr = 1 / fromIntegral (length xs - 1)
@@ -134,23 +173,23 @@ shape f xs =
134 in fromFreqs (zip xs ps)
173 in fromFreqs (zip xs ps)
135
174
136-- | Constructs a Linear distribution
175-- | Constructs a Linear distribution
137−linear :: (FromListsN () a) => [a] -> Dist a
176+linear :: (FLN () a) => [a] -> Dist a
138linear = shape id
177linear = shape id
139
178
140-- | Constructs an Uniform distribution
179-- | Constructs an Uniform distribution
141−uniform :: (FromListsN () a) => [a] -> Dist a
180+uniform :: (FLN () a) => [a] -> Dist a
142uniform = shape (const 1)
181uniform = shape (const 1)
143
182
144-- | Constructs an Negative Exponential distribution
183-- | Constructs an Negative Exponential distribution
145−negExp :: (FromListsN () a) => [a] -> Dist a
184+negExp :: (FLN () a) => [a] -> Dist a
146negExp = shape (\x -> exp (-x))
185negExp = shape (\x -> exp (-x))
147
186
148-- | Constructs an Normal distribution
187-- | Constructs an Normal distribution
149−normal :: (FromListsN () a) => [a] -> Dist a
188+normal :: (FLN () a) => [a] -> Dist a
150normal = shape (normalCurve 0.5 0.5)
189normal = shape (normalCurve 0.5 0.5)
151
190
152-- | Transforms a 'Dist' into a list of pairs.
191-- | Transforms a 'Dist' into a list of pairs.
153−toValues :: forall a . (Enum a, Countable a, FromListsN () a) => Dist a -> [(a, Prob)]
192+toValues :: forall a . (Enum a, Countable a, FLN () a) => Dist a -> [(a, Prob)]
154toValues (D d) =
193toValues (D d) =
155 let rows = fromInteger (natVal (Proxy :: Proxy (Count a)))
194 let rows = fromInteger (natVal (Proxy :: Proxy (Count a)))
156 probs = toList d
195 probs = toList d
@@ -158,7 +197,7 @@ toValues (D d) =
158 in res
197 in res
159
198
160-- | Pretty a distribution
199-- | Pretty a distribution
161−prettyDist :: forall a. (Show a, Enum a, Countable a, FromListsN () a) => Dist a -> String
200+prettyDist :: forall a. (Show a, Enum a, Countable a, FLN () a) => Dist a -> String
162prettyDist d =
201prettyDist d =
163 let values = sortBy (\(a, p1) (b, p2) -> compare p2 p1) (toValues @a d)
202 let values = sortBy (\(a, p1) (b, p2) -> compare p2 p1) (toValues @a d)
164 w = maximum (map (length . show . fst) values)
203 w = maximum (map (length . show . fst) values)
@@ -170,12 +209,12 @@ prettyDist d =
170 showR n x = show x ++ " "
209 showR n x = show x ++ " "
171
210
172-- | Pretty Print a distribution
211-- | Pretty Print a distribution
173−prettyPrintDist :: forall a . (Show a, Enum a, Countable a, FromListsN () a) => Dist a -> IO ()
212+prettyPrintDist :: forall a . (Show a, Enum a, Countable a, FLN () a) => Dist a -> IO ()
174prettyPrintDist = putStrLn . prettyDist @a
213prettyPrintDist = putStrLn . prettyDist @a
175
214
176-- Auxiliary functions
215-- Auxiliary functions
177
216
178−fromFreqs :: (FromListsN () a) => [(a,Prob)] -> Dist a
217+fromFreqs :: (FLN () a) => [(a,Prob)] -> Dist a
179fromFreqs xs = D (col (map (\(x,p) -> p/q) xs))
218fromFreqs xs = D (col (map (\(x,p) -> p/q) xs))
180 where q = sum $ map snd xs
219 where q = sum $ map snd xs
181
220
src/LAoP/Matrix/Internal.hs+396−396
@@ -30,7 +30,7 @@
30-- motivation behind the library, the underlying theory, and implementation details.
30-- motivation behind the library, the underlying theory, and implementation details.
31--
31--
32-- This module offers many of the combinators mentioned in the work of
32-- This module offers many of the combinators mentioned in the work of
33−-- Macedo (2012) and Oliveira (2012).
33+-- Macedo (2012) and Oliveira (2012).
34--
34--
35-- This is an Internal module and it is no supposed to be imported.
35-- This is an Internal module and it is no supposed to be imported.
36--
36--
@@ -43,17 +43,26 @@ module LAoP.Matrix.Internal
43 --
43 --
44 -- There exists two type families that make it easier to write
44 -- There exists two type families that make it easier to write
45 -- matrix dimensions: 'FromNat' and 'Count'. This approach
45 -- matrix dimensions: 'FromNat' and 'Count'. This approach
46− -- leads to a very straightforward implementation
46+ -- leads to a very straightforward implementation
47− -- of LAoP combinators.
47+ -- of LAoP combinators.
48
48
49 -- * Type safe matrix representation
49 -- * Type safe matrix representation
50 Matrix (..),
50 Matrix (..),
51
51
52+ -- * Constraint type aliases
53+ Countable,
54+ CountableDims,
55+ CountableN,
56+ CountableDimsN,
57+ FL,
58+ FLN,
59+ Liftable,
60+ Trivial,
61+
52 -- * Primitives
62 -- * Primitives
53− empty,
54 one,
63 one,
55− junc,
64+ join,
56− split,
65+ fork,
57
66
58 -- * Auxiliary type families
67 -- * Auxiliary type families
59 FromNat,
68 FromNat,
@@ -66,6 +75,7 @@ module LAoP.Matrix.Internal
66 toLists,
75 toLists,
67 toList,
76 toList,
68 matrixBuilder,
77 matrixBuilder,
78+ matrixBuilder',
69 row,
79 row,
70 col,
80 col,
71 zeros,
81 zeros,
@@ -76,11 +86,17 @@ module LAoP.Matrix.Internal
76 -- * Misc
86 -- * Misc
77 -- ** Get dimensions
87 -- ** Get dimensions
78 columns,
88 columns,
89+ columns',
79 rows,
90 rows,
91+ rows',
80
92
81 -- ** Matrix Transposition
93 -- ** Matrix Transposition
82 tr,
94 tr,
83
95
96+ -- ** Scalar multiplication/division of matrices
97+ (.|),
98+ (./),
99+
84 -- ** Selective operator
100 -- ** Selective operator
85 select,
101 select,
86 branch,
102 branch,
@@ -89,16 +105,19 @@ module LAoP.Matrix.Internal
89 cond,
105 cond,
90
106
91 -- ** Matrix "abiding"
107 -- ** Matrix "abiding"
92− abideJS,
108+ abideJF,
93− abideSJ,
109+ abideFJ,
110+
111+ -- ** Zip matrices
112+ zipWithM,
94
113
95 -- * Biproduct approach
114 -- * Biproduct approach
96− -- ** Split
115+ -- ** Fork
97 (===),
116 (===),
98 -- *** Projections
117 -- *** Projections
99 p1,
118 p1,
100 p2,
119 p2,
101− -- ** Junc
120+ -- ** Join
102 (|||),
121 (|||),
103 -- *** Injections
122 -- *** Injections
104 i1,
123 i1,
@@ -111,12 +130,13 @@ module LAoP.Matrix.Internal
111
130
112 -- | Note that given the restrictions imposed it is not possible to
131 -- | Note that given the restrictions imposed it is not possible to
113 -- implement the standard type classes present in standard Haskell.
132 -- implement the standard type classes present in standard Haskell.
133+
114 -- *** Matrix pairing projections
134 -- *** Matrix pairing projections
115− kp1,
135+ fstM,
116− kp2,
136+ sndM,
117
137
118 -- *** Matrix pairing
138 -- *** Matrix pairing
119− khatri,
139+ kr,
120
140
121 -- * Matrix composition and lifting
141 -- * Matrix composition and lifting
122
142
@@ -124,10 +144,10 @@ module LAoP.Matrix.Internal
124
144
125 -- | Note that given the restrictions imposed it is not possible to
145 -- | Note that given the restrictions imposed it is not possible to
126 -- implement the standard type classes present in standard Haskell.
146 -- implement the standard type classes present in standard Haskell.
127− identity,
147+ iden,
128 comp,
148 comp,
129− fromF,
130 fromF',
149 fromF',
150+ fromF,
131
151
132 -- * Matrix printing
152 -- * Matrix printing
133 pretty,
153 pretty,
@@ -154,21 +174,22 @@ import LAoP.Utils.Internal
154import Data.Bool
174import Data.Bool
155import Data.Kind
175import Data.Kind
156import Data.List
176import Data.List
177+import Data.Maybe
157import Data.Proxy
178import Data.Proxy
179+import Data.Typeable
158import Data.Void
180import Data.Void
159import GHC.TypeLits
181import GHC.TypeLits
160import Data.Type.Equality
182import Data.Type.Equality
161import GHC.Generics
183import GHC.Generics
162import Control.DeepSeq
184import Control.DeepSeq
163−import Control.Category
185+import Prelude hiding (id, (.))
164−import Prelude hiding ((.))
186+import qualified Prelude (id, (.))
165
187
166-- | LAoP (Linear Algebra of Programming) Inductive Matrix definition.
188-- | LAoP (Linear Algebra of Programming) Inductive Matrix definition.
167data Matrix e cols rows where
189data Matrix e cols rows where
168− Empty :: Matrix e Void Void
169 One :: e -> Matrix e () ()
190 One :: e -> Matrix e () ()
170− Junc :: Matrix e a rows -> Matrix e b rows -> Matrix e (Either a b) rows
191+ Join :: Matrix e a rows -> Matrix e b rows -> Matrix e (Either a b) rows
171− Split :: Matrix e cols a -> Matrix e cols b -> Matrix e cols (Either a b)
192+ Fork :: Matrix e cols a -> Matrix e cols b -> Matrix e cols (Either a b)
172
193
173deriving instance (Show e) => Show (Matrix e cols rows)
194deriving instance (Show e) => Show (Matrix e cols rows)
174
195
@@ -195,122 +216,95 @@ type family Count (d :: Type) :: Nat where
195--
216--
196-- Thanks to Li-Yao Xia this type family is super fast.
217-- Thanks to Li-Yao Xia this type family is super fast.
197type family FromNat (n :: Nat) :: Type where
218type family FromNat (n :: Nat) :: Type where
198− FromNat 0 = Void
199 FromNat 1 = ()
219 FromNat 1 = ()
200 FromNat n = FromNat' (Mod n 2 == 0) (FromNat (Div n 2))
220 FromNat n = FromNat' (Mod n 2 == 0) (FromNat (Div n 2))
201
221
202type family FromNat' (b :: Bool) (m :: Type) :: Type where
222type family FromNat' (b :: Bool) (m :: Type) :: Type where
203− FromNat' 'True m = Either m m
223+ FromNat' 'True m = Either m m
204 FromNat' 'False m = Either () (Either m m)
224 FromNat' 'False m = Either () (Either m m)
205
225
206-- | Type family that normalizes the representation of a given data
226-- | Type family that normalizes the representation of a given data
207-- structure
227-- structure
208type family Normalize (d :: Type) :: Type where
228type family Normalize (d :: Type) :: Type where
209− Normalize (Either a b) = Either (Normalize a) (Normalize b)
229+ Normalize (Either a b) = Either (Normalize a) (Normalize b)
210− Normalize d = FromNat (Count d)
230+ Normalize d = FromNat (Count d)
211
231
212-- | Constraint type synonyms to keep the type signatures less convoluted
232-- | Constraint type synonyms to keep the type signatures less convoluted
213type Countable a = KnownNat (Count a)
233type Countable a = KnownNat (Count a)
214type CountableN a = KnownNat (Count (Normalize a))
234type CountableN a = KnownNat (Count (Normalize a))
215−type CountableDimensions a b = (Countable a, Countable b)
235+type CountableDims a b = (Countable a, Countable b)
216−type CountableDimensionsN a b = (CountableN a, CountableN b)
236+type CountableDimsN a b = (CountableN a, CountableN b)
237+type FL a b = FromLists a b
217−type FromListsN e a b = FromLists e (Normalize a) (Normalize b)
238+type FLN a b = FromLists (Normalize a) (Normalize b)
218type Liftable e a b = (Bounded a, Bounded b, Enum a, Enum b, Eq b, Num e, Ord e)
239type Liftable e a b = (Bounded a, Bounded b, Enum a, Enum b, Eq b, Num e, Ord e)
219type Trivial a = FromNat (Count a) ~ a
240type Trivial a = FromNat (Count a) ~ a
220
241
221−-- | It isn't possible to implement the 'id' function so it's
242+-- | It is possible to implement a constrained version of the category type
222−-- implementation is 'undefined'. However 'comp' can be and this partial
243+-- class.
223−-- class implementation exists just to make the code more readable.
224−--
225−-- Please use 'identity' instead.
226instance (Num e) => Category (Matrix e) where
244instance (Num e) => Category (Matrix e) where
227− id = undefined
245+ type Object (Matrix e) a = (FL a a, Countable a)
246+ id = iden
228− (.) = comp
247+ (.) = comp
229
248
230instance NFData e => NFData (Matrix e cols rows) where
249instance NFData e => NFData (Matrix e cols rows) where
231− rnf Empty = ()
232− rnf (One e) = rnf e
250+ rnf (One e) = rnf e
233− rnf (Junc a b) = rnf a `seq` rnf b
251+ rnf (Join a b) = rnf a `seq` rnf b
234− rnf (Split a b) = rnf a `seq` rnf b
252+ rnf (Fork a b) = rnf a `seq` rnf b
235
253
236instance Eq e => Eq (Matrix e cols rows) where
254instance Eq e => Eq (Matrix e cols rows) where
237− Empty == Empty = True
238− (One a) == (One b) = a == b
255+ (One a) == (One b) = a == b
239− (Junc a b) == (Junc c d) = a == c && b == d
256+ (Join a b) == (Join c d) = a == c && b == d
240− (Split a b) == (Split c d) = a == c && b == d
257+ (Fork a b) == (Fork c d) = a == c && b == d
241− x@(Split _ _) == y@(Junc _ _) = x == abideJS y
258+ x@(Fork _ _) == y@(Join _ _) = x == abideJF y
242− x@(Junc _ _) == y@(Split _ _) = abideJS x == y
259+ x@(Join _ _) == y@(Fork _ _) = abideJF x == y
243
260
244instance Num e => Num (Matrix e cols rows) where
261instance Num e => Num (Matrix e cols rows) where
262+ a + b = zipWithM (+) a b
263+
264+ a - b = zipWithM (-) a b
265+
266+ a * b = zipWithM (*) a b
245
267
246− Empty + Empty = Empty
247− (One a) + (One b) = One (a + b)
248− (Junc a b) + (Junc c d) = Junc (a + c) (b + d)
249− (Split a b) + (Split c d) = Split (a + c) (b + d)
250− x@(Split _ _) + y@(Junc _ _) = x + abideJS y
251− x@(Junc _ _) + y@(Split _ _) = abideJS x + y
252−
253− Empty - Empty = Empty
254− (One a) - (One b) = One (a - b)
255− (Junc a b) - (Junc c d) = Junc (a - c) (b - d)
256− (Split a b) - (Split c d) = Split (a - c) (b - d)
257− x@(Split _ _) - y@(Junc _ _) = x - abideJS y
258− x@(Junc _ _) - y@(Split _ _) = abideJS x - y
259−
260− Empty * Empty = Empty
261− (One a) * (One b) = One (a * b)
262− (Junc a b) * (Junc c d) = Junc (a * c) (b * d)
263− (Split a b) * (Split c d) = Split (a * c) (b * d)
264− x@(Split _ _) * y@(Junc _ _) = x * abideJS y
265− x@(Junc _ _) * y@(Split _ _) = abideJS x * y
266−
267− abs Empty = Empty
268− abs (One a) = One (abs a)
268+ abs (One a) = One (abs a)
269− abs (Junc a b) = Junc (abs a) (abs b)
269+ abs (Join a b) = Join (abs a) (abs b)
270− abs (Split a b) = Split (abs a) (abs b)
270+ abs (Fork a b) = Fork (abs a) (abs b)
271−
271+
272− signum Empty = Empty
273− signum (One a) = One (signum a)
272+ signum (One a) = One (signum a)
274− signum (Junc a b) = Junc (signum a) (signum b)
273+ signum (Join a b) = Join (signum a) (signum b)
275− signum (Split a b) = Split (signum a) (signum b)
274+ signum (Fork a b) = Fork (signum a) (signum b)
276
275
277instance Ord e => Ord (Matrix e cols rows) where
276instance Ord e => Ord (Matrix e cols rows) where
278− Empty <= Empty = True
279− (One a) <= (One b) = a <= b
277+ (One a) <= (One b) = a <= b
280− (Junc a b) <= (Junc c d) = (a <= c) && (b <= d)
278+ (Join a b) <= (Join c d) = (a <= c) && (b <= d)
281− (Split a b) <= (Split c d) = (a <= c) && (b <= d)
279+ (Fork a b) <= (Fork c d) = (a <= c) && (b <= d)
282− x@(Split _ _) <= y@(Junc _ _) = x <= abideJS y
280+ x@(Fork _ _) <= y@(Join _ _) = x <= abideJF y
283− x@(Junc _ _) <= y@(Split _ _) = abideJS x <= y
281+ x@(Join _ _) <= y@(Fork _ _) = abideJF x <= y
284
282
285-- Primitives
283-- Primitives
286
284
287−-- | Empty matrix constructor
288−empty :: Matrix e Void Void
289−empty = Empty
290−
291-- | Unit matrix constructor
285-- | Unit matrix constructor
292one :: e -> Matrix e () ()
286one :: e -> Matrix e () ()
293one = One
287one = One
294
288
295−-- | Matrix 'Junc' constructor
289+-- | Matrix 'Join' constructor
296−junc :: Matrix e a rows -> Matrix e b rows -> Matrix e (Either a b) rows
290+join :: Matrix e a rows -> Matrix e b rows -> Matrix e (Either a b) rows
297−junc = Junc
291+join = Join
298
292
299infixl 3 |||
293infixl 3 |||
300
294
301−-- | Matrix 'Junc' constructor
295+-- | Matrix 'Join' constructor
302(|||) :: Matrix e a rows -> Matrix e b rows -> Matrix e (Either a b) rows
296(|||) :: Matrix e a rows -> Matrix e b rows -> Matrix e (Either a b) rows
303−(|||) = Junc
297+(|||) = Join
304
298
305−-- | Matrix 'Split' constructor
299+-- | Matrix 'Fork' constructor
306−split :: Matrix e cols a -> Matrix e cols b -> Matrix e cols (Either a b)
300+fork :: Matrix e cols a -> Matrix e cols b -> Matrix e cols (Either a b)
307−split = Split
301+fork = Fork
308
302
309infixl 2 ===
303infixl 2 ===
310
304
311−-- | Matrix 'Split' constructor
305+-- | Matrix 'Fork' constructor
312(===) :: Matrix e cols a -> Matrix e cols b -> Matrix e cols (Either a b)
306(===) :: Matrix e cols a -> Matrix e cols b -> Matrix e cols (Either a b)
313−(===) = Split
307+(===) = Fork
314
308
315-- Construction
309-- Construction
316
310
@@ -318,84 +312,101 @@ infixl 2 ===
318--
312--
319-- Given that it is not possible to branch on types at the term level type
313-- Given that it is not possible to branch on types at the term level type
320-- classes are needed very much like an inductive definition but on types.
314-- classes are needed very much like an inductive definition but on types.
321−class FromLists e cols rows where
315+class FromLists cols rows where
322 -- | Build a matrix out of a list of list of elements. Throws a runtime
316 -- | Build a matrix out of a list of list of elements. Throws a runtime
323 -- error if the dimensions do not match.
317 -- error if the dimensions do not match.
324 fromLists :: [[e]] -> Matrix e cols rows
318 fromLists :: [[e]] -> Matrix e cols rows
325
319
326−instance FromLists e Void Void where
320+instance FromLists () () where
327− fromLists [] = Empty
328− fromLists _ = error "Wrong dimensions"
329−
330−instance {-# OVERLAPPING #-} FromLists e () () where
331 fromLists [[e]] = One e
321 fromLists [[e]] = One e
332 fromLists _ = error "Wrong dimensions"
322 fromLists _ = error "Wrong dimensions"
333
323
334−instance {-# OVERLAPPING #-} (FromLists e cols ()) => FromLists e (Either () cols) () where
324+instance (FromLists cols ()) => FromLists (Either () cols) () where
335− fromLists [h : t] = Junc (One h) (fromLists [t])
325+ fromLists [h : t] = Join (One h) (fromLists [t])
336 fromLists _ = error "Wrong dimensions"
326 fromLists _ = error "Wrong dimensions"
337
327
328+instance {-# OVERLAPPABLE #-}
338−instance {-# OVERLAPPABLE #-} (FromLists e a (), FromLists e b (), Countable a) => FromLists e (Either a b) () where
329+ (FromLists a (), FromLists b (), Countable a) => FromLists (Either a b) () where
339− fromLists [l] =
330+ fromLists [l] =
340 let rowsA = fromInteger (natVal (Proxy :: Proxy (Count a)))
331 let rowsA = fromInteger (natVal (Proxy :: Proxy (Count a)))
341− in Junc (fromLists [take rowsA l]) (fromLists [drop rowsA l])
332+ in Join (fromLists [take rowsA l]) (fromLists [drop rowsA l])
342 fromLists _ = error "Wrong dimensions"
333 fromLists _ = error "Wrong dimensions"
343
334
344−instance {-# OVERLAPPING #-} (FromLists e () rows) => FromLists e () (Either () rows) where
335+instance (FromLists () rows) => FromLists () (Either () rows) where
345− fromLists ([h] : t) = Split (One h) (fromLists t)
336+ fromLists ([h] : t) = Fork (One h) (fromLists t)
346 fromLists _ = error "Wrong dimensions"
337 fromLists _ = error "Wrong dimensions"
347
338
339+instance {-# OVERLAPPABLE #-}
348−instance {-# OVERLAPPABLE #-} (FromLists e () a, FromLists e () b, Countable a) => FromLists e () (Either a b) where
340+ (FromLists () a, FromLists () b, Countable a) => FromLists () (Either a b) where
349− fromLists l@([_] : _) =
341+ fromLists l@([_] : _) =
350 let rowsA = fromInteger (natVal (Proxy :: Proxy (Count a)))
342 let rowsA = fromInteger (natVal (Proxy :: Proxy (Count a)))
351− in Split (fromLists (take rowsA l)) (fromLists (drop rowsA l))
343+ in Fork (fromLists (take rowsA l)) (fromLists (drop rowsA l))
352 fromLists _ = error "Wrong dimensions"
344 fromLists _ = error "Wrong dimensions"
353
345
354−instance {-# OVERLAPPABLE #-} (FromLists e (Either a b) c, FromLists e (Either a b) d, Countable c) => FromLists e (Either a b) (Either c d) where
346+instance (FromLists (Either a b) c, FromLists (Either a b) d, Countable c)
347+ => FromLists (Either a b) (Either c d) where
355 fromLists l@(h : t) =
348 fromLists l@(h : t) =
356 let lh = length h
349 let lh = length h
357 rowsC = fromInteger (natVal (Proxy :: Proxy (Count c)))
350 rowsC = fromInteger (natVal (Proxy :: Proxy (Count c)))
358− condition = all (== lh) (map length t)
351+ condition = all ((== lh) . length) t
359 in if lh > 0 && condition
352 in if lh > 0 && condition
360− then Split (fromLists (take rowsC l)) (fromLists (drop rowsC l))
353+ then Fork (fromLists (take rowsC l)) (fromLists (drop rowsC l))
361 else error "Not all rows have the same length"
354 else error "Not all rows have the same length"
362
355
363-- | Matrix builder function. Constructs a matrix provided with
356-- | Matrix builder function. Constructs a matrix provided with
364−-- a construction function.
357+-- a construction function that operates with indices.
365−matrixBuilder ::
358+matrixBuilder' ::
366 forall e cols rows.
359 forall e cols rows.
367− ( FromLists e cols rows,
360+ ( FL cols rows,
368− CountableDimensions cols rows
361+ CountableDims cols rows
369− ) =>
370− ((Int, Int) -> e) ->
371− Matrix e cols rows
362+ ) => ((Int, Int) -> e) -> Matrix e cols rows
372−matrixBuilder f =
363+matrixBuilder' f =
373 let c = fromInteger $ natVal (Proxy :: Proxy (Count cols))
364 let c = fromInteger $ natVal (Proxy :: Proxy (Count cols))
374 r = fromInteger $ natVal (Proxy :: Proxy (Count rows))
365 r = fromInteger $ natVal (Proxy :: Proxy (Count rows))
375 positions = [(a, b) | a <- [0 .. (r - 1)], b <- [0 .. (c - 1)]]
366 positions = [(a, b) | a <- [0 .. (r - 1)], b <- [0 .. (c - 1)]]
376 in fromLists . map (map f) . groupBy (\(x, _) (w, _) -> x == w) $ positions
367 in fromLists . map (map f) . groupBy (\(x, _) (w, _) -> x == w) $ positions
377
368
369+-- | Matrix builder function. Constructs a matrix provided with
370+-- a construction function that operates with arbitrary types.
371+matrixBuilder ::
372+ forall e a b.
373+ ( FLN a b,
374+ Enum a,
375+ Enum b,
376+ Bounded a,
377+ Bounded b,
378+ Eq a,
379+ Countable b
380+ ) => ((a, b) -> e) -> Matrix e (Normalize a) (Normalize b)
381+matrixBuilder f =
382+ let r = fromInteger $ natVal (Proxy :: Proxy (Count b))
383+ positions = [(a, b) | a <- [minBound .. maxBound], b <- [minBound .. maxBound]]
384+ in fromLists . map (map f) . transpose . buildList r $ positions
385+ where
386+ buildList _ [] = []
387+ buildList r l = take r l : buildList r (drop r l)
388+
378-- | Constructs a column vector matrix
389-- | Constructs a column vector matrix
379−col :: (FromLists e () rows) => [e] -> Matrix e () rows
390+col :: (FL () rows) => [e] -> Matrix e () rows
380col = fromLists . map (: [])
391col = fromLists . map (: [])
381
392
382-- | Constructs a row vector matrix
393-- | Constructs a row vector matrix
383−row :: (FromLists e cols ()) => [e] -> Matrix e cols ()
394+row :: (FL cols ()) => [e] -> Matrix e cols ()
384row = fromLists . (: [])
395row = fromLists . (: [])
385
396
386-- | Lifts functions to matrices with arbitrary dimensions.
397-- | Lifts functions to matrices with arbitrary dimensions.
387--
398--
388-- NOTE: Be careful to not ask for a matrix bigger than the cardinality of
399-- NOTE: Be careful to not ask for a matrix bigger than the cardinality of
389-- types @a@ or @b@ allows.
400-- types @a@ or @b@ allows.
390−fromF ::
401+fromF' ::
391 forall a b cols rows e.
402 forall a b cols rows e.
392 ( Liftable e a b,
403 ( Liftable e a b,
393− CountableDimensions cols rows,
404+ CountableDims cols rows,
394− FromLists e rows cols
405+ FL rows cols
395 ) =>
406 ) =>
396 (a -> b) ->
407 (a -> b) ->
397 Matrix e cols rows
408 Matrix e cols rows
398−fromF f =
409+fromF' f =
399 let minA = minBound @a
410 let minA = minBound @a
400 maxA = maxBound @a
411 maxA = maxBound @a
401 minB = minBound @b
412 minB = minBound @b
@@ -405,8 +416,8 @@ fromF f =
405 elementsA = take ccols [minA .. maxA]
416 elementsA = take ccols [minA .. maxA]
406 elementsB = take rrows [minB .. maxB]
417 elementsB = take rrows [minB .. maxB]
407 combinations = (,) <$> elementsA <*> elementsB
418 combinations = (,) <$> elementsA <*> elementsB
408− combAp = map snd . sort . map (\(a, b) -> if f a == b
419+ combAp = map snd . sort . map (\(a, b) -> if f a == b
409− then ((fromEnum a, fromEnum b), 1)
420+ then ((fromEnum a, fromEnum b), 1)
410 else ((fromEnum a, fromEnum b), 0)) $ combinations
421 else ((fromEnum a, fromEnum b), 0)) $ combinations
411 mList = buildList combAp rrows
422 mList = buildList combAp rrows
412 in tr $ fromLists mList
423 in tr $ fromLists mList
@@ -416,41 +427,23 @@ fromF f =
416
427
417-- | Lifts functions to matrices with dimensions matching @a@ and @b@
428-- | Lifts functions to matrices with dimensions matching @a@ and @b@
418-- cardinality's.
429-- cardinality's.
419−fromF' ::
430+fromF ::
420 forall a b e.
431 forall a b e.
421 ( Liftable e a b,
432 ( Liftable e a b,
422− CountableDimensionsN a b,
433+ CountableDimsN a b,
423− FromListsN e b a
434+ FLN b a
424 ) =>
435 ) =>
425 (a -> b) ->
436 (a -> b) ->
426 Matrix e (Normalize a) (Normalize b)
437 Matrix e (Normalize a) (Normalize b)
427−fromF' f =
438+fromF = fromF'
428− let minA = minBound @a
429− maxA = maxBound @a
430− minB = minBound @b
431− maxB = maxBound @b
432− ccols = fromInteger $ natVal (Proxy :: Proxy (Count (Normalize a)))
433− rrows = fromInteger $ natVal (Proxy :: Proxy (Count (Normalize b)))
434− elementsA = take ccols [minA .. maxA]
435− elementsB = take rrows [minB .. maxB]
436− combinations = (,) <$> elementsA <*> elementsB
437− combAp = map snd . sort . map (\(a, b) -> if f a == b
438− then ((fromEnum a, fromEnum b), 1)
439− else ((fromEnum a, fromEnum b), 0)) $ combinations
440− mList = buildList combAp rrows
441− in tr $ fromLists mList
442− where
443− buildList [] _ = []
444− buildList l r = take r l : buildList (drop r l) r
445
439
446-- Conversion
440-- Conversion
447
441
448-- | Converts a matrix to a list of lists of elements.
442-- | Converts a matrix to a list of lists of elements.
449toLists :: Matrix e cols rows -> [[e]]
443toLists :: Matrix e cols rows -> [[e]]
450−toLists Empty = []
451toLists (One e) = [[e]]
444toLists (One e) = [[e]]
452−toLists (Split l r) = toLists l ++ toLists r
445+toLists (Fork l r) = toLists l ++ toLists r
453−toLists (Junc l r) = zipWith (++) (toLists l) (toLists r)
446+toLists (Join l r) = zipWith (++) (toLists l) (toLists r)
454
447
455-- | Converts a matrix to a list of elements.
448-- | Converts a matrix to a list of elements.
456toList :: Matrix e cols rows -> [e]
449toList :: Matrix e cols rows -> [e]
@@ -459,38 +452,38 @@ toList = concat . toLists
459-- Zeros Matrix
452-- Zeros Matrix
460
453
461-- | The zero matrix. A matrix wholly filled with zeros.
454-- | The zero matrix. A matrix wholly filled with zeros.
462−zeros :: (Num e, FromLists e cols rows, CountableDimensions cols rows) => Matrix e cols rows
455+zeros :: (Num e, FL cols rows, CountableDims cols rows) => Matrix e cols rows
463−zeros = matrixBuilder (const 0)
456+zeros = matrixBuilder' (const 0)
464
457
465-- Ones Matrix
458-- Ones Matrix
466
459
467-- | The ones matrix. A matrix wholly filled with ones.
460-- | The ones matrix. A matrix wholly filled with ones.
468--
461--
469-- Also known as T (Top) matrix.
462-- Also known as T (Top) matrix.
470−ones :: (Num e, FromLists e cols rows, CountableDimensions cols rows) => Matrix e cols rows
463+ones :: (Num e, FL cols rows, CountableDims cols rows) => Matrix e cols rows
471−ones = matrixBuilder (const 1)
464+ones = matrixBuilder' (const 1)
472
465
473-- Const Matrix
466-- Const Matrix
474
467
475-- | The constant matrix constructor. A matrix wholly filled with a given
468-- | The constant matrix constructor. A matrix wholly filled with a given
476-- value.
469-- value.
477−constant :: (Num e, FromLists e cols rows, CountableDimensions cols rows) => e -> Matrix e cols rows
470+constant :: (Num e, FL cols rows, CountableDims cols rows) => e -> Matrix e cols rows
478−constant e = matrixBuilder (const e)
471+constant e = matrixBuilder' (const e)
479
472
480-- Bang Matrix
473-- Bang Matrix
481
474
482-- | The T (Top) row vector matrix.
475-- | The T (Top) row vector matrix.
483−bang :: forall e cols. (Num e, Enum e, FromLists e cols (), Countable cols) => Matrix e cols ()
476+bang :: forall e cols. (Num e, Enum e, FL cols (), Countable cols) => Matrix e cols ()
484bang =
477bang =
485 let c = fromInteger $ natVal (Proxy :: Proxy (Count cols))
478 let c = fromInteger $ natVal (Proxy :: Proxy (Count cols))
486 in fromLists [take c [1, 1 ..]]
479 in fromLists [take c [1, 1 ..]]
487
480
488−-- Identity Matrix
481+-- iden Matrix
489
482
490−-- | Identity matrix.
483+-- | iden matrix.
491−identity :: (Num e, FromLists e cols cols, Countable cols) => Matrix e cols cols
484+iden :: forall e cols . (Num e, FL cols cols, Countable cols) => Matrix e cols cols
492−identity = matrixBuilder (bool 0 1 . uncurry (==))
485+iden = matrixBuilder' (bool 0 1 . uncurry (==))
493−{-# NOINLINE identity #-}
486+{-# NOINLINE iden #-}
494
487
495-- Matrix composition (MMM)
488-- Matrix composition (MMM)
496
489
@@ -499,65 +492,90 @@ identity = matrixBuilder (bool 0 1 . uncurry (==))
499-- This definition takes advantage of divide-and-conquer and fusion laws
492-- This definition takes advantage of divide-and-conquer and fusion laws
500-- from LAoP.
493-- from LAoP.
501comp :: (Num e) => Matrix e cr rows -> Matrix e cols cr -> Matrix e cols rows
494comp :: (Num e) => Matrix e cr rows -> Matrix e cols cr -> Matrix e cols rows
502−comp Empty Empty = Empty
503−comp (One a) (One b) = One (a * b)
495+comp (One a) (One b) = One (a * b)
504−comp (Junc a b) (Split c d) = comp a c + comp b d -- Divide-and-conquer law
496+comp (Join a b) (Fork c d) = comp a c + comp b d -- Divide-and-conquer law
505−comp (Split a b) c = Split (comp a c) (comp b c) -- Split fusion law
497+comp (Fork a b) c = Fork (comp a c) (comp b c) -- Fork fusion law
506−comp c (Junc a b) = Junc (comp c a) (comp c b) -- Junc fusion law
498+comp c (Join a b) = Join (comp c a) (comp c b) -- Join fusion law
507{-# NOINLINE comp #-}
499{-# NOINLINE comp #-}
508−{-# RULES
500+{-# RULES
509− "comp/identity1" forall m. comp m identity = m ;
501+ "comp/iden1" forall m. comp m iden = m ;
510− "comp/identity2" forall m. comp identity m = m
502+ "comp/iden2" forall m. comp iden m = m
511#-}
503#-}
512
504
505+-- Scalar multiplication of matrices
506+
507+infixl 7 .|
508+-- | Scalar multiplication of matrices.
509+(.|) :: Num e => e -> Matrix e cols rows -> Matrix e cols rows
510+(.|) e (One a) = One (e * a)
511+(.|) e (Join a b) = Join (e .| a) (e .| b)
512+(.|) e (Fork a b) = Fork (e .| a) (e .| b)
513+
514+-- Scalar division of matrices
515+
516+infixl 7 ./
517+-- | Scalar multiplication of matrices.
518+(./) :: Fractional e => Matrix e cols rows -> e -> Matrix e cols rows
519+(./) (One a) e = One (a / e)
520+(./) (Join a b) e = Join (a ./ e) (b ./ e)
521+(./) (Fork a b) e = Fork (a ./ e) (b ./ e)
522+
513-- Projections
523-- Projections
514
524
515-- | Biproduct first component projection
525-- | Biproduct first component projection
516−p1 :: forall e m n. (Num e, CountableDimensions n m, FromLists e n m, FromLists e m m) => Matrix e (Either m n) m
526+p1 :: (Num e, CountableDims n m, FL n m, FL m m) => Matrix e (Either m n) m
517−p1 =
527+p1 = join id zeros
518− let iden = identity :: Matrix e m m
519− zero = zeros :: Matrix e n m
520− in junc iden zero
521
528
522-- | Biproduct second component projection
529-- | Biproduct second component projection
523−p2 :: forall e m n. (Num e, CountableDimensions n m, FromLists e m n, FromLists e n n) => Matrix e (Either m n) n
530+p2 :: (Num e, CountableDims n m, FL m n, FL n n) => Matrix e (Either m n) n
524−p2 =
531+p2 = join zeros id
525− let iden = identity :: Matrix e n n
526− zero = zeros :: Matrix e m n
527− in junc zero iden
528
532
529-- Injections
533-- Injections
530
534
531-- | Biproduct first component injection
535-- | Biproduct first component injection
532−i1 :: (Num e, CountableDimensions n m, FromLists e n m, FromLists e m m) => Matrix e m (Either m n)
536+i1 :: (Num e, CountableDims n m, FL n m, FL m m) => Matrix e m (Either m n)
533i1 = tr p1
537i1 = tr p1
534
538
535-- | Biproduct second component injection
539-- | Biproduct second component injection
536−i2 :: (Num e, CountableDimensions n m, FromLists e m n, FromLists e n n) => Matrix e n (Either m n)
540+i2 :: (Num e, CountableDims n m, FL m n, FL n n) => Matrix e n (Either m n)
537i2 = tr p2
541i2 = tr p2
538
542
539-- Dimensions
543-- Dimensions
540
544
541-- | Obtain the number of rows.
545-- | Obtain the number of rows.
542--
546--
543−-- NOTE: The 'KnownNat' constaint is needed in order to obtain the
547+-- NOTE: The 'KnownNat' constraint is needed in order to obtain the
544−-- dimensions in constant time.
548+-- dimensions in constant time. For a version that doesn't require the
545−--
549+-- constraint see 'rows''.
546−-- TODO: A 'rows' function that does not need the 'KnownNat' constraint in
547−-- exchange for performance.
548rows :: forall e cols rows. (Countable rows) => Matrix e cols rows -> Int
550rows :: forall e cols rows. (Countable rows) => Matrix e cols rows -> Int
549rows _ = fromInteger $ natVal (Proxy :: Proxy (Count rows))
551rows _ = fromInteger $ natVal (Proxy :: Proxy (Count rows))
550
552
553+-- | Obtain the number of rows in an inefficient manner, but without any
554+-- constraints.
555+--
556+-- For a more efficient version see 'rows'.
557+rows' :: Matrix e cols rows -> Int
558+rows' (One _) = 1
559+rows' (Join lhs _) = rows' lhs
560+rows' (Fork top bottom) = rows' top + rows' bottom
561+
551-- | Obtain the number of columns.
562-- | Obtain the number of columns.
552−--
553−-- NOTE: The 'KnownNat' constaint is needed in order to obtain the
554−-- dimensions in constant time.
555--
563--
556−-- TODO: A 'columns' function that does not need the 'KnownNat' constraint in
564+-- NOTE: The 'KnownNat' constraint is needed in order to obtain the
557−-- exchange for performance.
565+-- dimensions in constant time. For a version that doesn't require the
566+-- constraint see 'columns''.
558columns :: forall e cols rows. (Countable cols) => Matrix e cols rows -> Int
567columns :: forall e cols rows. (Countable cols) => Matrix e cols rows -> Int
559columns _ = fromInteger $ natVal (Proxy :: Proxy (Count cols))
568columns _ = fromInteger $ natVal (Proxy :: Proxy (Count cols))
560
569
570+-- | Obtain the number of columns in an inefficient manner, but without any
571+-- constraints.
572+--
573+-- For a more efficient version see 'columns'.
574+columns' :: Matrix e cols rows -> Int
575+columns' (One _) = 1
576+columns' (Join lhs rhs) = columns' lhs + columns' rhs
577+columns' (Fork top _) = columns' top
578+
561-- Coproduct Bifunctor
579-- Coproduct Bifunctor
562
580
563infixl 5 -|-
581infixl 5 -|-
@@ -566,164 +584,161 @@ infixl 5 -|-
566(-|-) ::
584(-|-) ::
567 forall e n k m j.
585 forall e n k m j.
568 ( Num e,
586 ( Num e,
569− CountableDimensions j k,
587+ CountableDims j k,
570− FromLists e k k,
588+ FL k k,
571− FromLists e j k,
589+ FL j k,
572− FromLists e k j,
590+ FL k j,
573− FromLists e j j
591+ FL j j
574 ) =>
592 ) =>
575 Matrix e n k ->
593 Matrix e n k ->
576 Matrix e m j ->
594 Matrix e m j ->
577 Matrix e (Either n m) (Either k j)
595 Matrix e (Either n m) (Either k j)
578−(-|-) a b = Junc (i1 . a) (i2 . b)
596+(-|-) a b = Join (i1 . a) (i2 . b)
579
597
580-- Khatri Rao Product and projections
598-- Khatri Rao Product and projections
581
599
582-- | Khatri Rao product first component projection matrix.
600-- | Khatri Rao product first component projection matrix.
583−kp1 ::
601+fstM ::
584 forall e m k .
602 forall e m k .
585 ( Num e,
603 ( Num e,
586− CountableDimensions k m,
604+ CountableDims k m,
587− FromLists e (Normalize (m, k)) m,
605+ FL (Normalize (m, k)) m,
588 CountableN (m, k)
606 CountableN (m, k)
589 ) => Matrix e (Normalize (m, k)) m
607 ) => Matrix e (Normalize (m, k)) m
590−kp1 = matrixBuilder f
608+fstM = matrixBuilder' f
591 where
609 where
592 offset = fromInteger (natVal (Proxy :: Proxy (Count k)))
610 offset = fromInteger (natVal (Proxy :: Proxy (Count k)))
593 f (x, y)
611 f (x, y)
594 | y >= (x * offset) && y <= (x * offset + offset - 1) = 1
612 | y >= (x * offset) && y <= (x * offset + offset - 1) = 1
595− | otherwise = 0
613+ | otherwise = 0
596
614
597-- | Khatri Rao product second component projection matrix.
615-- | Khatri Rao product second component projection matrix.
598−kp2 ::
616+sndM ::
599 forall e m k .
617 forall e m k .
600 ( Num e,
618 ( Num e,
601− CountableDimensions k m,
619+ CountableDims k m,
602− FromLists e (Normalize (m, k)) k,
620+ FL (Normalize (m, k)) k,
603 CountableN (m, k)
621 CountableN (m, k)
604 ) => Matrix e (Normalize (m, k)) k
622 ) => Matrix e (Normalize (m, k)) k
605−kp2 = matrixBuilder f
623+sndM = matrixBuilder' f
606 where
624 where
607 offset = fromInteger (natVal (Proxy :: Proxy (Count k)))
625 offset = fromInteger (natVal (Proxy :: Proxy (Count k)))
608 f (x, y)
626 f (x, y)
609 | x == y || mod (y - x) offset == 0 = 1
627 | x == y || mod (y - x) offset == 0 = 1
610− | otherwise = 0
628+ | otherwise = 0
611
629
612-- | Khatri Rao Matrix product also known as matrix pairing.
630-- | Khatri Rao Matrix product also known as matrix pairing.
613--
631--
614-- NOTE: That this is not a true categorical product, see for instance:
632-- NOTE: That this is not a true categorical product, see for instance:
615−--
633+--
616-- @
634-- @
617−-- | kp1 . khatri a b == a
635+-- | fstM . kr a b == a
618−-- khatri a b ==> |
636+-- kr a b ==> |
619−-- | kp2 . khatri a b == b
637+-- | sndM . kr a b == b
620-- @
638-- @
621--
639--
622-- __Emphasis__ on the implication symbol.
640-- __Emphasis__ on the implication symbol.
623−khatri ::
641+kr ::
624− forall e cols a b.
642+ forall e cols a b.
625 ( Num e,
643 ( Num e,
626− CountableDimensions a b,
644+ CountableDims a b,
627 CountableN (a, b),
645 CountableN (a, b),
628− FromLists e (Normalize (a, b)) a,
646+ FL (Normalize (a, b)) a,
629− FromLists e (Normalize (a, b)) b
647+ FL (Normalize (a, b)) b
630 ) => Matrix e cols a -> Matrix e cols b -> Matrix e cols (Normalize (a, b))
648 ) => Matrix e cols a -> Matrix e cols b -> Matrix e cols (Normalize (a, b))
631−khatri a b =
649+kr a b =
632− let kp1' = kp1 @e @a @b
650+ let fstM' = fstM @e @a @b
633− kp2' = kp2 @e @a @b
651+ sndM' = sndM @e @a @b
634− in (tr kp1') . a * (tr kp2') . b
652+ in (tr fstM' . a) * (tr sndM' . b)
635
653
636-- Product Bifunctor (Kronecker)
654-- Product Bifunctor (Kronecker)
637
655
638infixl 4 ><
656infixl 4 ><
639
657
640-- | Matrix product functor also known as kronecker product
658-- | Matrix product functor also known as kronecker product
641−(><) ::
659+(><) ::
642− forall e m p n q.
660+ forall e m p n q.
643 ( Num e,
661 ( Num e,
644− CountableDimensions m n,
662+ CountableDims m n,
645− CountableDimensions p q,
663+ CountableDims p q,
646− CountableDimensionsN (m, n) (p, q),
664+ CountableDimsN (m, n) (p, q),
647− FromLists e (Normalize (m, n)) m,
665+ FL (Normalize (m, n)) m,
648− FromLists e (Normalize (m, n)) n,
666+ FL (Normalize (m, n)) n,
649− FromLists e (Normalize (p, q)) p,
667+ FL (Normalize (p, q)) p,
650− FromLists e (Normalize (p, q)) q
668+ FL (Normalize (p, q)) q
651− )
669+ )
652 => Matrix e m p -> Matrix e n q -> Matrix e (Normalize (m, n)) (Normalize (p, q))
670 => Matrix e m p -> Matrix e n q -> Matrix e (Normalize (m, n)) (Normalize (p, q))
653(><) a b =
671(><) a b =
654− let kp1' = kp1 @e @m @n
672+ let fstM' = fstM @e @m @n
655− kp2' = kp2 @e @m @n
673+ sndM' = sndM @e @m @n
656− in khatri (a . kp1') (b . kp2')
674+ in kr (a . fstM') (b . sndM')
657
675
658−-- Matrix abide Junc Split
676+-- Matrix abide Join Fork
659
677
660−-- | Matrix "abiding" followin the 'Junc'-'Split' abide law.
678+-- | Matrix "abiding" following the 'Join'-'Fork' exchange law.
661−--
679+--
662-- Law:
680-- Law:
663--
681--
664-- @
682-- @
665−-- 'Junc' ('Split' a c) ('Split' b d) == 'Split' ('Junc' a b) ('Junc' c d)
683+-- 'Join' ('Fork' a c) ('Fork' b d) == 'Fork' ('Join' a b) ('Join' c d)
666-- @
684-- @
667−abideJS :: Matrix e cols rows -> Matrix e cols rows
685+abideJF :: Matrix e cols rows -> Matrix e cols rows
668−abideJS (Junc (Split a c) (Split b d)) = Split (Junc (abideJS a) (abideJS b)) (Junc (abideJS c) (abideJS d)) -- Junc-Split abide law
686+abideJF (Join (Fork a c) (Fork b d)) = Fork (Join (abideJF a) (abideJF b)) (Join (abideJF c) (abideJF d)) -- Join-Fork abide law
669−abideJS Empty = Empty
670−abideJS (One e) = One e
687+abideJF (One e) = One e
671−abideJS (Junc a b) = Junc (abideJS a) (abideJS b)
688+abideJF (Join a b) = Join (abideJF a) (abideJF b)
672−abideJS (Split a b) = Split (abideJS a) (abideJS b)
689+abideJF (Fork a b) = Fork (abideJF a) (abideJF b)
673
690
674−-- Matrix abide Split Junc
691+-- Matrix abide Fork Join
675
692
676−-- | Matrix "abiding" followin the 'Split'-'Junc' abide law.
693+-- | Matrix "abiding" followin the 'Fork'-'Join' abide law.
677−--
694+--
678-- @
695-- @
679−-- 'Split' ('Junc' a b) ('Junc' c d) == 'Junc' ('Split' a c) ('Split' b d)
696+-- 'Fork' ('Join' a b) ('Join' c d) == 'Join' ('Fork' a c) ('Fork' b d)
680-- @
697-- @
681−abideSJ :: Matrix e cols rows -> Matrix e cols rows
698+abideFJ :: Matrix e cols rows -> Matrix e cols rows
682−abideSJ (Split (Junc a b) (Junc c d)) = Junc (Split (abideSJ a) (abideSJ c)) (Split (abideSJ b) (abideSJ d)) -- Split-Junc abide law
699+abideFJ (Fork (Join a b) (Join c d)) = Join (Fork (abideFJ a) (abideFJ c)) (Fork (abideFJ b) (abideFJ d)) -- Fork-Join abide law
683−abideSJ Empty = Empty
684−abideSJ (One e) = One e
700+abideFJ (One e) = One e
685−abideSJ (Junc a b) = Junc (abideSJ a) (abideSJ b)
701+abideFJ (Join a b) = Join (abideFJ a) (abideFJ b)
686−abideSJ (Split a b) = Split (abideSJ a) (abideSJ b)
702+abideFJ (Fork a b) = Fork (abideFJ a) (abideFJ b)
687
703
688-- Matrix transposition
704-- Matrix transposition
689
705
690-- | Matrix transposition.
706-- | Matrix transposition.
691tr :: Matrix e cols rows -> Matrix e rows cols
707tr :: Matrix e cols rows -> Matrix e rows cols
692−tr Empty = Empty
693−tr (One e) = One e
708+tr (One e) = One e
694−tr (Junc a b) = Split (tr a) (tr b)
709+tr (Join a b) = Fork (tr a) (tr b)
695−tr (Split a b) = Junc (tr a) (tr b)
710+tr (Fork a b) = Join (tr a) (tr b)
696
711
697-- Selective 'select' operator
712-- Selective 'select' operator
698
713
699-- | Selective functors 'select' operator equivalent inspired by the
714-- | Selective functors 'select' operator equivalent inspired by the
700-- ArrowMonad solution presented in the paper.
715-- ArrowMonad solution presented in the paper.
701−select :: (Num e, FromLists e b b, Countable b) => Matrix e cols (Either a b) -> Matrix e a b -> Matrix e cols b
716+select :: (Num e, FL b b, Countable b) => Matrix e cols (Either a b) -> Matrix e a b -> Matrix e cols b
702−select (Split a b) y = y . a + b -- Divide-and-conquer law
717+select (Fork a b) y = y . a + b -- Divide-and-conquer law
703−select (Junc (Split a c) (Split b d)) y = junc (y . a + c) (y . b + d) -- Pattern matching + DnC law
718+select (Join (Fork a c) (Fork b d)) y = join (y . a + c) (y . b + d) -- Pattern matching + DnC law
704−select m y = junc y identity . m
719+select m y = join y id . m
705
720
706−branch ::
721+branch ::
707 ( Num e,
722 ( Num e,
708− CountableDimensions a b,
723+ CountableDims a b,
709− CountableDimensions c (Either b c),
724+ CountableDims c (Either b c),
710− FromLists e c b,
725+ FL c b,
711− FromLists e a b,
726+ FL a b,
712− FromLists e a a,
727+ FL a a,
713− FromLists e b b,
728+ FL b b,
714− FromLists e c c,
729+ FL c c,
715− FromLists e b a,
730+ FL b a,
716− FromLists e b c,
731+ FL b c,
717− FromLists e (Either b c) b,
732+ FL (Either b c) b,
718− FromLists e (Either b c) c
733+ FL (Either b c) c
719 )
734 )
720 => Matrix e cols (Either a b) -> Matrix e a c -> Matrix e b c -> Matrix e cols c
735 => Matrix e cols (Either a b) -> Matrix e a c -> Matrix e b c -> Matrix e cols c
721branch x l r = f x `select` g l `select` r
736branch x l r = f x `select` g l `select` r
722 where
737 where
723− f :: (Num e, Countable a, CountableDimensions b c, FromLists e a b, FromLists e c b, FromLists e b b, FromLists e b a, FromLists e a a)
738+ f :: (Num e, Countable a, CountableDims b c, FL a b, FL c b, FL b b, FL b a, FL a a)
724 => Matrix e cols (Either a b) -> Matrix e cols (Either a (Either b c))
739 => Matrix e cols (Either a b) -> Matrix e cols (Either a (Either b c))
725− f m = split (tr i1) (i1 . tr i2) . m
740+ f m = fork (tr i1) (i1 . tr i2) . m
726− g :: (Num e, CountableDimensions b c, FromLists e b c, FromLists e c c) => Matrix e a c -> Matrix e a (Either b c)
741+ g :: (Num e, CountableDims b c, FL b c, FL c c) => Matrix e a c -> Matrix e a (Either b c)
727 g m = i2 . m
742 g m = i2 . m
728
743
729-- McCarthy's Conditional
744-- McCarthy's Conditional
@@ -732,9 +747,9 @@ branch x l r = f x `select` g l `select` r
732cond ::
747cond ::
733 ( Trivial cols,
748 ( Trivial cols,
734 Countable cols,
749 Countable cols,
735− FromLists e () cols,
750+ FL () cols,
736− FromLists e cols (),
751+ FL cols (),
737− FromLists e cols cols,
752+ FL cols cols,
738 Bounded a,
753 Bounded a,
739 Enum a,
754 Enum a,
740 Num e,
755 Num e,
@@ -742,14 +757,14 @@ cond ::
742 )
757 )
743 =>
758 =>
744 (a -> Bool) -> Matrix e cols rows -> Matrix e cols rows -> Matrix e cols rows
759 (a -> Bool) -> Matrix e cols rows -> Matrix e cols rows -> Matrix e cols rows
745−cond p f g = junc f g . grd p
760+cond p f g = join f g . grd p
746
761
747−grd ::
762+grd ::
748 ( Trivial q,
763 ( Trivial q,
749 Countable q,
764 Countable q,
750− FromLists e () q,
765+ FL () q,
751− FromLists e q (),
766+ FL q (),
752− FromLists e q q,
767+ FL q q,
753 Bounded a,
768 Bounded a,
754 Enum a,
769 Enum a,
755 Num e,
770 Num e,
@@ -757,60 +772,86 @@ grd ::
757 )
772 )
758 =>
773 =>
759 (a -> Bool) -> Matrix e q (Either q q)
774 (a -> Bool) -> Matrix e q (Either q q)
760−grd f = split (corr f) (corr (not . f))
775+grd f = fork (corr f) (corr (not . f))
761
776
762−corr ::
777+corr ::
763− forall e a q .
778+ forall e a q .
764 ( Trivial q,
779 ( Trivial q,
765 Countable q,
780 Countable q,
766− FromLists e () q,
781+ FL () q,
767− FromLists e q (),
782+ FL q (),
768− FromLists e q q,
783+ FL q q,
769 Liftable e a Bool
784 Liftable e a Bool
770− )
785+ )
771 => (a -> Bool) -> Matrix e q q
786 => (a -> Bool) -> Matrix e q q
772−corr p = let f = fromF p :: Matrix e q ()
787+corr p = let f = fromF' p :: Matrix e q ()
773− in khatri f (identity :: Matrix e q q)
788+ in kr f (id :: Matrix e q q)
774
789
775-- Pretty print
790-- Pretty print
776
791
777prettyAux :: Show e => [[e]] -> [[e]] -> String
792prettyAux :: Show e => [[e]] -> [[e]] -> String
778prettyAux [] _ = ""
793prettyAux [] _ = ""
779−prettyAux [[e]] m = "│ " ++ fill (show e) ++ " │\n"
794+prettyAux [[e]] m = "│ " ++ fill (show e) ++ " │\n"
780 where
795 where
781 v = fmap show m
796 v = fmap show m
782 widest = maximum $ fmap length v
797 widest = maximum $ fmap length v
783 fill str = replicate (widest - length str - 2) ' ' ++ str
798 fill str = replicate (widest - length str - 2) ' ' ++ str
784−prettyAux [h] m = "│ " ++ fill (unwords $ map show h) ++ " │\n"
799+prettyAux [h] m = "│ " ++ fill (unwords $ map show h) ++ " │\n"
785 where
800 where
786− v = fmap show m
801+ v = fmap show m
787− widest = maximum $ fmap length v
802+ widest = maximum $ fmap length v
788 fill str = replicate (widest - length str - 2) ' ' ++ str
803 fill str = replicate (widest - length str - 2) ' ' ++ str
789−prettyAux (h : t) l = "│ " ++ fill (unwords $ map show h) ++ " │\n" ++
804+prettyAux (h : t) l = "│ " ++ fill (unwords $ map show h) ++ " │\n" ++
790 prettyAux t l
805 prettyAux t l
791 where
806 where
792− v = fmap show l
807+ v = fmap show l
793− widest = maximum $ fmap length v
808+ widest = maximum $ fmap length v
794 fill str = replicate (widest - length str - 2) ' ' ++ str
809 fill str = replicate (widest - length str - 2) ' ' ++ str
795
810
796-- | Matrix pretty printer
811-- | Matrix pretty printer
797−pretty :: (Countable cols, Show e) => Matrix e cols rows -> String
812+pretty :: (CountableDims cols rows, Show e) => Matrix e cols rows -> String
813+pretty m = concat
798−pretty m = "┌ " ++ unwords (replicate (columns m) blank) ++ " ┐\n" ++
814+ [ "┌ ", unwords (replicate (columns m) blank), " ┐\n"
799− prettyAux (toLists m) (toLists m) ++
815+ , unlines
816+ [ "│ " ++ unwords (fmap (\j -> fill $ show $ getElem i j m) [1..columns m]) ++ " │" | i <- [1..rows m] ]
800− "└ " ++ unwords (replicate (columns m) blank) ++ " ┘"
817+ , "└ ", unwords (replicate (columns m) blank), " ┘"
818+ ]
801− where
819+ where
802− v = fmap show (toList m)
820+ strings = map show (toList m)
803− widest = maximum $ fmap length v
821+ widest = maximum $ map length strings
804 fill str = replicate (widest - length str) ' ' ++ str
822 fill str = replicate (widest - length str) ' ' ++ str
805− blank = fill ""
823+ blank = fill ""
824+ safeGet i j m
825+ | i > rows m || j > columns m || i < 1 || j < 1 = Nothing
826+ | otherwise = Just $ unsafeGet i j m (toList m)
827+ unsafeGet i j m l = l !! encode (columns m) (i,j)
828+ encode m (i,j) = (i-1)*m + j - 1
829+ getElem i j m =
830+ fromMaybe
831+ (error $
832+ "getElem: Trying to get the "
833+ ++ show (i, j)
834+ ++ " element from a "
835+ ++ show (rows m) ++ "x" ++ show (columns m)
836+ ++ " matrix."
837+ )
838+ (safeGet i j m)
806
839
807-- | Matrix pretty printer
840-- | Matrix pretty printer
808−prettyPrint :: (Countable cols, Show e) => Matrix e cols rows -> IO ()
841+prettyPrint :: (CountableDims cols rows, Show e) => Matrix e cols rows -> IO ()
809prettyPrint = putStrLn . pretty
842prettyPrint = putStrLn . pretty
810
843
844+-- | Zip two matrices with a given binary function
845+zipWithM :: (e -> f -> g) -> Matrix e cols rows -> Matrix f cols rows -> Matrix g cols rows
846+zipWithM f (One a) (One b) = One (f a b)
847+zipWithM f (Join a b) (Join c d) = Join (zipWithM f a c) (zipWithM f b d)
848+zipWithM f (Fork a b) (Fork c d) = Fork (zipWithM f a c) (zipWithM f b d)
849+zipWithM f x@(Fork _ _) y@(Join _ _) = zipWithM f x (abideJF y)
850+zipWithM f x@(Join _ _) y@(Fork _ _) = zipWithM f (abideJF x) y
851+
811-- Relational operators functions
852-- Relational operators functions
812
853
813−type Boolean = Natural 0 1
854+type Boolean = Natural 0 1
814type Relation a b = Matrix Boolean a b
855type Relation a b = Matrix Boolean a b
815
856
816-- | Helper conversion function
857-- | Helper conversion function
@@ -826,54 +867,47 @@ fromBool False = nat 0
826
867
827-- | Relational negation
868-- | Relational negation
828negateM :: Relation cols rows -> Relation cols rows
869negateM :: Relation cols rows -> Relation cols rows
829−negateM Empty = Empty
830−negateM (One (Nat 0)) = One (Nat 1)
870+negateM (One (Nat p)) = One (Nat (negate p))
831−negateM (One (Nat 1)) = One (Nat 0)
832−negateM (Junc a b) = Junc (negateM a) (negateM b)
871+negateM (Join a b) = Join (negateM a) (negateM b)
833−negateM (Split a b) = Split (negateM a) (negateM b)
872+negateM (Fork a b) = Fork (negateM a) (negateM b)
834
873
835-- | Relational addition
874-- | Relational addition
836orM :: Relation cols rows -> Relation cols rows -> Relation cols rows
875orM :: Relation cols rows -> Relation cols rows -> Relation cols rows
837−orM Empty Empty = Empty
838−orM (One a) (One b) = One (fromBool (toBool a || toBool b))
876+orM (One a) (One b) = One (fromBool (toBool a || toBool b))
839−orM (Junc a b) (Junc c d) = Junc (orM a c) (orM b d)
877+orM (Join a b) (Join c d) = Join (orM a c) (orM b d)
840−orM (Split a b) (Split c d) = Split (orM a c) (orM b d)
878+orM (Fork a b) (Fork c d) = Fork (orM a c) (orM b d)
841−orM x@(Split _ _) y@(Junc _ _) = orM x (abideJS y)
879+orM x@(Fork _ _) y@(Join _ _) = orM x (abideJF y)
842−orM x@(Junc _ _) y@(Split _ _) = orM (abideJS x) y
880+orM x@(Join _ _) y@(Fork _ _) = orM (abideJF x) y
843
881
844-- | Relational multiplication
882-- | Relational multiplication
845andM :: Relation cols rows -> Relation cols rows -> Relation cols rows
883andM :: Relation cols rows -> Relation cols rows -> Relation cols rows
846−andM Empty Empty = Empty
847−andM (One a) (One b) = One (fromBool (toBool a && toBool b))
884+andM (One a) (One b) = One (fromBool (toBool a && toBool b))
848−andM (Junc a b) (Junc c d) = Junc (andM a c) (andM b d)
885+andM (Join a b) (Join c d) = Join (andM a c) (andM b d)
849−andM (Split a b) (Split c d) = Split (andM a c) (andM b d)
886+andM (Fork a b) (Fork c d) = Fork (andM a c) (andM b d)
850−andM x@(Split _ _) y@(Junc _ _) = andM x (abideJS y)
887+andM x@(Fork _ _) y@(Join _ _) = andM x (abideJF y)
851−andM x@(Junc _ _) y@(Split _ _) = andM (abideJS x) y
888+andM x@(Join _ _) y@(Fork _ _) = andM (abideJF x) y
852
889
853-- | Relational subtraction
890-- | Relational subtraction
854subM :: Relation cols rows -> Relation cols rows -> Relation cols rows
891subM :: Relation cols rows -> Relation cols rows -> Relation cols rows
855−subM Empty Empty = Empty
856−subM (One a) (One b) = if a - b < nat 0 then One (nat 0) else One (a - b)
892+subM (One a) (One b) = if a - b < nat 0 then One (nat 0) else One (a - b)
857−subM (Junc a b) (Junc c d) = Junc (subM a c) (subM b d)
893+subM (Join a b) (Join c d) = Join (subM a c) (subM b d)
858−subM (Split a b) (Split c d) = Split (subM a c) (subM b d)
894+subM (Fork a b) (Fork c d) = Fork (subM a c) (subM b d)
859−subM x@(Split _ _) y@(Junc _ _) = subM x (abideJS y)
895+subM x@(Fork _ _) y@(Join _ _) = subM x (abideJF y)
860−subM x@(Junc _ _) y@(Split _ _) = subM (abideJS x) y
896+subM x@(Join _ _) y@(Fork _ _) = subM (abideJF x) y
861
897
862-- | Matrix relational composition.
898-- | Matrix relational composition.
863compRel :: Relation cr rows -> Relation cols cr -> Relation cols rows
899compRel :: Relation cr rows -> Relation cols cr -> Relation cols rows
864−compRel Empty Empty = Empty
865−compRel (One a) (One b) = One (fromBool (toBool a && toBool b))
900+compRel (One a) (One b) = One (fromBool (toBool a && toBool b))
866−compRel (Junc a b) (Split c d) = orM (compRel a c) (compRel b d) -- Divide-and-conquer law
901+compRel (Join a b) (Fork c d) = orM (compRel a c) (compRel b d) -- Divide-and-conquer law
867−compRel (Split a b) c = Split (compRel a c) (compRel b c) -- Split fusion law
902+compRel (Fork a b) c = Fork (compRel a c) (compRel b c) -- Fork fusion law
868−compRel c (Junc a b) = Junc (compRel c a) (compRel c b) -- Junc fusion law
903+compRel c (Join a b) = Join (compRel c a) (compRel c b) -- Join fusion law
869
904
870-- | Matrix relational right division
905-- | Matrix relational right division
871divR :: Relation b c -> Relation b a -> Relation a c
906divR :: Relation b c -> Relation b a -> Relation a c
872−divR Empty Empty = Empty
873divR (One a) (One b) = One (fromBool (not (toBool b) || toBool a)) -- b implies a
907divR (One a) (One b) = One (fromBool (not (toBool b) || toBool a)) -- b implies a
874−divR (Junc a b) (Junc c d) = andM (divR a c) (divR b d)
908+divR (Join a b) (Join c d) = andM (divR a c) (divR b d)
875−divR (Split a b) c = Split (divR a c) (divR b c)
909+divR (Fork a b) c = Fork (divR a c) (divR b c)
876−divR c (Split a b) = Junc (divR c a) (divR c b)
910+divR c (Fork a b) = Join (divR c a) (divR c b)
877
911
878-- | Matrix relational left division
912-- | Matrix relational left division
879divL :: Relation c b -> Relation a b -> Relation a c
913divL :: Relation c b -> Relation a b -> Relation a c
@@ -889,86 +923,52 @@ divS s r = divL r s `intersection` divR (tr r) (tr s)
889--
923--
890-- NOTE: Be careful to not ask for a relation bigger than the cardinality of
924-- NOTE: Be careful to not ask for a relation bigger than the cardinality of
891-- types @a@ or @b@ allows.
925-- types @a@ or @b@ allows.
892−fromFRel ::
926+fromFRel' ::
893 forall a b cols rows.
927 forall a b cols rows.
894 ( Liftable Boolean a b,
928 ( Liftable Boolean a b,
895− CountableDimensions cols rows,
929+ CountableDims cols rows,
896− FromLists Boolean rows cols
930+ FL rows cols
897 ) =>
931 ) =>
898 (a -> b) ->
932 (a -> b) ->
899 Relation cols rows
933 Relation cols rows
900−fromFRel f =
934+fromFRel' = fromF'
901− let minA = minBound @a
902− maxA = maxBound @a
903− minB = minBound @b
904− maxB = maxBound @b
905− ccols = fromInteger $ natVal (Proxy :: Proxy (Count cols))
906− rrows = fromInteger $ natVal (Proxy :: Proxy (Count rows))
907− elementsA = take ccols [minA .. maxA]
908− elementsB = take rrows [minB .. maxB]
909− combinations = (,) <$> elementsA <*> elementsB
910− combAp = map snd . sort . map (\(a, b) -> if f a == b
911− then ((fromEnum a, fromEnum b), nat 1)
912− else ((fromEnum a, fromEnum b), nat 0)) $ combinations
913− mList = buildList combAp rrows
914− in tr $ fromLists mList
915− where
916− buildList [] _ = []
917− buildList l r = take r l : buildList (drop r l) r
918
935
919-- | Lifts functions to relations with dimensions matching @a@ and @b@
936-- | Lifts functions to relations with dimensions matching @a@ and @b@
920-- cardinality's.
937-- cardinality's.
921−fromFRel' ::
938+fromFRel ::
922 forall a b.
939 forall a b.
923 ( Liftable Boolean a b,
940 ( Liftable Boolean a b,
924− CountableDimensionsN a b,
941+ CountableDimsN a b,
925− FromLists Boolean (Normalize b) (Normalize a)
942+ FLN b a
926 ) =>
943 ) =>
927 (a -> b) ->
944 (a -> b) ->
928 Relation (Normalize a) (Normalize b)
945 Relation (Normalize a) (Normalize b)
929−fromFRel' f =
946+fromFRel = fromFRel'
930− let minA = minBound @a
931− maxA = maxBound @a
932− minB = minBound @b
933− maxB = maxBound @b
934− ccols = fromInteger $ natVal (Proxy :: Proxy (Count (Normalize a)))
935− rrows = fromInteger $ natVal (Proxy :: Proxy (Count (Normalize b)))
936− elementsA = take ccols [minA .. maxA]
937− elementsB = take rrows [minB .. maxB]
938− combinations = (,) <$> elementsA <*> elementsB
939− combAp = map snd . sort . map (\(a, b) -> if f a == b
940− then ((fromEnum a, fromEnum b), nat 1)
941− else ((fromEnum a, fromEnum b), nat 0)) $ combinations
942− mList = buildList combAp rrows
943− in tr $ fromLists mList
944− where
945− buildList [] _ = []
946− buildList l r = take r l : buildList (drop r l) r
947
947
948-- | Lifts a relation function to a Boolean Matrix
948-- | Lifts a relation function to a Boolean Matrix
949−toRel ::
949+toRel ::
950 forall a b.
950 forall a b.
951 ( Bounded a,
951 ( Bounded a,
952 Bounded b,
952 Bounded b,
953 Enum a,
953 Enum a,
954 Enum b,
954 Enum b,
955 Eq b,
955 Eq b,
956− CountableDimensionsN a b,
956+ CountableDims a b,
957− FromListsN Boolean b a
957+ FLN b a
958− )
958+ )
959 => (a -> b -> Bool) -> Relation (Normalize a) (Normalize b)
959 => (a -> b -> Bool) -> Relation (Normalize a) (Normalize b)
960toRel f =
960toRel f =
961 let minA = minBound @a
961 let minA = minBound @a
962 maxA = maxBound @a
962 maxA = maxBound @a
963 minB = minBound @b
963 minB = minBound @b
964 maxB = maxBound @b
964 maxB = maxBound @b
965− ccols = fromInteger $ natVal (Proxy :: Proxy (Count (Normalize a)))
965+ ccols = fromInteger $ natVal (Proxy :: Proxy (Count a))
966− rrows = fromInteger $ natVal (Proxy :: Proxy (Count (Normalize b)))
966+ rrows = fromInteger $ natVal (Proxy :: Proxy (Count b))
967 elementsA = take ccols [minA .. maxA]
967 elementsA = take ccols [minA .. maxA]
968 elementsB = take rrows [minB .. maxB]
968 elementsB = take rrows [minB .. maxB]
969 combinations = (,) <$> elementsA <*> elementsB
969 combinations = (,) <$> elementsA <*> elementsB
970− combAp = map snd . sort . map (\(a, b) -> if uncurry f (a, b)
970+ combAp = map snd . sort . map (\(a, b) -> if uncurry f (a, b)
971− then ((fromEnum a, fromEnum b), nat 1)
971+ then ((fromEnum a, fromEnum b), nat 1)
972 else ((fromEnum a, fromEnum b), nat 0)) $ combinations
972 else ((fromEnum a, fromEnum b), nat 0)) $ combinations
973 mList = buildList combAp rrows
973 mList = buildList combAp rrows
974 in tr $ fromLists mList
974 in tr $ fromLists mList
src/LAoP/Matrix/Nat.hs+139−124
@@ -56,21 +56,20 @@ module LAoP.Matrix.Nat
56
56
57 -- * Constraint type synonyms
57 -- * Constraint type synonyms
58 Countable,
58 Countable,
59− CountableDimensions,
59+ CountableDims,
60 CountableN,
60 CountableN,
61 CountableNz,
61 CountableNz,
62− CountableDimensionsN,
62+ CountableDimsN,
63− FromListsN,
63+ FLN,
64− FromListsNz,
64+ FLNz,
65 Liftable,
65 Liftable,
66 TrivialE,
66 TrivialE,
67 TrivialP,
67 TrivialP,
68
68
69 -- * Primitives
69 -- * Primitives
70− empty,
71 one,
70 one,
72− junc,
71+ join,
73− split,
72+ fork,
74
73
75 -- * Auxiliary type families
74 -- * Auxiliary type families
76 I.FromNat,
75 I.FromNat,
@@ -78,11 +77,11 @@ module LAoP.Matrix.Nat
78 I.Normalize,
77 I.Normalize,
79
78
80 -- * Matrix construction and conversion
79 -- * Matrix construction and conversion
81− I.FromLists,
80+ I.FL,
82 fromLists,
81 fromLists,
83 toLists,
82 toLists,
84 toList,
83 toList,
85− matrixBuilder,
84+ matrixBuilder',
86 row,
85 row,
87 col,
86 col,
88 zeros,
87 zeros,
@@ -98,6 +97,10 @@ module LAoP.Matrix.Nat
98 -- ** Matrix Transposition
97 -- ** Matrix Transposition
99 tr,
98 tr,
100
99
100+ -- ** Scalar multiplication/division of matrices
101+ (.|),
102+ (./),
103+
101 -- ** Selective operator
104 -- ** Selective operator
102 select,
105 select,
103
106
@@ -105,16 +108,19 @@ module LAoP.Matrix.Nat
105 cond,
108 cond,
106
109
107 -- ** Matrix "abiding"
110 -- ** Matrix "abiding"
108− abideJS,
111+ abideJF,
109− abideSJ,
112+ abideFJ,
113+
114+ -- ** Zip Matrices
115+ zipWithM,
110
116
111 -- * Biproduct approach
117 -- * Biproduct approach
112− -- ** Split
118+ -- ** Fork
113 (===),
119 (===),
114 -- *** Projections
120 -- *** Projections
115 p1,
121 p1,
116 p2,
122 p2,
117− -- ** Junc
123+ -- ** Join
118 (|||),
124 (|||),
119 -- *** Injections
125 -- *** Injections
120 i1,
126 i1,
@@ -128,11 +134,11 @@ module LAoP.Matrix.Nat
128 -- | Note that given the restrictions imposed it is not possible to
134 -- | Note that given the restrictions imposed it is not possible to
129 -- implement the standard type classes present in standard Haskell.
135 -- implement the standard type classes present in standard Haskell.
130 -- *** Matrix pairing projections
136 -- *** Matrix pairing projections
131− kp1,
137+ fstM,
132− kp2,
138+ sndM,
133
139
134 -- *** Matrix pairing
140 -- *** Matrix pairing
135− khatri,
141+ kr,
136
142
137 -- * Matrix composition and lifting
143 -- * Matrix composition and lifting
138
144
@@ -140,10 +146,10 @@ module LAoP.Matrix.Nat
140
146
141 -- | Note that given the restrictions imposed it is not possible to
147 -- | Note that given the restrictions imposed it is not possible to
142 -- implement the standard type classes present in standard Haskell.
148 -- implement the standard type classes present in standard Haskell.
143− identity,
149+ iden,
144 comp,
150 comp,
145− fromF,
146 fromF',
151 fromF',
152+ fromF,
147
153
148 -- * Matrix printing
154 -- * Matrix printing
149 pretty,
155 pretty,
@@ -154,47 +160,34 @@ where
154import Data.Proxy
160import Data.Proxy
155import GHC.TypeLits
161import GHC.TypeLits
156import Control.DeepSeq
162import Control.DeepSeq
157−import qualified Control.Category as C
158import qualified LAoP.Matrix.Internal as I
163import qualified LAoP.Matrix.Internal as I
159
164
160newtype Matrix e (cols :: Nat) (rows :: Nat) = M (I.Matrix e (I.FromNat cols) (I.FromNat rows))
165newtype Matrix e (cols :: Nat) (rows :: Nat) = M (I.Matrix e (I.FromNat cols) (I.FromNat rows))
161 deriving (Show, Num, Eq, Ord, NFData) via (I.Matrix e (I.FromNat cols) (I.FromNat rows))
166 deriving (Show, Num, Eq, Ord, NFData) via (I.Matrix e (I.FromNat cols) (I.FromNat rows))
162
167
163-- | Constraint type synonyms to keep the type signatures less convoluted
168-- | Constraint type synonyms to keep the type signatures less convoluted
164−type Countable a = KnownNat (I.Count a)
169+type Countable a = KnownNat (I.Count a)
165−type CountableDimensions a b = (Countable a, Countable b)
170+type CountableDims a b = (Countable a, Countable b)
166−type CountableN a = KnownNat (I.Count (I.FromNat a))
171+type CountableN a = KnownNat (I.Count (I.FromNat a))
167−type CountableNz a = KnownNat (I.Count (I.Normalize a))
172+type CountableNz a = KnownNat (I.Count (I.Normalize a))
168−type CountableDimensionsN a b = (CountableN a, CountableN b)
173+type CountableDimsN a b = (CountableN a, CountableN b)
169−type FromListsN e a b = I.FromLists e (I.FromNat a) (I.FromNat b)
174+type FLN e a b = I.FL (I.FromNat a) (I.FromNat b)
170−type FromListsNz e a b = I.FromLists e (I.Normalize a) (I.Normalize b)
175+type FLNz e a b = I.FL (I.Normalize a) (I.Normalize b)
171−type Liftable e a b = (Bounded a, Bounded b, Enum a, Enum b, Eq b, Num e, Ord e)
176+type Liftable e a b = (Bounded a, Bounded b, Enum a, Enum b, Eq b, Num e, Ord e)
172−type TrivialE a b = I.FromNat (a + b) ~ Either (I.FromNat a) (I.FromNat b)
177+type TrivialE a b = I.FromNat (a + b) ~ Either (I.FromNat a) (I.FromNat b)
173−type TrivialP a b = I.FromNat (a * b) ~ I.FromNat (I.Count (I.FromNat a) * I.Count (I.FromNat b))
178+type TrivialP a b = I.FromNat (a * b) ~ I.FromNat (I.Count (I.FromNat a) * I.Count (I.FromNat b))
174−
175−-- | It isn't possible to implement the 'id' function so it's
176−-- implementation is 'undefined'. However 'comp' can be and this partial
177−-- class implementation exists just to make the code more readable.
178−--
179−-- Please use 'identity' instead.
180−instance (Num e) => C.Category (Matrix e) where
181− id = undefined
182− (.) = comp
183
179
184-- Primitives
180-- Primitives
185
181
186−empty :: Matrix e 0 0
187−empty = M I.Empty
188−
189one :: e -> Matrix e 1 1
182one :: e -> Matrix e 1 1
190one = M . I.One
183one = M . I.One
191
184
192−junc ::
185+join ::
193 (TrivialE a b) =>
186 (TrivialE a b) =>
194 Matrix e a rows ->
187 Matrix e a rows ->
195 Matrix e b rows ->
188 Matrix e b rows ->
196 Matrix e (a + b) rows
189 Matrix e (a + b) rows
197−junc (M a) (M b) = M (I.Junc a b)
190+join (M a) (M b) = M (I.Join a b)
198
191
199infixl 3 |||
192infixl 3 |||
200(|||) ::
193(|||) ::
@@ -202,14 +195,14 @@ infixl 3 |||
202 Matrix e a rows ->
195 Matrix e a rows ->
203 Matrix e b rows ->
196 Matrix e b rows ->
204 Matrix e (a + b) rows
197 Matrix e (a + b) rows
205−(|||) = junc
198+(|||) = join
206
199
207−split ::
200+fork ::
208 (TrivialE a b) =>
201 (TrivialE a b) =>
209 Matrix e cols a ->
202 Matrix e cols a ->
210 Matrix e cols b ->
203 Matrix e cols b ->
211 Matrix e cols (a + b)
204 Matrix e cols (a + b)
212−split (M a) (M b) = M (I.Split a b)
205+fork (M a) (M b) = M (I.Fork a b)
213
206
214infixl 2 ===
207infixl 2 ===
215(===) ::
208(===) ::
@@ -217,43 +210,45 @@ infixl 2 ===
217 Matrix e cols a ->
210 Matrix e cols a ->
218 Matrix e cols b ->
211 Matrix e cols b ->
219 Matrix e cols (a + b)
212 Matrix e cols (a + b)
220−(===) = split
213+(===) = fork
221
214
222-- Construction
215-- Construction
223
216
224−fromLists :: (FromListsN e cols rows) => [[e]] -> Matrix e cols rows
217+fromLists :: (FLN e cols rows) => [[e]] -> Matrix e cols rows
225fromLists = M . I.fromLists
218fromLists = M . I.fromLists
226
219
220+-- | Matrix builder function. Constructs a matrix provided with
221+-- a construction function that operates with indices.
227−matrixBuilder ::
222+matrixBuilder' ::
228− (FromListsN e cols rows, CountableN cols, CountableN rows)
223+ (FLN e cols rows, CountableN cols, CountableN rows)
229 => ((Int, Int) -> e) -> Matrix e cols rows
224 => ((Int, Int) -> e) -> Matrix e cols rows
230−matrixBuilder = M . I.matrixBuilder
225+matrixBuilder' = M . I.matrixBuilder'
231
226
232−col :: (I.FromLists e () (I.FromNat rows)) => [e] -> Matrix e 1 rows
227+col :: (I.FL () (I.FromNat rows)) => [e] -> Matrix e 1 rows
233col = M . I.col
228col = M . I.col
234
229
235−row :: (I.FromLists e (I.FromNat cols) ()) => [e] -> Matrix e cols 1
230+row :: (I.FL (I.FromNat cols) ()) => [e] -> Matrix e cols 1
236row = M . I.row
231row = M . I.row
237
232
238−fromF ::
233+fromF' ::
239 ( Liftable e a b,
234 ( Liftable e a b,
240 CountableN cols,
235 CountableN cols,
241 CountableN rows,
236 CountableN rows,
242− FromListsN e rows cols
237+ FLN e rows cols
243 ) =>
238 ) =>
244 (a -> b) ->
239 (a -> b) ->
245 Matrix e cols rows
240 Matrix e cols rows
246−fromF = M . I.fromF
241+fromF' = M . I.fromF'
247
242
248−fromF' ::
243+fromF ::
249 ( Liftable e a b,
244 ( Liftable e a b,
250 CountableNz a,
245 CountableNz a,
251 CountableNz b,
246 CountableNz b,
252− FromListsNz e b a
247+ FLNz e b a
253 ) =>
248 ) =>
254 (a -> b) ->
249 (a -> b) ->
255 Matrix e (I.Count a) (I.Count b)
250 Matrix e (I.Count a) (I.Count b)
256−fromF' = undefined -- M . I.fromF'
251+fromF = undefined -- M . I.fromF
257
252
258-- Conversion
253-- Conversion
259
254
@@ -266,21 +261,21 @@ toList (M m) = I.toList m
266-- Zeros Matrix
261-- Zeros Matrix
267
262
268zeros ::
263zeros ::
269− (Num e, FromListsN e cols rows, CountableN cols, CountableN rows) =>
264+ (Num e, FLN e cols rows, CountableN cols, CountableN rows) =>
270 Matrix e cols rows
265 Matrix e cols rows
271zeros = M I.zeros
266zeros = M I.zeros
272
267
273-- Ones Matrix
268-- Ones Matrix
274
269
275ones ::
270ones ::
276− (Num e, FromListsN e cols rows, CountableN cols, CountableN rows) =>
271+ (Num e, FLN e cols rows, CountableN cols, CountableN rows) =>
277 Matrix e cols rows
272 Matrix e cols rows
278ones = M I.ones
273ones = M I.ones
279
274
280-- Const Matrix
275-- Const Matrix
281
276
282constant ::
277constant ::
283− (Num e, FromListsN e cols rows, CountableN cols, CountableN rows) =>
278+ (Num e, FLN e cols rows, CountableN cols, CountableN rows) =>
284 e ->
279 e ->
285 Matrix e cols rows
280 Matrix e cols rows
286constant = M . I.constant
281constant = M . I.constant
@@ -289,27 +284,41 @@ constant = M . I.constant
289
284
290bang ::
285bang ::
291 forall e cols.
286 forall e cols.
292− (Num e, Enum e, I.FromLists e (I.FromNat cols) (), CountableN cols) =>
287+ (Num e, Enum e, I.FL (I.FromNat cols) (), CountableN cols) =>
293 Matrix e cols 1
288 Matrix e cols 1
294bang = M I.bang
289bang = M I.bang
295
290
296−-- Identity Matrix
291+-- iden Matrix
297
292
298−identity ::
293+iden ::
299− (Num e, FromListsN e cols cols, CountableN cols) =>
294+ (Num e, FLN e cols cols, CountableN cols) =>
300 Matrix e cols cols
295 Matrix e cols cols
301−identity = M I.identity
296+iden = M I.iden
302
297
303-- Matrix composition (MMM)
298-- Matrix composition (MMM)
304
299
305comp :: (Num e) => Matrix e cr rows -> Matrix e cols cr -> Matrix e cols rows
300comp :: (Num e) => Matrix e cr rows -> Matrix e cols cr -> Matrix e cols rows
306comp (M a) (M b) = M (I.comp a b)
301comp (M a) (M b) = M (I.comp a b)
307
302
303+-- Scalar multiplication of matrices
304+
305+infixl 7 .|
306+-- | Scalar multiplication of matrices.
307+(.|) :: Num e => e -> Matrix e cols rows -> Matrix e cols rows
308+(.|) e (M m) = M (e I..| m)
309+
310+-- Scalar division of matrices
311+
312+infixl 7 ./
313+-- | Scalar multiplication of matrices.
314+(./) :: Fractional e => Matrix e cols rows -> e -> Matrix e cols rows
315+(./) (M m) e = M (m I../ e)
316+
308p1 ::
317p1 ::
309 ( Num e,
318 ( Num e,
310− CountableDimensionsN n m,
319+ CountableDimsN n m,
311− FromListsN e n m,
320+ FLN e n m,
312− FromListsN e m m,
321+ FLN e m m,
313 TrivialE m n
322 TrivialE m n
314 ) =>
323 ) =>
315 Matrix e (m + n) m
324 Matrix e (m + n) m
@@ -317,9 +326,9 @@ p1 = M I.p1
317
326
318p2 ::
327p2 ::
319 ( Num e,
328 ( Num e,
320− CountableDimensionsN n m,
329+ CountableDimsN n m,
321− FromListsN e m n,
330+ FLN e m n,
322− FromListsN e n n,
331+ FLN e n n,
323 TrivialE m n
332 TrivialE m n
324 ) =>
333 ) =>
325 Matrix e (m + n) n
334 Matrix e (m + n) n
@@ -329,9 +338,9 @@ p2 = M I.p2
329
338
330i1 ::
339i1 ::
331 ( Num e,
340 ( Num e,
332− CountableDimensionsN n rows,
341+ CountableDimsN n rows,
333− FromListsN e n rows,
342+ FLN e n rows,
334− FromListsN e rows rows,
343+ FLN e rows rows,
335 TrivialE rows n
344 TrivialE rows n
336 ) =>
345 ) =>
337 Matrix e rows (rows + n)
346 Matrix e rows (rows + n)
@@ -339,9 +348,9 @@ i1 = tr p1
339
348
340i2 ::
349i2 ::
341 ( Num e,
350 ( Num e,
342− CountableDimensionsN rows m,
351+ CountableDimsN rows m,
343− FromListsN e m rows,
352+ FLN e m rows,
344− FromListsN e rows rows,
353+ FLN e rows rows,
345 TrivialE m rows
354 TrivialE m rows
346 ) =>
355 ) =>
347 Matrix e rows (m + rows)
356 Matrix e rows (m + rows)
@@ -355,16 +364,16 @@ rows (M m) = I.rows m
355columns :: (CountableN cols) => Matrix e cols rows -> Int
364columns :: (CountableN cols) => Matrix e cols rows -> Int
356columns (M m) = I.columns m
365columns (M m) = I.columns m
357
366
358−-- | Coproduct Bifunctor
359infixl 5 -|-
367infixl 5 -|-
360
368
369+-- | Coproduct Bifunctor (Direct sum)
361(-|-) ::
370(-|-) ::
362 ( Num e,
371 ( Num e,
363− CountableDimensionsN j k,
372+ CountableDimsN j k,
364− FromListsN e k k,
373+ FLN e k k,
365− FromListsN e j k,
374+ FLN e j k,
366− FromListsN e k j,
375+ FLN e k j,
367− FromListsN e j j,
376+ FLN e j j,
368 TrivialE n m,
377 TrivialE n m,
369 TrivialE k j
378 TrivialE k j
370 ) =>
379 ) =>
@@ -373,40 +382,42 @@ infixl 5 -|-
373 Matrix e (n + m) (k + j)
382 Matrix e (n + m) (k + j)
374(-|-) (M a) (M b) = M ((I.-|-) a b)
383(-|-) (M a) (M b) = M ((I.-|-) a b)
375
384
376−-- | Khatri Rao Product and projections
385+-- | Khatri Rao Product first projection
377−kp1 ::
386+fstM ::
378 forall e m k .
387 forall e m k .
379 ( Num e,
388 ( Num e,
380− CountableDimensionsN m k,
389+ CountableDimsN m k,
381 CountableN (m * k),
390 CountableN (m * k),
382− FromListsN e (m * k) m,
391+ FLN e (m * k) m,
383 TrivialP m k
392 TrivialP m k
384 ) => Matrix e (m * k) m
393 ) => Matrix e (m * k) m
385−kp1 = M (I.kp1 @e @(I.FromNat m) @(I.FromNat k))
394+fstM = M (I.fstM @e @(I.FromNat m) @(I.FromNat k))
386
395
387−kp2 ::
396+-- | Khatri Rao Product second projection
397+sndM ::
388 forall e m k.
398 forall e m k.
389 ( Num e,
399 ( Num e,
390− CountableDimensionsN k m,
400+ CountableDimsN k m,
391− FromListsN e (m * k) k,
401+ FLN e (m * k) k,
392 CountableN (m * k),
402 CountableN (m * k),
393 TrivialP m k
403 TrivialP m k
394 ) => Matrix e (m * k) k
404 ) => Matrix e (m * k) k
395−kp2 = M (I.kp2 @e @(I.FromNat m) @(I.FromNat k))
405+sndM = M (I.sndM @e @(I.FromNat m) @(I.FromNat k))
396
406
397−khatri ::
407+-- | Khatri Rao Product
408+kr ::
398 forall e cols a b.
409 forall e cols a b.
399 ( Num e,
410 ( Num e,
400− CountableDimensionsN a b,
411+ CountableDimsN a b,
401 CountableN (a * b),
412 CountableN (a * b),
402− FromListsN e (a * b) a,
413+ FLN e (a * b) a,
403− FromListsN e (a * b) b,
414+ FLN e (a * b) b,
404 TrivialP a b
415 TrivialP a b
405 ) => Matrix e cols a -> Matrix e cols b -> Matrix e cols (a * b)
416 ) => Matrix e cols a -> Matrix e cols b -> Matrix e cols (a * b)
406−khatri a b =
417+kr a b =
407− let kp1' = kp1 @e @a @b
418+ let fstM' = fstM @e @a @b
408− kp2' = kp2 @e @a @b
419+ sndM' = sndM @e @a @b
409− in comp (tr kp1') a * comp (tr kp2') b
420+ in comp (tr fstM') a * comp (tr sndM') b
410
421
411-- | Product Bifunctor (Kronecker)
422-- | Product Bifunctor (Kronecker)
412infixl 4 ><
423infixl 4 ><
@@ -414,28 +425,28 @@ infixl 4 ><
414(><) ::
425(><) ::
415 forall e m p n q.
426 forall e m p n q.
416 ( Num e,
427 ( Num e,
417− CountableDimensionsN m n,
428+ CountableDimsN m n,
418− CountableDimensionsN p q,
429+ CountableDimsN p q,
419− CountableDimensionsN (m * n) (p * q),
430+ CountableDimsN (m * n) (p * q),
420− FromListsN e (m * n) m,
431+ FLN e (m * n) m,
421− FromListsN e (m * n) n,
432+ FLN e (m * n) n,
422− FromListsN e (p * q) p,
433+ FLN e (p * q) p,
423− FromListsN e (p * q) q,
434+ FLN e (p * q) q,
424 TrivialP m n,
435 TrivialP m n,
425 TrivialP p q
436 TrivialP p q
426 ) => Matrix e m p -> Matrix e n q -> Matrix e (m * n) (p * q)
437 ) => Matrix e m p -> Matrix e n q -> Matrix e (m * n) (p * q)
427(><) a b =
438(><) a b =
428− let kp1' = kp1 @e @m @n
439+ let fstM' = fstM @e @m @n
429− kp2' = kp2 @e @m @n
440+ sndM' = sndM @e @m @n
430− in khatri (comp a kp1') (comp b kp2')
441+ in kr (comp a fstM') (comp b sndM')
431
442
432−-- | Matrix abide Junc Split
443+-- | Matrix abide Join Fork
433−abideJS :: Matrix e cols rows -> Matrix e cols rows
444+abideJF :: Matrix e cols rows -> Matrix e cols rows
434−abideJS (M m) = M (I.abideJS m)
445+abideJF (M m) = M (I.abideJF m)
435
446
436−-- | Matrix abide Split Junc
447+-- | Matrix abide Fork Join
437−abideSJ :: Matrix e cols rows -> Matrix e cols rows
448+abideFJ :: Matrix e cols rows -> Matrix e cols rows
438−abideSJ (M m) = M (I.abideSJ m)
449+abideFJ (M m) = M (I.abideFJ m)
439
450
440-- | Matrix transposition
451-- | Matrix transposition
441tr :: Matrix e cols rows -> Matrix e rows cols
452tr :: Matrix e cols rows -> Matrix e rows cols
@@ -444,7 +455,7 @@ tr (M m) = M (I.tr m)
444-- Selective 'select' operator
455-- Selective 'select' operator
445select ::
456select ::
446 ( Num e,
457 ( Num e,
447− FromListsN e rows1 rows1,
458+ FLN e rows1 rows1,
448 CountableN rows1,
459 CountableN rows1,
449 I.FromNat rows2 ~ I.FromNat rows1,
460 I.FromNat rows2 ~ I.FromNat rows1,
450 I.FromNat cols1 ~ I.FromNat cols2,
461 I.FromNat cols1 ~ I.FromNat cols2,
@@ -457,9 +468,9 @@ select (M m) (M y) = M (I.select m y)
457cond ::
468cond ::
458 ( I.FromNat (I.Count (I.FromNat cols)) ~ I.FromNat cols,
469 ( I.FromNat (I.Count (I.FromNat cols)) ~ I.FromNat cols,
459 CountableN cols,
470 CountableN cols,
460− I.FromLists e () (I.FromNat cols),
471+ I.FL () (I.FromNat cols),
461− I.FromLists e (I.FromNat cols) (),
472+ I.FL (I.FromNat cols) (),
462− FromListsN e cols cols,
473+ FLN e cols cols,
463 Liftable e a Bool
474 Liftable e a Bool
464 )
475 )
465 =>
476 =>
@@ -468,8 +479,12 @@ cond p (M a) (M b) = M (I.cond p a b)
468
479
469-- Pretty print
480-- Pretty print
470
481
471−pretty :: (CountableN cols, Show e) => Matrix e cols rows -> String
482+pretty :: (CountableDimsN cols rows, Show e) => Matrix e cols rows -> String
472pretty (M m) = I.pretty m
483pretty (M m) = I.pretty m
473
484
474−prettyPrint :: (CountableN cols, Show e) => Matrix e cols rows -> IO ()
485+prettyPrint :: (CountableDimsN cols rows, Show e) => Matrix e cols rows -> IO ()
475prettyPrint (M m) = I.prettyPrint m
486prettyPrint (M m) = I.prettyPrint m
487+
488+-- | Zip two matrices with a given binary function
489+zipWithM :: (e -> f -> g) -> Matrix e cols rows -> Matrix f cols rows -> Matrix g cols rows
490+zipWithM f (M a) (M b) = M (I.zipWithM f a b)
src/LAoP/Matrix/Type.hs+231−175
@@ -1,11 +1,11 @@
1{-# LANGUAGE ConstraintKinds #-}
1{-# LANGUAGE ConstraintKinds #-}
2+{-# LANGUAGE TypeFamilies #-}
2{-# LANGUAGE AllowAmbiguousTypes #-}
3{-# LANGUAGE AllowAmbiguousTypes #-}
3{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE DerivingVia #-}
5{-# LANGUAGE DerivingVia #-}
5{-# LANGUAGE FlexibleContexts #-}
6{-# LANGUAGE FlexibleContexts #-}
6{-# LANGUAGE FlexibleInstances #-}
7{-# LANGUAGE FlexibleInstances #-}
7{-# LANGUAGE GADTs #-}
8{-# LANGUAGE GADTs #-}
8−{-# LANGUAGE KindSignatures #-}
9{-# LANGUAGE MultiParamTypeClasses #-}
9{-# LANGUAGE MultiParamTypeClasses #-}
10{-# LANGUAGE NoStarIsType #-}
10{-# LANGUAGE NoStarIsType #-}
11{-# LANGUAGE RankNTypes #-}
11{-# LANGUAGE RankNTypes #-}
@@ -58,10 +58,10 @@ module LAoP.Matrix.Type
58
58
59 -- * Constraint type aliases
59 -- * Constraint type aliases
60 Countable,
60 Countable,
61− CountableDimensions,
61+ CountableDims,
62 CountableN,
62 CountableN,
63− CountableDimensionsN,
63+ CountableDimsN,
64− FromListsN,
64+ FLN,
65 Liftable,
65 Liftable,
66 Trivial,
66 Trivial,
67 TrivialP,
67 TrivialP,
@@ -71,10 +71,9 @@ module LAoP.Matrix.Type
71 One,
71 One,
72
72
73 -- * Primitives
73 -- * Primitives
74− empty,
75 one,
74 one,
76− junc,
75+ join,
77− split,
76+ fork,
78
77
79 -- * Auxiliary type families
78 -- * Auxiliary type families
80 I.FromNat,
79 I.FromNat,
@@ -86,6 +85,7 @@ module LAoP.Matrix.Type
86 fromLists,
85 fromLists,
87 toLists,
86 toLists,
88 toList,
87 toList,
88+ matrixBuilder',
89 matrixBuilder,
89 matrixBuilder,
90 row,
90 row,
91 col,
91 col,
@@ -97,14 +97,15 @@ module LAoP.Matrix.Type
97
97
98 -- * Functor instance equivalent function
98 -- * Functor instance equivalent function
99 fmapM,
99 fmapM,
100+ bimapM,
100
101
101 -- * Applicative/Monoidal instance equivalent functions
102 -- * Applicative/Monoidal instance equivalent functions
102 unitM,
103 unitM,
103 multM,
104 multM,
104
105
105 -- * Selective equivalent instance function
106 -- * Selective equivalent instance function
106− selectM,
107+ selectM,
107−
108+
108 -- * Monad equivalent instance function
109 -- * Monad equivalent instance function
109 returnM,
110 returnM,
110 bindM,
111 bindM,
@@ -112,25 +113,34 @@ module LAoP.Matrix.Type
112 -- * Misc
113 -- * Misc
113 -- ** Get dimensions
114 -- ** Get dimensions
114 columns,
115 columns,
116+ columns',
115 rows,
117 rows,
118+ rows',
116
119
117 -- ** Matrix Transposition
120 -- ** Matrix Transposition
118 tr,
121 tr,
119
122
123+ -- ** Scalar multiplication/division of matrices
124+ (.|),
125+ (./),
126+
120 -- ** McCarthy's Conditional
127 -- ** McCarthy's Conditional
121 cond,
128 cond,
122
129
123 -- ** Matrix "abiding"
130 -- ** Matrix "abiding"
124− abideJS,
131+ abideJF,
125− abideSJ,
132+ abideFJ,
133+
134+ -- ** Zip Matrices
135+ zipWithM,
126
136
127 -- * Biproduct approach
137 -- * Biproduct approach
128− -- ** Split
138+ -- ** Fork
129 (===),
139 (===),
130 -- *** Projections
140 -- *** Projections
131 p1,
141 p1,
132 p2,
142 p2,
133− -- ** Junc
143+ -- ** Join
134 (|||),
144 (|||),
135 -- *** Injections
145 -- *** Injections
136 i1,
146 i1,
@@ -144,11 +154,11 @@ module LAoP.Matrix.Type
144 -- | Note that given the restrictions imposed it is not possible to
154 -- | Note that given the restrictions imposed it is not possible to
145 -- implement the standard type classes present in standard Haskell.
155 -- implement the standard type classes present in standard Haskell.
146 -- *** Matrix pairing projections
156 -- *** Matrix pairing projections
147− kp1,
157+ fstM,
148− kp2,
158+ sndM,
149
159
150 -- *** Matrix pairing
160 -- *** Matrix pairing
151− khatri,
161+ kr,
152
162
153 -- * Matrix composition and lifting
163 -- * Matrix composition and lifting
154
164
@@ -156,10 +166,10 @@ module LAoP.Matrix.Type
156
166
157 -- | Note that given the restrictions imposed it is not possible to
167 -- | Note that given the restrictions imposed it is not possible to
158 -- implement the standard type classes present in standard Haskell.
168 -- implement the standard type classes present in standard Haskell.
159− identity,
169+ iden,
160 comp,
170 comp,
161− fromF,
162 fromF',
171 fromF',
172+ fromF,
163
173
164 -- * Relation
174 -- * Relation
165 toRel,
175 toRel,
@@ -173,35 +183,44 @@ where
173import Data.Void
183import Data.Void
174import Data.Proxy
184import Data.Proxy
175import Data.Kind
185import Data.Kind
176−import GHC.TypeLits
186+import GHC.TypeLits
177import Control.DeepSeq
187import Control.DeepSeq
178import LAoP.Utils
188import LAoP.Utils
179−import qualified Control.Category as C
180import qualified LAoP.Matrix.Internal as I
189import qualified LAoP.Matrix.Internal as I
190+import Prelude hiding (id, (.))
181
191
182newtype Matrix e (cols :: Type) (rows :: Type) = M (I.Matrix e (I.Normalize cols) (I.Normalize rows))
192newtype Matrix e (cols :: Type) (rows :: Type) = M (I.Matrix e (I.Normalize cols) (I.Normalize rows))
183 deriving (Show, Num, Eq, Ord, NFData) via (I.Matrix e (I.Normalize cols) (I.Normalize rows))
193 deriving (Show, Num, Eq, Ord, NFData) via (I.Matrix e (I.Normalize cols) (I.Normalize rows))
184
194
185-- | Constraint type synonyms to keep the type signatures less convoluted
195-- | Constraint type synonyms to keep the type signatures less convoluted
186−type Countable a = KnownNat (I.Count a)
196+type Countable a = KnownNat (I.Count a)
187−type CountableDimensions a b = (Countable a, Countable b)
197+type CountableDims a b = (Countable a, Countable b)
188−type CountableN a = KnownNat (I.Count (I.Normalize a))
198+type CountableN a = KnownNat (I.Count (I.Normalize a))
189−type CountableDimensionsN a b = (CountableN a, CountableN b)
199+type CountableDimsN a b = (CountableN a, CountableN b)
190−type FromListsN e a b = I.FromLists e (I.Normalize a) (I.Normalize b)
200+type FLN a b = I.FromLists (I.Normalize a) (I.Normalize b)
191−type Liftable e a b = (Bounded a, Bounded b, Enum a, Enum b, Eq b, Num e, Ord e)
201+type Liftable e a b = (Bounded a, Bounded b, Enum a, Enum b, Eq b, Num e, Ord e)
192−type Trivial a = I.Normalize (I.Normalize a) ~ I.Normalize (I.Normalize (I.Normalize a))
202+type Trivial a = I.Normalize (I.Normalize a) ~ I.Normalize (I.Normalize (I.Normalize a))
193−type Trivial2 a = I.Normalize a ~ I.Normalize (I.Normalize a)
203+type Trivial2 a = I.Normalize a ~ I.Normalize (I.Normalize a)
194−type Trivial3 a = I.FromNat (I.Count (I.Normalize (I.Normalize a))) ~ I.Normalize (I.Normalize a)
204+type Trivial3 a = I.FromNat (I.Count (I.Normalize (I.Normalize a))) ~ I.Normalize (I.Normalize a)
195−type TrivialP a b = I.Normalize (a, b) ~ I.Normalize (I.Normalize a, I.Normalize b)
205+type TrivialP a b = I.Normalize (a, b) ~ I.Normalize (I.Normalize a, I.Normalize b)
196−
206+
197−-- | It isn't possible to implement the 'id' function so it's
207+-- | It is possible to implement a constrained version of the category type
198−-- implementation is 'undefined'. However 'comp' can be and this partial
208+-- class.
199−-- class implementation exists just to make the code more readable.
200−--
201−-- Please use 'identity' instead.
202−instance (Num e) => C.Category (Matrix e) where
209+instance (Num e) => Category (Matrix e) where
203− id = undefined
210+ type Object (Matrix e) a = (FLN a a, CountableN a)
211+ id = iden
204− (.) = comp
212+ (.) = comp
213+
214+-- | Bifunctor equivalent function
215+bimapM ::
216+ ( Liftable e a b,
217+ Liftable e c d,
218+ CountableDimsN a c,
219+ CountableDimsN b d,
220+ FLN d c,
221+ FLN b a
222+ ) => (a -> b) -> (c -> d) -> Matrix e a c -> Matrix e b d
223+bimapM f g m = fromF g . m . tr (fromF f)
205
224
206-- | Zero type alias
225-- | Zero type alias
207type Zero = Void
226type Zero = Void
@@ -211,78 +230,74 @@ type One = ()
211
230
212-- Primitives
231-- Primitives
213
232
214−-- | Empty matrix constructor
215−empty :: Matrix e Zero Zero
216−empty = M I.Empty
217−
218-- | Unit matrix constructor
233-- | Unit matrix constructor
219one :: e -> Matrix e One One
234one :: e -> Matrix e One One
220one = M . I.One
235one = M . I.One
221
236
222−-- | Matrix 'Junc' constructor
237+-- | Matrix 'Join' constructor
223−junc ::
238+join ::
224 Matrix e a rows ->
239 Matrix e a rows ->
225 Matrix e b rows ->
240 Matrix e b rows ->
226 Matrix e (Either a b) rows
241 Matrix e (Either a b) rows
227−junc (M a) (M b) = M (I.Junc a b)
242+join (M a) (M b) = M (I.Join a b)
228
243
229infixl 3 |||
244infixl 3 |||
230−-- | Matrix 'Junc' constructor
245+-- | Matrix 'Join' constructor
231(|||) ::
246(|||) ::
232 Matrix e a rows ->
247 Matrix e a rows ->
233 Matrix e b rows ->
248 Matrix e b rows ->
234 Matrix e (Either a b) rows
249 Matrix e (Either a b) rows
235−(|||) = junc
250+(|||) = join
236
251
237−-- | Matrix 'Split' constructor
252+-- | Matrix 'Fork' constructor
238−split ::
253+fork ::
239 Matrix e cols a ->
254 Matrix e cols a ->
240 Matrix e cols b ->
255 Matrix e cols b ->
241 Matrix e cols (Either a b)
256 Matrix e cols (Either a b)
242−split (M a) (M b) = M (I.Split a b)
257+fork (M a) (M b) = M (I.Fork a b)
243
258
244infixl 2 ===
259infixl 2 ===
245−-- | Matrix 'Split' constructor
260+-- | Matrix 'Fork' constructor
246(===) ::
261(===) ::
247 Matrix e cols a ->
262 Matrix e cols a ->
248 Matrix e cols b ->
263 Matrix e cols b ->
249 Matrix e cols (Either a b)
264 Matrix e cols (Either a b)
250−(===) = split
265+(===) = fork
251
266
252-- Functor hierarchy
267-- Functor hierarchy
253
268
254-- | Functor instance equivalent function
269-- | Functor instance equivalent function
255−fmapM ::
270+fmapM ::
256 ( Liftable e a b,
271 ( Liftable e a b,
257− CountableDimensionsN a b,
272+ CountableDimsN a b,
258− FromListsN e b a
273+ FLN b a
259 )
274 )
260 =>
275 =>
261 (a -> b) -> Matrix e c a -> Matrix e c b
276 (a -> b) -> Matrix e c a -> Matrix e c b
262−fmapM f m = fromF' f `comp` m
277+fmapM f m = fromF f . m
263
278
264-- | Applicative instance equivalent 'unit' function,
279-- | Applicative instance equivalent 'unit' function,
265unitM :: (Num e) => Matrix e () ()
280unitM :: (Num e) => Matrix e () ()
266unitM = one 1
281unitM = one 1
267
282
268-- | Applicative instance equivalent 'unit' function,
283-- | Applicative instance equivalent 'unit' function,
269−multM ::
284+multM ::
270− ( CountableDimensionsN a b,
285+ ( CountableDimsN a b,
271 CountableN (a, b),
286 CountableN (a, b),
272 Num e,
287 Num e,
273− FromListsN e (a, b) a,
288+ FLN (a, b) a,
274− FromListsN e (a, b) b,
289+ FLN (a, b) b,
275 TrivialP a b
290 TrivialP a b
276 ) => Matrix e c a -> Matrix e c b -> Matrix e c (a, b)
291 ) => Matrix e c a -> Matrix e c b -> Matrix e c (a, b)
277−multM = khatri
292+multM = kr
278
293
279-- | Monad instance equivalent 'return' function,
294-- | Monad instance equivalent 'return' function,
280−returnM ::
295+returnM ::
281− forall e a .
296+ forall e a .
282 ( Num e,
297 ( Num e,
283 Enum e,
298 Enum e,
284 Enum a,
299 Enum a,
285− FromListsN e () a,
300+ FLN () a,
286 Countable a
301 Countable a
287 ) => a -> Matrix e One a
302 ) => a -> Matrix e One a
288returnM a = col l
303returnM a = col l
@@ -299,51 +314,64 @@ bindM = flip comp
299
314
300-- | Build a matrix out of a list of list of elements. Throws a runtime
315-- | Build a matrix out of a list of list of elements. Throws a runtime
301-- error if the dimensions do not match.
316-- error if the dimensions do not match.
302−fromLists :: (FromListsN e cols rows) => [[e]] -> Matrix e cols rows
317+fromLists :: (FLN cols rows) => [[e]] -> Matrix e cols rows
303fromLists = M . I.fromLists
318fromLists = M . I.fromLists
304
319
305-- | Matrix builder function. Constructs a matrix provided with
320-- | Matrix builder function. Constructs a matrix provided with
306−-- a construction function.
321+-- a construction function that operates with indices.
307−matrixBuilder ::
322+matrixBuilder' ::
308− (FromListsN e cols rows, CountableDimensionsN cols rows )
323+ (FLN cols rows, CountableDimsN cols rows )
309 => ((Int, Int) -> e) -> Matrix e cols rows
324 => ((Int, Int) -> e) -> Matrix e cols rows
310−matrixBuilder = M . I.matrixBuilder
325+matrixBuilder' = M . I.matrixBuilder'
326+
327+-- | Matrix builder function. Constructs a matrix provided with
328+-- a construction function that operates with arbitrary types.
329+matrixBuilder ::
330+ ( FLN a b,
331+ Enum a,
332+ Enum b,
333+ Bounded a,
334+ Bounded b,
335+ Eq a,
336+ Countable b
337+ ) => ((a, b) -> e) -> Matrix e a b
338+matrixBuilder f = M (I.matrixBuilder f)
311
339
312-- | Constructs a column vector matrix
340-- | Constructs a column vector matrix
313−col :: (FromListsN e () rows) => [e] -> Matrix e One rows
341+col :: (FLN () rows) => [e] -> Matrix e One rows
314col = M . I.col
342col = M . I.col
315
343
316-- | Constructs a row vector matrix
344-- | Constructs a row vector matrix
317−row :: (FromListsN e cols ()) => [e] -> Matrix e cols One
345+row :: (FLN cols ()) => [e] -> Matrix e cols One
318row = M . I.row
346row = M . I.row
319
347
320-- | Lifts functions to matrices with arbitrary dimensions.
348-- | Lifts functions to matrices with arbitrary dimensions.
321--
349--
322-- NOTE: Be careful to not ask for a matrix bigger than the cardinality of
350-- NOTE: Be careful to not ask for a matrix bigger than the cardinality of
323-- types @a@ or @b@ allows.
351-- types @a@ or @b@ allows.
324−fromF ::
352+fromF' ::
325 ( Liftable e a b,
353 ( Liftable e a b,
326− CountableDimensionsN cols rows,
354+ CountableDimsN cols rows,
327− FromListsN e rows cols
355+ FLN rows cols
328 ) =>
356 ) =>
329 (a -> b) -> Matrix e cols rows
357 (a -> b) -> Matrix e cols rows
330−fromF = M . I.fromF
358+fromF' = M . I.fromF'
331
359
332-- | Lifts functions to matrices with dimensions matching @a@ and @b@
360-- | Lifts functions to matrices with dimensions matching @a@ and @b@
333-- cardinality's.
361-- cardinality's.
334−fromF' ::
362+fromF ::
335 ( Liftable e a b,
363 ( Liftable e a b,
336− CountableDimensionsN a b,
364+ CountableDimsN a b,
337− FromListsN e b a
365+ FLN b a
338 ) =>
366 ) =>
339 (a -> b) -> Matrix e a b
367 (a -> b) -> Matrix e a b
340−fromF' = M . I.fromF'
368+fromF = M . I.fromF
341
369
342-- | Lifts relation functions to Boolean Matrix
370-- | Lifts relation functions to Boolean Matrix
343toRel ::
371toRel ::
344 ( Liftable (Natural 0 1) a b,
372 ( Liftable (Natural 0 1) a b,
345− CountableDimensionsN a b,
373+ CountableDims a b,
346− FromListsN (Natural 0 1) b a
374+ FLN b a
347 ) => (a -> b -> Bool) -> Matrix (Natural 0 1) a b
375 ) => (a -> b -> Bool) -> Matrix (Natural 0 1) a b
348toRel = M . I.toRel
376toRel = M . I.toRel
349
377
@@ -361,7 +389,7 @@ toList (M m) = I.toList m
361
389
362-- | The zero matrix. A matrix wholly filled with zeros.
390-- | The zero matrix. A matrix wholly filled with zeros.
363zeros ::
391zeros ::
364− (Num e, FromListsN e cols rows, CountableDimensionsN cols rows)
392+ (Num e, FLN cols rows, CountableDimsN cols rows)
365 => Matrix e cols rows
393 => Matrix e cols rows
366zeros = M I.zeros
394zeros = M I.zeros
367
395
@@ -371,7 +399,7 @@ zeros = M I.zeros
371--
399--
372-- Also known as T (Top) matrix.
400-- Also known as T (Top) matrix.
373ones ::
401ones ::
374− (Num e, FromListsN e cols rows, CountableDimensionsN cols rows)
402+ (Num e, FLN cols rows, CountableDimsN cols rows)
375 => Matrix e cols rows
403 => Matrix e cols rows
376ones = M I.ones
404ones = M I.ones
377
405
@@ -380,7 +408,7 @@ ones = M I.ones
380-- | The constant matrix constructor. A matrix wholly filled with a given
408-- | The constant matrix constructor. A matrix wholly filled with a given
381-- value.
409-- value.
382constant ::
410constant ::
383− (Num e, FromListsN e cols rows, CountableDimensionsN cols rows)
411+ (Num e, FLN cols rows, CountableDimsN cols rows)
384 => e -> Matrix e cols rows
412 => e -> Matrix e cols rows
385constant = M . I.constant
413constant = M . I.constant
386
414
@@ -389,30 +417,30 @@ constant = M . I.constant
389-- | The T (Top) row vector matrix.
417-- | The T (Top) row vector matrix.
390bang ::
418bang ::
391 forall e cols.
419 forall e cols.
392− (Num e, Enum e, FromListsN e cols (), CountableN cols) =>
420+ (Num e, Enum e, FLN cols (), CountableN cols) =>
393 Matrix e cols One
421 Matrix e cols One
394bang = M I.bang
422bang = M I.bang
395
423
396-- | Point constant relation
424-- | Point constant relation
397−point ::
425+point ::
398 ( Bounded a,
426 ( Bounded a,
399 Enum a,
427 Enum a,
400 Eq a,
428 Eq a,
401 Num e,
429 Num e,
402 Ord e,
430 Ord e,
403 CountableN a,
431 CountableN a,
404− FromListsN e a One
432+ FLN a One
405 ) => a -> Matrix e One a
433 ) => a -> Matrix e One a
406−point = fromF' . const
434+point = fromF . const
407
435
408−-- Identity Matrix
436+-- iden Matrix
409
437
410−-- | Identity matrix
438+-- | iden matrix
411−identity ::
439+iden ::
412− (Num e, FromListsN e a a, CountableN a) =>
440+ (Num e, FLN a a, CountableN a) =>
413 Matrix e a a
441 Matrix e a a
414−identity = M I.identity
442+iden = M I.iden
415−{-# NOINLINE identity #-}
443+{-# NOINLINE iden #-}
416
444
417-- Matrix composition (MMM)
445-- Matrix composition (MMM)
418
446
@@ -423,17 +451,31 @@ identity = M I.identity
423comp :: (Num e) => Matrix e cr rows -> Matrix e cols cr -> Matrix e cols rows
451comp :: (Num e) => Matrix e cr rows -> Matrix e cols cr -> Matrix e cols rows
424comp (M a) (M b) = M (I.comp a b)
452comp (M a) (M b) = M (I.comp a b)
425{-# NOINLINE comp #-}
453{-# NOINLINE comp #-}
426−{-# RULES
454+{-# RULES
427− "comp/identity1" forall m. comp m identity = m ;
455+ "comp/iden1" forall m. comp m iden = m ;
428− "comp/identity2" forall m. comp identity m = m
456+ "comp/iden2" forall m. comp iden m = m
429#-}
457#-}
430
458
459+-- Scalar multiplication of matrices
460+
461+infixl 7 .|
462+-- | Scalar multiplication of matrices.
463+(.|) :: Num e => e -> Matrix e cols rows -> Matrix e cols rows
464+(.|) e (M m) = M (e I..| m)
465+
466+-- Scalar division of matrices
467+
468+infixl 7 ./
469+-- | Scalar multiplication of matrices.
470+(./) :: Fractional e => Matrix e cols rows -> e -> Matrix e cols rows
471+(./) (M m) e = M (m I../ e)
472+
431-- | Biproduct first component projection
473-- | Biproduct first component projection
432p1 ::
474p1 ::
433 ( Num e,
475 ( Num e,
434− CountableDimensionsN n m,
476+ CountableDimsN n m,
435− FromListsN e n m,
477+ FLN n m,
436− FromListsN e m m
478+ FLN m m
437 ) =>
479 ) =>
438 Matrix e (Either m n) m
480 Matrix e (Either m n) m
439p1 = M I.p1
481p1 = M I.p1
@@ -441,9 +483,9 @@ p1 = M I.p1
441-- | Biproduct second component projection
483-- | Biproduct second component projection
442p2 ::
484p2 ::
443 ( Num e,
485 ( Num e,
444− CountableDimensionsN n m,
486+ CountableDimsN n m,
445− FromListsN e m n,
487+ FLN m n,
446− FromListsN e n n
488+ FLN n n
447 ) =>
489 ) =>
448 Matrix e (Either m n) n
490 Matrix e (Either m n) n
449p2 = M I.p2
491p2 = M I.p2
@@ -453,9 +495,9 @@ p2 = M I.p2
453-- | Biproduct first component injection
495-- | Biproduct first component injection
454i1 ::
496i1 ::
455 ( Num e,
497 ( Num e,
456− CountableDimensionsN n m,
498+ CountableDimsN n m,
457− FromListsN e n m,
499+ FLN n m,
458− FromListsN e m m
500+ FLN m m
459 ) =>
501 ) =>
460 Matrix e m (Either m n)
502 Matrix e m (Either m n)
461i1 = tr p1
503i1 = tr p1
@@ -463,9 +505,9 @@ i1 = tr p1
463-- | Biproduct second component injection
505-- | Biproduct second component injection
464i2 ::
506i2 ::
465 ( Num e,
507 ( Num e,
466− CountableDimensionsN n m,
508+ CountableDimsN n m,
467− FromListsN e m n,
509+ FLN m n,
468− FromListsN e n n
510+ FLN n n
469 ) =>
511 ) =>
470 Matrix e n (Either m n)
512 Matrix e n (Either m n)
471i2 = tr p2
513i2 = tr p2
@@ -474,24 +516,34 @@ i2 = tr p2
474
516
475-- | Obtain the number of rows.
517-- | Obtain the number of rows.
476--
518--
477−-- NOTE: The 'KnownNat' constaint is needed in order to obtain the
519+-- NOTE: The 'KnownNat' constraint is needed in order to obtain the
478−-- dimensions in constant time.
520+-- dimensions in constant time. For a version that doesn't require the
479−--
521+-- constraint see 'rows''.
480−-- TODO: A 'rows' function that does not need the 'KnownNat' constraint in
481−-- exchange for performance.
482rows :: (CountableN rows) => Matrix e cols rows -> Int
522rows :: (CountableN rows) => Matrix e cols rows -> Int
483rows (M m) = I.rows m
523rows (M m) = I.rows m
484
524
525+-- | Obtain the number of rows in an inefficient manner, but without any
526+-- constraints.
527+--
528+-- For a more efficient version see 'rows'.
529+rows' :: Matrix e cols rows -> Int
530+rows' (M m) = I.rows' m
531+
485-- | Obtain the number of columns.
532-- | Obtain the number of columns.
486−--
487−-- NOTE: The 'KnownNat' constaint is needed in order to obtain the
488−-- dimensions in constant time.
489--
533--
490−-- TODO: A 'columns' function that does not need the 'KnownNat' constraint in
534+-- NOTE: The 'KnownNat' constraint is needed in order to obtain the
491−-- exchange for performance.
535+-- dimensions in constant time. For a version that doesn't require the
536+-- constraint see 'columns''.
492columns :: (CountableN cols) => Matrix e cols rows -> Int
537columns :: (CountableN cols) => Matrix e cols rows -> Int
493columns (M m) = I.columns m
538columns (M m) = I.columns m
494
539
540+-- | Obtain the number of columns in an inefficient manner, but without any
541+-- constraints.
542+--
543+-- For a more efficient version see 'columns'.
544+columns' :: Matrix e cols rows -> Int
545+columns' (M m) = I.columns' m
546+
495-- Coproduct Bifunctor
547-- Coproduct Bifunctor
496
548
497infixl 5 -|-
549infixl 5 -|-
@@ -499,11 +551,11 @@ infixl 5 -|-
499-- | Matrix coproduct functor also known as matrix direct sum.
551-- | Matrix coproduct functor also known as matrix direct sum.
500(-|-) ::
552(-|-) ::
501 ( Num e,
553 ( Num e,
502− CountableDimensionsN j k,
554+ CountableDimsN j k,
503− FromListsN e k k,
555+ FLN k k,
504− FromListsN e j k,
556+ FLN j k,
505− FromListsN e k j,
557+ FLN k j,
506− FromListsN e j j
558+ FLN j j
507 ) =>
559 ) =>
508 Matrix e n k ->
560 Matrix e n k ->
509 Matrix e m j ->
561 Matrix e m j ->
@@ -513,98 +565,98 @@ infixl 5 -|-
513-- Khatri Rao Product and projections
565-- Khatri Rao Product and projections
514
566
515-- | Khatri Rao product first component projection matrix.
567-- | Khatri Rao product first component projection matrix.
516−kp1 ::
568+fstM ::
517 forall e m k .
569 forall e m k .
518 ( Num e,
570 ( Num e,
519− CountableDimensionsN m k,
571+ CountableDimsN m k,
520 CountableN (m, k),
572 CountableN (m, k),
521− FromListsN e (m, k) m,
573+ FLN (m, k) m,
522 TrivialP m k
574 TrivialP m k
523 ) => Matrix e (m, k) m
575 ) => Matrix e (m, k) m
524−kp1 = M (I.kp1 @e @(I.Normalize m) @(I.Normalize k))
576+fstM = M (I.fstM @e @(I.Normalize m) @(I.Normalize k))
525
577
526-- | Khatri Rao product second component projection matrix.
578-- | Khatri Rao product second component projection matrix.
527−kp2 ::
579+sndM ::
528 forall e m k.
580 forall e m k.
529 ( Num e,
581 ( Num e,
530− CountableDimensionsN k m,
582+ CountableDimsN k m,
531 CountableN (m, k),
583 CountableN (m, k),
532− FromListsN e (m, k) k,
584+ FLN (m, k) k,
533 TrivialP m k
585 TrivialP m k
534 ) => Matrix e (m, k) k
586 ) => Matrix e (m, k) k
535−kp2 = M (I.kp2 @e @(I.Normalize m) @(I.Normalize k))
587+sndM = M (I.sndM @e @(I.Normalize m) @(I.Normalize k))
536
588
537-- | Khatri Rao Matrix product also known as matrix pairing.
589-- | Khatri Rao Matrix product also known as matrix pairing.
538--
590--
539-- NOTE: That this is not a true categorical product, see for instance:
591-- NOTE: That this is not a true categorical product, see for instance:
540−--
592+--
541-- @
593-- @
542−-- | kp1 `comp` khatri a b == a
594+-- | fstM . kr a b == a
543−-- khatri a b ==> |
595+-- kr a b ==> |
544−-- | kp2 `comp` khatri a b == b
596+-- | sndM . kr a b == b
545-- @
597-- @
546--
598--
547-- __Emphasis__ on the implication symbol.
599-- __Emphasis__ on the implication symbol.
548−khatri ::
600+kr ::
549 forall e cols a b.
601 forall e cols a b.
550 ( Num e,
602 ( Num e,
551− CountableDimensionsN a b,
603+ CountableDimsN a b,
552 CountableN (a, b),
604 CountableN (a, b),
553− FromListsN e (a, b) a,
605+ FLN (a, b) a,
554− FromListsN e (a, b) b,
606+ FLN (a, b) b,
555 TrivialP a b
607 TrivialP a b
556 ) => Matrix e cols a -> Matrix e cols b -> Matrix e cols (a, b)
608 ) => Matrix e cols a -> Matrix e cols b -> Matrix e cols (a, b)
557−khatri a b =
609+kr a b =
558− let kp1' = kp1 @e @a @b
610+ let fstM' = fstM @e @a @b
559− kp2' = kp2 @e @a @b
611+ sndM' = sndM @e @a @b
560− in comp (tr kp1') a * comp (tr kp2') b
612+ in comp (tr fstM') a * comp (tr sndM') b
561
613
562-- Product Bifunctor (Kronecker)
614-- Product Bifunctor (Kronecker)
563
615
564infixl 4 ><
616infixl 4 ><
565
617
566−-- | Matrix product functor also known as kronecker product
618+-- | Matrix product functor also known as Kronecker product
567(><) ::
619(><) ::
568 forall e m p n q.
620 forall e m p n q.
569 ( Num e,
621 ( Num e,
570− CountableDimensionsN m n,
622+ CountableDimsN m n,
571− CountableDimensionsN p q,
623+ CountableDimsN p q,
572− CountableDimensionsN (m, n) (p, q),
624+ CountableDimsN (m, n) (p, q),
573− FromListsN e (m, n) m,
625+ FLN (m, n) m,
574− FromListsN e (m, n) n,
626+ FLN (m, n) n,
575− FromListsN e (p, q) p,
627+ FLN (p, q) p,
576− FromListsN e (p, q) q,
628+ FLN (p, q) q,
577 TrivialP m n,
629 TrivialP m n,
578 TrivialP p q
630 TrivialP p q
579 ) => Matrix e m p -> Matrix e n q -> Matrix e (m, n) (p, q)
631 ) => Matrix e m p -> Matrix e n q -> Matrix e (m, n) (p, q)
580(><) a b =
632(><) a b =
581− let kp1' = kp1 @e @m @n
633+ let fstM' = fstM @e @m @n
582− kp2' = kp2 @e @m @n
634+ sndM' = sndM @e @m @n
583− in khatri (comp a kp1') (comp b kp2')
635+ in kr (comp a fstM') (comp b sndM')
584
636
585−-- Matrix abide Junc Split
637+-- Matrix abide Join Fork
586
638
587−-- | Matrix "abiding" followin the 'Junc'-'Split' abide law.
639+-- | Matrix "abiding" followin the 'Join'-'Fork' abide law.
588−--
640+--
589-- Law:
641-- Law:
590--
642--
591-- @
643-- @
592−-- 'Junc' ('Split' a c) ('Split' b d) == 'Split' ('Junc' a b) ('Junc' c d)
644+-- 'Join' ('Fork' a c) ('Fork' b d) == 'Fork' ('Join' a b) ('Join' c d)
593-- @
645-- @
594−abideJS :: Matrix e cols rows -> Matrix e cols rows
646+abideJF :: Matrix e cols rows -> Matrix e cols rows
595−abideJS (M m) = M (I.abideJS m)
647+abideJF (M m) = M (I.abideJF m)
596
648
597−-- Matrix abide Split Junc
649+-- Matrix abide Fork Join
598
650
599−-- | Matrix "abiding" followin the 'Split'-'Junc' abide law.
651+-- | Matrix "abiding" followin the 'Fork'-'Join' abide law.
600−--
652+--
601-- Law:
653-- Law:
602--
654--
603-- @
655-- @
604−-- 'Split' ('Junc' a b) ('Junc' c d) == 'Junc' ('Split' a c) ('Split' b d)
656+-- 'Fork' ('Join' a b) ('Join' c d) == 'Join' ('Fork' a c) ('Fork' b d)
605-- @
657-- @
606−abideSJ :: Matrix e cols rows -> Matrix e cols rows
658+abideFJ :: Matrix e cols rows -> Matrix e cols rows
607−abideSJ (M m) = M (I.abideSJ m)
659+abideFJ (M m) = M (I.abideFJ m)
608
660
609-- Matrix transposition
661-- Matrix transposition
610
662
@@ -616,9 +668,9 @@ tr (M m) = M (I.tr m)
616
668
617-- | Selective functors 'select' operator equivalent inspired by the
669-- | Selective functors 'select' operator equivalent inspired by the
618-- ArrowMonad solution presented in the paper.
670-- ArrowMonad solution presented in the paper.
619−selectM ::
671+selectM ::
620 ( Num e,
672 ( Num e,
621− FromListsN e b b,
673+ FLN b b,
622 CountableN b
674 CountableN b
623 ) => Matrix e cols (Either a b) -> Matrix e a b -> Matrix e cols b
675 ) => Matrix e cols (Either a b) -> Matrix e a b -> Matrix e cols b
624selectM (M m) (M y) = M (I.select m y)
676selectM (M m) (M y) = M (I.select m y)
@@ -631,9 +683,9 @@ cond ::
631 Trivial2 a,
683 Trivial2 a,
632 Trivial3 a,
684 Trivial3 a,
633 CountableN a,
685 CountableN a,
634− FromListsN e () a,
686+ FLN () a,
635− FromListsN e a (),
687+ FLN a (),
636− FromListsN e a a,
688+ FLN a a,
637 Liftable e a Bool
689 Liftable e a Bool
638 )
690 )
639 =>
691 =>
@@ -643,9 +695,13 @@ cond p (M a) (M b) = M (I.cond p a b)
643-- Pretty print
695-- Pretty print
644
696
645-- | Matrix pretty printer
697-- | Matrix pretty printer
646−pretty :: (CountableN cols, Show e) => Matrix e cols rows -> String
698+pretty :: (CountableDimsN cols rows, Show e) => Matrix e cols rows -> String
647pretty (M m) = I.pretty m
699pretty (M m) = I.pretty m
648
700
649-- | Matrix pretty printer
701-- | Matrix pretty printer
650−prettyPrint :: (CountableN cols, Show e) => Matrix e cols rows -> IO ()
702+prettyPrint :: (CountableDimsN cols rows, Show e) => Matrix e cols rows -> IO ()
651prettyPrint (M m) = I.prettyPrint m
703prettyPrint (M m) = I.prettyPrint m
704+
705+-- | Zip two matrices with a given binary function
706+zipWithM :: (e -> f -> g) -> Matrix e a b -> Matrix f a b -> Matrix g a b
707+zipWithM f (M a) (M b) = M (I.zipWithM f a b)
src/LAoP/Relation.hs+8−11
@@ -32,22 +32,19 @@ module LAoP.Relation
32
32
33 -- * Constraint type synonyms
33 -- * Constraint type synonyms
34 Countable,
34 Countable,
35− CountableDimensions,
35+ CountableDims,
36 CountableN,
36 CountableN,
37− CountableDimensionsN,
37+ CountableDimsN,
38− FromListsN,
38+ FLN,
39 Liftable,
39 Liftable,
40 Trivial,
40 Trivial,
41− TrivialE,
42 TrivialP,
41 TrivialP,
43− TrivialP2,
44
42
45 -- * Primitives
43 -- * Primitives
46− empty,
47 one,
44 one,
48− junc,
45+ join,
49 (|||),
46 (|||),
50− split,
47+ fork,
51 (===),
48 (===),
52
49
53 -- * Auxiliary type families
50 -- * Auxiliary type families
@@ -110,8 +107,8 @@ module LAoP.Relation
110 splitR,
107 splitR,
111
108
112 -- ** Projections
109 -- ** Projections
113− p1,
110+ fstR,
114− p2,
111+ sndR,
115 -- ** Bifunctor
112 -- ** Bifunctor
116 (><),
113 (><),
117 -- * Relational coproduct
114 -- * Relational coproduct
@@ -150,7 +147,7 @@ module LAoP.Relation
150 cond,
147 cond,
151
148
152 -- * Relational composition and lifting
149 -- * Relational composition and lifting
153− identity,
150+ iden,
154 comp,
151 comp,
155 fromF,
152 fromF,
156 fromF',
153 fromF',
src/LAoP/Relation/Internal.hs+250−254
@@ -1,3 +1,4 @@
1+{-# LANGUAGE TypeFamilies #-}
1{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE GADTs #-}
3{-# LANGUAGE GADTs #-}
3{-# LANGUAGE UndecidableInstances #-}
4{-# LANGUAGE UndecidableInstances #-}
@@ -42,22 +43,19 @@ module LAoP.Relation.Internal
42
43
43 -- * Constraint type synonyms
44 -- * Constraint type synonyms
44 Countable,
45 Countable,
45− CountableDimensions,
46+ CountableDims,
46 CountableN,
47 CountableN,
47− CountableDimensionsN,
48+ CountableDimsN,
48− FromListsN,
49+ FLN,
49 Liftable,
50 Liftable,
50 Trivial,
51 Trivial,
51− TrivialE,
52 TrivialP,
52 TrivialP,
53− TrivialP2,
54
53
55 -- * Primitives
54 -- * Primitives
56− empty,
57 one,
55 one,
58− junc,
56+ join,
59 (|||),
57 (|||),
60− split,
58+ fork,
61 (===),
59 (===),
62
60
63 -- * Auxiliary type families
61 -- * Auxiliary type families
@@ -68,14 +66,15 @@ module LAoP.Relation.Internal
68 -- * Matrix construction and conversion
66 -- * Matrix construction and conversion
69 I.FromLists,
67 I.FromLists,
70 fromLists,
68 fromLists,
71− fromF,
72 fromF',
69 fromF',
70+ fromF,
73 toRel,
71 toRel,
74 toLists,
72 toLists,
75 toList,
73 toList,
76 toBool,
74 toBool,
77 pt,
75 pt,
78 belongs,
76 belongs,
77+ relationBuilder',
79 relationBuilder,
78 relationBuilder,
80 zeros,
79 zeros,
81 ones,
80 ones,
@@ -120,8 +119,8 @@ module LAoP.Relation.Internal
120 splitR,
119 splitR,
121
120
122 -- ** Projections
121 -- ** Projections
123− p1,
122+ fstR,
124− p2,
123+ sndR,
125 -- ** Bifunctor
124 -- ** Bifunctor
126 (><),
125 (><),
127 -- * Relational coproduct
126 -- * Relational coproduct
@@ -160,10 +159,10 @@ module LAoP.Relation.Internal
160 cond,
159 cond,
161
160
162 -- * Relational composition and lifting
161 -- * Relational composition and lifting
163− identity,
162+ iden,
164 comp,
163 comp,
165− fromF,
166 fromF',
164 fromF',
165+ fromF,
167
166
168 -- ** Relational application
167 -- ** Relational application
169 pointAp,
168 pointAp,
@@ -179,9 +178,9 @@ import Data.Void
179import qualified LAoP.Matrix.Internal as I
178import qualified LAoP.Matrix.Internal as I
180import LAoP.Utils.Internal
179import LAoP.Utils.Internal
181import Control.DeepSeq
180import Control.DeepSeq
182−import qualified Control.Category as C
183import Data.Bool
181import Data.Bool
184import GHC.TypeLits
182import GHC.TypeLits
183+import Prelude hiding (id, (.))
185
184
186-- | Boolean type synonym for working with boolean matrices
185-- | Boolean type synonym for working with boolean matrices
187type Boolean = Natural 0 1
186type Boolean = Natural 0 1
@@ -194,34 +193,30 @@ newtype Relation a b = R (I.Matrix Boolean (I.Normalize a) (I.Normalize b))
194deriving instance (Read (I.Matrix Boolean (I.Normalize a) (I.Normalize b))) => Read (Relation a b)
193deriving instance (Read (I.Matrix Boolean (I.Normalize a) (I.Normalize b))) => Read (Relation a b)
195
194
196-- | Constraint type synonyms to keep the type signatures less convoluted
195-- | Constraint type synonyms to keep the type signatures less convoluted
197−type Countable a = KnownNat (I.Count a)
196+type Countable a = KnownNat (I.Count a)
198−type CountableDimensions a b = (Countable a, Countable b)
197+type CountableDims a b = (Countable a, Countable b)
199−type CountableN a = KnownNat (I.Count (I.Normalize a))
198+type CountableN a = KnownNat (I.Count (I.Normalize a))
200−type CountableDimensionsN a b = (CountableN a, CountableN b)
199+type CountableDimsN a b = (CountableN a, CountableN b)
201−type FromListsN a b = I.FromLists Boolean (I.Normalize a) (I.Normalize b)
200+type FLN a b = I.FromLists (I.Normalize a) (I.Normalize b)
202−type Liftable a b = (Bounded a, Bounded b, Enum a, Enum b, Eq b, Num Boolean, Ord Boolean)
201+type Liftable a b = (Bounded a, Bounded b, Enum a, Enum b, Eq b, Num Boolean, Ord Boolean)
203−type Trivial a = I.Normalize a ~ I.Normalize (I.Normalize a)
202+type Trivial a = I.Normalize a ~ I.Normalize (I.Normalize a)
204−type TrivialE a b = I.Normalize (Either a b) ~ Either (I.Normalize a) (I.Normalize b)
205−type TrivialP a b = I.Normalize (a, b) ~ I.Normalize (I.Normalize a, I.Normalize b)
203+type TrivialP a b = I.Normalize (a, b) ~ I.Normalize (I.Normalize a, I.Normalize b)
206−type TrivialP2 a b = I.Normalize (I.Normalize a, I.Normalize b) ~ I.Normalize (I.Normalize (a, b))
204+
207−
208−-- | It isn't possible to implement the 'id' function so it's
205+-- | It is possible to implement a constrained version of the category type
209−-- implementation is 'undefined'. However 'comp' can be and this partial
206+-- class.
210−-- class implementation exists just to make the code more readable.
211−--
212−-- Please use 'identity' instead.
213−instance C.Category Relation where
207+instance Category Relation where
214− id = undefined
208+ type Object Relation a = (FLN a a, CountableN a)
209+ id = iden
215− (.) = comp
210+ (.) = comp
216
211
217instance Num (Relation a b) where
212instance Num (Relation a b) where
218− -- | Matrix addition becomes Boolean matrix disjunction
213+ -- | Matrix addition becomes Boolean matrix disjointion
219 (R a) + (R b) = R (I.orM a b)
214 (R a) + (R b) = R (I.orM a b)
220
215
221 -- | Matrix subtraction becomes Relational subtraction
216 -- | Matrix subtraction becomes Relational subtraction
222 (R a) - (R b) = R (I.subM a b)
217 (R a) - (R b) = R (I.subM a b)
223
218
224− -- | Matrix multiplication becomes Boolean matrix conjunction
219+ -- | Matrix multiplication becomes Boolean matrix conjointion
225 (R a) * (R b) = R (I.andM a b)
220 (R a) * (R b) = R (I.andM a b)
226
221
227 -- | Matrix negation becomes Boolean matrix negation
222 -- | Matrix negation becomes Boolean matrix negation
@@ -233,87 +228,92 @@ type One = ()
233
228
234-- Primitives
229-- Primitives
235
230
236−-- | Empty matrix constructor
237−empty :: Relation Zero Zero
238−empty = R I.Empty
239−
240-- | Unit matrix constructor
231-- | Unit matrix constructor
241one :: Boolean -> Relation One One
232one :: Boolean -> Relation One One
242one = R . I.One
233one = R . I.One
243
234
244−-- | Boolean Matrix 'Junc' constructor, also known as relational coproduct.
235+-- | Boolean Matrix 'Join' constructor, also known as relational coproduct.
245--
236--
246-- See 'eitherR'.
237-- See 'eitherR'.
247−junc :: (TrivialE a b)
248− => Relation a c -> Relation b c -> Relation (Either a b) c
238+join :: Relation a c -> Relation b c -> Relation (Either a b) c
249−junc (R a) (R b) = R (I.Junc a b)
239+join (R a) (R b) = R (I.Join a b)
250
240
251infixl 3 |||
241infixl 3 |||
252−-- | Boolean Matrix 'Junc' constructor
242+-- | Boolean Matrix 'Join' constructor
253--
243--
254-- See 'eitherR'.
244-- See 'eitherR'.
255(|||) ::
245(|||) ::
256− (TrivialE a b) =>
257 Relation a c ->
246 Relation a c ->
258 Relation b c ->
247 Relation b c ->
259 Relation (Either a b) c
248 Relation (Either a b) c
260−(|||) = junc
249+(|||) = join
261
250
262−-- | Boolean Matrix 'Split' constructor, also known as relational product.
251+-- | Boolean Matrix 'Fork' constructor, also known as relational product.
263−split :: (TrivialE a b)
264− => Relation c a -> Relation c b -> Relation c (Either a b)
252+fork :: Relation c a -> Relation c b -> Relation c (Either a b)
265−split (R a) (R b) = R (I.Split a b)
253+fork (R a) (R b) = R (I.Fork a b)
266
254
267infixl 2 ===
255infixl 2 ===
268−-- | Boolean Matrix 'Split' constructor
256+-- | Boolean Matrix 'Fork' constructor
269(===) ::
257(===) ::
270− (TrivialE a b) =>
271 Relation c a ->
258 Relation c a ->
272 Relation c b ->
259 Relation c b ->
273 Relation c (Either a b)
260 Relation c (Either a b)
274−(===) = split
261+(===) = fork
275
262
276-- Construction
263-- Construction
277
264
278-- | Build a matrix out of a list of list of elements. Throws a runtime
265-- | Build a matrix out of a list of list of elements. Throws a runtime
279-- error if the dimensions do not match.
266-- error if the dimensions do not match.
280−fromLists :: (FromListsN a b) => [[Boolean]] -> Relation a b
267+fromLists :: (FLN a b) => [[Boolean]] -> Relation a b
281fromLists = R . I.fromLists
268fromLists = R . I.fromLists
282
269
283−-- | Matrix builder function. Constructs a matrix provided with
270+-- | Relation builder function. Constructs a relation provided with
284−-- a construction function.
271+-- a construction function that operates with indices.
285−relationBuilder ::
272+relationBuilder' ::
286− (FromListsN a b, CountableDimensionsN a b) =>
273+ (FLN a b, CountableDimsN a b) =>
287 ((Int, Int) -> Boolean) -> Relation a b
274 ((Int, Int) -> Boolean) -> Relation a b
275+relationBuilder' = R . I.matrixBuilder'
276+
277+-- | Relation builder function. Constructs a relation provided with
278+-- a construction function that operates with arbitrary types.
279+relationBuilder ::
280+ ( FLN a b,
281+ Enum a,
282+ Enum b,
283+ Bounded a,
284+ Bounded b,
285+ Eq a,
286+ CountableDims a b
287+ ) => ((a, b) -> Boolean) -> Relation a b
288relationBuilder = R . I.matrixBuilder
288relationBuilder = R . I.matrixBuilder
289
289
290-- | Lifts functions to matrices with arbitrary dimensions.
290-- | Lifts functions to matrices with arbitrary dimensions.
291--
291--
292-- NOTE: Be careful to not ask for a matrix bigger than the cardinality of
292-- NOTE: Be careful to not ask for a matrix bigger than the cardinality of
293-- types @a@ or @b@ allows.
293-- types @a@ or @b@ allows.
294−fromF ::
294+fromF' ::
295 ( Liftable a b,
295 ( Liftable a b,
296− CountableDimensionsN c d,
296+ CountableDimsN c d,
297− FromListsN d c
297+ FLN d c
298 )
298 )
299 => (a -> b) -> Relation c d
299 => (a -> b) -> Relation c d
300−fromF f = R (I.fromFRel f)
300+fromF' f = R (I.fromFRel' f)
301
301
302-- | Lifts functions to matrices with dimensions matching @a@ and @b@
302-- | Lifts functions to matrices with dimensions matching @a@ and @b@
303-- cardinality's.
303-- cardinality's.
304−fromF' ::
304+fromF ::
305 ( Liftable a b,
305 ( Liftable a b,
306− CountableDimensionsN a b,
306+ CountableDimsN a b,
307− FromListsN b a
307+ FLN b a
308 )
308 )
309 => (a -> b) -> Relation a b
309 => (a -> b) -> Relation a b
310−fromF' f = R (I.fromFRel' f)
310+fromF f = R (I.fromFRel f)
311
311
312-- | Lifts relation functions to 'Relation'
312-- | Lifts relation functions to 'Relation'
313toRel ::
313toRel ::
314 ( Liftable a b,
314 ( Liftable a b,
315− CountableDimensionsN a b,
315+ CountableDims a b,
316− FromListsN b a
316+ FLN b a
317 )
317 )
318 => (a -> b -> Bool) -> Relation a b
318 => (a -> b -> Bool) -> Relation a b
319toRel = R . I.toRel
319toRel = R . I.toRel
@@ -322,9 +322,9 @@ toRel = R . I.toRel
322fromRel ::
322fromRel ::
323 ( Liftable a b,
323 ( Liftable a b,
324 Eq a,
324 Eq a,
325− CountableDimensionsN a b,
325+ CountableDimsN a b,
326− FromListsN a One,
326+ FLN a One,
327− FromListsN b One
327+ FLN b One
328 )
328 )
329 => Relation a b -> (a -> b -> Bool)
329 => Relation a b -> (a -> b -> Bool)
330fromRel r a b = pointApBool a b r
330fromRel r a b = pointApBool a b r
@@ -348,12 +348,12 @@ toBool r = case toList r of
348-- | Power transpose.
348-- | Power transpose.
349--
349--
350-- Maps a relation to a set valued function.
350-- Maps a relation to a set valued function.
351−pt ::
351+pt ::
352 ( Liftable a b,
352 ( Liftable a b,
353 Eq a,
353 Eq a,
354− CountableDimensionsN a b,
354+ CountableDimsN a b,
355− FromListsN a One,
355+ FLN a One,
356− FromListsN b One
356+ FLN b One
357 )
357 )
358 => Relation a b -> (a -> List b)
358 => Relation a b -> (a -> List b)
359pt r a =
359pt r a =
@@ -365,8 +365,8 @@ belongs ::
365 ( Bounded a,
365 ( Bounded a,
366 Enum a,
366 Enum a,
367 Eq a,
367 Eq a,
368− CountableDimensionsN (List a) a,
368+ CountableDims (List a) a,
369− FromListsN a (List a)
369+ FLN a (List a)
370 )
370 )
371 => Relation (List a) a
371 => Relation (List a) a
372belongs = toRel elemR
372belongs = toRel elemR
@@ -378,16 +378,16 @@ belongs = toRel elemR
378-- | The zero relation. A relation where no element of type @a@ relates
378-- | The zero relation. A relation where no element of type @a@ relates
379-- with elements of type @b@.
379-- with elements of type @b@.
380--
380--
381−-- Also known as ⊥ (Bottom) Relation or empty Relation.
381+-- Also known as ⊥ (Bottom) Relation.
382--
382--
383-- @
383-- @
384−-- r ``comp`` ⊥ == ⊥ ``comp`` r == ⊥
384+-- r `.` ⊥ == ⊥ `.` r == ⊥
385-- ⊥ ``sse`` R && R ``sse`` T == True
385-- ⊥ ``sse`` R && R ``sse`` T == True
386-- @
386-- @
387zeros ::
387zeros ::
388− (FromListsN a b, CountableDimensionsN a b) =>
388+ (FLN a b, CountableDimsN a b) =>
389 Relation a b
389 Relation a b
390−zeros = relationBuilder (const (nat 0))
390+zeros = relationBuilder' (const (nat 0))
391
391
392-- Ones Matrix
392-- Ones Matrix
393
393
@@ -400,43 +400,43 @@ zeros = relationBuilder (const (nat 0))
400-- ⊥ ``sse`` R && R ``sse`` T == True
400-- ⊥ ``sse`` R && R ``sse`` T == True
401-- @
401-- @
402ones ::
402ones ::
403− (FromListsN a b, CountableDimensionsN a b) =>
403+ (FLN a b, CountableDimsN a b) =>
404 Relation a b
404 Relation a b
405−ones = relationBuilder (const (nat 1))
405+ones = relationBuilder' (const (nat 1))
406
406
407-- Bang Matrix
407-- Bang Matrix
408
408
409-- | The T (Top) row vector relation.
409-- | The T (Top) row vector relation.
410bang ::
410bang ::
411− (FromListsN a One, CountableN a) =>
411+ (FLN a One, CountableN a) =>
412 Relation a One
412 Relation a One
413bang = ones
413bang = ones
414
414
415-- | Point constant relation
415-- | Point constant relation
416−point ::
416+point ::
417 ( Bounded a,
417 ( Bounded a,
418 Enum a,
418 Enum a,
419 Eq a,
419 Eq a,
420 CountableN a,
420 CountableN a,
421− FromListsN a One
421+ FLN a One
422 ) => a -> Relation One a
422 ) => a -> Relation One a
423−point = fromF' . const
423+point = fromF . const
424
424
425−-- Identity Matrix
425+-- iden Matrix
426
426
427−-- | Identity matrix
427+-- | iden matrix
428--
428--
429-- @
429-- @
430−-- 'identity' ``comp`` r == r == r ``comp`` 'identity'
430+-- 'iden' `.` r == r == r `.` 'iden'
431-- @
431-- @
432−identity ::
432+iden ::
433− (FromListsN a a, CountableN a) => Relation a a
433+ (FLN a a, CountableN a) => Relation a a
434−identity = relationBuilder (bool (nat 0) (nat 1) . uncurry (==))
434+iden = relationBuilder' (bool (nat 0) (nat 1) . uncurry (==))
435
435
436-- | Relational composition
436-- | Relational composition
437--
437--
438-- @
438-- @
439−-- r ``comp`` (s ``comp`` p) = (r ``comp`` s) ``comp`` p
439+-- r `.` (s `.` p) = (r `.` s) `.` p
440-- @
440-- @
441comp :: Relation b c -> Relation a b -> Relation a c
441comp :: Relation b c -> Relation a b -> Relation a c
442comp (R a) (R b) = R (I.compRel a b)
442comp (R a) (R b) = R (I.compRel a b)
@@ -484,7 +484,7 @@ shrunkBy r s = r `intersection` divR s (conv r)
484-- r ``overriddenBy`` r == r
484-- r ``overriddenBy`` r == r
485-- @
485-- @
486overriddenBy ::
486overriddenBy ::
487− ( FromListsN b b,
487+ ( FLN b b,
488 CountableN b
488 CountableN b
489 ) => Relation a b -> Relation a b -> Relation a b
489 ) => Relation a b -> Relation a b -> Relation a b
490overriddenBy r s = s `union` r `intersection` divR zeros (conv s)
490overriddenBy r s = s `union` r `intersection` divR zeros (conv s)
@@ -496,11 +496,11 @@ overriddenBy r s = s `union` r `intersection` divR zeros (conv s)
496pointAp ::
496pointAp ::
497 ( Liftable a b,
497 ( Liftable a b,
498 Eq a,
498 Eq a,
499− CountableDimensionsN a b,
499+ CountableDimsN a b,
500− FromListsN a One,
500+ FLN a One,
501− FromListsN b One
501+ FLN b One
502 ) => a -> b -> Relation a b -> Relation One One
502 ) => a -> b -> Relation a b -> Relation One One
503−pointAp a b r = conv (point b) `comp` r `comp` point a
503+pointAp a b r = conv (point b) . r . point a
504
504
505-- | Relational application
505-- | Relational application
506--
506--
@@ -508,11 +508,11 @@ pointAp a b r = conv (point b) `comp` r `comp` point a
508pointApBool ::
508pointApBool ::
509 ( Liftable a b,
509 ( Liftable a b,
510 Eq a,
510 Eq a,
511− CountableDimensionsN a b,
511+ CountableDimsN a b,
512− FromListsN a One,
512+ FLN a One,
513− FromListsN b One
513+ FLN b One
514 ) => a -> b -> Relation a b -> Bool
514 ) => a -> b -> Relation a b -> Bool
515−pointApBool a b r = toBool $ conv (point b) `comp` r `comp` point a
515+pointApBool a b r = toBool $ conv (point b) . r . point a
516
516
517-- | Relational converse
517-- | Relational converse
518--
518--
@@ -538,7 +538,7 @@ iff r s = r == s
538
538
539-- | Relational intersection
539-- | Relational intersection
540--
540--
541−-- Lifts pointwise conjunction.
541+-- Lifts pointwise conjointion.
542--
542--
543-- @
543-- @
544-- (r ``intersection`` s) ``intersection`` t == r ``intersection`` (s ``intersection`` t)
544-- (r ``intersection`` s) ``intersection`` t == r ``intersection`` (s ``intersection`` t)
@@ -549,13 +549,13 @@ intersection a b = a * b
549
549
550-- | Relational union
550-- | Relational union
551--
551--
552−-- Lifts pointwise disjunction.
552+-- Lifts pointwise disjointion.
553--
553--
554-- @
554-- @
555-- (r ``union`` s) ``union`` t == r `'union' (s ``union`` t)
555-- (r ``union`` s) ``union`` t == r `'union' (s ``union`` t)
556-- r ``union`` s ``sse`` x == r ``sse`` x && s ``sse`` x
556-- r ``union`` s ``sse`` x == r ``sse`` x && s ``sse`` x
557−-- r ``comp`` (s ``union`` t) == (r ``comp`` s) ``union`` (r ``comp`` t)
557+-- r `.` (s ``union`` t) == (r `.` s) ``union`` (r `.` t)
558−-- (s ``union`` t) ``comp`` r == (s ``comp`` r) ``union`` (t ``comp`` r)
558+-- (s ``union`` t) `.` r == (s `.` r) ``union`` (t `.` r)
559-- @
559-- @
560union :: Relation a b -> Relation a b -> Relation a b
560union :: Relation a b -> Relation a b -> Relation a b
561union a b = a + b
561union a b = a + b
@@ -563,46 +563,46 @@ union a b = a + b
563-- | Relation Kernel
563-- | Relation Kernel
564--
564--
565-- @
565-- @
566−-- 'ker' r == 'conv' r ``comp`` r
566+-- 'ker' r == 'conv' r `.` r
567-- 'ker' r == 'img' ('conv' r)
567-- 'ker' r == 'img' ('conv' r)
568-- @
568-- @
569ker :: Relation a b -> Relation a a
569ker :: Relation a b -> Relation a a
570−ker r = conv r `comp` r
570+ker r = conv r . r
571
571
572-- | Relation Image
572-- | Relation Image
573--
573--
574-- @
574-- @
575−-- 'img' r == r ``comp`` conv r
575+-- 'img' r == r `.` conv r
576-- 'img' r == 'ker' ('conv' r)
576-- 'img' r == 'ker' ('conv' r)
577-- @
577-- @
578img :: Relation a b -> Relation b b
578img :: Relation a b -> Relation b b
579−img r = r `comp` conv r
579+img r = r . conv r
580
580
581-- | Function division. Special case of 'divS'.
581-- | Function division. Special case of 'divS'.
582--
582--
583-- NOTE: _This is only valid_ if @f@ and @g@ are 'function's, i.e. 'simple' and
583-- NOTE: _This is only valid_ if @f@ and @g@ are 'function's, i.e. 'simple' and
584-- 'entire'.
584-- 'entire'.
585--
585--
586−-- @'divisionF' f g == 'conv' g ``comp`` f@
586+-- @'divisionF' f g == 'conv' g `.` f@
587divisionF :: Relation a c -> Relation b c -> Relation a b
587divisionF :: Relation a c -> Relation b c -> Relation a b
588−divisionF f g = conv g `comp` f
588+divisionF f g = conv g . f
589
589
590-- Taxonomy of binary relations
590-- Taxonomy of binary relations
591
591
592-- | A 'Relation' @r@ is 'simple' 'iff' @'coreflexive' ('img' r)@
592-- | A 'Relation' @r@ is 'simple' 'iff' @'coreflexive' ('img' r)@
593−simple :: (CountableN b, FromListsN b b) => Relation a b -> Bool
593+simple :: (CountableN b, FLN b b) => Relation a b -> Bool
594simple = coreflexive . img
594simple = coreflexive . img
595
595
596-- | A 'Relation' @r@ is 'injective' 'iff' @'coreflexive' ('ker' r)@
596-- | A 'Relation' @r@ is 'injective' 'iff' @'coreflexive' ('ker' r)@
597−injective :: (CountableN a, FromListsN a a) => Relation a b -> Bool
597+injective :: (CountableN a, FLN a a) => Relation a b -> Bool
598injective = coreflexive . ker
598injective = coreflexive . ker
599
599
600-- | A 'Relation' @r@ is 'entire' 'iff' @'reflexive' ('ker' r)@
600-- | A 'Relation' @r@ is 'entire' 'iff' @'reflexive' ('ker' r)@
601−entire :: (CountableN a, FromListsN a a) => Relation a b -> Bool
601+entire :: (CountableN a, FLN a a) => Relation a b -> Bool
602entire = reflexive . ker
602entire = reflexive . ker
603
603
604-- | A 'Relation' @r@ is 'surjective' 'iff' @'reflexive' ('img' r)@
604-- | A 'Relation' @r@ is 'surjective' 'iff' @'reflexive' ('img' r)@
605−surjective :: (CountableN b, FromListsN b b) => Relation a b -> Bool
605+surjective :: (CountableN b, FLN b b) => Relation a b -> Bool
606surjective = reflexive . img
606surjective = reflexive . img
607
607
608-- | A 'Relation' @r@ is a 'function' 'iff' @'simple' r && 'entire' r@
608-- | A 'Relation' @r@ is a 'function' 'iff' @'simple' r && 'entire' r@
@@ -611,13 +611,13 @@ surjective = reflexive . img
611-- relations:
611-- relations:
612--
612--
613-- @
613-- @
614−-- f ``comp`` r ``sse`` s == r ``sse`` f ``comp`` s
614+-- f `.` r ``sse`` s == r ``sse`` f `.` s
615−-- r ``comp`` f ``sse`` s == r ``sse`` s ``comp`` f
615+-- r `.` f ``sse`` s == r ``sse`` s `.` f
616-- @
616-- @
617function ::
617function ::
618− ( CountableDimensionsN a b,
618+ ( CountableDimsN a b,
619− FromListsN a a,
619+ FLN a a,
620− FromListsN b b
620+ FLN b b
621 )
621 )
622 => Relation a b -> Bool
622 => Relation a b -> Bool
623function r = simple r && entire r
623function r = simple r && entire r
@@ -625,7 +625,7 @@ function r = simple r && entire r
625-- | A 'Relation' @r@ is a 'representation' 'iff' @'injective' r && 'entire' r@
625-- | A 'Relation' @r@ is a 'representation' 'iff' @'injective' r && 'entire' r@
626representation ::
626representation ::
627 ( CountableN a,
627 ( CountableN a,
628− FromListsN a a
628+ FLN a a
629 )
629 )
630 => Relation a b -> Bool
630 => Relation a b -> Bool
631representation r = injective r && entire r
631representation r = injective r && entire r
@@ -633,91 +633,91 @@ representation r = injective r && entire r
633-- | A 'Relation' @r@ is an 'abstraction' 'iff' @'surjective' r && 'simple' r@
633-- | A 'Relation' @r@ is an 'abstraction' 'iff' @'surjective' r && 'simple' r@
634abstraction ::
634abstraction ::
635 ( CountableN b,
635 ( CountableN b,
636− FromListsN b b
636+ FLN b b
637 )
637 )
638 => Relation a b -> Bool
638 => Relation a b -> Bool
639abstraction r = surjective r && simple r
639abstraction r = surjective r && simple r
640
640
641-- | A 'Relation' @r@ is a 'surjection' 'iff' @'function' r && 'abstraction' r@
641-- | A 'Relation' @r@ is a 'surjection' 'iff' @'function' r && 'abstraction' r@
642surjection ::
642surjection ::
643− ( CountableDimensionsN a b,
643+ ( CountableDimsN a b,
644− FromListsN a a,
644+ FLN a a,
645− FromListsN b b
645+ FLN b b
646 )
646 )
647 => Relation a b -> Bool
647 => Relation a b -> Bool
648surjection r = function r && abstraction r
648surjection r = function r && abstraction r
649
649
650-- | A 'Relation' @r@ is a 'injection' 'iff' @'function' r && 'representation' r@
650-- | A 'Relation' @r@ is a 'injection' 'iff' @'function' r && 'representation' r@
651injection ::
651injection ::
652− ( CountableDimensionsN a b,
652+ ( CountableDimsN a b,
653− FromListsN a a,
653+ FLN a a,
654− FromListsN b b
654+ FLN b b
655 )
655 )
656 => Relation a b -> Bool
656 => Relation a b -> Bool
657injection r = function r && representation r
657injection r = function r && representation r
658
658
659-- | A 'Relation' @r@ is an 'bijection' 'iff' @'injection' r && 'surjection' r@
659-- | A 'Relation' @r@ is an 'bijection' 'iff' @'injection' r && 'surjection' r@
660bijection ::
660bijection ::
661− ( CountableDimensionsN a b,
661+ ( CountableDimsN a b,
662− FromListsN b b,
662+ FLN b b,
663− FromListsN a a
663+ FLN a a
664 ) => Relation a b -> Bool
664 ) => Relation a b -> Bool
665bijection r = injection r && surjection r
665bijection r = injection r && surjection r
666
666
667-- Properties of relations
667-- Properties of relations
668
668
669−-- | A 'Relation' @r@ is 'reflexive' 'iff' @'identity' ``sse`` r@
669+-- | A 'Relation' @r@ is 'reflexive' 'iff' @'id' ``sse`` r@
670−reflexive :: (CountableN a, FromListsN a a) => Relation a a -> Bool
670+reflexive :: (CountableN a, FLN a a) => Relation a a -> Bool
671−reflexive r = identity <= r
671+reflexive r = id <= r
672
672
673−-- | A 'Relation' @r@ is 'coreflexive' 'iff' @r ``sse`` 'identity'@
673+-- | A 'Relation' @r@ is 'coreflexive' 'iff' @r ``sse`` 'id'@
674−coreflexive :: (CountableN a, FromListsN a a) => Relation a a -> Bool
674+coreflexive :: (CountableN a, FLN a a) => Relation a a -> Bool
675−coreflexive r = r <= identity
675+coreflexive r = r <= id
676
676
677−-- | A 'Relation' @r@ is 'transitive' 'iff' @(r ``comp`` r) ``sse`` r@
677+-- | A 'Relation' @r@ is 'transitive' 'iff' @(r `.` r) ``sse`` r@
678transitive :: Relation a a -> Bool
678transitive :: Relation a a -> Bool
679−transitive r = (r `comp` r) `sse` r
679+transitive r = (r . r) `sse` r
680
680
681-- | A 'Relation' @r@ is 'symmetric' 'iff' @r == 'conv' r@
681-- | A 'Relation' @r@ is 'symmetric' 'iff' @r == 'conv' r@
682symmetric :: Relation a a -> Bool
682symmetric :: Relation a a -> Bool
683symmetric r = r == conv r
683symmetric r = r == conv r
684
684
685−-- | A 'Relation' @r@ is anti-symmetric 'iff' @(r ``intersection`` 'conv' r) ``sse`` 'identity'@
685+-- | A 'Relation' @r@ is anti-symmetric 'iff' @(r ``intersection`` 'conv' r) ``sse`` 'id'@
686−antiSymmetric :: (CountableN a, FromListsN a a) => Relation a a -> Bool
686+antiSymmetric :: (CountableN a, FLN a a) => Relation a a -> Bool
687−antiSymmetric r = (r `intersection` conv r) `sse` identity
687+antiSymmetric r = (r `intersection` conv r) `sse` id
688
688
689−-- | A 'Relation' @r@ is 'irreflexive' 'iff' @(r ``intersection`` 'identity') == 'zeros'@
689+-- | A 'Relation' @r@ is 'irreflexive' 'iff' @(r ``intersection`` 'id') == 'zeros'@
690−irreflexive :: (CountableN a, FromListsN a a) => Relation a a -> Bool
690+irreflexive :: (CountableN a, FLN a a) => Relation a a -> Bool
691−irreflexive r = (r `intersection` identity) == zeros
691+irreflexive r = (r `intersection` id) == zeros
692
692
693-- | A 'Relation' @r@ is 'connected' 'iff' @(r ``union`` 'conv' r) == 'ones'@
693-- | A 'Relation' @r@ is 'connected' 'iff' @(r ``union`` 'conv' r) == 'ones'@
694−connected :: (CountableN a, FromListsN a a) => Relation a a -> Bool
694+connected :: (CountableN a, FLN a a) => Relation a a -> Bool
695connected r = (r `union` conv r) == ones
695connected r = (r `union` conv r) == ones
696
696
697-- | A 'Relation' @r@ is a 'preorder' 'iff' @'reflexive' r && 'transitive' r@
697-- | A 'Relation' @r@ is a 'preorder' 'iff' @'reflexive' r && 'transitive' r@
698−preorder :: (CountableN a, FromListsN a a) => Relation a a -> Bool
698+preorder :: (CountableN a, FLN a a) => Relation a a -> Bool
699preorder r = reflexive r && transitive r
699preorder r = reflexive r && transitive r
700
700
701-- | A 'Relation' @r@ is a partial-order 'iff' @'antiSymmetric' r && 'preorder' r@
701-- | A 'Relation' @r@ is a partial-order 'iff' @'antiSymmetric' r && 'preorder' r@
702−partialOrder :: (CountableN a, FromListsN a a) => Relation a a -> Bool
702+partialOrder :: (CountableN a, FLN a a) => Relation a a -> Bool
703partialOrder r = antiSymmetric r && preorder r
703partialOrder r = antiSymmetric r && preorder r
704
704
705-- | A 'Relation' @r@ is a linear-order 'iff' @'connected' r && 'partialOrder' r@
705-- | A 'Relation' @r@ is a linear-order 'iff' @'connected' r && 'partialOrder' r@
706−linearOrder :: (CountableN a, FromListsN a a) => Relation a a -> Bool
706+linearOrder :: (CountableN a, FLN a a) => Relation a a -> Bool
707linearOrder r = connected r && partialOrder r
707linearOrder r = connected r && partialOrder r
708
708
709-- | A 'Relation' @r@ is an 'equivalence' 'iff' @'symmetric' r && 'preorder' r@
709-- | A 'Relation' @r@ is an 'equivalence' 'iff' @'symmetric' r && 'preorder' r@
710−equivalence :: (CountableN a, FromListsN a a) => Relation a a -> Bool
710+equivalence :: (CountableN a, FLN a a) => Relation a a -> Bool
711equivalence r = symmetric r && preorder r
711equivalence r = symmetric r && preorder r
712
712
713-- | A 'Relation' @r@ is a partial-equivalence 'iff' @'partialOrder' r && 'equivalence' r@
713-- | A 'Relation' @r@ is a partial-equivalence 'iff' @'partialOrder' r && 'equivalence' r@
714−partialEquivalence :: (CountableN a, FromListsN a a) => Relation a a -> Bool
714+partialEquivalence :: (CountableN a, FLN a a) => Relation a a -> Bool
715partialEquivalence r = partialOrder r && equivalence r
715partialEquivalence r = partialOrder r && equivalence r
716
716
717-- | A 'Relation' @r@ is 'difunctional' or regular wherever
717-- | A 'Relation' @r@ is 'difunctional' or regular wherever
718−-- @r ``comp`` 'conv' r ``comp`` r == r@
718+-- @r `.` 'conv' r `.` r == r@
719difunctional :: Relation a b -> Bool
719difunctional :: Relation a b -> Bool
720−difunctional r = r `comp` conv r `comp` r == r
720+difunctional r = r . conv r . r == r
721
721
722-- Relational pairing
722-- Relational pairing
723
723
@@ -726,61 +726,61 @@ difunctional r = r `comp` conv r `comp` r == r
726-- NOTE: That this is not a true categorical product, see for instance:
726-- NOTE: That this is not a true categorical product, see for instance:
727--
727--
728-- @
728-- @
729−-- | 'p1' ``comp`` 'splitR' a b ``sse`` a
729+-- | 'fstR' `.` 'splitR' a b ``sse`` a
730-- 'splitR' a b <=> |
730-- 'splitR' a b <=> |
731−-- | 'p2' ``comp`` 'splitR' a b ``sse`` b
731+-- | 'sndR' `.` 'splitR' a b ``sse`` b
732-- @
732-- @
733--
733--
734-- __Emphasis__ on the 'sse'.
734-- __Emphasis__ on the 'sse'.
735--
735--
736-- @
736-- @
737−-- 'splitR' r s ``comp`` f == 'splitR' (r ``comp`` f) (s ``comp`` f)
737+-- 'splitR' r s `.` f == 'splitR' (r `.` f) (s `.` f)
738−-- (R '><' S) ``comp`` 'splitR' p q == 'splitR' (r ``comp`` p) (s ``comp`` q)
738+-- (R '><' S) `.` 'splitR' p q == 'splitR' (r `.` p) (s `.` q)
739−-- 'conv' ('splitR' r s) ``comp`` 'splitR' x y == ('conv' r ``comp`` x) ``intersection`` ('conv' s ``comp`` y)
739+-- 'conv' ('splitR' r s) `.` 'splitR' x y == ('conv' r `.` x) ``intersection`` ('conv' s `.` y)
740-- @
740-- @
741--
741--
742-- @
742-- @
743-- 'eitherR' ('splitR' r s) ('splitR' t v) == 'splitR' ('eitherR' r t) ('eitherR' s v)
743-- 'eitherR' ('splitR' r s) ('splitR' t v) == 'splitR' ('eitherR' r t) ('eitherR' s v)
744-- @
744-- @
745splitR ::
745splitR ::
746− ( CountableDimensionsN a b,
746+ ( CountableDimsN a b,
747 CountableN (a, b),
747 CountableN (a, b),
748− FromListsN (a, b) a,
748+ FLN (a, b) a,
749− FromListsN (a, b) b,
749+ FLN (a, b) b,
750 TrivialP a b
750 TrivialP a b
751 )
751 )
752 => Relation c a -> Relation c b -> Relation c (a, b)
752 => Relation c a -> Relation c b -> Relation c (a, b)
753−splitR (R f) (R g) = R (I.khatri f g)
753+splitR (R f) (R g) = R (I.kr f g)
754
754
755-- | Relational pairing first component projection
755-- | Relational pairing first component projection
756--
756--
757-- @
757-- @
758−-- 'p1' ``comp`` 'splitR' r s ``sse`` r
758+-- 'fstR' `.` 'splitR' r s ``sse`` r
759-- @
759-- @
760−p1 ::
760+fstR ::
761 forall a b .
761 forall a b .
762− ( CountableDimensionsN a b,
762+ ( CountableDimsN a b,
763 CountableN (a, b),
763 CountableN (a, b),
764− FromListsN (a, b) a,
764+ FLN (a, b) a,
765 TrivialP a b
765 TrivialP a b
766 )
766 )
767 => Relation (a, b) a
767 => Relation (a, b) a
768−p1 = R (I.kp1 @Boolean @(I.Normalize a) @(I.Normalize b))
768+fstR = R (I.fstM @Boolean @(I.Normalize a) @(I.Normalize b))
769
769
770-- | Relational pairing second component projection
770-- | Relational pairing second component projection
771--
771--
772-- @
772-- @
773−-- 'p2' ``comp`` 'splitR' r s ``sse`` s
773+-- 'sndR' `.` 'splitR' r s ``sse`` s
774-- @
774-- @
775−p2 ::
775+sndR ::
776 forall a b .
776 forall a b .
777− ( CountableDimensionsN a b,
777+ ( CountableDimsN a b,
778 CountableN (a, b),
778 CountableN (a, b),
779− FromListsN (a, b) b,
779+ FLN (a, b) b,
780 TrivialP a b
780 TrivialP a b
781 )
781 )
782 => Relation (a, b) b
782 => Relation (a, b) b
783−p2 = R (I.kp2 @Boolean @(I.Normalize a) @(I.Normalize b))
783+sndR = R (I.sndM @Boolean @(I.Normalize a) @(I.Normalize b))
784
784
785-- Relational pairing functor
785-- Relational pairing functor
786
786
@@ -788,17 +788,17 @@ infixl 4 ><
788-- | Relational pairing functor
788-- | Relational pairing functor
789--
789--
790-- @
790-- @
791−-- r '><' s == 'splitR' (r ``comp`` p1) (s ``comp`` p2)
791+-- r '><' s == 'splitR' (r `.` fstR) (s `.` sndR)
792−-- (r '><' s) ``comp`` (p '><' q) == (r ``comp`` p) '><' (s ``comp`` q)
792+-- (r '><' s) `.` (p '><' q) == (r `.` p) '><' (s `.` q)
793-- @
793-- @
794(><) ::
794(><) ::
795− ( CountableDimensionsN a b,
795+ ( CountableDimsN a b,
796− CountableDimensionsN c d,
796+ CountableDimsN c d,
797− CountableDimensionsN (a, c) (b, d),
797+ CountableDimsN (a, c) (b, d),
798− FromListsN (a, c) a,
798+ FLN (a, c) a,
799− FromListsN (a, c) c,
799+ FLN (a, c) c,
800− FromListsN (b, d) b,
800+ FLN (b, d) b,
801− FromListsN (b, d) d,
801+ FLN (b, d) d,
802 TrivialP a c,
802 TrivialP a c,
803 TrivialP b d
803 TrivialP b d
804 )
804 )
@@ -810,33 +810,31 @@ infixl 4 ><
810-- | Relational coproduct.
810-- | Relational coproduct.
811--
811--
812-- @
812-- @
813−-- | 'eitherR' a b ``comp`` 'i1' == a
813+-- | 'eitherR' a b `.` 'i1' == a
814-- 'eitherR' a b <=> |
814-- 'eitherR' a b <=> |
815−-- | 'eitherR' a b ``comp`` 'i2' == b
815+-- | 'eitherR' a b `.` 'i2' == b
816-- @
816-- @
817--
817--
818-- @
818-- @
819−-- 'eitherR' r s ``comp`` 'conv' ('eitherR' t u) == (r ``comp`` 'conv' t) ``union`` (s ``comp`` 'conv' u)
819+-- 'eitherR' r s `.` 'conv' ('eitherR' t u) == (r `.` 'conv' t) ``union`` (s `.` 'conv' u)
820-- @
820-- @
821--
821--
822-- @
822-- @
823-- 'eitherR' ('splitR' r s) ('splitR' t v) == 'splitR' ('eitherR' r t) ('eitherR' s v)
823-- 'eitherR' ('splitR' r s) ('splitR' t v) == 'splitR' ('eitherR' r t) ('eitherR' s v)
824-- @
824-- @
825−eitherR :: (TrivialE a b)
826− => Relation a c -> Relation b c -> Relation (Either a b) c
825+eitherR :: Relation a c -> Relation b c -> Relation (Either a b) c
827−eitherR = junc
826+eitherR = join
828
827
829-- | Relational coproduct first component injection
828-- | Relational coproduct first component injection
830--
829--
831-- @
830-- @
832−-- 'img' 'i1' ``union`` 'img' 'i2' == 'identity'
831+-- 'img' 'i1' ``union`` 'img' 'i2' == 'id'
833−-- 'i1' ``comp`` 'i2' = 'zeros'
832+-- 'i1' `.` 'i2' = 'zeros'
834-- @
833-- @
835i1 ::
834i1 ::
836− ( CountableDimensionsN a b,
835+ ( CountableDimsN a b,
837− FromListsN b a,
836+ FLN b a,
838− FromListsN a a,
837+ FLN a a
839− TrivialE a b
840 )
838 )
841 => Relation a (Either a b)
839 => Relation a (Either a b)
842i1 = R I.i1
840i1 = R I.i1
@@ -844,14 +842,13 @@ i1 = R I.i1
844-- | Relational coproduct second component injection
842-- | Relational coproduct second component injection
845--
843--
846-- @
844-- @
847−-- 'img' 'i1' ``union`` 'img' 'i2' == 'identity'
845+-- 'img' 'i1' ``union`` 'img' 'i2' == 'id'
848−-- 'i1' ``comp`` 'i2' = 'zeros'
846+-- 'i1' `.` 'i2' = 'zeros'
849-- @
847-- @
850i2 ::
848i2 ::
851− ( CountableDimensionsN a b,
849+ ( CountableDimsN a b,
852− FromListsN a b,
850+ FLN a b,
853− FromListsN b b,
851+ FLN b b
854− TrivialE a b
855 )
852 )
856 => Relation b (Either a b)
853 => Relation b (Either a b)
857i2 = R I.i2
854i2 = R I.i2
@@ -861,16 +858,14 @@ infixl 5 -|-
861-- | Relational coproduct functor.
858-- | Relational coproduct functor.
862--
859--
863-- @
860-- @
864−-- r '-|-' s == 'eitherR' ('i1' ``comp`` r) ('i2' ``comp`` s)
861+-- r '-|-' s == 'eitherR' ('i1' `.` r) ('i2' `.` s)
865-- @
862-- @
866(-|-) ::
863(-|-) ::
867− ( CountableDimensionsN b d,
864+ ( CountableDimsN b d,
868− FromListsN b b,
865+ FLN b b,
869− FromListsN d b,
866+ FLN d b,
870− FromListsN b d,
867+ FLN b d,
871− FromListsN d d,
868+ FLN d d
872− TrivialE a c,
873− TrivialE b d
874 )
869 )
875 => Relation a b -> Relation c d -> Relation (Either a c) (Either b d)
870 => Relation a b -> Relation c d -> Relation (Either a c) (Either b d)
876(-|-) (R a) (R b) = R ((I.-|-) a b)
871(-|-) (R a) (R b) = R ((I.-|-) a b)
@@ -883,20 +878,20 @@ infixl 5 -|-
883-- 'trans'/'untrans';
878-- 'trans'/'untrans';
884-- more-over, where each particular attribute is placed (input/output) is irrelevant.
879-- more-over, where each particular attribute is placed (input/output) is irrelevant.
885trans ::
880trans ::
886− ( CountableDimensionsN a b,
881+ ( CountableDimsN a b,
887 CountableN c,
882 CountableN c,
888− CountableDimensionsN (a, b) (c, b),
883+ CountableDimsN (a, b) (c, b),
889− FromListsN (c, b) c,
884+ FLN (c, b) c,
890− FromListsN (c, b) b,
885+ FLN (c, b) b,
891− FromListsN (a, b) a,
886+ FLN (a, b) a,
892− FromListsN (a, b) b,
887+ FLN (a, b) b,
893 Trivial (a, b),
888 Trivial (a, b),
894 Trivial (c, b),
889 Trivial (c, b),
895− TrivialP2 a b,
890+ TrivialP a b,
896− TrivialP2 c b
891+ TrivialP c b
897 )
892 )
898 => Relation (a, b) c -> Relation a (c, b)
893 => Relation (a, b) c -> Relation a (c, b)
899−trans r = splitR r p2 `comp` conv p1
894+trans r = splitR r sndR . conv fstR
900
895
901-- | Relational 'untrans'
896-- | Relational 'untrans'
902--
897--
@@ -904,109 +899,110 @@ trans r = splitR r p2 `comp` conv p1
904-- 'trans'/'untrans';
899-- 'trans'/'untrans';
905-- more-over, where each particular attribute is placed (input/output) is irrelevant.
900-- more-over, where each particular attribute is placed (input/output) is irrelevant.
906untrans ::
901untrans ::
907− ( CountableDimensionsN a b,
902+ ( CountableDimsN a b,
908 CountableN c,
903 CountableN c,
909− CountableDimensionsN (a, b) (c, b),
904+ CountableDimsN (a, b) (c, b),
910− FromListsN (c, b) c,
905+ FLN (c, b) c,
911− FromListsN (c, b) b,
906+ FLN (c, b) b,
912− FromListsN (a, b) b,
907+ FLN (a, b) b,
913− FromListsN (a, b) a,
908+ FLN (a, b) a,
914 Trivial (a, b),
909 Trivial (a, b),
915 Trivial (c, b),
910 Trivial (c, b),
916− TrivialP2 a b,
911+ TrivialP a b,
917− TrivialP2 c b
912+ TrivialP c b
918 )
913 )
919 => Relation a (c, b) -> Relation (a, b) c
914 => Relation a (c, b) -> Relation (a, b) c
920−untrans s = p1 `comp` conv (splitR (conv s) p2)
915+untrans s = fstR . conv (splitR (conv s) sndR)
921
916
922-- | Transforms predicate @p@ into a correflexive relation.
917-- | Transforms predicate @p@ into a correflexive relation.
923--
918--
924-- @
919-- @
925−-- 'predR' ('const' True) == 'identity'
920+-- 'predR' ('const' True) == 'id'
926-- 'predR' ('const' False) == 'zeros'
921-- 'predR' ('const' False) == 'zeros'
927-- @
922-- @
928--
923--
929-- @
924-- @
930−-- 'predR' q ``comp`` 'predR' p == 'predR' q ``union`` 'predR' p
925+-- 'predR' q `.` 'predR' p == 'predR' q ``union`` 'predR' p
931-- @
926-- @
932predR ::
927predR ::
933 ( Bounded a,
928 ( Bounded a,
934 Enum a,
929 Enum a,
930+ Countable a,
935 CountableN a,
931 CountableN a,
936− FromListsN a a,
932+ FLN a a,
937− FromListsN Bool a
933+ FLN Bool a
938 )
934 )
939 => Relation a Bool -> Relation a a
935 => Relation a Bool -> Relation a a
940−predR p = identity `intersection` divisionF (fromF' (const True)) p
936+predR p = id `intersection` divisionF (fromF (const True)) p
941
937
942-- | Equalizes functions @f@ and @g@.
938-- | Equalizes functions @f@ and @g@.
943-- That is, @'equalizer' f g@ is the largest coreflexive
939-- That is, @'equalizer' f g@ is the largest coreflexive
944-- that restricts @g@ so that @f@ and @g@ yield the same outputs.
940-- that restricts @g@ so that @f@ and @g@ yield the same outputs.
945--
941--
946-- @
942-- @
947−-- 'equalizer' r r == 'identity'
943+-- 'equalizer' r r == 'id'
948-- 'equalizer' ('point' True) ('point' False) == 'zeros'
944-- 'equalizer' ('point' True) ('point' False) == 'zeros'
949-- @
945-- @
950equalizer ::
946equalizer ::
951 ( CountableN a,
947 ( CountableN a,
952− FromListsN a a
948+ FLN a a
953 )
949 )
954 => Relation a b -> Relation a b -> Relation a a
950 => Relation a b -> Relation a b -> Relation a a
955−equalizer f g = identity `intersection` divisionF f g
951+equalizer f g = id `intersection` divisionF f g
956
952
957-- | Relational conditional guard.
953-- | Relational conditional guard.
958--
954--
959-- @
955-- @
960−-- 'guard' p = 'i2' ``overriddenBy`` 'i1' ``comp`` 'predR' p
956+-- 'guard' p = 'i2' ``overriddenBy`` 'i1' `.` 'predR' p
961-- @
957-- @
962−guard ::
958+guard ::
963 ( Bounded b,
959 ( Bounded b,
964 Enum b,
960 Enum b,
965 CountableN b,
961 CountableN b,
966− FromListsN b b,
962+ Countable b,
963+ FLN b b,
967− FromListsN Bool b,
964+ FLN Bool b
968− TrivialE b b
969 ) => Relation b Bool -> Relation b (Either b b)
965 ) => Relation b Bool -> Relation b (Either b b)
970guard p = conv (eitherR (predR p) (predR (negate p)))
966guard p = conv (eitherR (predR p) (predR (negate p)))
971
967
972-- | Relational McCarthy's conditional.
968-- | Relational McCarthy's conditional.
973−cond ::
969+cond ::
974 ( Bounded b,
970 ( Bounded b,
975 Enum b,
971 Enum b,
972+ Countable b,
976 CountableN b,
973 CountableN b,
977− FromListsN b b,
974+ FLN b b,
978− FromListsN Bool b,
975+ FLN Bool b
979− TrivialE b b
980− )
976+ )
981 => Relation b Bool -> Relation b c -> Relation b c -> Relation b c
977 => Relation b Bool -> Relation b c -> Relation b c -> Relation b c
982−cond p r s = eitherR r s `comp` guard p
978+cond p r s = eitherR r s . guard p
983
979
984-- | Relational domain.
980-- | Relational domain.
985--
981--
986-- For injective relations, 'domain' and 'ker'nel coincide,
982-- For injective relations, 'domain' and 'ker'nel coincide,
987−-- since @'ker' r ``sse`` 'identity'@ in such situations.
983+-- since @'ker' r ``sse`` 'id'@ in such situations.
988domain ::
984domain ::
989 ( CountableN a,
985 ( CountableN a,
990− FromListsN a a
986+ FLN a a
991 ) => Relation a b -> Relation a a
987 ) => Relation a b -> Relation a a
992−domain r = ker r `intersection` identity
988+domain r = ker r `intersection` id
993
989
994-- | Relational range.
990-- | Relational range.
995--
991--
996-- For functions, 'range' and 'img' (image) coincide,
992-- For functions, 'range' and 'img' (image) coincide,
997−-- since @'img' f ``sse`` 'identity'@ for any @f@.
993+-- since @'img' f ``sse`` id@ for any @f@.
998range ::
994range ::
999 ( CountableN b,
995 ( CountableN b,
1000− FromListsN b b
996+ FLN b b
1001 ) => Relation a b -> Relation b b
997 ) => Relation a b -> Relation b b
1002−range r = img r `intersection` identity
998+range r = img r `intersection` id
1003
999
1004-- Relation pretty print
1000-- Relation pretty print
1005
1001
1006-- | Relation pretty printing
1002-- | Relation pretty printing
1007−pretty :: (CountableN a) => Relation a b -> String
1003+pretty :: (CountableDimsN a b) => Relation a b -> String
1008pretty (R a) = I.pretty a
1004pretty (R a) = I.pretty a
1009
1005
1010-- | Relation pretty printing
1006-- | Relation pretty printing
1011−prettyPrint :: (CountableN a) => Relation a b -> IO ()
1007+prettyPrint :: (CountableDimsN a b) => Relation a b -> IO ()
1012prettyPrint (R a) = I.prettyPrint a
1008prettyPrint (R a) = I.prettyPrint a
src/LAoP/Utils.hs+5−2
@@ -95,8 +95,11 @@ module LAoP.Utils
95 coerceNat2,
95 coerceNat2,
96 coerceNat3,
96 coerceNat3,
97
97
98− -- * Powerset data type
98+ -- * List data type
99− List (..)
99+ List (..),
100+
101+ -- * Category type-class
102+ Category(..)
100 )
103 )
101where
104where
102
105
src/LAoP/Utils/Internal.hs+30−74
@@ -1,83 +1,13 @@
1+{-# LANGUAGE TypeFamilies #-}
1{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE TypeApplications #-}
3{-# LANGUAGE TypeApplications #-}
3{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE GeneralizedNewtypeDeriving #-}
6{-# LANGUAGE GeneralizedNewtypeDeriving #-}
6−{-# LANGUAGE KindSignatures #-}
7{-# LANGUAGE ScopedTypeVariables #-}
7{-# LANGUAGE ScopedTypeVariables #-}
8
8
9module LAoP.Utils.Internal
9module LAoP.Utils.Internal
10− ( -- | This is an internal module and it is not meant to be imported.
10+ (
11− --
12− -- Utility module that provides the 'Natural' data type.
13− -- The semantic associated with this data type is that
14− -- it's meant to be a restricted 'Int' value. For example
15− -- the type @Natural 6@ can only be instanciated with @Nat n@
16− -- where @0 <= n <= 6@. Why, You might ask, because with normal
17− -- 'Int's it is not possible to have a decent @Enum (Int, Int)@
18− -- instance. See the following probabilistic programming model as and
19− -- example:
20− --
21− -- We want to calculate the probability of the sum of two dice throws.
22− -- To do this we start by defining the sample space:
23− --
24− -- @
25− -- type SampleSpace = Int -- We think 'Int' are enough
26− --
27− -- die :: Dist Int 6
28− -- die = unifrom [1..6]
29− --
30− -- -- Promote 'Int' addition to a matrix
31− -- addM = fromF (uncurry (+)) -- Impossible
32− -- @
33− --
34− -- The last line is impossible because @(Int, Int)@ does not have
35− -- a good 'Enum' instance: @[(0, 1), (0, 2), .. (0, maxBound), (1, 0),
36− -- ..]@. And we'd like the addition matrix to be of 36 columns by 12
37− -- rows but limited to integers up to @6@!
38− --
39− -- One way to solve this issue is by defining and auxilary data type to
40− -- represent the sample space:
41− --
42− -- @
43− -- data SampleSpace = S1 | S2 | S3 | S4 | S5 | S6
44− -- deriving (Show, Eq, Enum, Bounded) -- Enum and Bounded are
45− -- important
46− -- @
47− --
48− -- And write the sample space addition function:
49− --
50− -- @
51− -- ssAdd :: SampleSpace -> SampleSpace -> Int
52− -- ssAdd a b = (fromEnum a + 1) + (fromEnum b + 1)
53− -- @
54− --
55− -- And then promote that function to matrix and everything is alright:
56− --
57− -- @
58− -- ssAddM = fromF' (uncurry ssAdd)
59− --
60− -- dieSumProb = ssAddM `comp` (khatri die die)
61− -- @
62− --
63− -- This is a nice solution for small sample spaces. But for larger ones
64− -- it is not feasible to write a data type with hundreds of constructors
65− -- and then write manipulation functions that need to deal with them.
66− -- To mitigate this limitation the 'Natural' type comes a long way and
67− -- allows one to model the sample in an easier way. See for instance:
68− --
69− -- @
70− -- ssAdd :: Natural 6 -> Natural 6 -> Natural 12
71− -- ssAdd = coerceNat (+)
72− --
73− -- ssAddM = fromF' (uncurry sumSS)
74− --
75− -- die :: Dist (Natural 6) 6
76− -- die = uniform [nat @6 1 .. nat 6]
77− --
78− -- dieSumProb = ssAddM `comp` (khatri die die)
79− -- @
80− --
81 -- * 'Natural' data type
11 -- * 'Natural' data type
82 Natural(..),
12 Natural(..),
83 nat,
13 nat,
@@ -88,8 +18,11 @@ module LAoP.Utils.Internal
88 coerceNat2,
18 coerceNat2,
89 coerceNat3,
19 coerceNat3,
90
20
91− -- * Powerset data type
21+ -- * 'List' data type
92− List (..)
22+ List (..),
23+
24+ -- * Category type class
25+ Category(..)
93 )
26 )
94where
27where
95
28
@@ -100,6 +33,9 @@ import Data.Maybe
100import GHC.TypeLits
33import GHC.TypeLits
101import Control.DeepSeq
34import Control.DeepSeq
102import GHC.Generics
35import GHC.Generics
36+import Data.Kind
37+import Prelude hiding (id, (.))
38+import qualified Prelude
103
39
104-- | Wrapper around 'Int's that have a restrictive semantic associated.
40-- | Wrapper around 'Int's that have a restrictive semantic associated.
105-- A value of type @'Natural' n m@ can only be instanciated with some 'Int'
41-- A value of type @'Natural' n m@ can only be instanciated with some 'Int'
@@ -238,3 +174,23 @@ instance
238 fromEnum (L x) =
174 fromEnum (L x) =
239 let as = [minBound .. maxBound]
175 let as = [minBound .. maxBound]
240 in fromMaybe (error "Does not exist") $ elemIndex x (powerset as)
176 in fromMaybe (error "Does not exist") $ elemIndex x (powerset as)
177+
178+-- | Constrained category instance
179+class Category k where
180+ type Object k o :: Constraint
181+ type Object k o = ()
182+ id :: Object k a => k a a
183+ (.) :: k b c -> k a b -> k a c
184+
185+{-# RULES
186+"identity/left" forall p .
187+ id . p = p
188+"identity/right" forall p .
189+ p . id = p
190+"association" forall p q r .
191+ (p . q) . r = p . (q . r)
192+ #-}
193+
194+instance Category (->) where
195+ id = Prelude.id
196+ (.) = (Prelude..)
stack-8.8.3.yamlnew file+1
@@ -0,0 +1 @@
1+resolver: lts-15.5
stack.yaml+1−66
@@ -1,66 +1 @@
1−# This file was automatically generated by 'stack init'
2−#
3−# Some commonly used options have been documented as comments in this file.
4−# For advanced use and comprehensive documentation of the format, please see:
5−# https://docs.haskellstack.org/en/stable/yaml_configuration/
6−
7−# Resolver to choose a 'specific' stackage snapshot or a compiler version.
8−# A snapshot resolver dictates the compiler version and the set of packages
9−# to be used for project dependencies. For example:
10−#
11−# resolver: lts-3.5
12−# resolver: nightly-2015-09-21
13−# resolver: ghc-7.10.2
14−#
15−# The location of a snapshot can be provided as a file or url. Stack assumes
16−# a snapshot provided as a file might change, whereas a url resource does not.
17−#
18−# resolver: ./custom-snapshot.yaml
19−# resolver: https://example.com/snapshots/2018-01-01.yaml
20−resolver: lts-14.18
1+resolver: lts-14.3
21−
22−# User packages to be built.
23−# Various formats can be used as shown in the example below.
24−#
25−# packages:
26−# - some-directory
27−# - https://example.com/foo/bar/baz-0.0.2.tar.gz
28−# subdirs:
29−# - auto-update
30−# - wai
31−packages:
32−- .
33−# Dependency packages to be pulled from upstream that are not in the resolver.
34−# These entries can reference officially published versions as well as
35−# forks / in-progress versions pinned to a git hash. For example:
36−#
37−# extra-deps:
38−# - acme-missiles-0.3
39−# - git: https://github.com/commercialhaskell/stack.git
40−# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
41−#
42−# extra-deps: []
43−
44−# Override default flag values for local packages and extra-deps
45−# flags: {}
46−
47−# Extra package databases containing global packages
48−# extra-package-dbs: []
49−
50−# Control whether we use the GHC we find on the path
51−# system-ghc: true
52−#
53−# Require a specific version of stack, using version ranges
54−# require-stack-version: -any # Default
55−# require-stack-version: ">=2.1"
56−#
57−# Override the architecture used by stack, especially useful on Windows
58−# arch: i386
59−# arch: x86_64
60−#
61−# Extra directories used by stack for building
62−# extra-include-dirs: [/path/to/dir]
63−# extra-lib-dirs: [/path/to/dir]
64−#
65−# Allow a newer minor version of GHC than the snapshot specifies
66−# compiler-check: newer-minor
stack.yaml.lock+4−4
@@ -6,7 +6,7 @@
6packages: []
6packages: []
7snapshots:
7snapshots:
8- completed:
8- completed:
9− size: 524789
9+ size: 523878
10− url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/18.yaml
10+ url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/3.yaml
11− sha256: 646be71223e08234131c6989912e6011e01b9767bc447b6d466a35e14360bdf2
11+ sha256: 470c46c27746a48c7c50f829efc0cf00112787a7804ee4ac7a27754658f6d92c
12− original: lts-14.18
12+ original: lts-14.3
test/Examples/Quantum.hsnew file+31
@@ -0,0 +1,31 @@
1+{-# LANGUAGE StandaloneDeriving #-}
2+module Examples.Quantum where
3+
4+import LAoP.Utils
5+import LAoP.Matrix.Type
6+import Data.Complex
7+import Prelude hiding (id, (.))
8+
9+deriving instance Ord a => Ord (Complex a)
10+
11+xor :: (Bool, Bool) -> Bool
12+xor (False, b) = b
13+xor (True, b) = not b
14+
15+ker :: Num e => Matrix e a b -> Matrix e a a
16+ker m = tr m . m
17+
18+cnot :: Matrix (Complex Double) (Bool, Bool) (Bool, Bool)
19+cnot = kr fstM (fromF xor)
20+
21+ccnot :: (Num e, Ord e) => Matrix e ((Bool, Bool), Bool) ((Bool, Bool), Bool)
22+ccnot = kr fstM (fromF f)
23+ where
24+ f = xor . tp (uncurry (&&)) id
25+ tp f g (a,b) = (f a, g b)
26+
27+had :: Matrix (Complex Double) Bool Bool
28+had = (1/sqrt 2) .| fromLists [[1, 1], [1, -1]]
29+
30+bell :: Matrix (Complex Double) (Bool, Bool) (Bool, Bool)
31+bell = cnot . (had >< iden)
app/Examples.hs → test/Examples/Readme.hsrenamed+56−31
@@ -1,10 +1,10 @@
1+{-# LANGUAGE GADTs #-}
1{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleContexts #-}
3−{-# LANGUAGE TypeOperators #-}
4{-# LANGUAGE TypeApplications #-}
4{-# LANGUAGE TypeApplications #-}
5{-# LANGUAGE DataKinds #-}
5{-# LANGUAGE DataKinds #-}
6
6
7−module Examples
7+module Examples.Readme
8 ( exec
8 ( exec
9 )
9 )
10 where
10 where
@@ -15,13 +15,12 @@ import LAoP.Utils
15import LAoP.Dist
15import LAoP.Dist
16import GHC.TypeLits
16import GHC.TypeLits
17import Data.Coerce
17import Data.Coerce
18−import GHC.Generics
18+import qualified GHC.Generics as G
19−import Control.Category hiding (id)
19+import Prelude hiding (id, (.))
20−import Prelude hiding ((.))
21
20
22-- Monty Hall Problem
21-- Monty Hall Problem
23data Outcome = Win | Lose
22data Outcome = Win | Lose
24− deriving (Bounded, Enum, Eq, Show, Generic)
23+ deriving (Bounded, Enum, Eq, Show, G.Generic)
25
24
26switch :: Outcome -> Outcome
25switch :: Outcome -> Outcome
27switch Win = Lose
26switch Win = Lose
@@ -31,7 +30,7 @@ firstChoice :: Matrix Double () Outcome
31firstChoice = col [1/3, 2/3]
30firstChoice = col [1/3, 2/3]
32
31
33secondChoice :: Matrix Double Outcome Outcome
32secondChoice :: Matrix Double Outcome Outcome
34−secondChoice = fromF' switch
33+secondChoice = fromF switch
35
34
36-- Dice sum
35-- Dice sum
37
36
@@ -40,7 +39,7 @@ type SS = Natural 1 6 -- Sample Space
40sumSS :: SS -> SS -> Natural 2 12
39sumSS :: SS -> SS -> Natural 2 12
41sumSS = coerceNat (+)
40sumSS = coerceNat (+)
42
41
43−sumSSM = fromF' (uncurry sumSS)
42+sumSSM = fromF (uncurry sumSS)
44
43
45condition :: (Int, Int) -> Int -> Int
44condition :: (Int, Int) -> Int -> Int
46condition (fst, snd) thrd = if fst == snd
45condition (fst, snd) thrd = if fst == snd
@@ -50,38 +49,64 @@ condition (fst, snd) thrd = if fst == snd
50conditionSS :: (SS, SS) -> SS -> Natural 3 18
49conditionSS :: (SS, SS) -> SS -> Natural 3 18
51conditionSS = coerceNat2 condition
50conditionSS = coerceNat2 condition
52
51
53−conditionalThrows = fromF' (uncurry conditionSS) . khatri (khatri die die) die
52+conditionalThrows = fromF (uncurry conditionSS) . kr (kr die die) die
54
53
55die :: Matrix Double () SS
54die :: Matrix Double () SS
56die = col $ map (const (1/6)) [nat @1 @6 1 .. nat 6]
55die = col $ map (const (1/6)) [nat @1 @6 1 .. nat 6]
57
56
58-- Sprinkler
57-- Sprinkler
58+data G = Dry | Wet
59+ deriving (Bounded, Enum, Eq, Show, G.Generic)
59
60
60−rain :: Matrix Double () Bool
61+data S = Off | On
61−rain = col [0.8, 0.2]
62+ deriving (Bounded, Enum, Eq, Show, G.Generic)
62
63
63−sprinkler :: Matrix Double Bool Bool
64+data R = No | Yes
64−sprinkler = fromLists [[0.6, 0.99], [0.4, 0.01]]
65+ deriving (Bounded, Enum, Eq, Show, G.Generic)
65
66
67+rain :: Matrix Double () R
68+rain = matrixBuilder gen
69+ where
70+ gen (_, No) = 0.8
71+ gen (_, Yes) = 0.2
72+
73+sprinkler :: Matrix Double R S
74+sprinkler = matrixBuilder gen
75+ where
76+ gen (No, Off) = 0.6
77+ gen (No, On) = 0.4
78+ gen (Yes, Off) = 0.99
79+ gen (Yes, On) = 0.01
80+
66−grass :: Matrix Double (Bool, Bool) Bool
81+grass :: Matrix Double (S, R) G
67−grass = fromLists [[1, 0.2, 0.1, 0.01], [0, 0.8, 0.9, 0.99]]
82+grass = matrixBuilder gen
83+ where
84+ gen ((Off, No), Dry) = 1
85+ gen ((Off, Yes), Dry) = 0.2
86+ gen ((On, No), Dry) = 0.1
87+ gen ((On, Yes), Dry) = 0.01
88+ gen ((Off, No), Wet) = 0
89+ gen ((Off, Yes), Wet) = 0.8
90+ gen ((On, No), Wet) = 0.9
91+ gen ((On, Yes), Wet) = 0.99
92+
93+tag f = kr f id
68
94
69−state :: Matrix Double () (Bool, (Bool, Bool))
95+state g s r = tag g . tag s . r
70−state = khatri grass identity . khatri sprinkler identity . rain
71
96
72−grass_wet :: Matrix Double (Bool, (Bool, Bool)) One
97+grass_wet :: Matrix Double () (G, (S, R)) -> Matrix Double One One
73−grass_wet = row [0,1] . kp1
98+grass_wet state = row [0,1] . fstM . state
74
99
75−rainning :: Matrix Double (Bool, (Bool, Bool)) One
100+rainning :: Matrix Double (G, (S, R)) One
76−rainning = row [0,1] . kp2 . kp2
101+rainning = row [0,1] . sndM . sndM
77
102
78-- Alcuin Puzzle
103-- Alcuin Puzzle
79
104
80data Being = Farmer | Fox | Goose | Beans
105data Being = Farmer | Fox | Goose | Beans
81− deriving (Bounded, Enum, Eq, Show, Generic)
106+ deriving (Bounded, Enum, Eq, Show, G.Generic)
82
107
83data Bank = LeftB | RightB
108data Bank = LeftB | RightB
84− deriving (Bounded, Enum, Eq, Show, Generic)
109+ deriving (Bounded, Enum, Eq, Show, G.Generic)
85
110
86eats :: Being -> Being -> Bool
111eats :: Being -> Being -> Bool
87eats Fox Goose = True
112eats Fox Goose = True
@@ -96,21 +121,21 @@ cross LeftB = RightB
96cross RightB = LeftB
121cross RightB = LeftB
97
122
98crossR :: R.Relation Bank Bank
123crossR :: R.Relation Bank Bank
99−crossR = R.fromF' cross
124+crossR = R.fromF cross
100
125
101-- | Initial state, everyone in the left bank
126-- | Initial state, everyone in the left bank
102locationLeft :: Being -> Bank
127locationLeft :: Being -> Bank
103locationLeft _ = LeftB
128locationLeft _ = LeftB
104
129
105locationLeftR :: R.Relation Being Bank
130locationLeftR :: R.Relation Being Bank
106−locationLeftR = R.fromF' locationLeft
131+locationLeftR = R.fromF locationLeft
107
132
108-- | Initial state, everyone in the right bank
133-- | Initial state, everyone in the right bank
109locationRight :: Being -> Bank
134locationRight :: Being -> Bank
110locationRight _ = RightB
135locationRight _ = RightB
111
136
112locationRightR :: R.Relation Being Bank
137locationRightR :: R.Relation Being Bank
113−locationRightR = R.fromF' locationRight
138+locationRightR = R.fromF locationRight
114
139
115-- Properties
140-- Properties
116
141
@@ -127,7 +152,7 @@ inv :: R.Relation Being Bank -> Bool
127inv w = (w `R.comp` canEat w) `R.sse` (w `R.comp` farmer)
152inv w = (w `R.comp` canEat w) `R.sse` (w `R.comp` farmer)
128 where
153 where
129 farmer :: R.Relation Being Being
154 farmer :: R.Relation Being Being
130− farmer = R.fromF' (const Farmer)
155+ farmer = R.fromF (const Farmer)
131
156
132-- Arbitrary state
157-- Arbitrary state
133bankState :: Being -> Bank -> Bool
158bankState :: Being -> Bank -> Bool
@@ -146,14 +171,14 @@ exec = do
146 putStrLn "Monty Hall Problem solution:"
171 putStrLn "Monty Hall Problem solution:"
147 prettyPrint (secondChoice . firstChoice)
172 prettyPrint (secondChoice . firstChoice)
148 putStrLn "\n Sum of dices probability:"
173 putStrLn "\n Sum of dices probability:"
149− prettyPrint (sumSSM `comp` khatri die die)
174+ prettyPrint (sumSSM . kr die die)
150 putStrLn "\n Conditional dice throw:"
175 putStrLn "\n Conditional dice throw:"
151 prettyPrint conditionalThrows
176 prettyPrint conditionalThrows
152 putStrLn "\n Checking that the last result is indeed a distribution: "
177 putStrLn "\n Checking that the last result is indeed a distribution: "
153− prettyPrint (bang . sumSSM . khatri die die)
178+ prettyPrint (bang . sumSSM . kr die die)
154 putStrLn "\n Probability of grass being wet:"
179 putStrLn "\n Probability of grass being wet:"
155− prettyPrint (grass_wet . state)
180+ prettyPrint (grass_wet (state grass sprinkler rain))
156 putStrLn "\n Probability of rain:"
181 putStrLn "\n Probability of rain:"
157− prettyPrint (rainning . state)
182+ prettyPrint (rainning . state grass sprinkler rain)
158 putStrLn "\n Is the arbitrary state a valid state? (Alcuin Puzzle)"
183 putStrLn "\n Is the arbitrary state a valid state? (Alcuin Puzzle)"
159 print (inv bankStateR)
184 print (inv bankStateR)
test/Examples/Spreadsheets.hsnew file+47
@@ -0,0 +1,47 @@
1+{-# LANGUAGE DeriveGeneric #-}
2+
3+module Examples.Spreadsheets
4+
5+import LAoP.Utils
6+import LAoP.Matrix.Type
7+import GHC.Generics
8+import Prelude hiding (id, (.))
9+
10+data Student = Student1 | Student2 | Student3 | Student4
11+ deriving (Eq, Show, Enum, Bounded, Generic)
12+
13+data Question = Question1 | Question2 | Question3 | Question4
14+ deriving (Eq, Show, Enum, Bounded, Generic)
15+
16+data Results = Exam | Test | Final
17+ deriving (Eq, Show, Enum, Bounded, Generic)
18+
19+test :: Matrix Float One Results
20+test = point Test
21+
22+exam :: Matrix Float One Results
23+exam = point Exam
24+
25+final :: Matrix Float One Results
26+final = point Final
27+
28+m :: Matrix Float Question Student
29+m = fromLists [[95, 90, 100, 40], [20, 90, 90, 0], [30, 20, 95, 0], [50, 80, 100, 30]]
30+
31+w :: Matrix Float Question One
32+w = fromLists [[0.2, 0.3, 0.2, 0.3]]
33+
34+xls :: Matrix Float Question One
35+ -> Matrix Float Question Student
36+ -> Matrix Float Student One
37+ -> Matrix Float (Either Question Results) (Either One Student)
38+xls w m t = join (fork w m) (fork zeros r)
39+ where
40+ rExam = m . tr w
41+ rTest = tr t
42+ rFinal = rTest `maxPW` rExam
43+ r = (rExam . tr exam) + (rTest . tr test) + (rFinal . tr final)
44+
45+-- | Overloaded, point-wise 'max' function
46+maxPW :: Ord e => Matrix e a b -> Matrix e a b -> Matrix e a b
47+maxPW = zipWithM max
test/Spec.hs+7−1
@@ -1,2 +1,8 @@
1+module Main (main) where
2+
3+import qualified Examples.Readme as RD
4+
1main :: IO ()
5main :: IO ()
2−main = putStrLn "Test suite not yet implemented"
6+main = do
7+ putStrLn ("Testing if README works" :: String)
8+ RD.exec