Cpsc 440 Problem Set 1 Question 1

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

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

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

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

View Full Document
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"
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 07/19/2008 for the course CPSC 440 taught by Professor Vladimirrokhlin during the Spring '08 term at Yale.

### Page1 / 6

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

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

View Full Document
Ask a homework question - tutors are online