PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
example_spotrf.c File Reference

Example of Cholesky factorization. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <plasma.h>
#include <cblas.h>
#include <lapacke.h>
#include <core_blas.h>
Include dependency graph for example_spotrf.c:

Go to the source code of this file.

Functions

int check_factorization (int, float *, float *, int, int)
int main ()

Variables

int IONE = 1
int ISEED [4] = {0,0,0,1}

Detailed Description

Example of Cholesky factorization.

PLASMA testing routines PLASMA is a software package provided by Univ. of Tennessee, Univ. of California Berkeley and Univ. of Colorado Denver

Version:
2.4.5
Author:
Bilel Hadri
Date:
2010-11-15 s Tue Nov 22 14:35:53 2011

Definition in file example_spotrf.c.


Function Documentation

int check_factorization ( int  N,
float *  A1,
float *  A2,
int  LDA,
int  uplo 
)

Definition at line 80 of file example_spotrf.c.

References cblas_strmm(), CblasColMajor, CblasLeft, CblasLower, CblasNonUnit, CblasRight, CblasTrans, CblasUpper, lapack_const, PlasmaInfNorm, and PlasmaUpper.

{
float Anorm, Rnorm;
float alpha;
int info_factorization;
int i,j;
float eps;
eps = LAPACKE_slamch_work('e');
float *Residual = (float *)malloc(N*N*sizeof(float));
float *L1 = (float *)malloc(N*N*sizeof(float));
float *L2 = (float *)malloc(N*N*sizeof(float));
float *work = (float *)malloc(N*sizeof(float));
memset((void*)L1, 0, N*N*sizeof(float));
memset((void*)L2, 0, N*N*sizeof(float));
alpha= 1.0;
LAPACKE_slacpy_work(LAPACK_COL_MAJOR,' ', N, N, A1, LDA, Residual, N);
/* Dealing with L'L or U'U */
if (uplo == PlasmaUpper){
LAPACKE_slacpy_work(LAPACK_COL_MAJOR,'u', N, N, A2, LDA, L1, N);
LAPACKE_slacpy_work(LAPACK_COL_MAJOR,'u', N, N, A2, LDA, L2, N);
}
else{
LAPACKE_slacpy_work(LAPACK_COL_MAJOR,'l', N, N, A2, LDA, L1, N);
LAPACKE_slacpy_work(LAPACK_COL_MAJOR,'l', N, N, A2, LDA, L2, N);
}
/* Compute the Residual || A -L'L|| */
for (i = 0; i < N; i++)
for (j = 0; j < N; j++)
Residual[j*N+i] = L2[j*N+i] - Residual[j*N+i];
Rnorm = LAPACKE_slange_work(LAPACK_COL_MAJOR, lapack_const(PlasmaInfNorm), N, N, Residual, N, work);
Anorm = LAPACKE_slange_work(LAPACK_COL_MAJOR, lapack_const(PlasmaInfNorm), N, N, A1, LDA, work);
printf("============\n");
printf("Checking the Cholesky Factorization \n");
printf("-- ||L'L-A||_oo/(||A||_oo.N.eps) = %e \n",Rnorm/(Anorm*N*eps));
if ( isnan(Rnorm/(Anorm*N*eps)) || (Rnorm/(Anorm*N*eps) > 10.0) ){
printf("-- Factorization is suspicious ! \n");
info_factorization = 1;
}
else{
printf("-- Factorization is CORRECT ! \n");
info_factorization = 0;
}
free(Residual); free(L1); free(L2); free(work);
return info_factorization;
}

Here is the call graph for this function:

int main ( )

Definition at line 32 of file example_spotrf.c.

References check_factorization(), PLASMA_Finalize(), PLASMA_Init(), PLASMA_slacpy(), PLASMA_splgsy(), PLASMA_spotrf(), PlasmaUpper, and PlasmaUpperLower.

{
int cores = 2;
int N = 10 ;
int LDA = 10 ;
int info_factorization;
float *A1 = (float *)malloc(LDA*N*sizeof(float));
float *A2 = (float *)malloc(LDA*N*sizeof(float));
/* Check if unable to allocate memory */
if ((!A1)||(!A2)){
printf("Out of Memory \n ");
return EXIT_SUCCESS;
}
/* Plasma Initialize */
PLASMA_Init(cores);
printf("-- PLASMA is initialized to run on %d cores. \n",cores);
/* Initialize A1 and A2 for Symmetric Positive Matrix */
PLASMA_splgsy( (float)N, N, A1, LDA, 51 );
PLASMA_slacpy( PlasmaUpperLower, N, N, A1, LDA, A2, LDA );
/* Plasma routines */
PLASMA_spotrf(PlasmaUpper, N, A2, LDA);
/* Check the factorization */
info_factorization = check_factorization( N, A1, A2, LDA, PlasmaUpper);
if ( info_factorization != 0 )
printf("-- Error in SPOTRF example ! \n");
else
printf("-- Run of SPOTRF example successful ! \n");
free(A1); free(A2);
return EXIT_SUCCESS;
}

Here is the call graph for this function:


Variable Documentation

int IONE = 1

Definition at line 29 of file example_spotrf.c.

int ISEED[4] = {0,0,0,1}

Definition at line 30 of file example_spotrf.c.