help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] basic question about using gsl matrix types


From: Martin Jansche
Subject: Re: [Help-gsl] basic question about using gsl matrix types
Date: Thu, 1 Jan 2009 23:17:30 -0500

This is a C issue, independent of GSL.  Look at the first warning:
implicit declaration of function.  So either provide a prototype for
my_print_matrix, or move the entire declaration of my_print_matrix
before main.
-- mj

On Thu, Jan 1, 2009 at 22:11, Alan Mead <address@hidden> wrote:
> I'm new to GSL and fairly new to C and I have a beginner's question. I'm
> using GSL 1.10 on Fedora 9 with gcc 4.3.0.
>
> How do I change line 14 and/or 19 (marked below) to avoid these warnings
> about "conflicting types for 'my_print_matrix'"? The GSL docs (section
> 8.4.5) say " pointer ... const gsl_matrix * can be obtained by taking the
> address of the matrix component with the & operator." So, shouldn't I write
> "&a.matrix" on line 14?
>
> Please let me know if this is not an appropriate question for this list.
>
> -Alan
>
> address@hidden examples]$ gcc -Wall -Wextra -lgsl -lgslcblas simple.c -o 
> simple
> simple.c: In function 'main':
> simple.c:14: warning: implicit declaration of function 'my_print_matrix'
> simple.c: At top level:
> simple.c:19: warning: conflicting types for 'my_print_matrix'
> simple.c:14: warning: previous implicit declaration of 'my_print_matrix' was
> here
> address@hidden examples]$ ./simple
> Matrix A (6 x 3):
> 0.180 0.600 0.570
> 0.410 0.240 0.990
> 0.110 0.140 0.190
> 0.210 0.240 0.290
> 0.140 0.300 0.970
> 0.510 0.130 0.190
> address@hidden examples]$ cat simple.c
> #include <stdio.h>
> #include <gsl/gsl_linalg.h>
>
> int
> main (void)
> {
> double a_data[] = { 0.18, 0.60, 0.57,
> 0.41, 0.24, 0.99,
> 0.11, 0.14, 0.19,
> 0.21, 0.24, 0.29,
> 0.14, 0.30, 0.97,
> 0.51, 0.13, 0.19 };
> gsl_matrix_view a = gsl_matrix_view_array (a_data, 6, 3);
> my_print_matrix ( &a.matrix, "A", 6, 3); // line 14
> return 0;
> }
>
> void
> my_print_matrix( const gsl_matrix * m, char * name, int rows, int cols ) {
> // line 19
> int r,c;
>
> printf ("Matrix %s (%d x %d):\n", name, rows, cols );
> for( r = 0; r < rows; r++ ) {
> for( c = 0; c < cols; c++ ) {
> printf ("%8.3f", gsl_matrix_get (m, r, c));
> }
> printf ("\n");
> }
> }
>
> --
> Alan D. Mead, Ph.D. Assistant Professor, Institute of Psychology
> Scientific Adviser, Center for Research and Service
> Illinois Institute of Technology
> 3101 South Dearborn, 2nd floor
> Chicago IL 60616
>
>
>
>
>
> _______________________________________________
> Help-gsl mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-gsl
>




reply via email to

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