diff --git a/ArrayOperations.c b/ArrayOperations.c index 434d10b..8132889 100644 --- a/ArrayOperations.c +++ b/ArrayOperations.c @@ -47,6 +47,14 @@ void* checkedCalloc(size_t vectorLength, size_t sizeOfType) { return allocated; } +void incrementVector(double* vector, int vectorLength) { + int i = 0; + for (i = 0; i < vectorLength; i++) + { + vector[i]++; /*C indexes from 0 not 1*/ + }/*for length of array */ +}/* incrementVector(double*,int) */ + void printDoubleVector(double *vector, int vectorLength) { int i; diff --git a/ArrayOperations.h b/ArrayOperations.h index 3700258..20f88da 100644 --- a/ArrayOperations.h +++ b/ArrayOperations.h @@ -7,7 +7,7 @@ ** ** Author: Adam Pocock ** Created 17/2/2010 -** Updated - 22/02/2014 - Added checking on calloc. +** Updated - 22/02/2014 - Added checking on calloc, and an increment array function. ** ** Copyright 2010,2014 Adam Pocock, The University Of Manchester ** www.cs.manchester.ac.uk @@ -41,6 +41,11 @@ extern "C" { *******************************************************************************/ void* checkedCalloc(size_t vectorLength, size_t sizeOfType); +/******************************************************************************* +** Increments each value in a double array +*******************************************************************************/ +void incrementVector(double* vector, int vectorLength); + /******************************************************************************* ** Simple print functions for debugging *******************************************************************************/