Following your tips I have rewritten the "concatenation" function a little and it seems I have found a simple primitive that should provide stronger monotonicity.
varsAsVect xs = vOut
-- | Take a list of scalar variables and output them as a single vector Expr
where
vOut = foldl' (+~) (head vs) (tail vs)
xsIndices = zip ([0..] :: [Int]) xs
vs = f <$> xsIndices
f (ind, x) = v *~+ x
where
v = EConst $ orthonormal ind
orthonormal i = assoc (n, 1) 0.0 [((i, 0), 1.0)]
n = length xs
here *~+ is exactly the same as *~ except you can only have non-negative constants on the left, or it will throw an exception. Is my understanding correct that this requirement on the left argument will preserve monotonicity of the right argument?
Following your tips I have rewritten the "concatenation" function a little and it seems I have found a simple primitive that should provide stronger monotonicity.
here
*~+
is exactly the same as*~
except you can only have non-negative constants on the left, or it will throw an exception. Is my understanding correct that this requirement on the left argument will preserve monotonicity of the right argument?