For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
GitHubCUDA-X
    • Home
    • Installation
  • Getting Started
    • Introduction
    • Integrations
    • Use-cases
  • User Guide
    • API Guide
    • Benchmarking Guide
    • Field Guide
    • References
  • Developer Guide
    • Coding Guidelines
    • Contributing
  • API Reference
    • C API Documentation
      • Cluster Kmeans
      • Core C API
      • Distance Distance
      • Distance Pairwise Distance
      • Neighbors Multi GPU Cagra
      • Neighbors Multi GPU Common
      • Neighbors Multi GPU IVF Flat
      • Neighbors Multi GPU IVF PQ
      • Neighbors All Neighbors
      • Neighbors Brute Force
      • Neighbors Cagra
      • Neighbors Common
      • Neighbors HNSW
      • Neighbors IVF Flat
      • Neighbors IVF PQ
      • Neighbors IVF SQ
      • Neighbors NN Descent
      • Neighbors Refine
      • Neighbors Tiered Index
      • Neighbors Vamana
      • Preprocessing Quantize Binary
      • Preprocessing PCA
      • Preprocessing Quantize PQ
      • Preprocessing Quantize Scalar
    • Cpp API Documentation
    • Python API Documentation
    • Java API Documentation
    • Rust API Documentation
    • Go API Documentation
NVIDIANVIDIA
Developer-friendly docs for your API
Privacy Policy | Your Privacy Choices | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact

Copyright © 2026, NVIDIA Corporation.

LogoLogocuVS
GitHubCUDA-X
On this page
  • C API for PCA (Principal Component Analysis)
  • cuvsPcaSolver
  • cuvsPcaParams
  • cuvsPcaParamsCreate
  • cuvsPcaParamsDestroy
  • cuvsPcaFit
  • cuvsPcaFitTransform
  • cuvsPcaTransform
  • cuvsPcaInverseTransform
API ReferenceC API Documentation

PCA

||View as Markdown|
Previous

Preprocessing Quantize Binary

Next

Preprocessing Quantize PQ

Source header: cuvs/preprocessing/pca.h

C API for PCA (Principal Component Analysis)

cuvsPcaSolver

Solver algorithm for PCA eigen decomposition.

1enum cuvsPcaSolver {
2 CUVS_PCA_COV_EIG_DQ = 0,
3 CUVS_PCA_COV_EIG_JACOBI = 1
4};

Values

NameValue
CUVS_PCA_COV_EIG_DQ0
CUVS_PCA_COV_EIG_JACOBI1

cuvsPcaParams

Parameters for PCA decomposition.

1struct cuvsPcaParams {
2 int n_components;
3 bool copy;
4 bool whiten;
5 enum cuvsPcaSolver algorithm;
6 float tol;
7 int n_iterations;
8};

Fields

NameTypeDescription
n_componentsintNumber of principal components to keep.
copyboolIf false, data passed to fit are overwritten and running fit(X).transform(X) will not yield the expected results; use fit_transform(X) instead.
whitenboolWhen true the component vectors are multiplied by the square root of n_samples and then divided by the singular values to ensure uncorrelated outputs with unit component-wise variances.
algorithmenum cuvsPcaSolverSolver algorithm to use.
tolfloatTolerance for singular values (used by Jacobi solver).
n_iterationsintNumber of iterations for the power method (Jacobi solver).

cuvsPcaParamsCreate

Allocate PCA params and populate with default values.

1cuvsError_t cuvsPcaParamsCreate(cuvsPcaParams_t* params);

Parameters

NameDirectionTypeDescription
paramsoutcuvsPcaParams_t*cuvsPcaParams_t to allocate

Returns

cuvsError_t

cuvsPcaParamsDestroy

De-allocate PCA params.

1cuvsError_t cuvsPcaParamsDestroy(cuvsPcaParams_t params);

Parameters

NameDirectionTypeDescription
paramsincuvsPcaParams_tcuvsPcaParams_t to de-allocate

Returns

cuvsError_t

cuvsPcaFit

Perform PCA fit operation.

1cuvsError_t cuvsPcaFit(cuvsResources_t res,
2cuvsPcaParams_t params,
3DLManagedTensor* input,
4DLManagedTensor* components,
5DLManagedTensor* explained_var,
6DLManagedTensor* explained_var_ratio,
7DLManagedTensor* singular_vals,
8DLManagedTensor* mu,
9DLManagedTensor* noise_vars,
10bool flip_signs_based_on_U);

Computes the principal components, explained variances, singular values, and column means from the input data.

Parameters

NameDirectionTypeDescription
resincuvsResources_tcuvsResources_t opaque C handle
paramsincuvsPcaParams_tPCA parameters
inputinoutDLManagedTensor*input data [n_rows x n_cols] (col-major, float32, device)
componentsoutDLManagedTensor*principal components [n_components x n_cols] (col-major, float32, device)
explained_varoutDLManagedTensor*explained variances [n_components] (float32, device)
explained_var_ratiooutDLManagedTensor*explained variance ratios [n_components] (float32, device)
singular_valsoutDLManagedTensor*singular values [n_components] (float32, device)
muoutDLManagedTensor*column means [n_cols] (float32, device)
noise_varsoutDLManagedTensor*noise variance [1] (float32, device)
flip_signs_based_on_Uinboolwhether to determine signs by U (true) or V.T (false)

Returns

cuvsError_t

cuvsPcaFitTransform

Perform PCA fit and transform in a single operation.

1cuvsError_t cuvsPcaFitTransform(cuvsResources_t res,
2cuvsPcaParams_t params,
3DLManagedTensor* input,
4DLManagedTensor* trans_input,
5DLManagedTensor* components,
6DLManagedTensor* explained_var,
7DLManagedTensor* explained_var_ratio,
8DLManagedTensor* singular_vals,
9DLManagedTensor* mu,
10DLManagedTensor* noise_vars,
11bool flip_signs_based_on_U);

Computes the principal components and transforms the input data into the eigenspace.

Parameters

NameDirectionTypeDescription
resincuvsResources_tcuvsResources_t opaque C handle
paramsincuvsPcaParams_tPCA parameters
inputinoutDLManagedTensor*input data [n_rows x n_cols] (col-major, float32, device)
trans_inputoutDLManagedTensor*transformed data [n_rows x n_components] (col-major, float32, device)
componentsoutDLManagedTensor*principal components [n_components x n_cols] (col-major, float32, device)
explained_varoutDLManagedTensor*explained variances [n_components] (float32, device)
explained_var_ratiooutDLManagedTensor*explained variance ratios [n_components] (float32, device)
singular_valsoutDLManagedTensor*singular values [n_components] (float32, device)
muoutDLManagedTensor*column means [n_cols] (float32, device)
noise_varsoutDLManagedTensor*noise variance [1] (float32, device)
flip_signs_based_on_Uinboolwhether to determine signs by U (true) or V.T (false)

Returns

cuvsError_t

cuvsPcaTransform

Perform PCA transform operation.

1cuvsError_t cuvsPcaTransform(cuvsResources_t res,
2cuvsPcaParams_t params,
3DLManagedTensor* input,
4DLManagedTensor* components,
5DLManagedTensor* singular_vals,
6DLManagedTensor* mu,
7DLManagedTensor* trans_input);

Transforms the input data into the eigenspace using previously computed principal components.

Parameters

NameDirectionTypeDescription
resincuvsResources_tcuvsResources_t opaque C handle
paramsincuvsPcaParams_tPCA parameters
inputinoutDLManagedTensor*data to transform [n_rows x n_cols] (col-major, float32, device)
componentsinDLManagedTensor*principal components [n_components x n_cols] (col-major, float32, device)
singular_valsinDLManagedTensor*singular values [n_components] (float32, device)
muinDLManagedTensor*column means [n_cols] (float32, device)
trans_inputoutDLManagedTensor*transformed data [n_rows x n_components] (col-major, float32, device)

Returns

cuvsError_t

cuvsPcaInverseTransform

Perform PCA inverse transform operation.

1cuvsError_t cuvsPcaInverseTransform(cuvsResources_t res,
2cuvsPcaParams_t params,
3DLManagedTensor* trans_input,
4DLManagedTensor* components,
5DLManagedTensor* singular_vals,
6DLManagedTensor* mu,
7DLManagedTensor* output);

Transforms data from the eigenspace back to the original space.

Parameters

NameDirectionTypeDescription
resincuvsResources_tcuvsResources_t opaque C handle
paramsincuvsPcaParams_tPCA parameters
trans_inputinDLManagedTensor*transformed data [n_rows x n_components] (col-major, float32, device)
componentsinDLManagedTensor*principal components [n_components x n_cols] (col-major, float32, device)
singular_valsinDLManagedTensor*singular values [n_components] (float32, device)
muinDLManagedTensor*column means [n_cols] (float32, device)
outputoutDLManagedTensor*reconstructed data [n_rows x n_cols] (col-major, float32, device)

Returns

cuvsError_t