hvx icon indicating copy to clipboard operation
hvx copied to clipboard

Add multiply-by-positive-constant primitive hmulpos.

Open cheater opened this issue 8 years ago • 1 comments

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?

cheater avatar Aug 13 '17 21:08 cheater

I'm still skeptical about adding more exports. Also it seems unrelated to the other changes you're making.

chrisnc avatar Aug 23 '17 07:08 chrisnc