/** @class SmoothRefrac.cpp @author Brian Magill @datecreated 11/01/2007 $Date:$ $Revision:$ @copyright (©) Copyright 2006 by GATS Inc. 11864 Canon Blvd., Suite 101, Newport News, VA 23606 All Rights Reserved. No part of this software or publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise without the prior written permission of GATS Inc. @brief: Smooths a signal with a box car average */ //---------------------------------------------------------------------- // #include #include #include #include "SmoothRefrac.h" using namespace std; void SmoothRefrac::operator()(valarray const &inSignal, valarray &outSignal) { unsigned long i; unsigned long j; double sum; assert(inSignal.size() > 2*smoothSize); outSignal.resize(inSignal.size()); outSignal = inSignal; for (i = smoothSize; i < inSignal.size() - smoothSize; i++) { sum = 0.0; for (j = i - smoothSize; j < i + smoothSize + 1; j++) { sum += inSignal[j]; } outSignal[i] = sum/(2.*smoothSize + 1); } } // for i = 0+nsm,nrec-1-nsm do begin // // sol_ext_av(i) = mean( sol_ext(i-nsm:i+nsm)) // sol_ext_sd(i) = stddev(sol_ext(i-nsm:i+nsm)) / sqrt(2*nsm) // // endfor