sscal Subroutine

public subroutine sscal(n, sa, sx, incx)

NAME

sscal(3f) - [BLAS:SINGLE_BLAS_LEVEL1] SX:=SA*SX.

SYNOPSIS

 subroutine sscal(n,sa,sx,incx)

   .. Scalar Arguments ..
   real,intent(in)    :: sa
   integer,intent(in) :: incx,n
   ..
   .. Array Arguments ..
   real,intent(inout) :: sx(*)
   ..

DEFINITION

 SSCAL scales a vector by a constant.
 uses unrolled loops for increment equal to 1.

OPTIONS

N

       N is INTEGER
      number of elements in input vector(s)

SA

       SA is REAL
        On entry, SA specifies the scalar alpha.

SX

       SX is REAL array, dimension ( 1 + ( N - 1 )*abs( INCX ) )

INCX

       INCX is INTEGER
      storage spacing between elements of SX

AUTHORS

  • Univ. of Tennessee
  • Univ. of California Berkeley
  • Univ. of Colorado Denver
  • NAG Ltd.

date:November 2017

FURTHER DETAILS

  jack dongarra, linpack, 3/11/78.
  modified 3/93 to return if incx .le. 0.
  modified 12/3/93, array(1) declarations changed to array(*)

SEE ALSO

Online html documentation available at
http://www.netlib.org/lapack/explore-html/

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
real, intent(in) :: sa
real, intent(inout) :: sx(*)
integer, intent(in) :: incx

Contents

Source Code


Variables

Type Visibility Attributes Name Initial
integer, public :: i
integer, public :: m
integer, public :: mp1
integer, public :: nincx

Source Code

       subroutine sscal(n,sa,sx,incx)
      implicit none
!
!  -- Reference BLAS level1 routine (version 3.8.0) --
!  -- Reference BLAS is a software package provided by Univ. of Tennessee,    --
!  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
!     November 2017
!
!     .. Scalar Arguments ..
      real,intent(in)    :: sa
      integer,intent(in) :: incx,n
!     ..
!     .. Array Arguments ..
      real,intent(inout) :: sx(*)
!     ..
!
!  =====================================================================
!
!     .. Local Scalars ..
      integer i,m,mp1,nincx
!     ..
!     .. Intrinsic Functions ..
      intrinsic mod
!     ..
      if (n.le.0 .or. incx.le.0) return
      if (incx.eq.1) then
!
!        code for increment equal to 1
!
!
!        clean-up loop
!
         m = mod(n,5)
         if (m.ne.0) then
            do i = 1,m
               sx(i) = sa*sx(i)
            enddo
            if (n.lt.5) return
         endif
         mp1 = m + 1
         do i = mp1,n,5
            sx(i) = sa*sx(i)
            sx(i+1) = sa*sx(i+1)
            sx(i+2) = sa*sx(i+2)
            sx(i+3) = sa*sx(i+3)
            sx(i+4) = sa*sx(i+4)
         enddo
      else
!
!        code for increment not equal to 1
!
         nincx = n*incx
         do i = 1,nincx,incx
            sx(i) = sa*sx(i)
         enddo
      endif

      end subroutine sscal