---
name: "sc_RefSCMatrix"
section: "3"
platform: "linux"
package: "libsc-doc"
version: "2.3.1-22"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/sc_RefSCMatrix"
---

# sc\_RefSCMatrix(3)

The RefSCMatrix class is a smart pointer to an SCMatrix specialization.

## NAME

sc::RefSCMatrix - The **RefSCMatrix** class is a smart pointer to an **SCMatrix** specialization.

## SYNOPSIS

`#include <matrix.h>`

Inherits **sc::Ref\< SCMatrix \>**.

### Public Member Functions

**RefSCMatrix** ()\
 Initializes the matrix pointer to 0.  **RefSCMatrix** (const **RefSCMatrix** &m)\
 Make this and m refer to the same **SCMatrix**.  **RefSCMatrix** (**SCMatrix** \*m)\
 Make this refer to m.  **RefSCMatrix** & **operator=** (**SCMatrix** \*m)\
 Make this refer to m.  **RefSCMatrix** & **operator=** (const **RefSCMatrix** &m)\
 Make this and m refer to the same matrix.  **RefSCMatrix** (const **RefSCDimension** &d1, const **RefSCDimension** &d2, const **Ref**\< **SCMatrixKit** \> &)\
 Create a vector with dimension d1 by d2.  **RefSCVector** **operator\*** (const **RefSCVector** &) const\
 Multiply this by a vector and return a vector.  **RefSCMatrix** **operator\*** (const **RefSCMatrix** &) const\
 Multiply this by a matrix and return a matrix.  **RefSCMatrix** **operator\*** (const **RefSymmSCMatrix** &) const\
 **RefSCMatrix** **operator\*** (const **RefDiagSCMatrix** &) const\
 **RefSCMatrix** **operator\*** (double) const\
 Multiply this by a scalar and return the result.  **RefSCMatrix** **operator+** (const **RefSCMatrix** &) const\
 Matrix addition.  **RefSCMatrix** **operator-** (const **RefSCMatrix** &) const\
 Matrix subtraction.  **RefSCMatrix** **t** () const\
 Return the transpose of this.  **RefSCMatrix** **i** () const\
 Return the inverse of this.  **RefSCMatrix** **gi** () const\
 Return the generalized inverse of this.  **RefSCMatrix** **clone** () const\
 These call the **SCMatrix** members of the same name after checking for references to 0.  **RefSCMatrix** **copy** () const\
 **RefSCMatrix** **get\_subblock** (int br, int er, int bc, int ec)\
 void **assign\_subblock** (const **RefSCMatrix** &, int br, int er, int bc, int ec, int source\_br=0, int source\_bc=0)\
 void **accumulate\_subblock** (const **RefSCMatrix** &, int, int, int, int, int source\_br=0, int source\_bc=0)\
 **RefSCVector** **get\_row** (int) const\
 **RefSCVector** **get\_column** (int) const\
 void **assign\_row** (const **RefSCVector** &, int) const\
 void **assign\_column** (const **RefSCVector** &, int) const\
 void **accumulate\_row** (const **RefSCVector** &, int) const\
 void **accumulate\_column** (const **RefSCVector** &, int) const\
 void **accumulate\_outer\_product** (const **RefSCVector** &, const **RefSCVector** &) const\
 void **accumulate\_product** (const **RefSCMatrix** &, const **RefSCMatrix** &) const\
 void **assign** (const **RefSCMatrix** &) const\
 void **scale** (double) const\
 void **randomize** () const\
 void **assign** (double) const\
 void **assign** (const double \*) const\
 void **assign** (const double \*\*) const\
 void **convert** (double \*) const\
 void **convert** (double \*\*) const\
 void **accumulate** (const **RefSCMatrix** &) const\
 void **accumulate** (const **RefSymmSCMatrix** &) const\
 void **accumulate** (const **RefDiagSCMatrix** &) const\
 void **element\_op** (const **Ref**\< **SCElementOp** \> &) const\
 void **element\_op** (const **Ref**\< **SCElementOp2** \> &, const **RefSCMatrix** &) const\
 void **element\_op** (const **Ref**\< **SCElementOp3** \> &, const **RefSCMatrix** &, const **RefSCMatrix** &) const\
 int **nrow** () const\
 int **ncol** () const\
 **RefSCDimension** **rowdim** () const\
 **RefSCDimension** **coldim** () const\
 **Ref**\< **SCMatrixKit** \> **kit** () const\
 void **set\_element** (int, int, double) const\
 void **accumulate\_element** (int, int, double) const\
 double **get\_element** (int, int) const\
 void **print** (std::ostream &) const\
 void **print** (const char \*title=0, std::ostream &out=**ExEnv::out0**(), int=10) const\
 double **trace** () const\
 void **save** (**StateOut** &)\
 void **restore** (**StateIn** &)\
 Restores the matrix from **StateIn** object. The matrix must have been initialized already.  void **svd** (const **RefSCMatrix** &U, const **RefDiagSCMatrix** &sigma, const **RefSCMatrix** &V)\
 **Compute** the singular value decomposition, this = U sigma V.t().  double **solve\_lin** (const **RefSCVector** &v) const\
 Solves this x = v.  double **determ** () const\
 Returns the determinant of the referenced matrix.  **SCMatrixdouble** **operator()** (int **i**, int j) const\
 Assign and examine matrix elements.  int **nblock** () const\
 If this matrix is blocked return the number of blocks.  **RefSCMatrix** **block** (int **i**) const\
 If this matrix is blocked return block i.

### Additional Inherited Members

## Detailed Description

The **RefSCMatrix** class is a smart pointer to an **SCMatrix** specialization.

## Constructor & Destructor Documentation

### sc::RefSCMatrix::RefSCMatrix ()

Initializes the matrix pointer to 0. The reference must be initialized before it is used.

### sc::RefSCMatrix::RefSCMatrix (const RefSCDimension & d1, const RefSCDimension & d2, const Ref\< SCMatrixKit \> &)

Create a vector with dimension d1 by d2. The data values are undefined.

## Member Function Documentation

### RefSCMatrix sc::RefSCMatrix::block (int i) const

If this matrix is blocked return block i. Otherwise return this as block 0.

### int sc::RefSCMatrix::nblock () const

If this matrix is blocked return the number of blocks. Otherwise return 1.

### double sc::RefSCMatrix::solve\_lin (const RefSCVector & v) const

Solves this x = v. Overwrites v with x.

### void sc::RefSCMatrix::svd (const RefSCMatrix & U, const RefDiagSCMatrix & sigma, const RefSCMatrix & V)

**Compute** the singular value decomposition, this = U sigma V.t(). The dimension of sigma is the smallest dimension of this. U, V, and sigma must already have the correct dimensions and are overwritten.

## Author

Generated automatically by Doxygen for MPQC from the source code.
