@@ -115,11 +115,57 @@ for (Tx, TA, Ty) in Iterators.filter(
115
115
end
116
116
117
117
# # Division
118
+ function LinearAlgebra.:\ (A:: AbstractMatrix{T} , B:: AbstractMatrix ) where {T<: AbstractTracer }
119
+ if size (A, 1 ) != size (B, 1 )
120
+ throw (DimensionMismatch (" arguments must have the same number of rows" ))
121
+ end
122
+ t = second_order_or (A)
123
+ return Fill (t, size (A, 2 ), size (B, 2 ))
124
+ end
125
+ function LinearAlgebra.:\ (A:: AbstractMatrix{T} , B:: AbstractVector ) where {T<: AbstractTracer }
126
+ if size (A, 1 ) != size (B, 1 )
127
+ throw (DimensionMismatch (" arguments must have the same number of rows" ))
128
+ end
129
+ t = second_order_or (A)
130
+ return Fill (t, size (A, 2 ))
131
+ end
132
+
133
+ function LinearAlgebra.:\ (A:: AbstractMatrix , B:: AbstractMatrix{T} ) where {T<: AbstractTracer }
134
+ if size (A, 1 ) != size (B, 1 )
135
+ throw (DimensionMismatch (" arguments must have the same number of rows" ))
136
+ end
137
+ t = second_order_or (B)
138
+ return Fill (t, size (A, 2 ), size (B, 2 ))
139
+ end
140
+ function LinearAlgebra.:\ (A:: AbstractMatrix , B:: AbstractVector{T} ) where {T<: AbstractTracer }
141
+ if size (A, 1 ) != size (B, 1 )
142
+ throw (DimensionMismatch (" arguments must have the same number of rows" ))
143
+ end
144
+ t = second_order_or (B)
145
+ return Fill (t, size (A, 2 ))
146
+ end
147
+
148
+ function LinearAlgebra.:\ (
149
+ A:: AbstractMatrix{T} , B:: AbstractMatrix{T}
150
+ ) where {T<: AbstractTracer }
151
+ if size (A, 1 ) != size (B, 1 )
152
+ throw (DimensionMismatch (" arguments must have the same number of rows" ))
153
+ end
154
+ tA = second_order_or (A)
155
+ tB = second_order_or (B)
156
+ t = second_order_or (tA, tB)
157
+ return Fill (t, size (A, 2 ), size (B, 2 ))
158
+ end
118
159
function LinearAlgebra.:\ (
119
- A:: AbstractMatrix{T} , B:: AbstractVecOrMat
160
+ A:: AbstractMatrix{T} , B:: AbstractVector{T}
120
161
) where {T<: AbstractTracer }
121
- Ainv = LinearAlgebra. pinv (A)
122
- return Ainv * B
162
+ if size (A, 1 ) != size (B, 1 )
163
+ throw (DimensionMismatch (" arguments must have the same number of rows" ))
164
+ end
165
+ tA = second_order_or (A)
166
+ tB = second_order_or (B)
167
+ t = second_order_or (tA, tB)
168
+ return Fill (t, size (A, 2 ))
123
169
end
124
170
125
171
# # Exponential
@@ -187,6 +233,27 @@ function LinearAlgebra.logabsdet(A::AbstractMatrix{D}) where {D<:Dual}
187
233
t1, t2 = LinearAlgebra. logabsdet (tracers)
188
234
return (D (p1, t1), D (p2, t2))
189
235
end
236
+ function LinearAlgebra.:\ (A:: AbstractMatrix{<:Dual} , B:: AbstractVector )
237
+ primals, tracers = split_dual_array (A)
238
+ p = primals \ B
239
+ t = tracers \ B
240
+ return Dual .(p, t)
241
+ end
242
+ function LinearAlgebra.:\ (A:: AbstractMatrix , B:: AbstractVector{D} ) where {D<: Dual }
243
+ primals, tracers = split_dual_array (B)
244
+ p = A \ primals
245
+ t = A \ tracers
246
+ return Dual .(p, t)
247
+ end
248
+ function LinearAlgebra.:\ (
249
+ A:: AbstractMatrix{D1} , B:: AbstractVector{D2}
250
+ ) where {D1<: Dual ,D2<: Dual }
251
+ A_primals, A_tracers = split_dual_array (A)
252
+ B_primals, B_tracers = split_dual_array (B)
253
+ p = A_primals \ B_primals
254
+ t = A_tracers \ B_tracers
255
+ return Dual .(p, t)
256
+ end
190
257
191
258
#= =============#
192
259
# SparseArrays #
0 commit comments