In [109]:
Pkg.test("KroneckerMatrices")


INFO: Testing KroneckerMatrices
INFO: KroneckerMatrices tests passed
INFO: No packages to install, update or remove

In [1]:
using KroneckerMatrices

In [5]:
using Gadfly

In [6]:
using DataFrames

In [29]:
A = rand(3,3)
B = ones(4,4)

Cimpl = KroneckerProduct(A,B)
Cexpl = kronproduct(A,B)


Out[29]:
12x12 Array{Float64,2}:
 0.102267  0.102267  0.102267  0.102267  …  0.921396  0.921396  0.921396
 0.102267  0.102267  0.102267  0.102267     0.921396  0.921396  0.921396
 0.102267  0.102267  0.102267  0.102267     0.921396  0.921396  0.921396
 0.102267  0.102267  0.102267  0.102267     0.921396  0.921396  0.921396
 0.836437  0.836437  0.836437  0.836437     0.643881  0.643881  0.643881
 0.836437  0.836437  0.836437  0.836437  …  0.643881  0.643881  0.643881
 0.836437  0.836437  0.836437  0.836437     0.643881  0.643881  0.643881
 0.836437  0.836437  0.836437  0.836437     0.643881  0.643881  0.643881
 0.661172  0.661172  0.661172  0.661172     0.955642  0.955642  0.955642
 0.661172  0.661172  0.661172  0.661172     0.955642  0.955642  0.955642
 0.661172  0.661172  0.661172  0.661172  …  0.955642  0.955642  0.955642
 0.661172  0.661172  0.661172  0.661172     0.955642  0.955642  0.955642

In [50]:
Λimpl,Vimpl = eig(Cimpl)
Λimpl,Vimpl = vec(convert(Matrix{eltype(Λimpl)},Λimpl)),convert(Matrix{eltype(Vimpl)},Vimpl)
Λexpl,Vexpl = eig(Cexpl)
Λimplflat = [abs(λ)>10*eps() ? 1. : 0. for λ in Λimpl]
Λexplflat = [abs(λ)>10*eps() ? 1. : 0. for λ in Λexpl]


Out[50]:
12-element Array{Float64,1}:
 1.0
 1.0
 1.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0

In [61]:
maximum(abs(Vimpl*diagm(Λimplflat)*inv(Vimpl)-Vexpl*diagm(Λexplflat)*inv(Vexpl)))


Out[61]:
3.9430111370396e-13

In [57]:
round(3*abs(Vexpl*diagm(Λexplflat)*inv(Vexpl)))


Out[57]:
12x12 Array{Float64,2}:
 1.0  1.0  1.0  1.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 1.0  1.0  1.0  1.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 1.0  1.0  1.0  1.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 1.0  1.0  1.0  1.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  1.0  1.0  1.0  1.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  1.0  1.0  1.0  1.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  1.0  1.0  1.0  1.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  1.0  1.0  1.0  1.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  1.0  1.0  1.0  1.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  1.0  1.0  1.0  1.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  1.0  1.0  1.0  1.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  1.0  1.0  1.0  1.0

In [ ]:
#ΛU = diagm([λ >10*eps() ? 1. : 0. for λ in convert(Matrix{eltype(C)}eigvals(C)])
#ΛV = diagm([λ >10*eps() ? 1. : 0. for λ in eigvals(D)])
#err = maximum(abs(U*U'-V*V'))

In [21]:



Out[21]:
12-element Array{Float64,1}:
 0.0
 0.0
 0.0
 1.0
 0.0
 0.0
 0.0
 1.0
 0.0
 0.0
 0.0
 1.0

In [12]:
Λimpl[3,1]


Out[12]:
-1.6222713971230417e-19 + 2.0431019656590795e-18im

In [5]:
taco[:vectors]


Out[5]:
12x12 KroneckerProduct{Complex{Float64}}:
 -0.275502+0.0im      0.477183+0.0im  …  -0.335684+0.0im     
 -0.275502+0.0im     -0.477183+0.0im     -0.335684+0.0im     
  0.551004+0.0im  -5.90892e-17+0.0im     -0.335684+0.0im     
       0.0+0.0im           0.0+0.0im     -0.335684+0.0im     
 -0.213999+0.0im      0.370658+0.0im     0.0642928+0.272759im
 -0.213999+0.0im     -0.370658+0.0im  …  0.0642928+0.272759im
  0.427998+0.0im  -4.58983e-17+0.0im     0.0642928+0.272759im
       0.0+0.0im           0.0+0.0im     0.0642928+0.272759im
 -0.212061+0.0im        0.3673+0.0im      0.193026-0.146718im
 -0.212061+0.0im       -0.3673+0.0im      0.193026-0.146718im
  0.424121+0.0im  -4.54825e-17+0.0im  …   0.193026-0.146718im
       0.0+0.0im           0.0+0.0im      0.193026-0.146718im

In [126]:
U*U'*V*V'-V*V'*U*U'


Out[126]:
12x12 Array{Float64,2}:
 -2.22045e-16   5.39647e-5    0.000920147  …  -0.0395441    -0.0374592  
 -5.39647e-5   -4.44089e-16   0.000605818     -0.061658     -0.114027   
 -0.000920147  -0.000605818   2.22045e-16      0.105038      0.000937943
  0.000974111   0.000551853  -0.00152596      -0.00383547    0.150549   
  0.0120515     0.0219498     0.0346389       -0.013134      0.0238598  
  0.0181327    -0.0108376     0.0166599    …  -0.000880114   0.0200356  
  0.030965      0.0205865     0.0751401       -0.0517453     0.0370195  
 -0.0611492    -0.0316987    -0.126439         0.0657595    -0.0809148  
 -0.162128      0.0838743     0.0407619       -0.000526382   7.36538e-5 
  0.0851251    -0.25956       0.0652136       -0.00117709    0.00162981 
  0.0395441     0.061658     -0.105038     …   0.0          -0.00170347 
  0.0374592     0.114027     -0.000937943      0.00170347    0.0        

In [121]:
methods(step)


Out[121]:
3 methods for generic function step:

In [91]:
convert(Matrix{Float64},eigvecs(C))-D


Out[91]:
12x12 Array{Float64,2}:
 -0.687777   -0.130888  -0.628075   …  -0.4287     -0.537975  -0.561165
 -0.687777   -0.836994  -0.628075      -0.583892   -0.537975  -0.561165
 -0.0762709  -0.483941  -0.628075      -0.506296   -0.537975  -0.561165
 -0.483941   -0.483941  -0.0515415     -0.506296   -0.411261  -0.561165
 -0.718427    0.169914  -0.623191      -1.30901    -0.449804  -0.267463
 -0.718427   -0.956457  -0.623191   …  -0.0887611  -0.449804  -0.267463
  0.257039   -0.393272  -0.623191      -0.698887   -0.449804  -0.267463
 -0.393272   -0.393272   0.296487      -0.698887   -1.44614   -0.267463
 -0.806603   -0.426152  -0.765817       0.0979331  -0.393393  -0.497662
 -0.806603   -0.908545  -0.765817      -0.59985    -0.393393  -0.497662
 -0.388838   -0.667348  -0.765817   …  -0.250959   -0.393393  -0.497662
 -0.667348   -0.667348  -0.371944      -0.250959    0.176345  -0.497662

In [94]:
StridedMatrix


Out[94]:
Union(DenseArray{T,2},SubArray{T,2,A<:DenseArray{T,N},I<:(Union(Range{Int64},Int64)...,)})

In [76]:
hist


Out[76]:
hist (generic function with 6 methods)

In [31]:
V*U-U*V


Out[31]:
6x6 Array{Float64,2}:
  0.68168     1.00642   -2.00809     0.0125477   0.489742    0.141104
 -0.0124715  -0.33853    0.314008   -0.545658    0.116746   -0.346143
  0.0772363   0.180965  -0.416113   -0.0242226  -0.0150421   0.202047
 -0.372491    0.261971   0.369377   -0.0107876  -0.42254     0.356804
 -0.35363     0.819418   0.0485728  -1.03453    -0.174515   -0.287268
 -0.179193    0.139975  -0.011857   -0.340921   -0.238397    0.258265

In [12]:
kronpower(A::Matrix,n::Integer) = n==1 ? A : kron([A for _ in 1:n]...)


Out[12]:
kronpower (generic function with 1 method)

In [14]:
kronpower(A,2)


Out[14]:
4x4 Array{Float64,2}:
 0.520953  0.665588  0.665588  0.850379
 0.616715  0.161049  0.787937  0.205762
 0.616715  0.787937  0.161049  0.205762
 0.730079  0.190653  0.190653  0.049787

In [12]:
taco = KroneckerProduct(Diagonal([1,2]),ones(Int64,2,2),ones(Int64,2,2))


Out[12]:
8x8 KroneckerProduct{Int64}:
 1  0  1  0  1  0  1  0
 0  2  0  2  0  2  0  2
 1  0  1  0  1  0  1  0
 0  2  0  2  0  2  0  2
 1  0  1  0  1  0  1  0
 0  2  0  2  0  2  0  2
 1  0  1  0  1  0  1  0
 0  2  0  2  0  2  0  2

In [71]:
A = [[BigInt(4) BigInt(2)];[BigInt(1) BigInt(3)]]


Out[71]:
2x2 Array{BigInt,2}:
 4  2
 1  3

In [9]:
methods(eigvals)


Out[9]:
13 methods for generic function eigvals:

In [6]:
methods(eigvecs)


Out[6]:
7 methods for generic function eigvecs:

In [107]:
chol([[1 1];[1 -1]])


PosDefException(2)
while loading In[107], in expression starting on line 1

 in cholfact! at linalg/factorization.jl:38
 in cholfact at linalg/factorization.jl:42
 in chol at linalg/factorization.jl:46

In [92]:
det(Diagonal([1:20])),det(Diagonal([1:21]))


Out[92]:
(2432902008176640000,-4249290049419214848)

In [200]:
type Totemyst{T}
    As::Vector{AbstractMatrix{T}}
    Totemyst(As::Vector{AbstractMatrix{T}}) = new(As)
end

In [230]:
type Boldygomet{T} <:AbstractMatrix{T}
    vals::Vector{AbstractMatrix{T}}
end

In [236]:
import Base:size

In [ ]:
size(A::Boldygomet{Float64})

In [244]:
type KroneckerProducty{T}
    terms::Vector{AbstractMatrix{T}}
end

In [245]:
function KroneckerProducty(terms...)
    return KroneckerProduct(AbstractMatrix{Float64}[terms...])
end


Out[245]:
KroneckerProducty{T} (constructor with 2 methods)

In [251]:
KroneckerProducty(Any[Diagonal([3,4]),rand(5,6),rand(5,5)]...)


Out[251]:
KroneckerProduct{Float64}(AbstractArray{Float64,2}[
2x2 Diagonal{Float64}:
 3.0  0.0
 0.0  4.0,

5x6 Array{Float64,2}:
 0.280193  0.36612   0.164924  0.991472   0.262739  0.0346637
 0.958627  0.286257  0.40704   0.427967   0.758311  0.183003 
 0.381556  0.97064   0.824592  0.0473387  0.325171  0.868926 
 0.272017  0.355176  0.777711  0.449594   0.389063  0.667553 
 0.234192  0.532251  0.347744  0.40202    0.994352  0.819826 ,

5x5 Array{Float64,2}:
 0.353859  0.912156  0.598793  0.855992  0.100458
 0.323742  0.856881  0.650593  0.991217  0.348951
 0.29162   0.50453   0.328308  0.388857  0.640067
 0.869212  0.822574  0.446284  0.946121  0.557782
 0.140416  0.646262  0.189146  0.536111  0.65528 ])

In [16]:
methods(factor)


Out[16]:
1 method for generic function factor:

In [264]:
T = promote_type(Int64,Int64,Float64,Complex64)


Out[264]:
Complex{Float64} (constructor with 1 method)

In [51]:
A = [[1 0];
     [0 4]]
B = [[1 2];
     [0 4]]
C = [[1 2];
     [3 4]]
[eltype(det(M)) for M in (A,B,C)]


Out[51]:
3-element Array{Any,1}:
 Int64  
 Int64  
 Float64

In [50]:
det(C)


Out[50]:
-2.0

In [58]:
zero(Int64)


Out[58]:
0

In [52]:
taco = lufact(A)


Out[52]:
LU{Float64,Array{Float64,2}}(2x2 Array{Float64,2}:
 1.0  0.0
 0.0  4.0,[1,2],0)

In [53]:
methods(lufact)


Out[53]:
5 methods for generic function lufact:
  • lufact{Tv<:Union(Complex{Float64},Float64),Ti<:Union(Int32,Int64)}(S::SparseMatrixCSC{Tv<:Union(Complex{Float64},Float64),Ti<:Union(Int32,Int64)}) at linalg/umfpack.jl:118
  • lufact{T<:Union(Complex{Float64},Float32,Float64,Complex{Float32})}(A::AbstractArray{T<:Union(Complex{Float64},Float32,Float64,Complex{Float32}),2}) at linalg/lu.jl:64
  • lufact{T}(A::AbstractArray{T,2}) at linalg/lu.jl:65
  • lufact(x::Number) at linalg/lu.jl:66
  • lufact(F::LU{T,S<:AbstractArray{T,2}}) at linalg/lu.jl:67

In [57]:
one(Int64)/one(Int64)


Out[57]:
1.0

In [193]:
bob = Totem(rand(3,3),rand(3,3))


`Totem{T}` has no method matching Totem{T}(::Array{Float64,2}, ::Array{Float64,2})
while loading In[193], in expression starting on line 1

In [222]:
Any[Diagonal([1,2,4]) rand(3,3)]


Out[222]:
1x2 Array{Any,2}:
 3x3 Diagonal{Int64}:
 1  0  0
 0  2  0
 0  0  4  …  3x3 Array{Float64,2}:
 0.107489  0.799587  0.259546
 0.826937  0.7845    0.248249
 0.697025  0.83114   0.226918

In [225]:
abstract Lost{T} <: AbstractMatrix{T}

In [ ]:
type Lope{T} <:Lost{T}
end

In [189]:
function h(tacos::Matrix...)
    return tacos[1]
end


Out[189]:
h (generic function with 1 method)

In [190]:
h(rand(4,5),rand(2,2))


Out[190]:
4x5 Array{Float64,2}:
 0.0298125  0.0177663  0.231527  0.834273  0.555125
 0.821613   0.233224   0.829963  0.798345  0.745574
 0.777108   0.158121   0.958504  0.750942  0.506544
 0.551758   0.302045   0.598882  0.346077  0.022479

In [226]:
tom = Tote(AbstractMatrix{Float64}[rand(2,2), rand(2,2), rand(3,3)])


Out[226]:
Tote{Float64}(AbstractArray{Float64,2}[
2x2 Array{Float64,2}:
 0.603752  0.20194 
 0.323101  0.723753,

2x2 Array{Float64,2}:
 0.35319   0.559634 
 0.392129  0.0881243,

3x3 Array{Float64,2}:
 0.746471  0.602633   0.385239
 0.678258  0.0984073  0.680939
 0.164431  0.207257   0.625511])

In [169]:
bob = [A::Matrix{Float64} for A in Any[rand(2,2), rand(2,2), rand(3,3)]]


Out[169]:
3-element Array{Array{Float64,2},1}:
 2x2 Array{Float64,2}:
 0.409277  0.512014
 0.427051  0.291574                                                  
 2x2 Array{Float64,2}:
 0.126504  0.819804
 0.685401  0.777144                                                  
 3x3 Array{Float64,2}:
 0.51315   0.553133  0.173845
 0.837948  0.509068  0.641668
 0.702207  0.221764  0.287606

In [170]:



Out[170]:
3-element Array{Array{Float64,2},1}:
 2x2 Array{Float64,2}:
 0.023356  0.320177
 0.589151  0.145525                                                        
 2x2 Array{Float64,2}:
 0.0434465  0.630183
 0.0610082  0.274149                                                      
 3x3 Array{Float64,2}:
 0.995517   0.0465565  0.22003 
 0.0562721  0.157457   0.421315
 0.572043   0.723058   0.876339

In [113]:
A = rand(2,3)
B = rand(3,4)
C = KroneckerProduct(A,B)


Out[113]:
6x12 KroneckerProduct{Float64}:
 0.0595408  0.369519  0.585423  …  0.00433052  0.0268759  0.042579 
 0.506168   0.636393  0.967985     0.0368147   0.0462862  0.0704035
 0.042217   0.262005  0.415091     0.0254345   0.15785    0.25008  
 0.358895   0.451231  0.686344     0.216224    0.271854   0.413503 
 0.0594453  0.368926  0.584484     0.0553461   0.343486   0.54418  
 0.505357   0.635373  0.966433  …  0.470509    0.59156    0.899791 

In [109]:
sizes(C) = [size(term) for term in terms(C)]


Out[109]:
sizes (generic function with 1 method)

In [114]:
terms(C)


Out[114]:
(
2x3 Array{Float64,2}:
 0.059776  0.370979  0.587736
 0.508168  0.638908  0.971809,

3x4 Array{Float64,2}:
 0.996065  0.983974  0.899303  0.0724458
 0.706254  0.816492  0.848316  0.425498 
 0.994468  0.732049  0.56052   0.925893 )

In [149]:
tacos = [(2,2),(3,5),(4,4)]


Out[149]:
3-element Array{(Int64,Int64),1}:
 (2,2)
 (3,5)
 (4,4)

In [150]:
x,y = [[S...] for S in zip(tacos...)]


Out[150]:
2-element Array{Any,1}:
 [2,3,4]
 [2,5,4]

In [151]:
y


Out[151]:
3-element Array{Int64,1}:
 2
 5
 4

In [1]:
using Iterators

In [35]:
Ms = Any[rand(2,2) ones(3,3) rand(2,2)]
[prod([λs...])::Float64 for λs in product([eigvals(M) for M in Ms]...)]


Out[35]:
12-element Array{Float64,1}:
 -3.10224e-17
 -2.8891e-16 
  4.02956e-19
  3.75271e-18
  0.165477   
  1.54108    
  3.18059e-18
  2.96207e-17
 -4.13133e-20
 -3.84749e-19
 -0.0169657  
 -0.158      

In [87]:
Ms,Ns = [[S...] for S in  zip([(2,2),(3,3),(5,5)]...)]


Out[87]:
2-element Array{Any,1}:
 [2,3,5]
 [2,3,5]

In [97]:
all(Ms .== Ns)


Out[97]:
false

In [89]:
K = prod(Ms)


Out[89]:
30

In [90]:
Ks = [div(K,M) for M in Ms]


Out[90]:
3-element Array{Any,1}:
 15
 10
  6

In [37]:
[prod([taco...]) for taco in product(tacos...)]


Out[37]:
24-element Array{Any,1}:
 1.0
 2.0
 3.0
 1.0
 2.0
 3.0
 1.0
 2.0
 3.0
 1.0
 2.0
 3.0
 2.0
 4.0
 6.0
 2.0
 4.0
 6.0
 2.0
 4.0
 6.0
 2.0
 4.0
 6.0

In [151]:
A = ones(2,2)
B = rand(3,3)
C = kronproduct(A,B)
D = kronsum(A,B)


Out[151]:
6x6 Array{Float64,2}:
 1.65115   0.670688  0.790988  1.0       0.0       0.0     
 0.182858  1.39992   0.644648  0.0       1.0       0.0     
 0.57719   0.229437  1.82013   0.0       0.0       1.0     
 1.0       0.0       0.0       1.65115   0.670688  0.790988
 0.0       1.0       0.0       0.182858  1.39992   0.644648
 0.0       0.0       1.0       0.57719   0.229437  1.82013 

In [45]:
EC,VC = eig(C)
ED,VD = eig(D)


Out[45]:
([2.14702,-0.596853,1.34104,0.998677,0.192693,0.209131],
6x6 Array{Float64,2}:
 0.175534   0.505391   0.510511   0.0862698   0.250901   -0.173774
 0.194734  -0.709849   0.566351   0.165621    0.48168     0.244074
 0.206082   0.425787   0.599354  -0.27628    -0.803514   -0.146403
 0.496254  -0.127004  -0.12829    0.243894   -0.0630508  -0.491277
 0.550534   0.178383  -0.142323   0.468227   -0.121045    0.690025
 0.582616  -0.106999  -0.150616  -0.781073    0.201921   -0.413896)

In [53]:
maximum(abs(C*D-D*C))


Out[53]:
1.1102230246251565e-16

In [39]:
all(issquare,terms(C))


Out[39]:
7 methods for generic function all:

In [131]:
function spyy(A::AbstractMatrix)
    M,N = size(A)
    is, js, values = findnz(A)
    df = DataFrames.DataFrame(i=is, j=js, value=values)
    plot(df, x="j", y="i", color="value",
         Coord.cartesian(yflip=true,fixed=true,ymin=1,ymax=M,xmin=1,xmax=N),
         Guide.xlabel(""),Guide.ylabel(""),
         Scale.color_continuous,
         Theme(grid_line_width= 0pt),
    Scale.x_continuous(maxvalue = N-5),
    Scale.y_continuous(maxvalue = M-5),
         Geom.rectbin,
         Stat.identity)
end


Out[131]:
spyy (generic function with 1 method)

In [142]:
A = [1 1; 1 0]


Out[142]:
2x2 Array{Int64,2}:
 1  1
 1  0

In [143]:
size(kronpower(A,5))


Out[143]:
(64,64)

In [147]:
tacobeast = spyy(kronpower(A,5))


Out[147]:
-70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 1 value -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120

In [135]:
A = [1 1 1; 1 1 0; 1 0 0]
spyy(kronpower(A,3))


Out[135]:
-100 -80 -60 -40 -20 0 20 40 60 80 100 120 140 160 180 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 -100 0 100 200 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 1 value -100 -80 -60 -40 -20 0 20 40 60 80 100 120 140 160 180 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 -100 0 100 200 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160

In [82]:
boast = tacobeast.scales[2]


Out[82]:
ContinuousScale([:x,:xmin,:xmax,:xintercept,:xviewmin,:xviewmax],ContinuousScaleTransform(identity,identity,identity_formatter),nothing,nothing,2,10,nothing,nothing,true)

In [92]:
boast.vars


Out[92]:
6-element Array{Symbol,1}:
 :x         
 :xmin      
 :xmax      
 :xintercept
 :xviewmin  
 :xviewmax  

In [95]:
Scale.ContinuousScale()


ContinuousScaleTransform not defined
while loading In[95], in expression starting on line 1

In [32]:
A = [1 1 1 1 1; 1 1 1 1 0 ; 1 1 1 0 0; 1 1 0 1 1; 1 0 0 1 0]


Out[32]:
5x5 Array{Int64,2}:
 1  1  1  1  1
 1  1  1  1  0
 1  1  1  0  0
 1  1  0  1  1
 1  0  0  1  0

In [34]:
spyy(kronpower(A,2))


Out[34]:
-200 -150 -100 -50 0 50 100 150 200 250 300 350 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200 205 210 215 220 225 230 235 240 245 250 255 260 265 270 275 280 285 290 295 300 -200 0 200 400 -150 -140 -130 -120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 1 value -200 -150 -100 -50 0 50 100 150 200 250 300 350 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200 205 210 215 220 225 230 235 240 245 250 255 260 265 270 275 280 285 290 295 300 -200 0 200 400 -150 -140 -130 -120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300

In [172]:
P = [1,2,3,4]
N::Int = sqrt(length(P))


type: typeassert: expected Int64, got Float64
while loading In[172], in expression starting on line 2

In [167]:



N not defined
while loading In[167], in expression starting on line 1

In [168]:
N::Int = 3


N not defined
while loading In[168], in expression starting on line 1

In [207]:
a = [1,2,3]
b = [1,1]
c = [4,3,2,1]
m = kron(kron(a,b),c)'
spark(m),m


▂▂▁▁▂▂▁▁▅▄▂▁▅▄▂▁█▆▄▂█▆▄▂
Out[207]:
(nothing,
1x24 Array{Int64,2}:
 4  3  2  1  4  3  2  1  8  6  4  2  8  6  4  2  12  9  6  3  12  9  6  3)

In [218]:
[mod(i-1,length(c)) for i in 1:24]'


Out[218]:
1x24 Array{Any,2}:
 0  1  2  3  0  1  2  3  0  1  2  3  0  1  2  3  0  1  2  3  0  1  2  3

In [220]:
[mod(div(i-1,length(c)),length(b)) for i in 1:24]'


Out[220]:
1x24 Array{Any,2}:
 0  0  0  0  1  1  1  1  0  0  0  0  1  1  1  1  0  0  0  0  1  1  1  1

In [222]:
[mod(div(i-1,length(c)*length(b)),length(a)) for i in 1:24]'


Out[222]:
1x24 Array{Any,2}:
 0  0  0  0  0  0  0  0  1  1  1  1  1  1  1  1  2  2  2  2  2  2  2  2

In [230]:
function hindexes(i,widths)
    indexes = zeros(Int64,length(widths))
    q = 1
    for (level,width) in enumerate(widths)
        indexes[level] = mod(div(i-1,q),width)+1
        q = q*width
    end
    return indexes
end


Out[230]:
hindexes (generic function with 1 method)

In [293]:



Out[293]:
hindexes (generic function with 2 methods)

In [313]:
function hindexes(i::Int64,widths)
    return [(mod(div(i-1,u),w)+1)::Int64 for (u,w) in zip(cumprod([1, widths]),widths)]
end


Out[313]:
hindexes (generic function with 3 methods)

In [275]:
widths = [4,2,3]
divisors = cumprod([1, widths])


Out[275]:
4-element Array{Int64,1}:
  1
  4
  8
 24

In [314]:



KroneckerMatrix not defined
while loading In[314], in expression starting on line 1

In [304]:
tacos = [(1,2),(3,4),(5,6)]


Out[304]:
3-element Array{(Int64,Int64),1}:
 (1,2)
 (3,4)
 (5,6)

In [305]:
x,y = zip(tacos...)
x,y


Out[305]:
((1,3,5),(2,4,6))

In [312]:
typeof((1,"foo",2.5))


Out[312]:
(Int64,ASCIIString,Float64)

In [292]:
widths = [4,2,3]
taco = [hindexes(i,widths) for i=1:24]


Out[292]:
2-element Array{Array{Int64,N},1}:
 [1,1,1]
 [2,1,1]

In [251]:
x,y = zip([(1,2),(3,4),(5,6)]...)


Out[251]:
Zip{((Int64,Int64),(Int64,Int64),(Int64,Int64))}(((1,2),(3,4),(5,6)))

In [254]:
map(*,[(1,2),(3,4),(5,6)]...)


Out[254]:
(15,48)

In [ ]: