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_sgeqrf.c File Reference

Example using QR 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_sgeqrf.c:

Go to the source code of this file.

Macros

#define max(a, b)   ((a) > (b) ? (a) : (b))
#define min(a, b)   ((a) < (b) ? (a) : (b))

Functions

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

Variables

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

Detailed Description

Example using QR 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_sgeqrf.c.


Macro Definition Documentation

#define max (   a,
 
)    ((a) > (b) ? (a) : (b))

Definition at line 28 of file example_sgeqrf.c.

#define min (   a,
 
)    ((a) < (b) ? (a) : (b))

Definition at line 31 of file example_sgeqrf.c.


Function Documentation

int check_factorization ( int  M,
int  N,
float *  A1,
float *  A2,
int  LDA,
float *  Q 
)
int check_orthogonality ( int  M,
int  N,
int  LDQ,
float *  Q 
)
int main ( )

Definition at line 40 of file example_sgeqrf.c.

References check_factorization(), check_orthogonality(), IONE, ISEED, min, PLASMA_Alloc_Workspace_sgeqrf(), PLASMA_Finalize(), PLASMA_Init(), PLASMA_sgeqrf(), PLASMA_sorgqr(), Q, and T.

{
int cores = 2;
int M = 15;
int N = 10;
int LDA = 15;
int K = min(M, N);
int info;
int info_ortho, info_factorization;
int i,j;
int LDAxN = LDA*N;
float *A1 = (float *)malloc(LDA*N*sizeof(float));
float *A2 = (float *)malloc(LDA*N*sizeof(float));
float *Q = (float *)malloc(LDA*N*sizeof(float));
float *T;
/* Check if unable to allocate memory */
if ((!A1)||(!A2)||(!Q)){
printf("Out of Memory \n ");
return EXIT_SUCCESS;
}
/* Plasma Initialization */
PLASMA_Init(cores);
printf("-- PLASMA is initialized to run on %d cores. \n",cores);
/* Allocate T */
/* Initialize A1 and A2 */
LAPACKE_slarnv_work(IONE, ISEED, LDAxN, A1);
for (i = 0; i < M; i++)
for (j = 0; j < N; j++)
A2[LDA*j+i] = A1[LDA*j+i] ;
/* Factorization QR of the matrix A2 */
info = PLASMA_sgeqrf(M, N, A2, LDA, T);
/* Building the economy-size Q */
memset((void*)Q, 0, LDA*N*sizeof(float));
for (i = 0; i < K; i++)
Q[LDA*i+i] = 1.0;
PLASMA_sorgqr(M, N, K, A2, LDA, T, Q, LDA);
/* Check the orthogonality, factorization and the solution */
info_ortho = check_orthogonality(M, N, LDA, Q);
info_factorization = check_factorization(M, N, A1, A2, LDA, Q);
printf("--- info %d %d %d \n",info_factorization,info_ortho,info);
if ((info_ortho != 0)|(info_factorization != 0)|(info != 0))
printf("-- Error in SGEQRF example ! \n");
else
printf("-- Run of SGEQRF example successful ! \n");
free(A1); free(A2); free(Q); free(T);
return EXIT_SUCCESS;
}

Here is the call graph for this function:


Variable Documentation

int IONE = 1

Definition at line 37 of file example_sgeqrf.c.

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

Definition at line 38 of file example_sgeqrf.c.