Changeset 247 for cpp/frams/genetics


Ignore:
Timestamp:
11/07/14 17:51:01 (10 years ago)
Author:
Maciej Komosinski
Message:

Sources support both 32-bit and 64-bit, and more compilers

Location:
cpp/frams/genetics
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/f4/f4_general.cpp

    r197 r247  
    593593
    594594
    595 int f4_Cell::addlink(f4_Cell * nfrom, double nw, long nt)
     595int f4_Cell::addlink(f4_Cell * nfrom, double nw, int nt)
    596596{
    597597        if (nolink >= MAXINPUTS - 1) return -1; // full!
     
    675675
    676676
    677 f4_CellLink::f4_CellLink(f4_Cell * nfrom, double nw, long nt)
     677f4_CellLink::f4_CellLink(f4_Cell * nfrom, double nw, int nt)
    678678{
    679679        from = nfrom;
     
    12341234        int i, j, t, res;
    12351235        char tc1, tc2;
    1236         long relfrom;
     1236        int relfrom;
    12371237        double w;
    12381238        unsigned gpos, oldpos;
  • cpp/frams/genetics/f4/f4_general.h

    r197 r247  
    101101        int onestep();  // execute one simulation step (till a division)
    102102
    103         int   addlink(f4_Cell * nfrom, double nw, long nt);
     103        int   addlink(f4_Cell * nfrom, double nw, int nt);
    104104        void  adjustRec();
    105105
     
    129129        //f4_OrientMat OM;
    130130        double       mz;            // freedom in z
    131         long         p2_refno;   // number of last end part object, used in f0
    132         long         joint_refno;   // number of the joint object, used in f0
    133         long         neuro_refno;   // number of the neuro object, used in f0
    134 
    135         long         ctrl;  // neuron type
     131        int          p2_refno;   // number of last end part object, used in f0
     132        int          joint_refno;   // number of the joint object, used in f0
     133        int          neuro_refno;   // number of the neuro object, used in f0
     134
     135        int          ctrl;  // neuron type
    136136        double       state;
    137137        double       inertia;
     
    147147{
    148148public:
    149         f4_CellLink(f4_Cell * nfrom, double nw, long nt);
     149        f4_CellLink(f4_Cell * nfrom, double nw, int nt);
    150150        f4_Cell *    from;
    151151        // type: 0: input, 1 '*', 2 'G', 3 'T', 4 'S'
    152         long         t;
     152        int          t;
    153153        double       w;
    154154};
     
    205205        int       pos;        // original position in string
    206206        int       i1;           // internal int  parameter1
    207         long      l1;           // internal long parameter1
     207        int       l1;           // internal long parameter1
    208208        double    f1;           // internal double parameter1
    209209
  • cpp/frams/genetics/f4/oper_f4.cpp

    r199 r247  
    606606
    607607
    608 unsigned long Geno_f4::style(const char *g, int pos)
     608uint32_t Geno_f4::style(const char *g, int pos)
    609609{
    610610        char ch = g[pos];
     
    616616        if (!strchr(STYL4CAT_MODIFIC STYL4CAT_NEUMOD STYL4CAT_DIGIT STYL4CAT_REST, ch))
    617617                return GENSTYLE_CS(0, GENSTYLE_INVALID);
    618         unsigned long style = GENSTYLE_CS(0, GENSTYLE_STRIKEOUT); //default, should be changed below
     618        uint32_t style = GENSTYLE_CS(0, GENSTYLE_STRIKEOUT); //default, should be changed below
    619619        if (strchr("X ", ch))              style = GENSTYLE_CS(0, GENSTYLE_NONE);
    620620        if (strchr("N", ch))               style = GENSTYLE_RGBS(0, 200, 0, GENSTYLE_NONE);
  • cpp/frams/genetics/f4/oper_f4.h

    r197 r247  
    3838        int crossOver(char *&g1, char *&g2, float& chg1, float& chg2);
    3939        const char* getSimplest() { return "X"; }
    40         unsigned long style(const char *g, int pos);
     40        uint32_t style(const char *g, int pos);
    4141
    4242        // mutation probabilities
  • cpp/frams/genetics/f9/oper_f9.cpp

    r197 r247  
    109109
    110110///Applying some colors and font styles...
    111 unsigned long GenoOper_f9::style(const char *g, int pos)
     111uint32_t GenoOper_f9::style(const char *g, int pos)
    112112{
    113113        char ch = g[pos];
    114         unsigned long style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below
     114        uint32_t style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below
    115115        char *ptr = strchr((char*)turtle_commands_f9, ch);
    116116        if (ptr)
  • cpp/frams/genetics/f9/oper_f9.h

    r197 r247  
    1717        int mutate(char *&g,float& chg,int &method);
    1818        int crossOver(char *&g1,char *&g2,float& chg1,float& chg2);
    19         unsigned long style(const char *g, int pos);
     19        uint32_t style(const char *g, int pos);
    2020        const char* getSimplest() {return "R";}
    2121
  • cpp/frams/genetics/fF/oper_fF.cpp

    r197 r247  
    8989
    9090///Applying some colors and font styles...
    91 unsigned long GenoOper_fF::style(const char *g, int pos)
     91uint32_t GenoOper_fF::style(const char *g, int pos)
    9292{
    9393        char ch = g[pos];
    94         unsigned long style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below
     94        uint32_t style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below
    9595        if (strchr("-.e 0123456789", ch) != NULL)
    9696                style = GENSTYLE_CS(GENCOLOR_NUMBER, GENSTYLE_NONE);
  • cpp/frams/genetics/fF/oper_fF.h

    r197 r247  
    1717        int mutate(char *&g, float& chg, int &method);
    1818        int crossOver(char *&g1, char *&g2, float& chg1, float& chg2);
    19         unsigned long style(const char *g, int pos);
     19        uint32_t style(const char *g, int pos);
    2020        const char* getSimplest() { return "6, 1.05, 1.05, 1.05, 0, 0, 0"; }
    2121
  • cpp/frams/genetics/fT/oper_fTest.cpp

    r194 r247  
    115115
    116116///Applying some colors and font styles...
    117 unsigned long GenoOper_fTest::style(const char *g, int pos)
     117uint32_t GenoOper_fTest::style(const char *g, int pos)
    118118{
    119119        char ch = g[pos];
    120         unsigned long style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below
     120        uint32_t style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below
    121121        if (ch == 'A') style = GENSTYLE_RGBS(200, 0, 0, GENSTYLE_BOLD);
    122122        if (ch == 'T') style = GENSTYLE_RGBS(0, 200, 0, GENSTYLE_BOLD);
  • cpp/frams/genetics/fT/oper_fTest.h

    r194 r247  
    2929        int mutate(char *&geno, float& chg, int &method);
    3030        int crossOver(char *&g1, char *&g2, float& chg1, float& chg2);
    31         unsigned long style(const char *g, int pos);
     31        uint32_t style(const char *g, int pos);
    3232        const char* getSimplest() { return "GATCGATTACA"; }
    3333
  • cpp/frams/genetics/genman.cpp

    r240 r247  
    371371}
    372372
    373 unsigned long GenMan::Style(const char *g, int pos)
     373uint32_t GenMan::Style(const char *g, int pos)
    374374{
    375375        Geno G(g);
     
    380380}
    381381
    382 void GenMan::GetFullStyle(const char *g, unsigned long *styletab)
     382void GenMan::GetFullStyle(const char *g, uint32_t *styletab)
    383383{
    384384        Geno G(g);
     
    404404        int chars = 0, lines = 0;
    405405        bool shortened = false;
    406         unsigned long *styletab = new unsigned long[len];
     406        uint32_t *styletab = new uint32_t[len];
    407407        GetFullStyle(g, styletab);
    408408        SString html = "\n<div style=\"background:white;padding:0.2em;font-family:arial,helvetica,sans-serif;font-size:90%\">";
    409         unsigned long prevstyle, prevcolor, style = 0, color = 0;
     409        uint32_t prevstyle, prevcolor, style = 0, color = 0;
    410410        for (int i = 0; i<len; i++)
    411411        {
     
    501501}
    502502
    503 void GenMan::onDelGen(void *obj, long n)
     503void GenMan::onDelGen(void *obj, intptr_t n)
    504504{
    505505        //old code needs update:
  • cpp/frams/genetics/genman.h

    r197 r247  
    4646        Geno CrossOver(const Geno&, const Geno&); //returns xover genotype ("child") or empty if errors
    4747        float Similarity(const Geno&, const Geno&); //returns GENOPER_NOOPER or normalized similarity (1: identical, 0: different)
    48         unsigned long Style(const char* g, int pos); //returns Style (and validity) of a genotype char.
    49         void GetFullStyle(const char *g, unsigned long *styletab); //optimized. Fills styletab with styles for all genotype chars. sizeof(*styletab) must be at least strlen(g).
     48        uint32_t Style(const char* g, int pos); //returns Style (and validity) of a genotype char.
     49        void GetFullStyle(const char *g, uint32_t *styletab); //optimized. Fills styletab with styles for all genotype chars. sizeof(*styletab) must be at least strlen(g).
    5050        SString HTMLize(const char *g); //returns colored genotype in HTML.
    5151        SString HTMLizeShort(const char *g); //returns colored genotype (abbreviated if needed) in HTML.
     
    8383#undef STATRICKCLASS
    8484        void clearStats();
    85         static void onDelGen(void*, long);
     85        static void onDelGen(void*, intptr_t);
    8686};
    8787
  • cpp/frams/genetics/genoconv.h

    r197 r247  
    4646                out_format;     //< output format, eg. '0'
    4747        const char *info;       //< detailed info about converter, format or copyright
    48         long enabled;   //< don't touch this! (used by configuration module)
    49         long mapsupport; //< set to 1 if your converter supports genotype mapping
     48        paInt enabled;  //< don't touch this! (used by configuration module)
     49        paInt mapsupport; //< set to 1 if your converter supports genotype mapping
    5050
    5151        /// You have to reimplement this method.
  • cpp/frams/genetics/oper_fx.cpp

    r197 r247  
    5858        if (p->type(i)[0] == 'd')
    5959        {
    60                 long _mn = 0, _mx = 1, _def = 0;
     60                paInt _mn = 0, _mx = 1, _def = 0;
    6161                defined = p->getMinMax(i, _mn, _mx, _def);
    6262                if (defined == 1) _mx = _mn + 1;
     
    150150void GenoOperators::setIntFromDoubleWithProbabilisticDithering(ParamInterface &p, int index, double value) //TODO
    151151{
    152         p.setInt(index, value); //TODO value=2.5 will result in 2 but we want it to be 2 or 3 with equal probability. value=2.1 would be mostly 2, rarely 3. Careful with negative values (test it!)
     152        p.setInt(index, (paInt)value); //TODO value=2.5 will result in 2 but we want it to be 2 or 3 with equal probability. value=2.1 would be mostly 2, rarely 3. Careful with negative values (test it!)
    153153}
    154154
     
    187187NeuroClass* GenoOperators::parseNeuroClass(char*& s)
    188188{
    189         int len = strlen(s);
     189        int len = (int)strlen(s);
    190190        int Len = 0;
    191191        NeuroClass *I = NULL;
     
    193193        {
    194194                const char *n = Neuro::getClass(i)->name;
    195                 int l = strlen(n);
     195                int l = (int)strlen(n);
    196196                if (len >= l && l>Len && (strncmp(s, n, l) == 0)) { I = Neuro::getClass(i); Len = l; }
    197197        }
     
    210210int GenoOperators::neuroClassProp(char*& s, NeuroClass *nc, bool also_v1_N_props)
    211211{
    212         int len = strlen(s);
     212        int len = (int)strlen(s);
    213213        int Len = 0, I = -1;
    214214        if (nc)
     
    218218                {
    219219                        const char *n = p.id(i);
    220                         int l = strlen(n);
     220                        int l = (int)strlen(n);
    221221                        if (len >= l && l>Len && (strncmp(s, n, l) == 0)) { I = 100 + i; Len = l; }
    222222                        if (also_v1_N_props) //recognize old properties symbols /=!
     
    225225                                        if (strcmp(n, "in") == 0) n = "="; else
    226226                                                if (strcmp(n, "fo") == 0) n = "!";
    227                                 l = strlen(n);
     227                                l = (int)strlen(n);
    228228                                if (len >= l && l > Len && (strncmp(s, n, l) == 0)) { I = 100 + i; Len = l; }
    229229                        }
     
    235235        {
    236236                const char *n = p.id(i);
    237                 int l = strlen(n);
     237                int l = (int)strlen(n);
    238238                if (len >= l && l>Len && (strncmp(s, n, l) == 0)) { I = i; Len = l; }
    239239        }
  • cpp/frams/genetics/oper_fx.h

    r201 r247  
    3131/** \name other useful style/color macros */
    3232//@{
    33 #define GENRGB(r,g,b) ((unsigned long)(((unsigned char)(r)|((unsigned short)((unsigned char)(g))<<8))|(((unsigned long)(unsigned char)(b))<<16)))
    34 #define GENSTYLE_RGBS(r,g,b,s) ((unsigned long)((unsigned char)s)<<24 | GENRGB(r,g,b))
    35 #define GENSTYLE_CS(rgb,s) ((unsigned long)((unsigned char)s)<<24 | rgb)
     33#define GENRGB(r,g,b) ((uint32_t)(((uint8_t)(r)|((uint16_t)((uint8_t)(g))<<8))|(((uint32_t)(uint8_t)(b))<<16)))
     34#define GENSTYLE_RGBS(r,g,b,s) ((uint32_t)((uint8_t)s)<<24 | GENRGB(r,g,b))
     35#define GENSTYLE_CS(rgb,s) ((uint32_t)((uint8_t)s)<<24 | rgb)
    3636
    3737#define GENGETSTYLE(style) ((style)>>24)
     
    168168Assume white background.
    169169\sa GENSTYLE_* macros, like GENSTYLE_BOLD*/
    170    virtual unsigned long style(const char *geno,int pos) {return GENSTYLE_RGBS(0,0,0,GENSTYLE_NONE);}
     170   virtual uint32_t style(const char *geno,int pos) {return GENSTYLE_RGBS(0,0,0,GENSTYLE_NONE);}
    171171
    172172///currently not used (similarity of two genotypes)
Note: See TracChangeset for help on using the changeset viewer.