# spTScalar¶

## Purpose¶

Multiplies a sparse matrix by a scalar.

## Format¶

y = spTScalar(s, scal, rinds, cinds)
Parameters: s (NxM sparse matrix) – data scal (scalar) – data rinds (Kx1 vector) – row indices cinds (Lx1 vector) – column indices y (KxL sparse matrix) – result of multiplying sparse matrix s by a scalar, scal.

## Examples¶

sparse matrix y;
sparse matrix s;

// Create x matrix
x = { 3 0 2 1,
0 4 0 0,
5 0 0 3,
0 1 2 0 };

// Convert to sparse matrix
s = denseToSp(x, 0.04);

// Rows and columns
rinds = 0;
cinds = { 2, 4 };

// Multiply all elements in the second and fourth column
// by 'scal'
y = spTScalar(s, 10, rinds, cinds);
d = sptoDense(y);


The result, in d is:

3 0   2 10
0 40  0 0
5 0   0 3
0 10  2 0


## Remarks¶

Only the elements of s specified by rinds and cinds will be multiplied by scal. All other elements will be unchanged in the result.

To select all rows or all columns, input a scalar 0 for rinds or cinds.

Since sparse matrices are strongly typed in GAUSS, y must be defined as a sparse matrix before the call to spTScalar().

Functions spTrTDense()