# Dense Vector Data Structure

[next] [prev] [prev-tail] [tail] [up]

#### 3.3 Dense Vector Data Structure

The psb_T_vect_type data structure encapsulates the dense vectors in a way similar to sparse matrices, i.e. including a base type psb_T_base_vect_type. The user will not, in general, access the vector components directly, but rather via the routines of sec. 6. Among other simple things, we define here an extraction method that can be used to get a full copy of the part of the vector stored on the local process.

The type declaration is shown in figure 3 where T is a placeholder for the data type and precision variants

I
  Integer;
S
  Single precision real;
D
  Double precision real;
C
  Single precision complex;
Z
  Double precision complex.

The actual data is contained in the polymorphic component v%v; the separation between the application and the actual data is essential for cases where it is necessary to link to data storage made available elsewhere outside the direct control of the compiler/application, e.g. data stored in a graphics accelerator’s private memory.

      type psb_T_base_vect_type
        TYPE(KIND_), allocatable :: v(:)
      end type psb_T_base_vect_type
      type psb_T_vect_type
        class(psb_T_base_vect_type), allocatable :: v
      end type  psb_T_vect_type

Listing 3: The PSBLAS defined data type that contains a dense vector.

##### 3.3.1 Vector Methods

##### 3.3.2 get_nrows — Get number of rows in a dense vector

nr = v%get_nrows()

Type:
  Asynchronous.
On Entry
v
  the dense vector
  Scope: local

On Return
Function value
  The number of rows of dense vector v.

##### 3.3.3 sizeof — Get memory occupation in bytes of a dense vector

memory_size = v%sizeof()

Type:
  Asynchronous.
On Entry
v
  the dense vector
  Scope: local

On Return
Function value
  The memory occupation in bytes.

##### 3.3.4 set — Set contents of the vector

     call  v%set(alpha[,first,last])
     call  v%set(vect[,first,last])
     call  v%zero()

Type:
  Asynchronous.
On Entry
v
  the dense vector
  Scope: local
alpha
  A scalar value.
  Scope: local
  Type: required
  Intent: in.
  Specified as: a number of the data type indicated in Table 1.
first,last
  Boundaries for setting in the vector.
  Scope: local
  Type: optional
  Intent: in.
  Specified as: integers.
vect
  An array
  Scope: local
  Type: required
  Intent: in.
  Specified as: a number of the data type indicated in Table 1.

Note that a call to v%zero() is provided as a shorthand, but is equivalent to a call to v%set(zero) with the zero constant having the appropriate type and kind.

On Return
v
  the dense vector, with updated entries
  Scope: local

##### 3.3.5 get_vect — Get a copy of the vector contents

    extv = v%get_vect([n])

Type:
  Asynchronous.
On Entry
v
  the dense vector
  Scope: local
n
  Size to be returned
  Scope: local.
  Type: optional; default: entire vector.

On Return
Function value
  An allocatable array holding a copy of the dense vector contents. If the argument n is specified, the size of the returned array equals the minimum between n and the internal size of the vector, or 0 if n is negative; otherwise, the size of the array is the same as the internal size of the vector.

##### 3.3.6 clone — Clone current object

    call  x%clone(y,info)

Type:
  Asynchronous.
On Entry
x
  the dense vector.
  Scope: local.

On Return
y
  A copy of the input object.
info
  Return code.

[next] [prev] [prev-tail] [front] [up]