GSL矩阵元素向量及其欧几里德范数

#include <math.h>
#include <stdio.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_blas.h>

#pragma comment(lib, "libgsl_d.lib")
#pragma comment(lib, "libgslcblas_d.lib")

int
main (void)
{
  size_t i,j;

  gsl_matrix *m = gsl_matrix_alloc (10, 10);

  for (i = 0; i < 10; i++)
    for (j = 0; j < 10; j++)
      gsl_matrix_set (m, i, j, sin (i) + cos (j));

  for (j = 0; j < 10; j++)
    {
      gsl_vector_view column = gsl_matrix_column (m, j);
      double d;

      d = gsl_blas_dnrm2 (&column.vector);

      printf ("matrix column %d, norm = %g\n", j, d);
    }

  gsl_matrix_free (m);

  return 0;
}


GSL矩阵元素向量及其欧几里德范数_第1张图片

你可能感兴趣的:(GSL矩阵元素向量及其欧几里德范数)