Safe Haskell | None |
---|
gradients and hessians tend to be sparse. This can be probed by calculating these with NaNs as inputs. http:www.gpops2.com/ uses this strategy, but perhaps there are relatively common cases (calls to blas/lapack for example) that do not propagate NaNs correctly.
All functions provide indices that are affected (and should thus be included)
functions ending in 1 set one variable at a time to NaN, and additionally provide a hint as to which variable to change.
functions not ending in 1 set all input variables to NaN
it seems that adding a 1 achieves the same thing as doing one more derivative. In other words, nanPropagateG1 tells the same thing as nanPropagateH.
- nanPropagate1 :: Int -> (forall a. RealFloat a => Vector a -> a) -> [Int]
- nanPropagateG :: Int -> (forall a. RealFloat a => Vector a -> a) -> Vector Int
- nanPropagateJ :: Int -> (forall a. RealFloat a => Vector a -> Vector a) -> Vector (Int, Int)
- nanPropagateH :: Int -> (forall a. RealFloat a => Vector a -> a) -> Vector (Int, Int)
- nanPropagateG1 :: Int -> (forall a. RealFloat a => Vector a -> a) -> [(Int, Vector Int)]
- nanPropagateHF :: Int -> (forall a. RealFloat a => Vector a -> Vector a) -> Vector (Vector (Int, Int))
- jacobianSS :: RealFloat a => Vector (Int, Int) -> (forall a. RealFloat a => Vector a -> Vector a) -> Vector a -> Vector a
Documentation
>>>
let g x = x!0 + x!1 * x!1 * x!2
:: Int | size of input vector |
-> (forall a. RealFloat a => Vector a -> a) | |
-> [Int] | inputs that don't become NaN |
>>>
nanPropagate1 4 g
[0,1,2]
variable 3 isn't even used.
>>>
nanPropagateG 4 g
fromList [0,1,2]
jacobian
hessian sparsity
>>>
nanPropagateH 4 g
fromList [(1,1),(1,2),(2,1)]
:: Int | size of input vector |
-> (forall a. RealFloat a => Vector a -> a) | |
-> [(Int, Vector Int)] |
|
a nonzero gradient when inputs are NaN ==> no need to include that row/column in the hessian, since it will be zero
>>>
nanPropagateG1 4 g
[(1,fromList [1,2]),(2,fromList [1])]
nanPropagateHF :: Int -> (forall a. RealFloat a => Vector a -> Vector a) -> Vector (Vector (Int, Int))Source