11module DiffResults
22
3- using StaticArrays
3+ using StaticArraysCore : StaticArray, similar_type # , Size # Size is not yet in Core package
44
55# ########
66# Types #
@@ -76,7 +76,8 @@ shape information. If you want to allocate storage yourself, use the `DiffResult
7676constructor instead.
7777"""
7878JacobianResult (x:: AbstractArray ) = DiffResult (similar (x), similar (x, length (x), length (x)))
79- JacobianResult (x:: StaticArray ) = DiffResult (x, zeros (StaticArrays. similar_type (typeof (x), Size (length (x),length (x)))))
79+ # JacobianResult(x::StaticArray) = DiffResult(x, zeros(similar_type(typeof(x), Size(length(x),length(x)))))
80+ JacobianResult (x:: StaticArray ) = DiffResult (x, zeros (similar_type (typeof (x), (axes (vec (x))... , axes (vec (x))... ))))
8081
8182"""
8283 JacobianResult(y::AbstractArray, x::AbstractArray)
@@ -89,7 +90,8 @@ Like the single argument version, `y` and `x` are only used for type and
8990shape information and are not stored in the returned `DiffResult`.
9091"""
9192JacobianResult (y:: AbstractArray , x:: AbstractArray ) = DiffResult (similar (y), similar (y, length (y), length (x)))
92- JacobianResult (y:: StaticArray , x:: StaticArray ) = DiffResult (y, zeros (StaticArrays. similar_type (typeof (x), Size (length (y),length (x)))))
93+ # JacobianResult(y::StaticArray, x::StaticArray) = DiffResult(y, zeros(similar_type(typeof(x), Size(length(y),length(x)))))
94+ JacobianResult (y:: StaticArray , x:: StaticArray ) = DiffResult (y, zeros (similar_type (typeof (x), (axes (vec (y))... , axes (vec (x))... ))))
9395
9496"""
9597 HessianResult(x::AbstractArray)
@@ -102,7 +104,8 @@ shape information. If you want to allocate storage yourself, use the `DiffResult
102104constructor instead.
103105"""
104106HessianResult (x:: AbstractArray ) = DiffResult (first (x), zeros (eltype (x), size (x)), similar (x, length (x), length (x)))
105- HessianResult (x:: StaticArray ) = DiffResult (first (x), x, zeros (StaticArrays. similar_type (typeof (x), Size (length (x),length (x)))))
107+ # HessianResult(x::StaticArray) = DiffResult(first(x), x, zeros(similar_type(typeof(x), Size(length(x),length(x)))))
108+ HessianResult (x:: StaticArray ) = DiffResult (first (x), x, zeros (similar_type (typeof (x), (axes (vec (x))... , axes (vec (x))... ))))
106109
107110# ############
108111# Interface #
0 commit comments