{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Cpsc 440 Problem Set 1 Question 2

# Cpsc 440 Problem Set 1 Question 2 - hw1p2.h#ifndef...

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

hw1p2.h 2/13/2008 # ifndef HW1P2_H # define HW1P2_H typedef struct test_vector * test_vector ; test_vector newTestVector ( void ) ; void freeTestVector ( test_vector test_vec ) ; int read_data ( FILE * in , test_vector test_vec ) ; void process_data ( test_vector test_vec ) ; float library_calculator ( float x ) ; float taylors_calculator ( float x ) ; # endif 1

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

View Full Document
hw1p2.c 2/13/2008 # include < math . h > # include < stdio . h > # include < stdlib . h > # include "hw1p2.h" # define MIN_VECTOR_SIZE 10 # define ERROR_MARGIN 1e-18 struct test_vector { int num_data ; int capacity ; // x_values = values at which to evaluate F(X) // l_values = library values for F(X) // t_values = Taylor-series values for F(X) float * x_values ; float * l_values ; float * t_values ; } ; test_vector newTestVector ( void ) { test_vector test_vec = malloc ( sizeof ( struct test_vector ) ) ; test_vec - > num_data = 0 ; test_vec - > capacity = MIN_VECTOR_SIZE ; test_vec - > x_values = malloc ( test_vec - > capacity * sizeof ( float ) ) ; test_vec - > l_values = malloc ( test_vec - > capacity * sizeof ( float ) ) ; test_vec - > t_values = malloc ( test_vec - > capacity * sizeof ( float ) ) ; return ( test_vec ) ; } void freeTestVector ( test_vector test_vec ) { free ( test_vec - > x_values ) ; free ( test_vec - > l_values ) ; free ( test_vec - > t_values ) ; free ( test_vec ) ; } int main ( int argc , char * argv [] ) 1
hw1p2.c

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}