Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

utilities.C File Reference

#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <errno.h>
#include "utilities.h"
#include "config.h"

Go to the source code of this file.

Compounds

struct  vmd_timer

Functions

char * combine_arguments (int argc, const char **argv, int n)
 given an argc, argv pair, take all the arguments from the Nth one on and combine them into a single string with spaces separating words. This allocates space for the string, which must be freed by the user. More...

char * stringdup (const char *s)
 make a copy of a string using c++ new routine for memory alloc. More...

char * stringtoupper (char *s)
 convert the given string to upper case. More...

void stripslashes (char *str)
 strip trailing '/' characters from a string. More...

int strupcmp (const char *a, const char *b)
 do case-insensitive string comparisons. More...

int strupncmp (const char *a, const char *b, int n)
 do case-insensitive string comparisons. More...

void breakup_filename (const char *full, char **path, char **name)
 break a file name up into path + name, returning both in the specified character pointers. This creates storage for the new strings by allocating space for them. More...

char * str_tokenize (const char *newcmd, int *argc, char *argv[])
double time_of_day (void)
 get the time of day from the system clock, and return it (in seconds) (This is supposedly accurate to within about 1 millisecond. More...

void vmd_timer_start (vmd_timerhandle v)
 start a timer (clears timer). More...

void vmd_timer_stop (vmd_timerhandle v)
 stop a timer. More...

double vmd_timer_time (vmd_timerhandle v)
 report elapsed time in seconds. More...

vmd_timerhandle vmd_timer_create (void)
 create a timer (clears timer). More...

void vmd_timer_destroy (vmd_timerhandle v)
 create a timer (clears timer). More...

double vmd_timer_timenow (vmd_timerhandle v)
 report elapsed time in seconds. More...

msgtimermsg_timer_create (double updatetime)
 initialize periodic status message timer. More...

int msg_timer_timeout (msgtimer *mt)
 return true if it's time to print a status update message. More...

void msg_timer_destroy (msgtimer *mt)
 destroy message timer. More...

int vmd_check_stdin (void)
 check for input on stdin. More...

char * vmd_username (void)
 return the username of the currently logged-on user. More...

int vmd_getuid (void)
 return the uid of the currently logged-on user. More...

float * cross_prod (float *x1, const float *x2, const float *x3)
 compute the cross product, assumes that x1 memory is _different_ than both x2 and x3, and returns the pointer to x1. More...

float * vec_normalize (float *vect)
 normalizes the 3-vector to length one and returns the pointer note that this changes the vector. More...

float norm (const float *vect)
 find and return the norm of a 3-vector. More...

int tri_degenerate (const float *v0, const float *v1, const float *v2)
 determine if a triangle is degenerate or not. More...

float angle (const float *a, const float *b)
 compute the angle between two vectors a & b (0 to 180 deg). More...

float dihedral (const float *a1, const float *a2, const float *a3, const float *a4)
 Compute the dihedral angle for the given atoms, returning a value between -180 and 180. More...

float distance (const float *a, const float *b)
 compute the distance between two points a & b. More...

char * vmd_tempfile (const char *s)
 VMD temp file (portable) given a string, return a new one with the temp dir name prepended. The returned string must be deleted. More...

int vmd_delete_file (const char *path)
 VMD file deletion function (portable). More...

void vmd_sleep (int secs)
 VMD process sleep functions (portable). More...

void vmd_msleep (int msecs)
int vmd_system (const char *cmd)
 a buffer function to system() call to be replaced by a different implementation in console-free Win32 applications. More...

long vmd_random (void)
 portable random number generation, NOT thread-safe however XXX we should replace these with our own thread-safe random number generator implementation at some point. More...

void vmd_srandom (unsigned int seed)
 portable random number generation, NOT thread-safe however. More...

float vmd_random_gaussian ()
 Slow but accurate standard distribution random number generator (variance = 1). More...

long vmd_get_total_physmem_mb (void)
 return the number of MB of physical memory installed in the system. More...

long vmd_get_avail_physmem_mb (void)
 return the number of MB of physical memory "free" (no VM/swap counted...). More...

long vmd_get_avail_physmem_percent (void)
 return the percentage of physical memory available. More...


Function Documentation

float angle const float *    a,
const float *    b
 

compute the angle between two vectors a & b (0 to 180 deg).

Definition at line 493 of file utilities.C.

References cross_prod, and dot_prod.

void breakup_filename const char *    full,
char **    path,
char **    name
 

break a file name up into path + name, returning both in the specified character pointers. This creates storage for the new strings by allocating space for them.

Definition at line 156 of file utilities.C.

References NULL, and stringdup.

char* combine_arguments int    argc,
const char **    argv,
int    n
 

given an argc, argv pair, take all the arguments from the Nth one on and combine them into a single string with spaces separating words. This allocates space for the string, which must be freed by the user.

Definition at line 60 of file utilities.C.

References NULL.

float* cross_prod float *    x1,
const float *    x2,
const float *    x3
 

compute the cross product, assumes that x1 memory is _different_ than both x2 and x3, and returns the pointer to x1.

Definition at line 415 of file utilities.C.

float dihedral const float *    a1,
const float *    a2,
const float *    a3,
const float *    a4
 

Compute the dihedral angle for the given atoms, returning a value between -180 and 180.

Definition at line 505 of file utilities.C.

References cross_prod, dot_prod, and vec_sub.

float distance const float *    a,
const float *    b
 

compute the distance between two points a & b.

Definition at line 524 of file utilities.C.

References distance2.

msgtimer* msg_timer_create double    updatetime
 

initialize periodic status message timer.

Definition at line 317 of file utilities.C.

References NULL, msgtimer::timer, msgtimer::updatetime, vmd_timer_create, and vmd_timer_start.

void msg_timer_destroy msgtimer   mt
 

destroy message timer.

Definition at line 343 of file utilities.C.

References msgtimer::timer, and vmd_timer_destroy.

int msg_timer_timeout msgtimer   mt
 

return true if it's time to print a status update message.

Definition at line 329 of file utilities.C.

References msgtimer::timer, msgtimer::updatetime, vmd_timer_start, and vmd_timer_timenow.

float norm const float *    vect
 

find and return the norm of a 3-vector.

Definition at line 441 of file utilities.C.

char* str_tokenize const char *    newcmd,
int   argc,
char *    argv[]
 

Definition at line 188 of file utilities.C.

References NULL, and stringdup.

char* stringdup const char *    s
 

make a copy of a string using c++ new routine for memory alloc.

Definition at line 87 of file utilities.C.

References NULL.

char* stringtoupper char *    s
 

convert the given string to upper case.

Definition at line 101 of file utilities.C.

References NULL.

void stripslashes char *    str
 

strip trailing '/' characters from a string.

Definition at line 113 of file utilities.C.

int strupcmp const char *    a,
const char *    b
 

do case-insensitive string comparisons.

Definition at line 120 of file utilities.C.

References stringdup, and stringtoupper.

int strupncmp const char *    a,
const char *    b,
int    n
 

do case-insensitive string comparisons.

Definition at line 137 of file utilities.C.

double time_of_day void   
 

get the time of day from the system clock, and return it (in seconds) (This is supposedly accurate to within about 1 millisecond.

Definition at line 229 of file utilities.C.

Referenced by Animation::Animation, Animation::check_event, TclTextInterp::done_waiting, AtomColor::find, FPS::FPS, VMDTitle::prepare, FPS::prepare, VMDTitle::VMDTitle, and TclTextInterp::wait.

int tri_degenerate const float *    v0,
const float *    v1,
const float *    v2
 

determine if a triangle is degenerate or not.

Definition at line 447 of file utilities.C.

float* vec_normalize float *    vect
 

normalizes the 3-vector to length one and returns the pointer note that this changes the vector.

Definition at line 425 of file utilities.C.

int vmd_check_stdin void   
 

check for input on stdin.

Definition at line 348 of file utilities.C.

References NULL.

Referenced by TclTextInterp::doEvent, PythonTextInterp::doEvent, and main.

int vmd_delete_file const char *    path
 

VMD file deletion function (portable).

Definition at line 572 of file utilities.C.

long vmd_get_avail_physmem_mb void   
 

return the number of MB of physical memory "free" (no VM/swap counted...).

Definition at line 701 of file utilities.C.

References NULL.

Referenced by vmd_get_avail_physmem_percent, vmdinfo_tcl, and VMDinitialize.

long vmd_get_avail_physmem_percent void   
 

return the percentage of physical memory available.

Definition at line 769 of file utilities.C.

References vmd_get_avail_physmem_mb, and vmd_get_total_physmem_mb.

Referenced by VMDinitialize.

long vmd_get_total_physmem_mb void   
 

return the number of MB of physical memory installed in the system.

Definition at line 652 of file utilities.C.

References NULL.

Referenced by vmd_get_avail_physmem_percent.

int vmd_getuid void   
 

return the uid of the currently logged-on user.

Definition at line 404 of file utilities.C.

Referenced by Surf::compute, and MSMSInterface::compute_from_file.

void vmd_msleep int    msecs
 

Definition at line 591 of file utilities.C.

References NULL.

long vmd_random void   
 

portable random number generation, NOT thread-safe however XXX we should replace these with our own thread-safe random number generator implementation at some point.

Definition at line 610 of file utilities.C.

Referenced by Surf::compute, MSMSInterface::compute_from_file, VolMapCreateFastEnergy::compute_init, VolMapCreateSlowEnergy::compute_init, measure_sasa, trans_overlap, and vmd_random_gaussian.

float vmd_random_gaussian  
 

Slow but accurate standard distribution random number generator (variance = 1).

Definition at line 628 of file utilities.C.

References VMD_RAND_MAX, and vmd_random.

void vmd_sleep int    secs
 

VMD process sleep functions (portable).

Definition at line 583 of file utilities.C.

void vmd_srandom unsigned int    seed
 

portable random number generation, NOT thread-safe however.

Definition at line 618 of file utilities.C.

int vmd_system const char *    cmd
 

a buffer function to system() call to be replaced by a different implementation in console-free Win32 applications.

Definition at line 602 of file utilities.C.

char* vmd_tempfile const char *    s
 

VMD temp file (portable) given a string, return a new one with the temp dir name prepended. The returned string must be deleted.

Definition at line 528 of file utilities.C.

References NULL, stringdup, and stripslashes.

vmd_timerhandle vmd_timer_create void   
 

create a timer (clears timer).

Definition at line 300 of file utilities.C.

References vmd_timerhandle.

Referenced by VolMapCreate::compute_all, CoorPluginData::CoorPluginData, cudabusbw, cudaenergythread, cudamaddgflops, energythread, Symmetry::guess, msg_timer_create, stream_bench, vmd_cuda_vol_cpotential, vol_cpotential, and vol_cpotential_cpu.

void vmd_timer_destroy vmd_timerhandle    v
 

create a timer (clears timer).

Definition at line 307 of file utilities.C.

References vmd_timerhandle.

void vmd_timer_start vmd_timerhandle    v
 

start a timer (clears timer).

Definition at line 280 of file utilities.C.

References vmd_timer::tz, and vmd_timerhandle.

void vmd_timer_stop vmd_timerhandle    v
 

stop a timer.

Definition at line 285 of file utilities.C.

References vmd_timer::endtime, vmd_timer::tz, and vmd_timerhandle.

double vmd_timer_time vmd_timerhandle    v
 

report elapsed time in seconds.

Definition at line 290 of file utilities.C.

References vmd_timer::endtime, and vmd_timerhandle.

double vmd_timer_timenow vmd_timerhandle    v
 

report elapsed time in seconds.

Definition at line 311 of file utilities.C.

References vmd_timer_stop, vmd_timer_time, and vmd_timerhandle.

char* vmd_username void   
 

return the username of the currently logged-on user.

Definition at line 384 of file utilities.C.

References NULL, and stringdup.


Generated on Thu Jul 24 01:27:53 2008 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002