Pārlūkot izejas kodu

Silly mistakes

master
Pete Shadbolt pirms 10 gadiem
vecāks
revīzija
08f69afe28
1 mainītis faili ar 22 papildinājumiem un 0 dzēšanām
  1. +22
    -0
      src/permanents.h

+ 22
- 0
src/permanents.h Parādīt failu

@@ -0,0 +1,22 @@
// Ryser's algorithm
static npy_complex128 perm_ryser(PyArrayObject *submatrix) {
int n = (int) PyArray_DIM(submatrix, 0);
npy_complex128 rowsum, rowsumprod;
npy_complex128 perm = complex_zero;
int exp = 1 << n;
int i, y, z;
for (i=0; i<exp; ++i) {
rowsumprod = complex_one;
for (y=0; y<n; ++y) {
rowsum = complex_zero;
for (z=0; z<n; ++z) {
if ((i & (1 << z)) != 0) { complex_inc(&rowsum, SM(z, y)); }
}
complex_multiply(&rowsumprod, rowsum);
}
complex_inc(&perm, complex_float_prod(rowsumprod, bitparity(i)));
}
if (n%2 == 1) {perm=complex_float_prod(perm, -1);}
return perm;
}


Notiek ielāde…
Atcelt
Saglabāt