[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] Please, run the two programms.
From: |
Jo_Jo |
Subject: |
[Help-gsl] Please, run the two programms. |
Date: |
Thu, 18 Oct 2007 12:21:19 +0200 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20070728) |
Please, run the two programms.
In both programms vector v is not equal to vector Q*v, or Qtraqnsp * v.
With regards
Andrzej Buczynski
Moosburg, Germany
/*
int gsl_linalg_QR_Qvec (const gsl matrix * QR,
const gsl vector * tau,
gsl vector * v )
* This function applies the matrix Q encoded in the decomposition
* (QR,tau) to the vector v, storing the result Qv in v.
*
* Should be : v = Qv
*
*/
#include <stdio.h>
#include <gsl/gsl_linalg.h>
int main (void)
{
double a_data[] = {-0.18, 0.60, 0.57, 0.96,
0.41, 0.24, -0.99, 0.58,
-0.14, 0.30, 0.97, 0.66,
-0.51, 0.13, 0.19, 0.85,
0.33, 0.44, -0.66, 0.12 };
double b_data[] = { 1.0, 1.0, 1.0, 1.0 };
int M = 4, N = 4 , i ;
gsl_vector * tau = gsl_vector_alloc( GSL_MIN_INT ( M, N ) );
gsl_matrix_view m = gsl_matrix_view_array (a_data, M, N);
gsl_vector_set_zero ( tau ) ;
gsl_vector_view v = gsl_vector_view_array (b_data, N);
printf("-----vector v ---------\n");
for (i = 0; i < M; i++) {
printf ("%f ",gsl_vector_get (&v.vector, i ) );
printf("\n"); };
printf("now, we are calling the function gsl_linalg_QR_Qvec()--\n");
(void) gsl_linalg_QR_Qvec (&m.matrix, tau, &v.vector ) ;
printf(" and the-vector v should be Q *v , but is't ---------\n");
for (i = 0; i < M; i++) {
printf ("%f ",gsl_vector_get (&v.vector, i ) );
printf("\n"); };
printf(" the-vector tau is not chenged too---------\n");
for (i = 0; i < M; i++) {
printf ("%f ",gsl_vector_get (tau, i ) );
printf("\n"); };
gsl_vector_free(tau);
return 0;
} ;
/*
int gsl_linalg_QR_QTvec (const gsl_matrix * QR,
const gsl_vector * tau,
gsl_vector * v )
This function applies the matrix QT encoded in the decomposition
(QR,tau) to the vector v, storing the result QT*v in v.
The matrix multiplication is carried out directly
using the encoding of the Householder vectors without
needing to form the full matrix QT .
*/
#include <stdio.h>
#include <gsl/gsl_linalg.h>
int main (void)
{
double a_data[] = {-0.18, 0.60, 0.57, 0.96,
0.41, 0.24, -0.99, 0.58,
-0.14, 0.30, 0.97, 0.66,
-0.51, 0.13, 0.19, 0.85,
0.33, 0.44, -0.66, 0.12 };
double b_data[] = { 1.0, 1.0, 1.0, 1.0 };
int M = 4, N = 4 , i ;
gsl_vector * tau = gsl_vector_alloc( GSL_MIN_INT ( M, N ) );
gsl_matrix_view m = gsl_matrix_view_array (a_data, M, N);
// gsl_vector_set_zero ( tau ) ;
gsl_vector_view v = gsl_vector_view_array (b_data, N);
(void) gsl_linalg_QR_QTvec (&m.matrix, tau, &v.vector ) ;
printf("-----vector v = QTrans*v---------\n");
for (i = 0; i < M; i++) {
printf ("%f ",gsl_vector_get (&v.vector, i ) );
printf("\n"); };
printf("-----vector tau---------\n");
for (i = 0; i < M; i++) {
printf ("%f ",gsl_vector_get (tau, i ) );
printf("\n"); };
gsl_vector_free(tau);
return 0;
}