Cpsc 440 Problem Set 1 Question 3

# Cpsc 440 Problem Set 1 Question 3 - hw1p3.h#ifndef...

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

hw1p3.h 2/13/2008 # ifndef HW1P3_H # define HW1P3_H typedef struct test_vector * test_vector ; typedef struct series_expansion * series_expansion ; test_vector newTestVector ( void ) ; void freeTestVector ( test_vector test_vec ) ; series_expansion newSeriesExpansion ( float x_value ) ; void freeSeriesExpansion ( series_expansion ser_exp ) ; int read_data ( FILE * in , test_vector test_vec ) ; void process_data ( test_vector test_vec ) ; # endif 1

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

View Full Document
hw1p3.c 2/13/2008 # include < math . h > # include < stdio . h > # include < stdlib . h > # include "hw1p3.h" # define MIN_VECTOR_SIZE 2 # define ERROR_MARGIN 1e-6 struct test_vector { int num_data ; int capacity ; series_expansion * ser_exp ; } ; 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 - > ser_exp = malloc ( test_vec - > capacity * sizeof ( series_expansion ) ) ; return ( test_vec ) ; } void freeTestVector ( test_vector test_vec ) { for ( int i = 0 ; i < test_vec - > num_data ; i + + ) { freeSeriesExpansion ( test_vec - > ser_exp [ i ] ) ; } free ( test_vec - > ser_exp ) ; free ( test_vec ) ; } struct series_expansion { int num_data ; int capacity ; float x_value ; float * series_values ; float * approx_e_vals ; 1
hw1p3.c 2/13/2008 float * exact_e_vals ; } ; series_expansion newSeriesExpansion ( float x_value ) { series_expansion ser_exp = malloc ( sizeof ( struct series_expansion ) ) ; ser_exp - > num_data = 0 ; ser_exp - > capacity = MIN_VECTOR_SIZE ; ser_exp - > x_value = x_value ; ser_exp - > series_values = malloc ( ser_exp - > capacity * sizeof ( float

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 ]}

### Page1 / 8

Cpsc 440 Problem Set 1 Question 3 - hw1p3.h#ifndef...

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

View Full Document
Ask a homework question - tutors are online