text:
module NumericShiftTests

include(joinpath(dirname(@__FILE__), "..", "src", "AndersonMoore.jl"))
using .AndersonMoore

#tweaked= False
# test numericShift! firmvalue example
function firmvalueFalse()::Bool

neq=4::Int64;nlag=1::Int64;nlead=1::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,4,8)

condn=0.0000000001::Float64

iqExpected=3

nnumericMatlab=3

    hhIn = [0.0 0.0 0.0 0.0 -1.1 0.0 0.0 0.0 1.0 1.0 0.0 0.0;
            0.0 -0.4 0.0 0.0 0.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 1.0 0.0 0.0 0.0 0.0 0.0;
            0.0 0.0 0.0 -1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0]

    hExpected = [0.0 0.0 0.0 0.0 -1.1 0.0 0.0 0.0 1.0 1.0 0.0 0.0;
                  0.0 0.0 0.0 0.0 0.0 -0.4 0.0 0.0 0.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 1.0 0.0;
                  0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 0.0 1.0]

    qExpected = [0.0 -0.4 0.0 0.0 0.0 1.0 -1.0 0.0;
                  0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0;
                  0.0 0.0 0.0 -1.0 0.0 0.0 0.0 1.0;
                  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0]

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)
sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

#tweaked= False
# test numericShift! firmvalue3Leads2Lags example
function firmvalue3Leads2LagsFalse()::Bool

neq=4::Int64;nlag=2::Int64;nlead=3::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,12,20)

    hhIn = [0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.331 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0;
            0.0 -0.4 0.0 0.0 0.0 0.0 0.0 0.0 0.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 0.0;
            0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.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 0.0;
            0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 0.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]

    hExpected = [0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.331 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.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 0.0 0.0 0.0 0.0 -0.4 0.0 0.0 0.0 0.0 0.0 0.0 0.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 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.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 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 0.0 1.0]

    qExpected = [0.0 -0.4 0.0 0.0 0.0 0.0 0.0 0.0 0.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 0.0 0.0 0.0 0.0 0.0 0.0 0.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 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 0.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 0.0 -0.4 0.0 0.0 0.0 0.0 0.0 0.0 0.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 0.0 0.0 0.0 0.0 0.0 0.0 0.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 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 0.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 0.0 -0.4 0.0 0.0 0.0 0.0 0.0 0.0 0.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 0.0 0.0 0.0 0.0 0.0 0.0 0.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 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 0.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 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.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 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.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0]

condn=0.0000000001::Float64

iqExpected=9

nnumericMatlab=9

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)
sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

#tweaked= False
# test numericShift! example7 example
function example7False()::Bool

neq=4::Int64;nlag=1::Int64;nlead=1::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,4,8)

    hhIn = [0.0 0.0 0.0 0.0 1.0 0.0 0.0 1.0 -1.0 -1.0 0.0 0.0;
            0.0 0.0 0.0 0.0 -0.3 1.0 0.0 0.0 0.0 -0.99 0.0 0.0;
            0.0 0.0 0.0 1.0 0.0 0.0 1.0 -1.0 0.0 0.0 0.0 0.0;
            0.0 0.0 0.0 -0.66 0.0 -1.1 0.0 1.0 0.0 0.0 0.0 0.0]

    hExpected = [0.0  0.0  0.0  0.0  -0.49958772963417586  -0.7035445979201053  0.0  -0.7106511090102074  0.7106511090102074   1.4071602609511116      0.0   0.0;
 0.0  0.0  0.0  0.0  -0.9167399306231674    0.7106511090102072  0.0  -0.7035445979201053  0.7035445979201053   1.1102230246251565e-16  0.0   0.0;
 0.0  0.0  0.0  0.0   0.0                   0.0                 0.0   1.0                 0.0                  0.0                     1.0  -1.0;
 0.0  0.0  0.0  0.0   0.0                   0.0                 0.0  -0.66                0.0                 -1.1                     0.0   1.0]

    qExpected = [0.0 0.0 0.0 1.0 0.0 0.0 1.0 -1.0;
                  0.0 0.0 0.0 -0.66 0.0 -1.1 0.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 0.0 0.0 0.0 0.0]

condn=0.0000000001::Float64

iqExpected=2

nnumericMatlab=2

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)
    isapprox(hOutput,hExpected)&&
    isapprox(qOutput,qExpected)&&
sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

#tweaked= False
# test numericShift! oneEquationNoLead example
function oneEquationNoLeadFalse()::Bool

neq=1::Int64;nlag=1::Int64;nlead=1::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,1,2)

    hhIn = [2.0  3.0  0.0]
    hExpected = [0.0  2.0  3.0]
    qExpected = [2.0  3.0]

condn=0.0000000001::Float64

iqExpected=1

nnumericMatlab=1

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)
    isapprox(hOutput,hExpected)&&
    isapprox(qOutput,qExpected)&&
sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

#tweaked= False
# test numericShift! reliablePaperExmpl example
function reliablePaperExmplFalse()::Bool

neq=5::Int64;nlag=1::Int64;nlead=1::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,5,10)

    hhIn = [0.0  0.0  0.0  -0.5  0.0   0.0  -1.0  0.7  -0.5   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  0.0   1.0  -0.5  0.0  0.0   0.0  0.0  -0.5
 0.0  0.0  0.0   0.0  0.0  -1.0   0.0  1.0  -0.4   0.0  0.0  0.0  -0.9  0.0   0.0
 0.0  0.0  0.0   0.0  0.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   0.0  0.0   0.0   1.0  0.0   0.0   0.0  0.0  0.0   0.0  0.0   0.0]

    hExpected = [0.0  0.0  0.0  0.0  0.0  -1.0  0.0  1.0  -0.4   0.0  0.0   0.0  -0.9   0.0   0.0
 0.0  0.0  0.0  0.0  0.0   0.0  0.0  0.0   1.0  -0.5  0.0   0.0   0.0   0.0  -0.5
 0.0  0.0  0.0  0.0  0.0   0.0  0.0  0.0  -0.5   0.0  0.0  -1.0   0.7  -0.5   1.0
 0.0  0.0  0.0  0.0  0.0   0.0  0.0  0.0   0.0   0.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   0.0   0.0  0.0   1.0   0.0   0.0   0.0]

    qExpected = [0.0  0.0  0.0  -0.5  0.0  0.0  -1.0  0.7  -0.5  1.0
 0.0  0.0  0.0   0.0  0.0  1.0   0.0  0.0   0.0  0.0
 0.0  0.0  0.0   0.0  0.0  0.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  0.0
 0.0  0.0  0.0   0.0  0.0  0.0   0.0  0.0   0.0  0.0]

condn=0.0000000001::Float64

iqExpected=3

nnumericMatlab=3

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)
    isapprox(hOutput,hExpected)&&
    isapprox(qOutput,qExpected)&&
sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

#tweaked= False
# test numericShift! athan example
function athanFalse()::Bool

neq=9::Int64;nlag=1::Int64;nlead=1::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,9,18)

    hhIn = [-0.5     0.0    0.0     0.0    0.0  0.0  0.0  0.0   0.0   1.0  -0.18  0.0  0.0  -1.0   0.0  0.0   0.0  0.0  -0.5  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 -0.293  -0.764  0.293   0.0    0.0  0.0  0.0  0.0   0.0   0.0   1.0   0.0  0.0   0.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
  0.0     0.0    0.0     0.0    0.0  0.0  0.0  0.0   0.0  -2.0  -1.0   1.0  1.0   0.0   0.0  2.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     0.0    0.0    -0.911  0.0  0.0  0.0  0.0   0.0   0.0   0.0   0.0  1.0   0.0   0.0  0.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    0.0     0.0    0.0  0.0  0.0  0.0   0.0   0.0   0.0   0.0  0.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  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.0  0.0   0.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
  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.0   0.0   0.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     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.0   0.0  0.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    0.0     0.0    0.0  0.0  0.0  0.0  -1.0   0.0   0.0   0.0  0.0   0.0   0.0  0.0   0.0  1.0   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0]

    hExpected = [-0.5  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0   1.0    -0.18   0.0     0.0    -1.0  0.0  0.0  0.0   0.0  -0.5   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.0  0.0  0.0  0.0  0.0  -0.293  -0.764  0.293   0.0     0.0  0.0  0.0  0.0   0.0   0.0   1.0  0.0  0.0  0.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   0.0     0.0    0.0     0.0     0.0  0.0  0.0  0.0   0.0  -2.0  -1.0  1.0  1.0  0.0   0.0  2.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     0.0    0.0    -0.911   0.0  0.0  0.0  0.0   0.0   0.0   0.0  0.0  1.0  0.0   0.0  0.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    0.0     0.0     0.0  0.0  0.0  0.0   0.0   0.0   0.0  0.0  0.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  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.0  0.0  0.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   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.0  0.0   0.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     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.0   0.0  0.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    0.0     0.0     0.0  0.0  0.0  0.0  -1.0   0.0   0.0  0.0  0.0  0.0   0.0  0.0   0.0  1.0]

    qExpected = [-0.293  -0.764  0.293   0.0    0.0  0.0  0.0  0.0   0.0   0.0   1.0  0.0  0.0  0.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  -2.0  -1.0  1.0  1.0  0.0   0.0  2.0   0.0  0.0
  0.0     0.0    0.0    -0.911  0.0  0.0  0.0  0.0   0.0   0.0   0.0  0.0  1.0  0.0   0.0  0.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  0.0  0.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   0.0   0.0   0.0  0.0  0.0  0.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   0.0   0.0  0.0  0.0  0.0   0.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   0.0  0.0  0.0  0.0   0.0  0.0   1.0  0.0
  0.0     0.0    0.0     0.0    0.0  0.0  0.0  0.0  -1.0   0.0   0.0  0.0  0.0  0.0   0.0  0.0   0.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  0.0  0.0   0.0  0.0   0.0  0.0]

condn=0.0000000001::Float64

iqExpected=8

nnumericMatlab=8

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)

sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

#tweaked= False
# test numericShift! habitmod example
function habitmodFalse()::Bool

neq=12::Int64;nlag=4::Int64;nlead=1::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,12,60)

    hhIn = [  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.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      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.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  0.0  0.0    3.454185377005518   0.0                0.0  -0.74118  0.0020851713324080146  0.49411642948057477  -0.1149      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.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      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.0   0.0      0.0       0.0      0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.0      -0.88879   0.0       0.0       0.0      0.0   0.0      0.0  0.0  0.0  0.0   0.0   0.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   0.0  0.0   0.0   0.0   0.0   0.0          0.0       0.0       0.0      0.0
            0.52802  0.0  0.11279   0.031833  0.024734  0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.71526  0.0  0.042076  -0.22829  -0.012267  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.22215  0.0  -0.14172  0.26679  -0.11959  0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.42308   0.0      -0.61076  -0.10946   0.17172  0.0   0.0      0.0  0.0  0.0  0.0   0.0   0.0                 0.0   1.0  0.0  0.0    0.0                 0.0                0.0   0.0      0.0                    0.0                  -0.00011277  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.46436  0.0  0.16131   0.02744   0.17087   0.0  0.0  0.0  0.0  0.0  0.0  0.0  -1.3425   0.0  0.16794   -0.35818  -0.09837   0.0  0.0  0.0  0.0  0.0  0.0  0.0  1.06382  0.0  -0.02255  0.51594   0.08949  0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.46672   0.0      -0.11369  -1.10657  -0.26021  0.0   0.0      0.0  0.0  0.0  0.0   0.0   0.0                 0.0   0.0  1.0  0.0    0.0                 0.0                0.0   0.0      0.0                    0.0                  -0.00141     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.23292  0.0  0.08512  -0.04213   0.14149   0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.03313  0.0  0.15223    0.01572  -0.34762   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.70552  0.0  -0.24697  0.21888  -0.07805  0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.56316   0.0      -0.08268  -0.16054  -0.68637  0.0   0.0      0.0  0.0  0.0  0.0   0.0   0.0                 0.0   0.0  0.0  1.0    0.0                 0.0                0.0   0.0      0.0                    0.0                  -0.00348     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.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      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.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       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.0  1.0  0.0  -41.0                 0.0                0.0   0.0      0.0                    0.0                   0.0         0.0  0.0   0.0  0.0  -1.0  40.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  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.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  0.0  0.0  0.0  0.0  0.0  -0.99853   0.0       0.0       0.0       0.0      0.0  -0.00147  0.0  0.0  0.0  0.0   0.0   0.0                 0.0   0.0  0.0  0.0    0.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   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.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  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.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  0.0  0.0   0.0  -1.000825426258335   0.0   0.0  0.0  0.0    0.0                25.945871790089708  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.00146853   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.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  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.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  0.0   0.0   0.0                 0.0   1.0  0.0  0.0    0.0                 0.0                0.0   1.0      0.0                    0.0                   0.0         0.0  0.0  -1.0  0.0   0.0   0.0   0.0   0.0         -0.99578   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.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  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.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   0.0   0.0                 0.0   0.0  0.0  0.0    0.0                 0.0                1.0   0.0      1.0                    0.0                   0.0         0.0  0.0   0.0  0.0   0.0   0.0   0.0  -1.0          0.0      -0.99578   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.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  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.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   0.0                 0.0   0.0  0.0  0.0    0.0                 1.0                0.0   0.0      0.0                    1.0                   0.0         0.0  0.0   0.0  0.0   0.0   0.0  -1.0   0.0          0.0       0.0      -0.99578  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.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  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.0       0.0       0.0       0.0       0.0      0.0   0.0      0.0  0.0  0.0  0.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                   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]

    hExpected = [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.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                   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.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                     0.0                     -1.0                     0.0                    41.0    0.0                   0.0                 0.0  0.0                    0.0   0.0   0.0                     0.0                    0.0  0.0   1.0                   -40.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  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.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  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.0  0.0  0.0  0.0  0.0  -0.0014697405784171735   0.0                     0.0                      0.0                     0.0                     0.0    0.03810225001464054   1.0014674501280647  0.0  0.9999989217115636     0.0   0.0   0.0                     0.0                    0.0  0.0   0.0                     0.0                 0.0                     -1.0000010782895992       0.0      -0.9957789262619408       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.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  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.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   0.0                     0.0                     1.0                      0.0                     0.0                     0.0    0.0                   0.0                 1.0  0.0                    0.0   0.0   0.0                     0.0                   -1.0  0.0   0.0                     0.0                 0.0                      0.0                     -0.99578   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.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  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.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  0.0   0.0                     0.0                     0.0                      0.0                     0.0                     0.0    1.0                   0.0                 0.0  0.0                    1.0   0.0   0.0                     0.0                    0.0  0.0   0.0                     0.0                -1.0                      0.0                      0.0       0.0                     -0.99578               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.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   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.0                    -5.852556409771323e-14   0.0                      0.0                     0.0                     0.0  0.0  0.0  0.0  0.0  0.0  0.0   1.000824347079851       6.584858526503812e-14   0.0                      0.0                     0.0                     0.0  -25.945843812956188    -0.9985303932950625  0.0  0.0014685284165010825  0.0   0.0   0.0                     0.0                    0.0  0.0   0.0                     0.0                 0.0                      0.0                      0.0      -0.0014623312265834478    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.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  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.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   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  0.0   0.0                    -3.454185377005518   0.0                      0.0                      0.74118  -0.0020851713324080146   -0.49411642948057477   0.1149
                  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.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                   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.0                     0.0                      0.0                     0.0                     0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.99853                 0.0                     0.0                      0.0                     0.0                     0.0   -0.00147               0.0                 0.0  0.0                    0.0   0.0   0.0                     0.0                    0.0  0.0   0.0                     0.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  0.0  0.0  0.0  0.0  0.0   0.23291974884505737     0.0  -0.0851199082160883      0.04212995457170817   -0.14148984743296913     0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.0331299642763041    0.0  -0.15222983585215133     -0.01571998304930578     0.3476196251653737     0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.7055192392459424      0.0                     0.24696973369510486     -0.21887976398422704     0.07804991583958754     0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.5631593927510842     -0.0013052133713605226   0.08267991084711208      0.1605398268915744      0.686369259895166       0.0    0.0                   0.0                 0.0  0.0                    0.0   0.0   1.5646712745468128e-17  0.001468528416566931   0.0  0.0  -0.9999989217115636      0.0                -4.056327828800479e-16   -1.5574141753318106e-17   0.0       5.966643635249391e-20    0.0                   0.003479996247556241
                  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.52802                 0.0   0.11279                 0.031833               0.024734                0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.71526               0.0   0.042076                -0.22829                -0.012267               0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.22215                 0.0                    -0.14172                  0.26679                -0.11959                 0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.42308                 0.0                    -0.61076                 -0.10946                 0.17172                 0.0    0.0                   0.0                 0.0  0.0                    0.0   0.0   0.0                     0.0                    1.0  0.0   0.0                     0.0                 0.0                      0.0                      0.0       0.0                      0.0                  -0.00011277
                  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.00034204963878676955  0.0   0.0001250011388181772  -6.186910218996481e-5   0.00020778208566005508  0.0  0.0  0.0  0.0  0.0  0.0  0.0   4.865234644086243e-5  0.0   0.00022355408085398393   2.3085266708432158e-5  -0.0005104898481669965  0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.0010360761684563013   0.0                    -0.00036268246303953496   0.0003214314998181699  -0.00011461864291304896  0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.0008270164630738329  -0.8887890416280204     -0.00012141792948175387  -0.0002357575519956551  -0.0010079538492790445   0.0    0.0                   0.0                 0.0  0.0                    0.0   0.0  -6.59030902436833e-14    0.9999989217115635     0.0  0.0   0.001468528416566931    0.0                 1.7085028868880403e-12   6.587935840061616e-14    0.0       3.0621433503708756e-17   0.0                  -5.1104788896529205e-6
                  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.46436                 0.0   0.16131                 0.02744                0.17087                 0.0  0.0  0.0  0.0  0.0  0.0  0.0  -1.3425                0.0   0.16794                 -0.35818                -0.09837                0.0  0.0  0.0  0.0  0.0  0.0  0.0   1.06382                 0.0                    -0.02255                  0.51594                 0.08949                 0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.46672                 0.0                    -0.11369                 -1.10657                -0.26021                 0.0    0.0                   0.0                 0.0  0.0                    0.0   0.0   0.0                     0.0                    0.0  1.0   0.0                     0.0                 0.0                      0.0                      0.0       0.0                      0.0                  -0.00141
                  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.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                   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.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                     0.0                      0.0                     0.0                     0.0    0.0                   0.0                 0.0  0.0                    0.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                   1.0]

    qExpected = [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.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                    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.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  0.0   0.0                   -3.454185377005518   0.0                      0.0                     0.74118  -0.0020851713324080146   -0.49411642948057477   0.1149
                  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.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                    0.0   0.0                      0.0                     0.0                     0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.99853                 0.0                     0.0                      0.0                     0.0                    0.0  -0.00147  0.0  0.0  0.0  0.0   0.0   0.0                     0.0                   0.0  0.0   0.0                    0.0                 1.0                      0.0                     0.0       0.0                      0.0                   0.0
                  0.23291974884505737     0.0  -0.0851199082160883      0.04212995457170817   -0.14148984743296913     0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.0331299642763041    0.0  -0.15222983585215133     -0.01571998304930578     0.3476196251653737     0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.7055192392459424     0.0   0.24696973369510486     -0.21887976398422704     0.07804991583958754     0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.5631593927510842     -0.0013052133713605226   0.08267991084711208      0.1605398268915744      0.686369259895166      0.0   0.0      0.0  0.0  0.0  0.0   0.0   1.5646712745468128e-17  0.001468528416566931  0.0  0.0  -0.9999989217115636     0.0                -4.056327828800479e-16   -1.5574141753318106e-17  0.0       5.966643635249391e-20    0.0                   0.003479996247556241
                  0.52802                 0.0   0.11279                 0.031833               0.024734                0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.71526               0.0   0.042076                -0.22829                -0.012267               0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.22215                0.0  -0.14172                  0.26679                -0.11959                 0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.42308                 0.0                    -0.61076                 -0.10946                 0.17172                0.0   0.0      0.0  0.0  0.0  0.0   0.0   0.0                     0.0                   1.0  0.0   0.0                    0.0                 0.0                      0.0                     0.0       0.0                      0.0                  -0.00011277
                  -0.00034204963878676955  0.0   0.0001250011388181772  -6.186910218996481e-5   0.00020778208566005508  0.0  0.0  0.0  0.0  0.0  0.0  0.0   4.865234644086243e-5  0.0   0.00022355408085398393   2.3085266708432158e-5  -0.0005104898481669965  0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.0010360761684563013  0.0  -0.00036268246303953496   0.0003214314998181699  -0.00011461864291304896  0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.0008270164630738329  -0.8887890416280204     -0.00012141792948175387  -0.0002357575519956551  -0.0010079538492790445  0.0   0.0      0.0  0.0  0.0  0.0   0.0  -6.59030902436833e-14    0.9999989217115635    0.0  0.0   0.001468528416566931   0.0                 1.7085028868880403e-12   6.587935840061616e-14   0.0       3.0621433503708756e-17   0.0                  -5.1104788896529205e-6
                  0.46436                 0.0   0.16131                 0.02744                0.17087                 0.0  0.0  0.0  0.0  0.0  0.0  0.0  -1.3425                0.0   0.16794                 -0.35818                -0.09837                0.0  0.0  0.0  0.0  0.0  0.0  0.0   1.06382                0.0  -0.02255                  0.51594                 0.08949                 0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.46672                 0.0                    -0.11369                 -1.10657                -0.26021                0.0   0.0      0.0  0.0  0.0  0.0   0.0   0.0                     0.0                   0.0  1.0   0.0                    0.0                 0.0                      0.0                     0.0       0.0                      0.0                  -0.00141
                  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.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                    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.0                     0.0                      0.0                     0.0                    0.0   0.0      0.0  0.0  0.0  0.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                   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   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.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                     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.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   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.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                      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.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   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.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                    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.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   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.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  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.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  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.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       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.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  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.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   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.0 ]

condn=0.0000000001::Float64

iqExpected=7

nnumericMatlab=7

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)
    isapprox(hOutput,hExpected)&&
    isapprox(qOutput,qExpected)&&
sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

#tweaked= True
# test numericShift! firmvalue example
function firmvalueTrue()::Bool

neq=4::Int64;nlag=1::Int64;nlead=1::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,4,8)

    hhIn = [ 0.0   0.0  0.0   0.0  -2.2  0.0   0.0  0.0  2.0  2.0  0.0  0.0
 0.0  -0.4  0.0   0.0  -1.1  1.0  -1.0  0.0  1.0  1.0  0.0  0.0
 0.0   0.0  0.0   0.0  -1.1  0.0   1.0  0.0  1.0  1.0  0.0  0.0
 0.0   0.0  0.0  -1.0  -1.1  0.0   0.0  1.0  1.0  1.0  0.0  0.0]

    hExpected = [0.0  0.15118578920369088  0.0  0.3779644730092272  2.9103264421710495  -0.3779644730092272   0.0  -0.3779644730092272   -2.6457513110645907      -2.6457513110645907  0.0                      0.0
                  0.0  0.0                  0.0  0.0                 0.0                  0.17457431218879393  0.0   0.43643578047198467   2.220446049250313e-16   -0.4364357804719848  1.1102230246251565e-16  -0.43643578047198467
                  0.0  0.0                  0.0  0.0                 0.0                  0.23094010767585027  0.0   0.21132486540518705  -1.6653345369377348e-16  -0.5773502691896256  1.3660254037844386      -0.21132486540518705
                  0.0  0.0                  0.0  0.0                 0.0                  0.23094010767585027  0.0  -0.788675134594813    -1.1102230246251565e-16  -0.5773502691896256  0.3660254037844386       0.788675134594813  ]

    qExpected = [ 0.0  0.17457431218879393  0.0   0.43643578047198467   2.220446049250313e-16   -0.4364357804719848  1.1102230246251565e-16  -0.43643578047198467
                  0.0  0.23094010767585027  0.0   0.21132486540518705  -1.6653345369377348e-16  -0.5773502691896256  1.3660254037844386      -0.21132486540518705
                  0.0  0.23094010767585027  0.0  -0.788675134594813    -1.1102230246251565e-16  -0.5773502691896256  0.3660254037844386       0.788675134594813
                  0.0  0.0                  0.0   0.0                   0.0                      0.0                 0.0                      0.0 ]

condn=0.0000000001::Float64

iqExpected=3

nnumericMatlab=3

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)
sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

#tweaked= True
# test numericShift! firmvalue3Leads2Lags example
function firmvalue3Leads2LagsTrue()::Bool

neq=4::Int64;nlag=2::Int64;nlead=3::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,12,20)

 hhIn =   [0.0   0.0  0.0  0.0  0.0  0.0  0.0   0.0  -2.662000000000001   0.0   0.0  0.0  0.0  2.0  0.0  0.0  0.0  0.0  0.0  0.0  2.0  0.0  0.0  0.0
 0.0  -0.4  0.0  0.0  0.0  0.0  0.0   0.0  -1.3310000000000004  1.0  -1.0  0.0  0.0  1.0  0.0  0.0  0.0  0.0  0.0  0.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  -1.3310000000000004  0.0   1.0  0.0  0.0  1.0  0.0  0.0  0.0  0.0  0.0  0.0  1.0  0.0  0.0  0.0
 0.0   0.0  0.0  0.0  0.0  0.0  0.0  -1.0  -1.3310000000000004  0.0   0.0  1.0  0.0  1.0  0.0  0.0  0.0  0.0  0.0  0.0  1.0  0.0  0.0  0.0]

    hExpected = [0.0  0.15118578920369088  0.0  0.0  0.0  0.0  0.0  0.3779644730092272  3.521494995026971  -0.3779644730092272  0.0  -0.3779644730092272  0.0  -2.6457513110645907   0.0  0.0  0.0  0.0  0.0   0.0                  -2.6457513110645907      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.0                 0.0   0.0                 0.0   0.3141101189565458   0.0  0.0  0.0  0.0  0.0  -0.10915189360855129   4.965068306494546e-17  -0.7852752973913645   0.4472135954999578   0.10915189360855129
                  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.0   0.19343902401445667  0.0  0.0  0.0  0.0  0.0   0.03638396453618376  -9.930136612989092e-17  -0.4835975600361417   1.3416407864998738  -0.03638396453618376
                  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.0   0.0325428071975394   0.0  0.0  0.0  0.0  0.0  -0.9186429820061515    0.0                    -0.08135701799384851  0.0                  0.9186429820061515]

    qExpected = [0.0  -0.3674571928024606  0.0  0.0  0.0   0.0                 0.0   0.08135701799384851   0.0                      0.9186429820061515   -1.0  -0.08135701799384851   0.0                      5.551115123125783e-17    0.0   0.0                   0.0                     0.0                     0.0                  0.0
                  0.0   0.0325428071975394  0.0  0.0  0.0   0.0                 0.0   0.08135701799384851  -1.1102230246251565e-16  -0.08135701799384851   1.0  -0.08135701799384851   0.0                      2.7755575615628914e-17   0.0   0.0                   0.0                     0.0                     0.0                  0.0
                  0.0   0.0325428071975394  0.0  0.0  0.0   0.0                 0.0  -0.9186429820061515    0.0                     -0.08135701799384851   0.0   0.9186429820061515    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.0  -0.3674571928024606  0.0   0.0                   0.0                      0.0                   0.0   0.08135701799384851   0.0                      0.9186429820061515      -1.0  -0.08135701799384851   0.0                     5.551115123125783e-17   0.0                  0.0
                  0.0   0.0                 0.0  0.0  0.0   0.0325428071975394  0.0   0.0                   0.0                      0.0                   0.0   0.08135701799384851  -1.1102230246251565e-16  -0.08135701799384851      1.0  -0.08135701799384851   0.0                     2.7755575615628914e-17  0.0                  0.0
                  0.0   0.0                 0.0  0.0  0.0   0.0325428071975394  0.0   0.0                   0.0                      0.0                   0.0  -0.9186429820061515    0.0                     -0.08135701799384851      0.0   0.9186429820061515    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.0                      0.3141101189565458    0.0   0.0                   0.0                      0.0                      0.0  -0.10915189360855129   4.965068306494546e-17  -0.7852752973913645      0.4472135954999578   0.10915189360855129
                  0.0   0.0                 0.0  0.0  0.0   0.0                 0.0   0.0                   0.0                      0.19343902401445667   0.0   0.0                   0.0                      0.0                      0.0   0.03638396453618376  -9.930136612989092e-17  -0.4835975600361417      1.3416407864998738  -0.03638396453618376
                  0.0   0.0                 0.0  0.0  0.0   0.0                 0.0   0.0                   0.0                      0.0325428071975394    0.0   0.0                   0.0                      0.0                      0.0  -0.9186429820061515    0.0                    -0.08135701799384851     0.0                  0.9186429820061515
                  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.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   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.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                   0.0   0.0                   0.0                      0.0                      0.0   0.0                   0.0                     0.0                     0.0                  0.0      ]

condn=0.0000000001::Float64

iqExpected=9

nnumericMatlab=9

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)
sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

#tweaked= True
# test numericShift! example7 example
function example7True()::Bool

neq=4::Int64;nlag=1::Int64;nlead=1::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,4,8)

    hhIn= [ 0.0  0.0  0.0   0.0   1.7   1.0                  0.0  2.0  -2.0  -2.99  0.0  0.0
 0.0  0.0  0.0   0.0   0.4   2.0                  0.0  1.0  -1.0  -2.98  0.0  0.0
 0.0  0.0  0.0   1.0   0.7   1.0                  1.0  0.0  -1.0  -1.99  0.0  0.0
 0.0  0.0  0.0  -0.66  0.7  -0.10000000000000009  0.0  2.0  -1.0  -1.99  0.0  0.0]

    hExpected = [0.0  0.0  0.0  -0.1333588423723936      -1.785936255891603   -2.1170666951254504  -0.3922318893305694     -2.5504927879083263   2.550492787908326    5.0735293435635125       0.0                   0.0
                  0.0  0.0  0.0  -0.00018586476390033225   0.9167506148849223  -0.7100580642063362  -0.0005466610702950949   0.7035527974698241  -0.7035527974698241  -3.9855271860567143e-16   0.0                   0.0
                  0.0  0.0  0.0   0.0                      0.0                  0.0                  0.0                     0.9714485500374334   0.0                  0.09237233811418602      0.9160251471689218   -0.9999999999999999
                  0.0  0.0  0.0   0.0                      0.0                  0.0                  0.0                    -0.6885514499625665   0.0                 -1.007627661885814       -0.08397485283107814   1.0               ]

    qExpected = [0.0  0.0  0.0   0.9714485500374334  0.0   0.09237233811418602   0.9160251471689218   -0.9999999999999999
                  0.0  0.0  0.0  -0.6885514499625665  0.0  -1.007627661885814    -0.08397485283107814   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                 0.0   0.0                   0.0                   0.0]

condn=0.0000000001::Float64

iqExpected=2

nnumericMatlab=2

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)
sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

#tweaked= True
# test numericShift! oneEquationNoLead example
function oneEquationNoLeadTrue()::Bool

neq=1::Int64;nlag=1::Int64;nlead=1::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,1,2)

    hhIn= [2.0  3.0  0.0]
    hExpected = [0.0  2.0  3.0]
    qExpected = [2.0  3.0]

condn=0.0000000001::Float64

iqExpected=1

nnumericMatlab=1

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)
sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

#tweaked= True
# test numericShift! reliablePaperExmpl example
function reliablePaperExmplTrue()::Bool

neq=5::Int64;nlag=1::Int64;nlead=1::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,5,10)

    hhIn = [0.0  0.0  0.0  -0.5  0.0  -1.0  -1.0  1.7  0.09999999999999998   0.5  0.0  0.0  -0.9  0.0  -0.5
            0.0  0.0  0.0   0.0  0.0  -1.0   0.0  1.0  1.6                  -1.0  0.0  0.0  -0.9  0.0  -1.0
            0.0  0.0  0.0   0.0  0.0  -2.0   0.0  2.0  0.19999999999999996  -0.5  0.0  0.0  -1.8  0.0  -0.5
            0.0  0.0  0.0   0.0  0.0   0.0   0.0  1.0  0.6                  -0.5  0.0  0.0  -0.9  0.0  -0.5
            0.0  0.0  0.0   0.0  0.0  -1.0   1.0  1.0  0.6                  -0.5  0.0  0.0  -0.9  0.0  -0.5]

    hExpected = [ 0.0  0.0  0.0  0.17677669529663687  0.0   2.474873734152917    -5.551115123125783e-17  -3.075914498161482    -1.1667261889578036   0.8838834764831844   0.0                  0.0                  2.5455844122715714      0.0                   1.2374368670764584
                  0.0  0.0  0.0  0.04564354645876409  0.0  -0.09128709291752748   5.273559366969494e-16  -0.06390096504226989  -1.3236628473041514   0.5933661039639293   0.0                  0.0                  2.7755575615628914e-17  0.0                   0.6846531968814575
                  0.0  0.0  0.0  0.0                  0.0   0.0                   0.0                     0.0                   0.3969847178042136   0.0                 -0.1850509058906912   0.6089185297177356  -0.5557786049258994      0.39698471780421407  -0.7939694356084274
                  0.0  0.0  0.0  0.0                  0.0   0.0                   0.0                     0.0                   0.17185720889240513  0.0                  0.9076903413717948   0.251404759156605   -0.24060009244936742     0.17185720889240524  -0.3437144177848103
                  0.0  0.0  0.0  0.0                  0.0   0.0                   0.0                     0.0                   0.17185720889240513  0.0                 -0.09230965862820517  1.251404759156605   -0.24060009244936742     0.17185720889240524  -0.3437144177848103]

    qExpected = [0.0  0.0  0.0  0.3969847178042136   0.0  -0.1850509058906912   0.6089185297177356  -0.5557786049258994   0.39698471780421407  -0.7939694356084274
                  0.0  0.0  0.0  0.17185720889240513  0.0   0.9076903413717948   0.251404759156605   -0.24060009244936742  0.17185720889240524  -0.3437144177848103
                  0.0  0.0  0.0  0.17185720889240513  0.0  -0.09230965862820517  1.251404759156605   -0.24060009244936742  0.17185720889240524  -0.3437144177848103
                  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.0  0.0                  0.0   0.0                  0.0                  0.0                  0.0                   0.0]

condn=0.0000000001::Float64

iqExpected=3

nnumericMatlab=3

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)
sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

#tweaked= True
# test numericShift! athan example
function athanTrue()::Bool

neq=9::Int64;nlag=1::Int64;nlead=1::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,9,18)

    hhIn = [-1.0                  0.0    0.0     0.0    0.0  0.0  0.0  0.0   0.0   2.0  -0.36                0.0  0.0  -2.0   0.0  0.0   0.0  0.0  -1.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
            -0.7929999999999999  -0.764  0.293   0.0    0.0  0.0  0.0  0.0   0.0   1.0   0.8200000000000001  0.0  0.0  -1.0  -1.0  0.0   0.0  0.0  -0.5  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
            -0.5                  0.0    0.0     0.0    0.0  0.0  0.0  0.0   0.0  -1.0  -1.18                1.0  1.0  -1.0   0.0  2.0   0.0  0.0  -0.5  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
            -0.5                  0.0    0.0    -0.911  0.0  0.0  0.0  0.0   0.0   1.0  -0.18                0.0  1.0  -1.0   0.0  0.0  -1.0  0.0  -0.5  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
            -0.5                  0.0    0.0     0.0    0.0  0.0  0.0  0.0   0.0   1.0  -0.18                0.0  0.0   0.0   0.0  0.0   0.0  0.0  -0.5  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
            -0.5                  0.0    0.0     0.0    0.0  0.0  0.0  0.0   0.0   1.0  -0.18                0.0  0.0  -1.0   1.0  0.0   0.0  0.0  -0.5  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
            -0.5                  0.0    0.0     0.0    0.0  0.0  0.0  0.0   0.0   1.0  -0.18                0.0  0.0  -1.0   0.0  1.0   0.0  0.0  -0.5  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
            -0.5                  0.0    0.0     0.0    0.0  0.0  0.0  0.0   0.0   1.0  -0.18                0.0  0.0  -1.0   0.0  0.0   1.0  0.0  -0.5  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
            -0.5                  0.0    0.0     0.0    0.0  0.0  0.0  0.0  -1.0   1.0  -0.18                0.0  0.0  -1.0   0.0  0.0   0.0  1.0  -0.5  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0]

    hExpected = [1.8166326220051578  0.22054780283043704  -0.08458181443628017  0.26298304761587454  0.0  0.0  0.0  0.0  0.28867513459481287  -2.886751345948129      0.6235382907247957    -0.28867513459481287   -0.5773502691896257   3.175426480542942  0.0  -0.8660254037844386  0.0  -0.28867513459481287   1.7320508075688776    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.0  0.0  0.0  0.0  0.0                  -0.2775204536090702    -0.7236369507076094     0.27752045360907       0.04812923809603137  0.0                0.0   0.0                 0.0   0.05283121635129678   0.10566243270259362   1.0                     -0.05283121635129678  -0.10566243270259355  -0.052831216351296846  -1.0  -0.15849364905389032   0.0  -0.05283121635129678
                  0.0                 0.0                   0.0                  0.0                  0.0  0.0  0.0  0.0  0.0                   0.015479546390929903   0.040363049292390735  -0.015479546390929955   0.04812923809603137  0.0                0.0   0.0                 0.0   0.05283121635129678  -1.894337567297406    -1.0000000000000007       0.9471687836487033    0.8943375672974065   -0.0528312163512969     0.0   1.8415063509461098    0.0  -0.05283121635129678
                  0.0                 0.0                   0.0                  0.0                  0.0  0.0  0.0  0.0  0.0                   0.015479546390929876   0.040363049292390735  -0.015479546390929955  -0.8628707619039687   0.0                0.0   0.0                 0.0   0.05283121635129678   0.10566243270259362  -2.7755575615628914e-17  -0.05283121635129678   0.8943375672974065   -0.05283121635129696    0.0  -0.15849364905389032  -1.0  -0.05283121635129678
                  0.0                 0.0                   0.0                  0.0                  0.0  0.0  0.0  0.0  0.0                   0.015479546390929848   0.040363049292390735  -0.015479546390929955   0.04812923809603137  0.0                0.0   0.0                 0.0   0.05283121635129678   0.10566243270259368  -2.7755575615628914e-17  -0.05283121635129678  -0.10566243270259355   0.9471687836487028     0.0  -0.15849364905389032   0.0  -0.05283121635129678
                  0.0                 0.0                   0.0                  0.0                  0.0  0.0  0.0  0.0  0.0                   0.01547954639092982    0.040363049292390735  -0.015479546390929955   0.04812923809603137  0.0                0.0   0.0                 0.0   0.05283121635129678   0.10566243270259373  -1.3877787807814457e-17  -0.05283121635129678  -0.10566243270259355  -0.05283121635129701    1.0  -0.15849364905389032   0.0  -0.05283121635129678
                  0.0                 0.0                   0.0                  0.0                  0.0  0.0  0.0  0.0  0.0                   0.015479546390929792   0.040363049292390735  -0.015479546390929955   0.04812923809603137  0.0                0.0   0.0                 0.0   0.05283121635129678   0.10566243270259379   0.0                     -0.05283121635129678  -0.10566243270259355  -0.05283121635129707    0.0   0.8415063509461097    0.0  -0.05283121635129678
                  0.0                 0.0                   0.0                  0.0                  0.0  0.0  0.0  0.0  0.0                   0.015479546390929768   0.040363049292390735  -0.015479546390929955   0.04812923809603137  0.0                0.0   0.0                 0.0   0.05283121635129678   0.10566243270259384   1.3877787807814457e-17  -0.05283121635129678  -0.10566243270259355  -0.052831216351297124   0.0  -0.15849364905389032   1.0  -0.05283121635129678
                  0.0                 0.0                   0.0                  0.0                  0.0  0.0  0.0  0.0  0.0                   0.015479546390929744   0.040363049292390735  -0.015479546390929955   0.04812923809603137  0.0                0.0   0.0                 0.0  -0.9471687836487033    0.1056624327025939    2.7755575615628914e-17  -0.05283121635129678  -0.10566243270259355  -0.05283121635129717    0.0  -0.15849364905389032   0.0   0.9471687836487033]

    qExpected = [-0.2775204536090702    -0.7236369507076094     0.27752045360907       0.04812923809603137  0.0  0.0  0.0  0.0   0.05283121635129678   0.10566243270259362   1.0                     -0.05283121635129678  -0.10566243270259355  -0.052831216351296846  -1.0  -0.15849364905389032   0.0  -0.05283121635129678
                  0.015479546390929903   0.040363049292390735  -0.015479546390929955   0.04812923809603137  0.0  0.0  0.0  0.0   0.05283121635129678  -1.894337567297406    -1.0000000000000007       0.9471687836487033    0.8943375672974065   -0.0528312163512969     0.0   1.8415063509461098    0.0  -0.05283121635129678
                  0.015479546390929876   0.040363049292390735  -0.015479546390929955  -0.8628707619039687   0.0  0.0  0.0  0.0   0.05283121635129678   0.10566243270259362  -2.7755575615628914e-17  -0.05283121635129678   0.8943375672974065   -0.05283121635129696    0.0  -0.15849364905389032  -1.0  -0.05283121635129678
                  0.015479546390929848   0.040363049292390735  -0.015479546390929955   0.04812923809603137  0.0  0.0  0.0  0.0   0.05283121635129678   0.10566243270259368  -2.7755575615628914e-17  -0.05283121635129678  -0.10566243270259355   0.9471687836487028     0.0  -0.15849364905389032   0.0  -0.05283121635129678
                  0.01547954639092982    0.040363049292390735  -0.015479546390929955   0.04812923809603137  0.0  0.0  0.0  0.0   0.05283121635129678   0.10566243270259373  -1.3877787807814457e-17  -0.05283121635129678  -0.10566243270259355  -0.05283121635129701    1.0  -0.15849364905389032   0.0  -0.05283121635129678
                  0.015479546390929792   0.040363049292390735  -0.015479546390929955   0.04812923809603137  0.0  0.0  0.0  0.0   0.05283121635129678   0.10566243270259379   0.0                     -0.05283121635129678  -0.10566243270259355  -0.05283121635129707    0.0   0.8415063509461097    0.0  -0.05283121635129678
                  0.015479546390929768   0.040363049292390735  -0.015479546390929955   0.04812923809603137  0.0  0.0  0.0  0.0   0.05283121635129678   0.10566243270259384   1.3877787807814457e-17  -0.05283121635129678  -0.10566243270259355  -0.052831216351297124   0.0  -0.15849364905389032   1.0  -0.05283121635129678
                  0.015479546390929744   0.040363049292390735  -0.015479546390929955   0.04812923809603137  0.0  0.0  0.0  0.0  -0.9471687836487033    0.1056624327025939    2.7755575615628914e-17  -0.05283121635129678  -0.10566243270259355  -0.05283121635129717    0.0  -0.15849364905389032   0.0   0.9471687836487033
                  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.0                   0.0                    0.0   0.0                   0.0   0.0]

condn=0.0000000001::Float64

iqExpected=8

nnumericMatlab=8

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)
sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

#tweaked= True
# test numericShift! habitmod example
function habitmodTrue()::Bool

neq=12::Int64;nlag=4::Int64;nlead=1::Int64
qRows=(neq*nlead)::Int64;qCols=(neq*(nlag+nlead))::Int64

qq=zeros(Float64,12,60)

    hhIn = [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.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      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.0       0.0       0.0       0.0      0.0   0.0      0.0  0.0  0.0  0.0   0.0  -0.000825426258334927  -1.0  0.0  1.0  0.0  -37.545814622994484  26.945871790089708  2.0  0.25882000000000005  1.002085171332408  1.4941164294805747  -0.1149      0.0  0.0  -1.0  0.0  -1.0  40.0  -1.0  -1.00146853  -0.99578  -0.99578  -0.99578  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.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  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.0      -0.88879   0.0       0.0       0.0      0.0   0.0      0.0  0.0  0.0  0.0   0.0  -1.000825426258335      1.0  1.0  1.0  0.0  -41.0                26.945871790089708  2.0  1.0                  1.0                1.0                  0.0         0.0  0.0  -1.0  0.0  -1.0  40.0  -1.0  -1.00146853  -0.99578  -0.99578  -0.99578  0.0
            0.52802  0.0  0.11279   0.031833  0.024734  0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.71526  0.0  0.042076  -0.22829  -0.012267  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.22215  0.0  -0.14172  0.26679  -0.11959  0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.42308   0.0      -0.61076  -0.10946   0.17172  0.0   0.0      0.0  0.0  0.0  0.0   0.0  -1.000825426258335      0.0  2.0  1.0  0.0  -41.0                26.945871790089708  2.0  1.0                  1.0                1.0                 -0.00011277  0.0  0.0  -1.0  0.0  -1.0  40.0  -1.0  -1.00146853  -0.99578  -0.99578  -0.99578  0.0
            0.46436  0.0  0.16131   0.02744   0.17087   0.0  0.0  0.0  0.0  0.0  0.0  0.0  -1.3425   0.0  0.16794   -0.35818  -0.09837   0.0  0.0  0.0  0.0  0.0  0.0  0.0  1.06382  0.0  -0.02255  0.51594   0.08949  0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.46672   0.0      -0.11369  -1.10657  -0.26021  0.0   0.0      0.0  0.0  0.0  0.0   0.0  -1.000825426258335      0.0  1.0  2.0  0.0  -41.0                26.945871790089708  2.0  1.0                  1.0                1.0                 -0.00141     0.0  0.0  -1.0  0.0  -1.0  40.0  -1.0  -1.00146853  -0.99578  -0.99578  -0.99578  0.0
            -0.23292  0.0  0.08512  -0.04213   0.14149   0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.03313  0.0  0.15223    0.01572  -0.34762   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.70552  0.0  -0.24697  0.21888  -0.07805  0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.56316   0.0      -0.08268  -0.16054  -0.68637  0.0   0.0      0.0  0.0  0.0  0.0   0.0  -1.000825426258335      0.0  1.0  1.0  1.0  -41.0                26.945871790089708  2.0  1.0                  1.0                1.0                 -0.00348     0.0  0.0  -1.0  0.0  -1.0  40.0  -1.0  -1.00146853  -0.99578  -0.99578  -0.99578  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.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  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.0       0.0       0.0       0.0       0.0      0.0   0.0      0.0  0.0  0.0  0.0   0.0  -1.000825426258335      0.0  1.0  2.0  0.0  -82.0                26.945871790089708  2.0  1.0                  1.0                1.0                  0.0         0.0  0.0  -1.0  0.0  -2.0  80.0  -1.0  -1.00146853  -0.99578  -0.99578  -0.99578  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.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  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.99853   0.0       0.0       0.0       0.0      0.0  -0.00147  0.0  0.0  0.0  0.0   0.0  -1.000825426258335      0.0  1.0  1.0  0.0  -41.0                27.945871790089708  2.0  1.0                  1.0                1.0                  0.0         0.0  0.0  -1.0  0.0  -1.0  40.0  -1.0  -1.00146853  -0.99578  -0.99578  -0.99578  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.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  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.0       0.0       0.0       0.0       0.0      0.0   0.0      0.0  0.0  0.0  0.0   0.0  -2.00165085251667       0.0  1.0  1.0  0.0  -41.0                52.891743580179416  3.0  1.0                  1.0                1.0                  0.0         0.0  0.0  -1.0  0.0  -1.0  40.0  -1.0  -1.00293706  -0.99578  -0.99578  -0.99578  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.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  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.0       0.0       0.0       0.0       0.0      0.0   0.0      0.0  0.0  0.0  0.0   0.0  -1.000825426258335      0.0  2.0  1.0  0.0  -41.0                26.945871790089708  2.0  2.0                  1.0                1.0                  0.0         0.0  0.0  -2.0  0.0  -1.0  40.0  -1.0  -1.00146853  -1.99156  -0.99578  -0.99578  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.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  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.0       0.0       0.0       0.0       0.0      0.0   0.0      0.0  0.0  0.0  0.0   0.0  -1.000825426258335      0.0  1.0  1.0  0.0  -41.0                26.945871790089708  3.0  1.0                  2.0                1.0                  0.0         0.0  0.0  -1.0  0.0  -1.0  40.0  -1.0  -2.00146853  -0.99578  -1.99156  -0.99578  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.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  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.0       0.0       0.0       0.0       0.0      0.0   0.0      0.0  0.0  0.0  0.0   0.0  -1.000825426258335      0.0  1.0  1.0  0.0  -41.0                27.945871790089708  2.0  1.0                  1.0                2.0                  0.0         0.0  0.0  -1.0  0.0  -1.0  40.0  -2.0  -1.00146853  -0.99578  -0.99578  -1.99156  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.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  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.0       0.0       0.0       0.0       0.0      0.0   0.0      0.0  0.0  0.0  0.0  -1.0  -1.000825426258335      0.0  1.0  1.0  0.0  -41.0                26.945871790089708  2.0  1.0                  1.0                1.0                  1.0         0.0  0.0  -1.0  0.0  -1.0  40.0  -1.0  -1.00146853  -0.99578  -0.99578  -0.99578  0.0]

    hExpected = [-0.19609172880737902   0.0  -0.09275020517497523    -0.004426303566935583    -0.08703729654042955   0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.5227572181487948    0.0  -0.09353151501535015    0.1473670163231922      0.11832144861886483    0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.5142005069425739    0.0   0.10618171141962257    -0.25861458995965403     0.027924209926155477    0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.6329719962262681    0.22948459121837936    0.20840006988162618    0.35542884565924965    0.2000679917094853     0.0  0.00037955236792832687  0.0  0.0  0.0  0.0  0.25819888974716115    3.3595693047216795    5.551115123125783e-17   -3.6147844564602556     -4.131182235954578     -0.25819888974716115   157.90045036518043     -97.66171740233433        -7.229568912920511    -3.423412603357455     -3.615322845383216      -3.7423647699579714    -0.22724012765555193    0.0                      0.0                    3.6147844564602556       0.0                    3.8729833462074166      -154.91933384829667         3.6147844564602556       3.6200928758781017       3.599530066053994        3.599530066053994        3.599530066053994        0.0
                  -0.03644092919901393   0.0  -0.017236339750440813   -0.0008225671520010209   -0.01617467488401285   0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.09714718152924387   0.0  -0.017381535352258178   0.027386116899293177    0.02198840082684081    0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.09555703538111847   0.0   0.019732398972694395   -0.048059936132283904    0.005189327275792478    0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.1176290700261905    0.04264652972215994    0.03872826374581953    0.06605152332905827    0.03717986253278372    0.0  7.053454549620844e-5    0.0  0.0  0.0  0.0  0.04798268401102615    0.6253856599119053    3.7470027081099033e-16  -0.6717575761543662     -0.04798268401102618   -0.04798268401102615    -0.16574108546035782  -18.1764597444481         -2.063255412474126    -0.636193770419074     -1.3905424781742837     -0.6954666086547897    -0.04222942728606936    0.0                      0.0                    0.6717575761543666       0.0                    5.551115123125783e-17     -4.440892098500626e-16    0.6717575761543667       1.3914304721120743       0.6689227591829953       1.3845747590191704       0.6689227591829952       0.0
                  -0.02148109708725987   0.0  -0.010160429378354994   -0.0004848845855830418   -0.0095346021403797    0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.057266049029282534  0.0  -0.010246018875874341   0.016143491642158326    0.012961661059063585   0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.05632869412254378   0.0   0.01163179939188995    -0.02833023681769986     0.003058990137712529    0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.06933965541101128   0.02513915713821078    0.02282942866252345    0.038935867349708046   0.02191668144343895    0.0  4.15785067261896e-5     0.0  0.0  0.0  0.0  0.028284698453190205   0.3674450865332929   -9.71445146547012e-17    -1.2174050649691517     -0.028284698453190316  -0.028284698453190205   -0.09770059179002288  -10.683356622485734       -0.39482274686268837  -1.196441012169616      0.0005216833253154363  -0.4099617125532874    -0.024893284760038013   0.0                      0.0                    1.2174050649691515       0.0                   -5.551115123125783e-17     -4.440892098500626e-15    0.3959857783446624       1.3877787807814457e-17   1.2122676155949816      -0.0005782113750162979    0.39431471836004794      0.0
                  -0.015327421901668012  0.0  -0.0072497781259278655  -0.00034598003010072396  -0.006803231188635172  0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.04086108314430527   0.0  -0.007310848858651701   0.011518876636527283    0.009248542883618179   0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.04019225165637792   0.0   0.0082996457783714     -0.020214493259591914    0.0021826833258702157   0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.04947597176641304   0.01793755999260454    0.016289497853070992   0.02778193606928489    0.015638224705351755   0.0  2.9667540351633947e-5   0.0  0.0  0.0  0.0  0.020182000239206768   0.2621833439936799   -1.249000902703301e-16   -4.128641872824801e-16  -0.020182000239206768  -0.020182000239206768   -0.06971237010499354   -8.491558629145203       -0.2817181446998355    0.014958494937294984   0.0003722370600390025  -1.1611761301818164    -0.017762122506385234   0.0                      0.0                    1.9081958235744878e-16   0.0                   -3.122502256758253e-17      2.9976021664879227e-15   1.1512038722838436       6.591949208711867e-17    6.938893903907228e-17   -0.00041257155801759093   1.1463457919428055       0.0
                  -0.011916343170597763  0.0  -0.005636358456985405   -0.0002689830550306212   -0.005289189403983738  0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.031767553094945555  0.0  -0.005683838053585924   0.008955379960259495    0.007190303205341479   0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.03124756835226842   0.0   0.00645258073562353    -0.015715809236961052    0.0016969327073185687   0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.038465220181824925  0.013945601673062635   0.012664311567804233   0.021599136910896898   0.012157977601413393   0.0  2.306510475966965e-5    0.0  0.0  0.0  0.0  0.015690547455557584   1.1008976137840354    5.2829268737397683e-14   9.495876307497042e-14  -0.015690547455557667  -0.01569054745555767    -0.05419805957851742  -28.962650240682763       -1.1140288693459615    0.011629519963180547   0.001605673361858885   -0.007752957285382715  -0.013809207352808845   0.0                      0.0                    1.8735013540549517e-16   0.0                    1.3183898417423734e-16    -3.774758283725532e-15    1.0408340855860843e-16   1.214306433183765e-16    1.249000902703301e-16   -0.0016314768322516354    6.938893903907228e-17    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.0   0.048224301849328854  0.0  -0.005649146396284293   0.005226518012203298   -0.02215476160154963    0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.015308948646934087  0.0  -0.020587808201071183   -0.0012231602348608053   0.03455574961918122     0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.11508886468270901   0.0                    0.003849805355026825  -0.025663325721305353  -0.016092763906927973   0.0  0.0                     0.0  0.0  0.0  0.0  0.0                    0.11058349377473162   0.08577477266636502     -0.061557028897325894    0.08871511230103518    0.0984214691068183      0.0                    0.00011902473873962929   0.0                   0.0                    0.0                     0.0                    0.0809692100269587     0.9432665948914909      -1.0397739505843913    -0.8164459899560503      -0.08096921002695806   -0.08096921002695859        3.2582176786916612      -0.08096921002906798     -8.071321389024888e-14   -0.6991303348016144       0.0019668724624858913    0.46608352191604363     -0.1889689039025684
                  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.12184229367564271   0.0   0.01315643886009809    0.011776395875306685    0.0023242757310194748  0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.22059129119164317   0.0   0.0008029917295495695  -0.06129178127680296     0.04146298156278527     0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.045053126560429105  0.0                    0.031417064154452355   0.04730419872232132    0.020927007510204494   0.0  0.0                     0.0  0.0  0.0  0.0  0.0                    0.16967163509717323   0.7513241564441493      -0.02453854989239201    -0.1345796614826893     0.0795128651273466      0.0                    0.0002359986956209491    0.0                   0.0                    0.0                     0.0                    0.1605433303543872    -0.009553094281929408    -0.8357806250940358     0.045144309325711895     0.1413895852400555    -0.16054333035438648       -0.03299815857374        -0.16054333035395985      1.6431300764452317e-14   0.007080562419868097    -1.9919838332327355e-5   -0.004720340837070042    -0.15909036196827112
                  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.49066964504998173   0.0   0.09954535982417251    0.03022429851128815     0.01414185846355575    0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.6322622701252367    0.0   0.03051560021834706    -0.204489715485048      -0.00036338481301305056  0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.15680105798698918   0.0                   -0.12857418730353962    0.23014883764676913   -0.11536314620234255    0.0  0.0                     0.0  0.0  0.0  0.0  0.0                   -0.3509238693062533    0.05588670990545325     -0.5752655919239991     -0.06006928783796028    0.18817837065877402     0.0                    3.2590484883454946e-5    0.0                   0.0                    0.0                     0.0                    0.022170397879901303  -0.19933472888674186      0.13645518489380126    1.1510412890898465      -0.036640498627503154  -0.022170397879901615      -0.6885391056498145      -0.022170397878949033     3.6963487826113806e-14   0.14774291435624862     -0.00041564706222766215  -0.09849456450897717      0.0007546546080738729
                  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.1509586455410639    0.0   0.10232601434026455   -0.03481834638965288     0.15969870625813026    0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.18599969898555688   0.0   0.16812232476852762    -0.04156942535375936    -0.33475383010380316     0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.8310927439878807    0.0                   -0.22268395045033668    0.2830795846279476    -0.048811981161980406   0.0  0.0                     0.0  0.0  0.0  0.0  0.0                   -0.4803091015169949    0.2147997620409701      -0.0675544455608285     -0.3474368554746763    -0.6825772800634178      0.0                    0.0001474001947718218    0.0                   0.0                    0.0                     0.0                    0.04819962300129733   -2.493144579673867e-14   -0.24167661881993496   -0.04753534405872386      0.18637755529090044    0.9119238998199345         1.021405182655144e-14   -0.10027224134072954      2.4855117963795692e-14  -6.245004513516506e-17   -3.469446951953614e-17   -1.1796119636642288e-16  -0.05163054996488135
                  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.03898570051968027   0.0  -0.01418689239097786   -0.0016569485305627536  -0.011804941061041139   0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.08990058842161651   0.0  -0.01275032969693673     0.025579556628944945    0.01305049771901661     0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.0725132447801352    0.0                    0.013500321924465132  -0.03969311179902771    0.0036665672541703422  0.0  0.0                     0.0  0.0  0.0  0.0  0.0                   -0.8749975344470555    0.261761701981455        0.03547480534954783     0.056047435316729656   0.01937879065353837     0.0                   -0.0013663767846879649    0.0                   0.0                    0.0                     0.0                   -0.03689967572960394   -2.598615767013257e-14   -0.29451467948722987   -0.04693496623507955     -0.04254741414177614   -0.023846031180842154      -4.884981308350689e-15    0.9295080167952067       2.631228568361621e-14    9.71445146547012e-17     2.7755575615628914e-16   1.8041124150158794e-16   0.0370479446281955
                  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.47360918256095863   0.0  -0.12531586189663457   -0.03500540155108815    -0.12266496414159372    0.0  0.0  0.0  0.0  0.0  0.0  0.0   1.2331447673460467    0.0  -0.11679785807542903     0.3296614679484056      0.004648976784879369    0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.8052962088950498    0.0                   -0.04432176261119575   -0.41668642626540536   -0.10569955396538423    0.0  0.0                     0.0  0.0  0.0  0.0  0.0                    0.27299934180555274   0.05264877170439268      0.06781077687905307     0.9832847944523508     0.07585481312963546     0.0                   -1.216412233445487e-5     0.0                   0.0                    0.0                     0.0                    0.025205407433645053   1.2705114738054135e-14  -0.059236458223419226   0.028013880720362257    -0.9273473043277112     0.24805975279627446       -3.3306690738754696e-15   0.008274913152365726    -1.2552459072168176e-14   1.0755285551056204e-16   1.0755285551056204e-16   1.9081958235744878e-16  -0.024764254799602863
                  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.03907555039316141   0.0  -0.020259089736222164  -0.0007650944702003904  -0.020964584905621333   0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.11981378735802013   0.0  -0.021956266348871697    0.03290267049808291     0.026695298956530496    0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.12323522603228682   0.0                    0.02023625538916286   -0.05854921534781744    0.0020779438347818535  0.0  0.0                     0.0  0.0  0.0  0.0  0.0                    0.229780587961909     0.2047410640889027       0.03419820667815982     0.09225981389673804    0.050567880635814015    0.0                    0.00022122212856097207   0.0                   0.0                    0.0                     0.0                   -0.9446881295234946    -1.942890293094024e-14   -0.23035932457487446   -0.03513701932849023     -0.07188888962892004   -0.055211331533372834       0.0                     -0.1504912439185233       1.9539925233402755e-14  -1.1102230246251565e-16   1.1102230246251565e-16   0.0                      0.9449855906932771]

    qExpected = [0.048224301849328854  0.0  -0.005649146396284293   0.005226518012203298   -0.02215476160154963    0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.015308948646934087  0.0  -0.020587808201071183   -0.0012231602348608053   0.03455574961918122     0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.11508886468270901   0.0   0.003849805355026825  -0.025663325721305353  -0.016092763906927973   0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.11058349377473162  0.08577477266636502  -0.061557028897325894   0.08871511230103518    0.0984214691068183    0.0   0.00011902473873962929  0.0  0.0  0.0  0.0   0.0809692100269587     0.9432665948914909      -1.0397739505843913    -0.8164459899560503    -0.08096921002695806   -0.08096921002695859    3.2582176786916612      -0.08096921002906798   -8.071321389024888e-14   -0.6991303348016144       0.0019668724624858913    0.46608352191604363     -0.1889689039025684
  0.12184229367564271   0.0   0.01315643886009809    0.011776395875306685    0.0023242757310194748  0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.22059129119164317   0.0   0.0008029917295495695  -0.06129178127680296     0.04146298156278527     0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.045053126560429105  0.0   0.031417064154452355   0.04730419872232132    0.020927007510204494   0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.16967163509717323  0.7513241564441493   -0.02453854989239201   -0.1345796614826893     0.0795128651273466    0.0   0.0002359986956209491   0.0  0.0  0.0  0.0   0.1605433303543872    -0.009553094281929408    -0.8357806250940358     0.045144309325711895   0.1413895852400555    -0.16054333035438648   -0.03299815857374        -0.16054333035395985    1.6431300764452317e-14   0.007080562419868097    -1.9919838332327355e-5   -0.004720340837070042    -0.15909036196827112
  0.49066964504998173   0.0   0.09954535982417251    0.03022429851128815     0.01414185846355575    0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.6322622701252367    0.0   0.03051560021834706    -0.204489715485048      -0.00036338481301305056  0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.15680105798698918   0.0  -0.12857418730353962    0.23014883764676913   -0.11536314620234255    0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.3509238693062533   0.05588670990545325  -0.5752655919239991    -0.06006928783796028    0.18817837065877402   0.0   3.2590484883454946e-5   0.0  0.0  0.0  0.0   0.022170397879901303  -0.19933472888674186      0.13645518489380126    1.1510412890898465    -0.036640498627503154  -0.022170397879901615  -0.6885391056498145      -0.022170397878949033   3.6963487826113806e-14   0.14774291435624862     -0.00041564706222766215  -0.09849456450897717      0.0007546546080738729
 -0.1509586455410639    0.0   0.10232601434026455   -0.03481834638965288     0.15969870625813026    0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.18599969898555688   0.0   0.16812232476852762    -0.04156942535375936    -0.33475383010380316     0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.8310927439878807    0.0  -0.22268395045033668    0.2830795846279476    -0.048811981161980406   0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.4803091015169949   0.2147997620409701   -0.0675544455608285    -0.3474368554746763    -0.6825772800634178    0.0   0.0001474001947718218   0.0  0.0  0.0  0.0   0.04819962300129733   -2.493144579673867e-14   -0.24167661881993496   -0.04753534405872386    0.18637755529090044    0.9119238998199345     1.021405182655144e-14   -0.10027224134072954    2.4855117963795692e-14  -6.245004513516506e-17   -3.469446951953614e-17   -1.1796119636642288e-16  -0.05163054996488135
 -0.03898570051968027   0.0  -0.01418689239097786   -0.0016569485305627536  -0.011804941061041139   0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.08990058842161651   0.0  -0.01275032969693673     0.025579556628944945    0.01305049771901661     0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.0725132447801352    0.0   0.013500321924465132  -0.03969311179902771    0.0036665672541703422  0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.8749975344470555   0.261761701981455     0.03547480534954783    0.056047435316729656   0.01937879065353837   0.0  -0.0013663767846879649   0.0  0.0  0.0  0.0  -0.03689967572960394   -2.598615767013257e-14   -0.29451467948722987   -0.04693496623507955   -0.04254741414177614   -0.023846031180842154  -4.884981308350689e-15    0.9295080167952067     2.631228568361621e-14    9.71445146547012e-17     2.7755575615628914e-16   1.8041124150158794e-16   0.0370479446281955
 -0.47360918256095863   0.0  -0.12531586189663457   -0.03500540155108815    -0.12266496414159372    0.0  0.0  0.0  0.0  0.0  0.0  0.0   1.2331447673460467    0.0  -0.11679785807542903     0.3296614679484056      0.004648976784879369    0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.8052962088950498    0.0  -0.04432176261119575   -0.41668642626540536   -0.10569955396538423    0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.27299934180555274  0.05264877170439268   0.06781077687905307    0.9832847944523508     0.07585481312963546   0.0  -1.216412233445487e-5    0.0  0.0  0.0  0.0   0.025205407433645053   1.2705114738054135e-14  -0.059236458223419226   0.028013880720362257  -0.9273473043277112     0.24805975279627446   -3.3306690738754696e-15   0.008274913152365726  -1.2552459072168176e-14   1.0755285551056204e-16   1.0755285551056204e-16   1.9081958235744878e-16  -0.024764254799602863
 -0.03907555039316141   0.0  -0.020259089736222164  -0.0007650944702003904  -0.020964584905621333   0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.11981378735802013   0.0  -0.021956266348871697    0.03290267049808291     0.026695298956530496    0.0  0.0  0.0  0.0  0.0  0.0  0.0  -0.12323522603228682   0.0   0.02023625538916286   -0.05854921534781744    0.0020779438347818535  0.0  0.0  0.0  0.0  0.0  0.0  0.0   0.229780587961909    0.2047410640889027    0.03419820667815982    0.09225981389673804    0.050567880635814015  0.0   0.00022122212856097207  0.0  0.0  0.0  0.0  -0.9446881295234946    -1.942890293094024e-14   -0.23035932457487446   -0.03513701932849023   -0.07188888962892004   -0.055211331533372834   0.0                     -0.1504912439185233     1.9539925233402755e-14  -1.1102230246251565e-16   1.1102230246251565e-16   0.0                      0.9449855906932771
  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.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                   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.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                    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.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                     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.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                    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.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                    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.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  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.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                    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.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  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.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  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.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  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.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  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.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]

condn=0.0000000001::Float64

iqExpected=7

nnumericMatlab=7

(hOutput,qOutput,iqOutput,nnumeric)=numericShift!(hhIn,qq,0,qRows,qCols,neq,condn)
sameSpan(hOutput,hExpected)&&
sameSpan(qOutput,qExpected)&&
iqOutput==iqExpected&&
nnumeric==nnumericMatlab
end;

end


text:
#=
struct PadImg{N, I<:Tuple} <: Augmentor.ImageOperation
    borders::I
    function PadImg{N}(borders::NTuple{N,<:Integer}) where N
        new{N,typeof(borders)}(borders)
    end
end
PadImg(borders::Integer...) = PadImg{length(borders)}(borders)

@inline Augmentor.supports_eager(::Type{<:PadImg})      = false
@inline Augmentor.supports_affineview(::Type{<:PadImg}) = false
@inline Augmentor.supports_view(::Type{<:PadImg})       = false
@inline Augmentor.supports_stepview(::Type{<:PadImg})   = true

Augmentor.applystepview(op::PadImg, img::AbstractArray, param) = Augmentor.applyeager(op, img, param)
function Augmentor.applyeager(op::PadImg{N}, img::AbstractArray, param) where N
    PaddedView(Gray(0.0), img, size(img) .+ 2 .* op.borders, op.borders .+ 1)
end

let o = augment(CIFAR10.convert2image(CIFAR10.traintensor(2)), PadImg(4, 4) |> RCropSize(32))
    Base.display(o)
end
=#

"""
    PadBorders(border, lo, up)
    PadBorders(border, bo)
    PadBorders(border, bo...)

The argument `border` is a symbol or value:
* `:replicate` repeat edge values to infinity
* `:circular` image edges "wrap around"
* `:symmetric` the image reflects relative to a position between pixels
* `:reflect` the image reflects relative to the edge itself
* a numeric or color type value: for example RGB(0, 0, 0) will pad a RGB image
  with black

`lo` and `up` are tuples:
* `lo` number to extend by on the lower edge for each dimension
* `up` number to extend by on the upper edge for each dimension

If a single tuple (or an integer serie) is supplied, the padding is symmetric.

If `PadBorders` is used to process an image batch, you must define `lo` and `hi`
as tuples with the batch dimension set to 0.

# Example
```julia
# Pad the testpattern from Augmentor with black
julia> augment(PadBorders(RGB(0, 0, 0), (50, 100))) |> plot

# Pad the testpattern from Augmentor with circular borders
julia> augment(PadBorders(:circular, 50, 50)) |> plot

# Pad a fake image batch with 0
julia> augment(rand(32, 32, 3, 16), PadBorders(0, 8, 8, 0, 0))[:,:,1,1] |> heatmap
```
See also [`Pad`](https://juliaimages.org/ImageFiltering.jl/stable/function_reference/#ImageFiltering.Pad),
and [`Fill`](https://juliaimages.org/ImageFiltering.jl/stable/function_reference/#ImageFiltering.Fill).
"""
struct PadBorders{N, I <: Tuple} <: ImageOperation
    pad
end

PadBorders{N}(border::Symbol, lo::T, up::T) where {N, T <: NTuple{N, <:Integer}} =
    PadBorders{N, typeof(lo)}(Pad(border, lo, up))

PadBorders{N}(border, lo::T, up::T) where {N, T <: NTuple{N, <:Integer}} =
    PadBorders{N, typeof(lo)}(Fill(border, lo, up))

PadBorders(border, lo::T, up::T) where {N, T <: NTuple{N, <:Integer}} =
    PadBorders{length(lo)}(border, lo, up)

PadBorders(border, bo::T) where {N, T <: NTuple{N, <:Integer}} =
    PadBorders{length(bo)}(border, bo, bo)

PadBorders(border, bo::Integer...) = PadBorders(border, bo)

@inline supports_eager(::Type{<:PadBorders}) = false

@inline supports_affineview(::Type{<:PadBorders}) = false

@inline supports_view(::Type{<:PadBorders}) = false

@inline supports_stepview(::Type{<:PadBorders}) = true

applystepview(op::PadBorders,
              img::AbstractArray, param) = applyeager(op, img, param)

applyeager(op::PadBorders{N},
           img::AbstractArray, param) where N = padarray(img, op.pad)

ext: jl