[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] Help

From: Joakim Hove
Subject: Re: [Help-gsl] Help
Date: Fri, 03 Sep 2004 11:44:40 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.2 (gnu/linux)

"Kaustubh Patil" <address@hidden> writes:

> Dear Sir/Madam, 
> I am using GSL for vector and matrix
> manipulations. I need a function that can give a (symmetrical)
> matrix formed by (v * v^T). 

This *quick and naive* hack works at least:

void vector_mul_transpose(const gsl_vector *v, gsl_matrix *m) {
  size_t i,j;

  if (v->size != m->size1 || m->size1 != m->size2) {
    fprintf(stderr,"Dimensions do not agree *aborting* \n");

  for (i=0; i < v->size; i++) {
    double vi = gsl_vector_get(v,i);
    for (j=i; j < v->size; j++)
      gsl_matrix_set(m,i,j,vi * gsl_vector_get(v,j));

     Filling in the lower part of the symmetric matrix.

  for (i=0; i < v->size; i++) 
    for (j=0; j < i; j++)

Joakim Hove
hove AT ift uib no
+47 (55 5)8 27 90

reply via email to

[Prev in Thread] Current Thread [Next in Thread]