36.  FORALL的一个例子

BACKWARDFORWARD


  • 初始化
    • a = [0,1,2,3,4]
      b = [0,10,20,30,40]
      c = [-1,-1,-1,-1,-1]

      FORALL ( i = 2:4 )
        a(i) = a(i-1) + a(i+1)  
        c(i) = b(i) * a(i+1)

      END FORALL

  • 然后得:
    • a = [0,2,4,6,4]
      b = [0,10,20,30,40]
      c = [-1,40,120,120,-1]


Copyright: NPACT BACKWARDFORWARD