Skip to content

Commit c4487d5

Browse files
Merge pull request #449 from thisrod/mdimdoc
Document multidimensional arrays
2 parents b7cd005 + 82e4759 commit c4487d5

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/gradient.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
ForwardDiff.gradient(f, x::AbstractArray, cfg::GradientConfig = GradientConfig(f, x), check=Val{true}())
77
88
Return `∇f` evaluated at `x`, assuming `f` is called as `f(x)`.
9+
The array `∇f` has the same shape as `x`, and its elements are
10+
`∇f[j, k, ...] = ∂f/∂x[j, k, ...]`.
911
1012
This method assumes that `isa(f(x), Real)`.
1113

src/jacobian.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
ForwardDiff.jacobian(f, x::AbstractArray, cfg::JacobianConfig = JacobianConfig(f, x), check=Val{true}())
77
88
Return `J(f)` evaluated at `x`, assuming `f` is called as `f(x)`.
9+
Multidimensional arrays are flattened in iteration order: the array
10+
`J(f)` has shape `length(f(x)) × length(x)`, and its elements are
11+
`J(f)[j,k] = ∂f(x)[j]/∂x[k]`. When `x` is a vector, this means
12+
that `jacobian(x->[f(x)], x)` is the transpose of `gradient(f, x)`.
913
1014
This method assumes that `isa(f(x), AbstractArray)`.
1115

0 commit comments

Comments
 (0)