1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

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