Skip to content

Commit

Permalink
Merge pull request #79 from mhhennig/works
Browse files Browse the repository at this point in the history
more msvc fun
  • Loading branch information
mhhennig authored Jul 19, 2024
2 parents 0e26677 + 1d87487 commit 6ca1c8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
24 changes: 11 additions & 13 deletions herdingspikes/detection_lightning/Detection.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <algorithm>
#include <numeric>
#include <iostream>

#include <omp.h>

#include "Detection.h"
Expand All @@ -21,10 +21,8 @@ namespace HSDetection
: traceRaw(chunkLeftMargin, numChannels, chunkSize),
numChannels(numChannels), alignedChannels(alignChannel(numChannels)),
chunkSize(chunkSize), chunkLeftMargin(chunkLeftMargin), rescale(rescale),
// scale(new FloatRaw[alignedChannels * channelAlign]),
// offset(new FloatRaw[alignedChannels * channelAlign]),
scale((FloatRaw *)operator new[](sizeof(FloatRaw) * alignedChannels * channelAlign, (std::align_val_t(channelAlign * sizeof(IntVolt))))),
offset((FloatRaw *)operator new[](sizeof(FloatRaw) * alignedChannels * channelAlign, (std::align_val_t(channelAlign * sizeof(IntVolt))))),
scale((FloatRaw *) operator new[](sizeof(FloatRaw) * alignedChannels * channelAlign, (std::align_val_t(channelAlign * sizeof(IntVolt))))),
offset((FloatRaw *) operator new[](sizeof(FloatRaw) * alignedChannels * channelAlign, (std::align_val_t(channelAlign * sizeof(IntVolt))))),
trace(chunkSize + chunkLeftMargin, alignedChannels * channelAlign),
medianReference(medianReference), averageReference(averageReference),
commonRef(chunkSize + chunkLeftMargin, 1),
Expand Down Expand Up @@ -64,8 +62,8 @@ namespace HSDetection
delete[] spikeArea;
delete[] hasAHP;

operator delete[](scale, std::align_val_t(channelAlign * sizeof(IntVolt)));
operator delete[](offset, std::align_val_t(channelAlign * sizeof(IntVolt)));
operator delete[](scale, align_val_t(channelAlign * sizeof(IntVolt)));
operator delete[](offset, align_val_t(channelAlign * sizeof(IntVolt)));
}

void Detection::step(FloatRaw *traceBuffer, IntFrame chunkStart, IntFrame chunkLen)
Expand Down Expand Up @@ -197,7 +195,7 @@ namespace HSDetection
IntChannel thActualEnd = min(thAlignedEnd * channelAlign, numChannels);

// perform averaging over two frames
for (IntChannel t = chunkStart + chunkLen + 1; t > chunkStart; t--)
for (IntChannel t = chunkStart + chunkLen; t > chunkStart; t--)
{
for (IntChannel i = thAlignedStart * channelAlign; i < thActualEnd; i++)
{
Expand All @@ -208,13 +206,13 @@ namespace HSDetection
for (IntFrame t = chunkStart; t < chunkStart + chunkLen; t++)
{
estimation(runningBaseline[t], runningDeviation[t],
trace[t], commonRef[t],
runningBaseline[t - 1], runningDeviation[t - 1],
thAlignedStart, thAlignedEnd);
trace[t], commonRef[t],
runningBaseline[t - 1], runningDeviation[t - 1],
thAlignedStart, thAlignedEnd);

detection(trace[t], commonRef[t],
runningBaseline[t], runningDeviation[t],
thAlignedStart * channelAlign, thActualEnd, t);
runningBaseline[t], runningDeviation[t],
thAlignedStart * channelAlign, thActualEnd, t);
}
}

Expand Down
12 changes: 4 additions & 8 deletions herdingspikes/detection_lightning/RollingArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,14 @@ namespace HSDetection
// {
// arrayBuffer = new (memAlign) IntVolt[(IntCalc)(frameMask + 1) * numChannels];
// }
// ~RollingArray() { operator delete[](arrayBuffer, memAlign); }
// RollingArray(IntFrame rollingLen, IntChannel numChannels)
// : frameMask(getMask(rollingLen)), numChannels(numChannels)
// {
// arrayBuffer = new IntVolt[(IntCalc)(frameMask + 1) * numChannels];
// }
RollingArray(IntFrame rollingLen, IntChannel numChannels)
: frameMask(getMask(rollingLen)), numChannels(numChannels)
{
arrayBuffer = (IntVolt *)operator new[](sizeof(IntVolt) * (IntCalc)(frameMask + 1) * numChannels, memAlign);
// std::cout << "Rollingarray\n";
arrayBuffer = (IntVolt *) operator new[](sizeof(IntVolt) * (IntCalc)(frameMask + 1) * numChannels,memAlign);
}
~RollingArray() { delete[] arrayBuffer; }

~RollingArray() { operator delete[](arrayBuffer, memAlign); }

// copy constructor deleted to protect buffer
RollingArray(const RollingArray &) = delete;
Expand Down

0 comments on commit 6ca1c8d

Please sign in to comment.