Cpsc 440 Problem Set 1 Question 1

Cpsc 440 Problem Set 1 Question 1 - hw1p1.h #ifndef HW1P1_H...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
hw1p1.h 2/13/2008 # ifndef HW1P1_H # define HW1P1_H typedef struct regression_data * regression_data ; regression_data newRegressionData ( void ) ; void freeRegressionData ( regression_data reg_dat ) ; int read_data ( FILE * in , regression_data reg_dat ) ; int compute_coefficients ( regression_data reg_dat ) ; # endif 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2/13/2008 # include < stdio . h > # include < stdlib . h > # include "hw1p1.h" # define MIN_VECTOR_SIZE 10 // Define the structure to hold the regression data struct regression_data { int num_data ; int capacity ; float * x_data ; float * y_data ; float * f_data ; float a ; float b ; } ; regression_data newRegressionData ( void ) { regression_data reg_dat = malloc ( sizeof ( struct regression_data ) ) ; reg_dat - > num_data = 0 ; reg_dat - > capacity = MIN_VECTOR_SIZE ; reg_dat - > x_data = malloc ( reg_dat - > capacity * sizeof ( float ) ) ; reg_dat - > y_data = malloc ( reg_dat - > capacity * sizeof ( float ) ) ; reg_dat - > f_data = malloc ( reg_dat - > capacity * sizeof ( float ) ) ; return ( reg_dat ) ; } void freeRegressionData ( regression_data reg_dat ) { free ( reg_dat - > x_data ) ; free ( reg_dat - > y_data ) ; free ( reg_dat - > f_data ) ; free ( reg_dat ) ; } int main ( int argc , char * argv [] ) { // Extract the command-line arguments if ( argc ! = 3 ) { printf ( "\nERROR: %s expects 3 arguments, given %i\n"
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

Cpsc 440 Problem Set 1 Question 1 - hw1p1.h #ifndef HW1P1_H...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online