> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# compression:apply svd

**Version: 0.0.0**

## Description

Computes the coefficients (=U\*Sigma) and VT components from SVD.

## Inputs

This table lists the input pins for this operator. Input pins define the data that the operator requires to perform its operation.
Some inputs are required, while others are optional and provide additional configuration.
Each parameter is detailed in the sections that follow the table.

| Pin number | Name | Status | Expected type(s) |
| - | - | - | - |
| **0** | [field\_contaner\_to\_compress](#input_0) | Required | [`fields_container`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#fields-container) |
| **1** | [scalar\_int](#input_1) | | [`int32`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types) |
| **2** | [scalar\_double](#input_2) | | [`double`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types) |
| **3** | [boolean](#input_3) | | [`bool`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types) |

### field\_contaner\_to\_compress (Pin 0)

* **Required:** Yes
* **Expected type(s):** [`fields_container`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#fields-container)

Fields container with data to be compressed

### scalar\_int (Pin 1)

* **Required:** No
* **Expected type(s):** [`int32`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types)

Number of vectors (r) to keep for the future reconstraction of the matrix A, ex.A\[m,n] = coef\[m,r] \* VT\[r,n], where coef = U \* Sigma

### scalar\_double (Pin 2)

* **Required:** No
* **Expected type(s):** [`double`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types)

Threshold (precision) as a double (Default : 1e-7). If both pin1 and pin2 are provided, choose the min r-vectors

### boolean (Pin 3)

* **Required:** No
* **Expected type(s):** [`bool`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types)

Apply SVD on the initial data (Default : false), otherwise use reduced data (square matrix with the smallest dimensions).

## Outputs

This table lists the output pins for this operator.
Output pins provide the results of the operator's computation and can be connected to inputs of other operators or retrieved for further processing.
Each output is detailed in the sections that follow the table.

| Pin number | Name | Expected type(s) |
| - | - | - |
| **0** | [us\_svd](#output_0) | [`fields_container`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#fields-container) |
| **1** | [vt\_svd](#output_1) | [`fields_container`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#fields-container) |
| **2** | [sigma](#output_2) | [`field`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#field), [`fields_container`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#fields-container) |

### us\_svd (Pin 0)

* **Expected type(s):** [`fields_container`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#fields-container)

The output entity is a fields container (time dependant); it contains the product of two matrices, U and S, where A=U.S.Vt

### vt\_svd (Pin 1)

* **Expected type(s):** [`fields_container`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#fields-container)

The output entity is a field container (space dependant), containing the Vt, where A=U.S.Vt

### sigma (Pin 2)

* **Expected type(s):** [`field`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#field), [`fields_container`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#fields-container)

The output entity is a field (or a field container if input fc contains several labels, where field contains results per label), containing singular (S) values of the input data, where A=U.S.Vt

## Configurations

This operator supports [configuration options](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/operator-configurations.md) that modify its behavior.

### [mutex](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/operator-configurations.md#mutex)

* **Expected type(s):** [`bool`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types)
* **Default value:** false

If this option is set to true, the shared memory is prevented from being simultaneously accessed by multiple threads.

### [num\_threads](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/operator-configurations.md#num_threads)

* **Expected type(s):** [`int32`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types)
* **Default value:** 0

### [run\_in\_parallel](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/operator-configurations.md#run_in_parallel)

* **Expected type(s):** [`bool`](https://developer.synopsys.com/docs/dpf/dpf-framework/core-concepts/dpf-types#standard-types)
* **Default value:** true

Loops are allowed to run in parallel if the value of this config is set to true.

## Scripting

This operator can be accessed through scripting interfaces using these identifiers.

**Category**: compression

**Plugin**: N/A

**Scripting name**: apply\_svd

**Full name**: compression.apply\_svd

**Internal name**: svd\_operator

**License**: any\_dpf\_supported\_increments

## Examples

These examples demonstrate how to use this operator in different programming environments.
Each example shows how to instantiate the operator, connect the required inputs, and retrieve the output.

<details>
  <summary>C++</summary>

  ```cpp theme={null}
  #include "dpf_api.h"

  ansys::dpf::Operator op("svd_operator"); // operator instantiation
  op.connect(0, my_field_contaner_to_compress);
  op.connect(1, my_scalar_int);
  op.connect(2, my_scalar_double);
  op.connect(3, my_boolean);
  ansys::dpf::FieldsContainer my_us_svd = op.getOutput<ansys::dpf::FieldsContainer>(0);
  ansys::dpf::FieldsContainer my_vt_svd = op.getOutput<ansys::dpf::FieldsContainer>(1);
  ansys::dpf::Field my_sigma = op.getOutput<ansys::dpf::Field>(2);
  ```
</details>

<details>
  <summary>CPython</summary>

  ```python theme={null}
  import ansys.dpf.core as dpf

  op = dpf.operators.compression.apply_svd() # operator instantiation
  op.inputs.field_contaner_to_compress.connect(my_field_contaner_to_compress)
  op.inputs.scalar_int.connect(my_scalar_int)
  op.inputs.scalar_double.connect(my_scalar_double)
  op.inputs.boolean.connect(my_boolean)
  my_us_svd = op.outputs.us_svd()
  my_vt_svd = op.outputs.vt_svd()
  my_sigma_as_field = op.outputs.sigma_as_field()
  ```
</details>

<details>
  <summary>IPython</summary>

  ```python theme={null}
  import mech_dpf
  import Ans.DataProcessing as dpf

  op = dpf.operators.compression.apply_svd() # operator instantiation
  op.inputs.field_contaner_to_compress.Connect(my_field_contaner_to_compress)
  op.inputs.scalar_int.Connect(my_scalar_int)
  op.inputs.scalar_double.Connect(my_scalar_double)
  op.inputs.boolean.Connect(my_boolean)
  my_us_svd = op.outputs.us_svd.GetData()
  my_vt_svd = op.outputs.vt_svd.GetData()
  my_sigma = op.outputs.sigma.GetData()
  ```
</details>

## Changelog

* Version 0.0.0: Initial release.
