Demo entry 6350009

TensorProduct

   

Submitted by anonymous on Mar 02, 2017 at 09:07
Language: Fortran. Code size: 755 Bytes.

  type(Vect3D) pure function TensorProduct(NU, D, NV)
    ! (NU) D (NV)^T, row * matrix * column
    ! TODO (#6): TensorProduct: Investigate whether using DO loops triggers a temporary array.
    real(dp),     intent(in) :: NU(order), NV(order)
    type(Vect3D), intent(in) :: D(order, order)
    integer                  :: i, j
    type(Vect3D)             :: P(order,order)

    do concurrent (i = 1:order)
      do concurrent (j = 1:order)
        P(i,j) = NU(i) * D(i,j) * NV(j)
      end do
    end do
    tensorproduct = .sum. P
  end function

  type(Vect3D) pure function Sum2D(array)
    type(Vect3D), intent(in) :: array(:,:)

    sum2d%x = sum(array%x)
    sum2d%y = sum(array%y)
    sum2d%z = sum(array%z)
  end function

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).