]> granicus.if.org Git - graphviz/commitdiff
randomkit added
authorJonathan Zheng <jonathanzheng@hotmail.co.uk>
Thu, 16 Jan 2020 14:49:43 +0000 (14:49 +0000)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Sun, 5 Apr 2020 20:18:29 +0000 (22:18 +0200)
lib/neatogen/randomkit.c
lib/neatogen/sgd.c

index ba143a34bee380dfa40f61aea20ac90935a02d09..21dcda2ec9f6f1678e6a9d71777689478dae8b81 100644 (file)
 #include <limits.h>
 #include <math.h>
 
-#ifdef _WIN32
-/*
- * Windows
- * XXX: we have to use this ugly defined(__GNUC__) because it is not easy to
- * detect the compiler used in distutils itself
- */
-#if (defined(__GNUC__) && defined(NPY_NEEDS_MINGW_TIME_WORKAROUND))
-
 /*
- * FIXME: ideally, we should set this to the real version of MSVCRT. We need
- * something higher than 0x601 to enable _ftime64 and co
- */
-#define __MSVCRT_VERSION__ 0x0700
-#include <time.h>
-#include <sys/timeb.h>
-
-/*
- * mingw msvcr lib import wrongly export _ftime, which does not exist in the
- * actual msvc runtime for version >= 8; we make it an alias to _ftime64, which
- * is available in those versions of the runtime
- */
-#define _FTIME(x) _ftime64((x))
-#else
-#include <time.h>
-#include <sys/timeb.h>
-#define _FTIME(x) _ftime((x))
-#endif
-
-#ifndef RK_NO_WINCRYPT
-/* Windows crypto */
-#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0400
-#endif
-#include <windows.h>
-#include <wincrypt.h>
-#endif
+#ifdef _WIN32
 
-#else
-/* Unix */
-#include <time.h>
-#include <sys/time.h>
-#include <unistd.h>
-#endif
+// * Windows
+// * XXX: we have to use this ugly defined(__GNUC__) because it is not easy to
+// * detect the compiler used in distutils itself
+// */
+//#if (defined(__GNUC__) && defined(NPY_NEEDS_MINGW_TIME_WORKAROUND))
+//
+///*
+// * FIXME: ideally, we should set this to the real version of MSVCRT. We need
+// * something higher than 0x601 to enable _ftime64 and co
+// */
+//#define __MSVCRT_VERSION__ 0x0700
+//#include <time.h>
+//#include <sys/timeb.h>
+//
+///*
+// * mingw msvcr lib import wrongly export _ftime, which does not exist in the
+// * actual msvc runtime for version >= 8; we make it an alias to _ftime64, which
+// * is available in those versions of the runtime
+// */
+//#define _FTIME(x) _ftime64((x))
+//#else
+//#include <time.h>
+//#include <sys/timeb.h>
+//#define _FTIME(x) _ftime((x))
+//#endif
+//
+//#ifndef RK_NO_WINCRYPT
+///* Windows crypto */
+//#ifndef _WIN32_WINNT
+//#define _WIN32_WINNT 0x0400
+//#endif
+//#include <windows.h>
+//#include <wincrypt.h>
+//#endif
+//
+//#else
+///* Unix */
+//#include <time.h>
+//#include <sys/time.h>
+//#include <unistd.h>
+//#endif
 
 #include "randomkit.h"
 
index f7a69be7d63dd2d09b5b0a1f13b0015e4d7e989d..21269b15f56ee0be8667900338eb8f6013509b8f 100644 (file)
@@ -24,13 +24,11 @@ float calculate_stress(term *terms, int n_terms) {
 }
 // it is much faster to shuffle term rather than pointers to term, even though the swap is more expensive
 static rk_state rstate;
-void fisheryates_shuffle(term *terms, int n_terms) {
+static void fisheryates_shuffle(term *terms, int n_terms) {
     int i;
     for (i=n_terms-1; i>=1; i--) {
         // srand48() is called in neatoinit.c, so no need to seed here
         //int j = (int)(drand48() * (i+1));
-        // TODO: better RNG because shuffling is eating up at least 50% of computation
-
         int j = rk_interval(i, &rstate);
 
         term temp = terms[i];