float sum( x ) vector x, what is vector x at this position telling?

Discussion in 'C' started by cimon, May 1, 2008.

  1. cimon

    cimon New Member

    Joined:
    Feb 9, 2007
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    I dont understand what is the effect of writing "vector v" with the function . As below

    Code:
    print_vector( v ) vector v;
    or

    Code:
    float sum( x ) vector x;
    For a function defination , I have only seen and used the normal procedure

    like
    return_type function_name(input parameters_type input_parameter)

    what is the purpose of this extra thing given after this normal syntax.
    And sometimes 2 things are given not just one " vector x, y"

    Code:
    float scalar_mult( x, y ) vector x, y;
    {
      int i;
      float s = 0.0;
      for ( i = 0 ; i < NUM ; i++ )  s += ( x.p[i] * y.p[i] );
      return s;
    }
    The actual code is below



    Code:
    #include <stdio.h>
    
    #define NUM 2         /* Number of input nodes */
    #define LIMIT 100     /* Maximum number of inputs the system can handle */
    #define SESSIONS 3000 /* Number of training sessions that we'll put the system through */
    
    typedef struct
    {
      float p[NUM];  //Input vector
    } vector;
    
    vector w, test[LIMIT];
    int hits[LIMIT], total;
    
    float bias = 0.5;
    
    
    print_vector( v ) vector v;
    {
      int i;
      for ( i = 0 ; i < NUM ; i++ ) printf("  %.4f ", v.p[i] );
      printf("\n");
    }
    
    
    float sum( x ) vector x;
    {
      int i;
      float s = 0.0;
      for ( i = 0 ; i < NUM ; i++ )  s += x.p[i];
      return s;
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice