<<<<<<< HEAD
# How to build and run cuDSS examples (Linux)
```sh
ls # Assuming current directory contains example source files and CMakeLists.txt
export CMAKE_PREFIX_PATH=<path to cuDSS installation>/lib/cmake:$CMAKE_PREFIX_PATH
export LD_LIBRARY_PATH=${CUDA_PATH}/lib64:${LD_LIBRARY_PATH}
mkdir -p build
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC=1
cmake --build build --verbose

# Running all examples with ctest
ctest --test-dir build --output-on-failure --verbose

# (alternatively) Running individual static examples (available if BUILD_STATIC=1 option was used during th build)
cd build
./cudss_simple_static
./cudss_simple_complex_static
./cudss_get_set_static
./cudss_dense_matrix_helpers_static
./cudss_sparse_matrix_helpers_static
# other examples might follow ...
cd ..

# (alternatively) Running individual dynamically linked examples
# Note 1: you need to set the path to the cuDSS shared library. If you don't, you might see an error:
# error while loading shared libraries: libcudss.so.?: cannot open shared object file: No such file or directory
# Note 2: you need to set the CUDA_PATH to the path to the where cuda toolkit is installed
# If you don't, you might see an error:
# error while loading shared libraries: libcudart.so.12: cannot open shared object file: No such file or directory
CUDSS_LIB_PATH="<path to cuDSS installation>/lib" # path where libcudss.so is located
export LD_LIBRARY_PATH="$CUDSS_LIB_PATH:$CUDA_PATH/lib64:$LD_LIBRARY_PATH"
cd build
./cudss_simple
./cudss_simple_complex
./cudss_get_set
./cudss_dense_matrix_helpers
./cudss_sparse_matrix_helpers
# other examples might follow ...
cd ..

```

# How to build and run cuDSS examples (Windows)
```sh
:: set CMAKE_PATH to the CMake installation path
set CUDSS_INSTALL_DIR="<path to cuDSS installation>"

"%CMAKE_PATH%\bin\cmake.exe" -S. -Bbuild ^
    -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_CL_64=1 -A x64 ^
     -DBUILD_STATIC=1 -DCMAKE_BUILD_TYPE=Release ^
     -Dcudss_DIR=%CUDSS_INSTALL_DIR%/lib/cmake/cudss ^
     -DCUDSS_INSTALL_DIR=%CUDSS_INSTALL_DIR%

cmake --build build --verbose

cd build/Release

:: to run all tests (if it works?)
ctest --test-dir build --output-on-failure --verbose
:: or, alternatively, to run individual tests
.\cudss_simple
.\cudss_simple_complex
.\cudss_get_set

```

# Expected example output for `cudss_simple`
The expected output for this example is
```
---------------------------------------------------------
cuDSS example: solving a real linear 5x5 system
with a symmetric positive-definite matrix
---------------------------------------------------------
x[0] = 1.0000 expected 1.0000
x[1] = 2.0000 expected 2.0000
x[2] = 3.0000 expected 3.0000
x[3] = 4.0000 expected 4.0000
x[4] = 5.0000 expected 5.0000
Example PASSED
```

# Expected example output for `cudss_simple_complex`
The expected output for this example is
```
---------------------------------------------------------
cuDSS example: solving a complex linear 5x5 system
with a symmetric positive-definite matrix
---------------------------------------------------------
x[0] = (1.0000, 0.0000) expected (1.0000, 0)
x[1] = (2.0000, 0.0000) expected (2.0000, 0)
x[2] = (3.0000, 0.0000) expected (3.0000, 0)
x[3] = (4.0000, 0.0000) expected (4.0000, 0)
x[4] = (5.0000, 0.0000) expected (5.0000, 0)
Example PASSED
```

# Expected example output for `cudss_get_set`
The expected output for this example is
```
---------------------------------------------------------
cuDSS example: solving a real linear 5x5 system
with a symmetric positive-definite matrix
with extra settings and extra information retrieved
---------------------------------------------------------
perm[0] = 3
perm[1] = 1
perm[2] = 4
perm[3] = 0
perm[4] = 2
cuDSS info = 0
cuDSS npivots = 0
cuDSS inertia = 5 0
cuDSS requests 8 bytes for returning the #nnz in the factors
cuDSS #nnz in LU = 9
diag[0] = 1.000000
diag[1] = 3.000000
diag[2] = 2.000000
diag[3] = 4.000000
diag[4] = 2.916667
x[0] = 1.0000 expected 1.0000
x[1] = 2.0000 expected 2.0000
x[2] = 3.0000 expected 3.0000
x[3] = 4.0000 expected 4.0000
x[4] = 5.0000 expected 5.0000
Example PASSED
```

# Expected example output for `cudss_dense_matrix_helpers`
The expected output for this example is
```
---------------------------------------------------------
cuDSS example: creating, modifying and destroying cuDSS 
dense matrix objects
---------------------------------------------------------
CUDSS Version (Major,Minor,PatchLevel): 0.1.0
matrix B:
1.000e+00 6.000e+00 1.100e+01 1.600e+01 2.100e+01 
2.000e+00 7.000e+00 1.200e+01 1.700e+01 2.200e+01 
3.000e+00 8.000e+00 1.300e+01 1.800e+01 2.300e+01 
4.000e+00 9.000e+00 1.400e+01 1.900e+01 2.400e+01 
5.000e+00 1.000e+01 1.500e+01 2.000e+01 2.500e+01 
For validation later: first value of B is 1.000e+00, second 2.000e+00
Success: Check for matrix B from cudssMatrixGetDn passed
Success:After modifying in-place, first value of
matrix B equals -1.000e+00 (expected -1.000e+00)
matrix B (after modifying values in-place):
-1.000e+00 6.000e+00 1.100e+01 1.600e+01 2.100e+01 
2.000e+00 7.000e+00 1.200e+01 1.700e+01 2.200e+01 
3.000e+00 8.000e+00 1.300e+01 1.800e+01 2.300e+01 
4.000e+00 9.000e+00 1.400e+01 1.900e+01 2.400e+01 
5.000e+00 1.000e+01 1.500e+01 2.000e+01 2.500e+01 
Success: After modifying in-place, second value of
matrix B equals -4.000e+00 (expected -4.000e+00)
matrix B (after replacing the values array):
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
-4.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 
Success: Matrix B format returned as 0 (CSR)
Example PASSED
```

# Expected example output for `cudss_sparse_matrix_helpers`
The expected output for this example is
```
---------------------------------------------------------
cuDSS example: creating, modifying and destroying cuDSS 
sparse matrix objects
---------------------------------------------------------
CUDSS Version (Major,Minor,PatchLevel): 0.1.0
matrix A:
(0, 0.000e+00) (0, 2.000e+00) 
(1, 4.000e+00) (1, 6.000e+00) 
(2, 8.000e+00) (2, 1.000e+01) 
(3, 1.200e+01) (3, 1.400e+01) 
(4, 1.600e+01) 
For future validation: first value of A is 0.000e+00, second 2.000e+00
Success: Check for matrix A from cudssMatrixGetCsr passed
matrix A (after modifying values in place):
(0, -1.000e+00) (0, 2.000e+00) 
(1, 4.000e+00) (1, 6.000e+00) 
(2, 8.000e+00) (2, 1.000e+01) 
(3, 1.200e+01) (3, 1.400e+01) 
(4, 1.600e+01) 
Success: After modifying in-place, second value of
matrix A equals -4.000e+00 (expected -4.000e+00)
Note: Changing the matrix structure does not change the nnz returned by
cudssMatrixGetCsr. The original value =9 passed to cudssMatrixCreateCsr is
returned
matrix A (after changing the matrix structure):
(0, 0.000e+00) 
(1, 4.000e+00) 
(2, 8.000e+00) 
(3, 1.200e+01) 
(4, 1.600e+01) 
Success: Matrix A format returned as 1 (CSR)
Example PASSED
```
