dbcsr_scalar_negative Function

public elemental function dbcsr_scalar_negative(s) result(negated)

Returns an encapsulated scalar as a negation of the given

Arguments

Type IntentOptional Attributes Name
type(dbcsr_scalar_type), intent(in) :: s

given value

Return Value type(dbcsr_scalar_type)

negated value


Source Code

   ELEMENTAL FUNCTION dbcsr_scalar_negative(s) RESULT(negated)
      !! Returns an encapsulated scalar as a negation of the given

      TYPE(dbcsr_scalar_type), INTENT(IN)                :: s
         !! given value
      TYPE(dbcsr_scalar_type)                            :: negated
         !! negated value

      negated = dbcsr_scalar_zero(s%data_type)
      SELECT CASE (s%data_type)
      CASE (dbcsr_type_real_4)
         negated%r_sp = -s%r_sp
      CASE (dbcsr_type_real_8)
         negated%r_dp = -s%r_dp
      CASE (dbcsr_type_complex_4)
         negated%c_sp = -s%c_sp
      CASE (dbcsr_type_complex_8)
         negated%c_dp = -s%c_dp
      CASE default
         negated = dbcsr_scalar_zero(s%data_type)
      END SELECT
   END FUNCTION dbcsr_scalar_negative