Fix(parm.h): allow size to be correctly calculated
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
unsigned char dim = 10;
|
||||
unsigned char dim = 17;
|
||||
|
||||
void cube(float *d_surface, int *coord, unsigned char *grid)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ void klein_parametrize( struct klein * klein, struct parm parm );
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
static inline int __factorial(int n)
|
||||
static inline uint64_t __factorial(uint64_t n)
|
||||
{
|
||||
if (n == 1)
|
||||
return 1;
|
||||
@@ -33,7 +33,7 @@ static inline int __factorial(int n)
|
||||
return n * __factorial(n - 1);
|
||||
}
|
||||
|
||||
static inline int __face(int n)
|
||||
static inline uint64_t __face(int n)
|
||||
{
|
||||
if (n == 2)
|
||||
return 1;
|
||||
@@ -43,8 +43,8 @@ static inline int __face(int n)
|
||||
|
||||
void klein_parametrize( struct klein * klein, struct parm parm)
|
||||
{
|
||||
unsigned int i, j, k, o, p, n;
|
||||
unsigned long size, q = 0;
|
||||
unsigned long i, j, o, p, n;
|
||||
uint64_t k, size, q = 0;
|
||||
int *face;
|
||||
|
||||
#ifdef TEST
|
||||
@@ -56,28 +56,30 @@ void klein_parametrize( struct klein * klein, struct parm parm)
|
||||
klein->dim = parm.n;
|
||||
klein->vertex_size = 0;
|
||||
{
|
||||
unsigned char test = 0;
|
||||
uint64_t test = 0;
|
||||
|
||||
for (o = 0; o < parm.m; o++)
|
||||
{
|
||||
for (p = 0; p < o; p++)
|
||||
{
|
||||
test += 1;
|
||||
klein->vertex_size += parm.grid[p] * parm.grid[o] * 6 * __face(parm.m);
|
||||
}
|
||||
}
|
||||
klein->vertex_size /= test;
|
||||
|
||||
|
||||
for (o = 0; o < parm.m; o++)
|
||||
for (p = 0; p < o; p++)
|
||||
klein->vertex_size += (uint64_t)parm.grid[p] * parm.grid[o] * 6 * __face(parm.m)/test;
|
||||
|
||||
}
|
||||
|
||||
size = (klein->dim) * (klein->vertex_size);
|
||||
klein->vertex = malloc(size * sizeof(float));
|
||||
size = klein->vertex_size*klein->dim;
|
||||
|
||||
klein->vertex = malloc(size * sizeof(float));
|
||||
face = malloc(parm.m * sizeof(int));
|
||||
|
||||
|
||||
for (o = 0; o < parm.m; o++)
|
||||
{
|
||||
for (p = 0; p < o; p++)
|
||||
{
|
||||
for (k = 0; k < (1 << (parm.m - 2)); k++)
|
||||
for (k = 0; k < ((uint64_t)1 << (parm.m - 2)); k++)
|
||||
{
|
||||
unsigned char skip = 0;
|
||||
for (n = 0; n < parm.m; n++)
|
||||
@@ -85,7 +87,7 @@ void klein_parametrize( struct klein * klein, struct parm parm)
|
||||
if (n == o || n == p)
|
||||
skip++;
|
||||
|
||||
face[n] = (k & (1 << (n - skip))) ? parm.grid[n] : 0;
|
||||
face[n] = (k & ((uint64_t)1 << (n - skip))) ? parm.grid[n] : 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < parm.grid[p]; i++)
|
||||
|
||||
Reference in New Issue
Block a user