liblapackwrap 0.1

blaswrap_real_double.h File Reference

#include <liblapackwrap/lapackwrap_types_real_double.h>
#include <liblapackwrap/lapackwrap_types_real_double.h>
Include dependency graph for blaswrap_real_double.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define LLW_CONST   const

Functions

int llw_real_double_gemm_a (char transa, char transb, int M, int N, int K, LLW_real_double_COMPLEX *alpha, LLW_CONST LLW_real_double_COMPLEX *A, int LDA, LLW_CONST LLW_real_double_COMPLEX *B, int LDB, LLW_real_double_COMPLEX **C)
int llw_real_double_gemm (char transa, char transb, int M, int N, int K, LLW_real_double_COMPLEX *alpha, LLW_CONST LLW_real_double_COMPLEX *A, int LDA, LLW_CONST LLW_real_double_COMPLEX *B, int LDB, LLW_real_double_COMPLEX *beta, LLW_real_double_COMPLEX *C, int LDC)

Define Documentation

#define LLW_CONST   const
Note:
Generic LLW data types are placed in this header file. defining LLW_real_double_FOO helps translate the generic core lapackwrap and blaswrap patterns to the final version. An alternative method would be translating each genericized core datatype into the specific data type. However, that would require a more complicated, multi-substitution method (e.g. with a perl script. This may come later, when I've gotten more experience using this lib.This is to ensure safety. If you don't care, you can save some cycles at the expense of "guaranteeing" safety for the data you're passing in read-only by commenting out this define. This will make all const arrays non-const and therefore not "guaranteed" to not be modified by the routines. This is effected, in addition to the const keyword, by copying each array into a secondary one via memcopy(). Turning this off saves that copy, which is the largst cost of this safety.

Definition at line 49 of file blaswrap_real_double.h.


Function Documentation

int llw_real_double_gemm ( char  transa,
char  transb,
int  M,
int  N,
int  K,
LLW_real_double_COMPLEX *  alpha,
LLW_CONST LLW_real_double_COMPLEX *  A,
int  LDA,
LLW_CONST LLW_real_double_COMPLEX *  B,
int  LDB,
LLW_real_double_COMPLEX *  beta,
LLW_real_double_COMPLEX *  C,
int  LDC 
)

Performs matrix-matrix multiplication.

Definition at line 43 of file blaswrap_real_double.c.

References GEMM, LAPACK_COMPLEX_TYPENAME, and LLW_real_double_COMPLEX.

Referenced by llw_real_double_gemm_a().

                                                                                                                                                                                                                                                                          {
  int ka=(transa=='N')?K:M;
  int kb=(transb=='N')?K:N;
  LLW_real_double_COMPLEX *a;
  LLW_real_double_COMPLEX *b;
  #ifdef LLW_CONST
  a = (LLW_real_double_COMPLEX*)malloc(LDA*ka*sizeof(LLW_real_double_COMPLEX));
  if(a == NULL) return 100;
  b = (LLW_real_double_COMPLEX*)malloc(LDA*kb*sizeof(LLW_real_double_COMPLEX));
  if(b == NULL) {
    free(a);
    return 100;
  }
  memcpy(a, A, LDA*ka*sizeof(LLW_real_double_COMPLEX));
  memcpy(b, B, LDB*kb*sizeof(LLW_real_double_COMPLEX));
  #else
  a = A;
  b = B;
  #endif
  #ifdef FCALL
  GEMM(&transa, &transb, &M, &N, &K, 
       #ifdef LLW_real_double_IS_COMPLEX
       (LAPACK_COMPLEX_TYPENAME*)alpha, 
       #else
       (LAPACK_COMPLEX_TYPENAME*)&alpha, 
       #endif
       (LAPACK_COMPLEX_TYPENAME*)a, &LDA, (LAPACK_COMPLEX_TYPENAME*)b, &LDB, 
       #ifdef LLW_real_double_IS_COMPLEX
       (LAPACK_COMPLEX_TYPENAME*)beta, 
       #else
       (LAPACK_COMPLEX_TYPENAME*)&beta, 
       #endif
       (LAPACK_COMPLEX_TYPENAME*)C, &LDC);
  #else
  GEMM(transa, transb, M, N, K, 
       #ifdef LLW_real_double_IS_COMPLEX
       (LAPACK_COMPLEX_TYPENAME*)alpha,
       #else
       *alpha,
       #endif
       (LAPACK_COMPLEX_TYPENAME*)a, LDA, (LAPACK_COMPLEX_TYPENAME*)b, LDB,
       #ifdef LLW_real_double_IS_COMPLEX
       (LAPACK_COMPLEX_TYPENAME*)beta,
       #else
       *beta,
       #endif
       (LAPACK_COMPLEX_TYPENAME*)C, LDC);
  #endif
  #ifdef LLW_CONST
  free(a);
  free(b);
  #endif
  return 0;
}

Here is the caller graph for this function:

int llw_real_double_gemm_a ( char  transa,
char  transb,
int  M,
int  N,
int  K,
LLW_real_double_COMPLEX *  alpha,
LLW_CONST LLW_real_double_COMPLEX *  A,
int  LDA,
LLW_CONST LLW_real_double_COMPLEX *  B,
int  LDB,
LLW_real_double_COMPLEX **  C 
)

frontend for llw_double_gemm but if you don't have a matrix C yet (clearly, if you're calling this routine, you want one.

frontend for llw_real_double_gemm but if you don't have a matrix C yet (clearly, if you're calling this routine, you want one.

Definition at line 29 of file blaswrap_real_double.c.

References llw_bw_real_double_set_from_double(), LLW_real_double_COMPLEX, and llw_real_double_gemm().

                                                                                                                                                                                                                                     {
  *C = (LLW_real_double_COMPLEX*)malloc(M*N*sizeof(LLW_real_double_COMPLEX));
  if((*C) == NULL) return 100;
  //fprintf(stderr, "N=%d M=%d N*M=%lu\n", M, N, (long unsigned)M*N);
  for(long unsigned i=0; i<M*N; i++) {
    //fprintf(stderr, "\tC=%p *C=%p (*C)[%lu]=%g\n", (void*)C, (void*)*C, i, (*C)[i]);
    llw_bw_real_double_set_from_double(&((*C)[i]), 0);
    //fprintf(stderr, "\t\t->(*C)[%lu]=%g\n", i, (*C)[i]);
  }
  LLW_real_double_COMPLEX zero;
  llw_bw_real_double_set_from_double(&zero, 0.0);
  return llw_real_double_gemm(transa, transb, M, N, K, alpha, A, LDA, B, LDB, &zero, *C, M);
}

Here is the call graph for this function:

 All Classes Files Functions Variables Defines