random-array-shape
random-func1
random-func2
+ random-func2-rank&dims>0
random-input
random-list-element
random-non-empty-array
(with-generators
(random-func2-rank&dims>0 gx gy)
~ (apply-grad-amap2 ngrad 1) (apply-grad-amap2 v:grad 1))))
+(test-assert
+ (~ ((ngrad v:amap2 1) v:* #(1 2 3) #(10 20 30))
+ ((v:grad v:amap2 1) v:* #(1 2 3) #(10 20 30))))
+(test-assert
+ (let ((x #(10 20 30))
+ (y #(10 20 30)))
+ (~ ((ngrad (lambda (a) (v:amap2 (lambda (x y) (v:* a a)) x y))) #(1 2 3))
+ ((v:grad (lambda (a) (v:amap2 (lambda (x y) (v:* a a)) x y))) #(1 2 3)))))
;; `v:adot'
(define (random-shared-contractible)
~
(lambda (a b n) ((ngrad v:adot 0) a b n))
(lambda (a b n) ((v:grad v:adot 0) a b n)))))
+(test-assert
+ (receive (gx gy gz) (random-shared-contractible)
+ (with-generators
+ (gx gy gz)
+ ~
+ (lambda (a b n) ((ngrad v:adot 1) a b n))
+ (lambda (a b n) ((v:grad v:adot 1) a b n)))))
;; chain rule
(test-assert