问题
Can somebody help me figure out how to do this operation. I'm looking at the documentation, but its been so long since I've had to do any linear algebra type stuff I'm a little lost.
I have a 14x14 complex matrix called Y and a complex vector called I. I need to multiply them and set the result to a complex vector named IL.
So far I have figured out that I need to use:
gsl_blas_zgemv (CBLAS_TRANSPOSE_t TransA, const gsl_complex alpha, const
gsl_matrix_complex * A, const gsl_vector_complex * x, const
gsl_complex beta, gsl_vector_complex * y)
But I'm not sure what goes where. Not sure what goes where. Something like this? but what are the alpha and beta?
gsl_blas_zgemv(CblasNoTrans, ???, &Y, &I, ???, IL);
回答1:
Without seeing what you are actually doing, it looks like you haven't included the right headers. As the following works without errors for me:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_complex_math.h>
int
main(int argc, char **argv)
{
int size = 14;
gsl_matrix_complex *A = NULL;
gsl_vector_complex *x = NULL;
gsl_vector_complex *y = NULL;
A = gsl_matrix_complex_alloc(size, size);
x = gsl_vector_complex_alloc(size);
y = gsl_vector_complex_alloc(size);
gsl_matrix_complex_set_all(A, GSL_COMPLEX_ONE);
gsl_vector_complex_set_all(x, GSL_COMPLEX_ONE);
gsl_vector_complex_set_all(y, GSL_COMPLEX_ZERO);
gsl_blas_zgemv(CblasNoTrans, GSL_COMPLEX_ONE, A, x,
GSL_COMPLEX_ZERO, y);
return(EXIT_SUCCESS);
}
And compiling with
gcc -o test -I/opt/local/include/gsl -L/opt/local/lib -lgsl -lgslcblas test.c
(yes, I am on a Mac using MacPorts).
来源:https://stackoverflow.com/questions/16572823/gsl-complex-matrix-complex-vector