Re: [PyMOL] drand48 in ply_c.h

2017-10-24 Thread mathog

On 23-Oct-2017 23:19, Thomas Holder wrote:

drand48() returns a float in [0,1) whereas rand() returns an integer
in [0,MAX_RAND].


The usual trick (this comes up frequently on mingw) is to replace 
drand48 with


(rand() / (RAND_MAX + 1.0))


Regards,

David Mathog
mat...@caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net


Re: [PyMOL] drand48 in ply_c.h

2017-10-23 Thread Thomas Holder
Hi David,

ply_c.h is part of the VMD molfile plugins.
Would the following patch fix it for you?

--- a/contrib/uiuc/plugins/molfile_plugin/src/ply_c.h
+++ b/contrib/uiuc/plugins/molfile_plugin/src/ply_c.h
@@ -3121,7 +3121,7 @@ void *get_new_props_ply(PlyFile *ply)
   }
 
   /* in case we need a random choice */
-#if defined(_MSC_VER)
+#ifndef _XOPEN_SOURCE
   random_pick = 0;
 #else
   random_pick = (int) floor (rules->nprops * drand48());

If this works for you, I will also suggest this change upstream to the VMD 
authors.

drand48() returns a float in [0,1) whereas rand() returns an integer in 
[0,MAX_RAND].

Cheers,
  Thomas

> On Oct 24, 2017, at 2:08 AM, mathog  wrote:
> 
> Trying to build in mingw (have done this a couple of times before).
> 
> Somebody introduced a file ply_c.h which references drand48() since the last 
> time this was built.  That function isn't found in mingw, at least not with 
> the compile line setup.py produced.  I can patch around this but wonder why 
> drand48() was used instead of rand() in the first place.
> 
> Thanks,
> 
> David Mathog
> mat...@caltech.edu
> Manager, Sequence Analysis Facility, Biology Division, Caltech

--
Thomas Holder
PyMOL Principal Developer
Schrödinger, Inc.


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

[PyMOL] drand48 in ply_c.h

2017-10-23 Thread mathog

Trying to build in mingw (have done this a couple of times before).

Somebody introduced a file ply_c.h which references drand48() since the 
last time this was built.  That function isn't found in mingw, at least 
not with the compile line setup.py produced.  I can patch around this 
but wonder why drand48() was used instead of rand() in the first place.


Thanks,

David Mathog
mat...@caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net