mattloper / chumpy

MIT License
198 stars 121 forks source link

Please help me!! how to assemble a new array with chumpy object? #17

Open FLOWERCLOUD opened 6 years ago

FLOWERCLOUD commented 6 years ago

for example: a = ch.array(5)

Rx = ch.array([[1, 0, 0], [0, ch.cos(a), -ch.sin(a)], [0, ch.sin(a), ch.cos(a)]])

but when I change a[0] ,the value in Rx will not change . It seems that my way of array assembly will break the forward-mode So how can I assemble a new array and still hold the forward mode.

tneumann commented 6 years ago

It apparently works if you use the vstack, hstack, concatenate or reshape functions, e.g. one possibility with concatenate + reshape would be:

a = ch.array(5)
Rx = ch.concatenate([
  1, 0, 0,  
  0, ch.cos(a), -ch.sin(a),  
  0, ch.sin(a), ch.cos(a)]).reshape(3, 3)
FLOWERCLOUD commented 6 years ago

that works well ,thank you