Skip to content

Commit

Permalink
Fix indexing issues in core/strides cython units, Fix exception segfa…
Browse files Browse the repository at this point in the history
…ults
  • Loading branch information
ChristophWWagner committed Apr 19, 2023
1 parent ccd6a35 commit c97a21e
Show file tree
Hide file tree
Showing 7 changed files with 222 additions and 193 deletions.
7 changes: 4 additions & 3 deletions fastmat/Fourier.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,10 @@ cdef class Fourier(Matrix):
arrRes = np.fft.fft(arrX, axis=0)
else:
arrRes = _arrEmpty(
2, self._numL, M,
typeInfo[promoteFusedTypes(
self.fusedType, getFusedType(arrX))].numpyType)
2, self._numL, M, typeInfo[
promoteFusedTypes(self.fusedType, getFusedType(arrX))
].numpyType
)

strideInit(&strResPadding, arrRes, 0)
strideSliceElements(&strResPadding, self.order, -1, 1)
Expand Down
16 changes: 10 additions & 6 deletions fastmat/Hadamard.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,16 @@ cdef class Hadamard(Matrix):
# element 5 |C | D | B
# element 6 |D |C | C
# element 7 |D |D | D
strideSubgridVector(&strA, mm, 0,
1, butterflyDistance,
2 * butterflyDistance, butterflyCount)
strideSubgridVector(&strB, mm, butterflyDistance,
1, butterflyDistance,
2 * butterflyDistance, butterflyCount)
strideSubgrid(
&strA, mm, 0,
2 * butterflyDistance, 1,
butterflyCount, butterflyDistance
)
strideSubgrid(
&strB, mm, butterflyDistance,
2 * butterflyDistance, 1,
butterflyCount, butterflyDistance
)

if typeX == TYPE_FLOAT32:
_hadamardCore[np.float32_t](&strA, &strB, 0)
Expand Down
15 changes: 7 additions & 8 deletions fastmat/core/strides.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,19 @@ ctypedef struct STRIDE_s:
ftype dtype

################################################## Basic stride operations
cdef void strideInit(STRIDE_s *, np.ndarray, np.uint8_t)
cdef void strideInit(STRIDE_s *, np.ndarray, np.uint8_t) except *
cdef void strideCopy(STRIDE_s *, STRIDE_s *)
cdef void strideSliceVectors(STRIDE_s *, intsize, intsize, intsize)
cdef void strideSliceElements(STRIDE_s *, intsize, intsize, intsize)
cdef void strideSubgridVector(STRIDE_s *,
intsize, intsize,
intsize, intsize, intsize, intsize)
cdef void strideSubgrid(STRIDE_s *,
intsize, intsize, intsize, intsize, intsize, intsize)
cdef void strideFlipVectors(STRIDE_s *)
cdef void strideFlipElements(STRIDE_s *)

cdef stridePrint(STRIDE_s *, text=?)
cdef void stridePrint(STRIDE_s *, text=?) except *


################################################## Operations with strides
cdef opCopyVector(STRIDE_s *, intsize, STRIDE_s *, intsize)
cdef opZeroVector(STRIDE_s *, intsize)
cdef opZeroVectors(STRIDE_s *)
cdef void opCopyVector(STRIDE_s *, intsize, STRIDE_s *, intsize) except *
cdef void opZeroVector(STRIDE_s *, intsize)
cdef void opZeroVectors(STRIDE_s *)

0 comments on commit c97a21e

Please sign in to comment.