Changeset 133ae7 in git


Ignore:
Timestamp:
Sep 27, 2019, 5:40:04 PM (5 years ago)
Author:
Murray Heymann <heymann.murray@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
Children:
2e7edcbc061197869575d17124cb197dafd4ef45
Parents:
50fb15949d9519d601bdaaa9bf8bbb49921c95a7
git-author:
Murray Heymann <heymann.murray@gmail.com>2019-09-27 17:40:04+02:00
git-committer:
Murray Heymann <heymann.murray@gmail.com>2019-09-27 17:40:07+02:00
Message:
Convert machine learning to dynamic module
Files:
3 deleted
9 edited
20 moved

Legend:

Unmodified
Added
Removed
  • .gitignore

    r50fb159 r133ae7  
    123123.coverage
    124124*.pyc
    125 machine_learning/machine_learning-config.h
  • Makefile.am

    r50fb159 r133ae7  
    22
    33SUBDIRS = resources omalloc factory \
    4 libpolys machine_learning gfanlib IntegerProgramming \
     4libpolys gfanlib IntegerProgramming \
    55kernel Singular \
    66dox emacs redhat desktop
  • Singular/Makefile.am

    r50fb159 r133ae7  
    137137
    138138libSingular_la_LDFLAGS    =$(SINGULAR_LDFLAGS) ${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} -release ${PACKAGE_VERSION} $(CCLUSTER_LIBS) ${PTHREAD_LDFLAGS} -lpython2.7
    139 libSingular_la_LIBADD     =${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} ${BUILTIN_FLAGS} ${top_builddir}/kernel/libkernel.la ${PTHREAD_LIBS} ${top_builddir}/machine_learning/libmlearn.la
     139libSingular_la_LIBADD     =${USEPPROCSDYNAMICLDFLAGS} ${USEPPROCSDYNAMICLD} ${BUILTIN_FLAGS} ${top_builddir}/kernel/libkernel.la ${PTHREAD_LIBS}
    140140libSingular_includedir = ${includedir}/singular/Singular
    141141nobase_libSingular_include_HEADERS = $(SingularHEADERS)
  • Singular/dyn_modules/machinelearning/Makefile.am

    r50fb159 r133ae7  
    1616
    1717##########################################################################
    18 AM_CPPFLAGS = -I${top_srcdir} -I${top_builddir} -I${top_srcdir}/kernel -I${top_builddir}/kernel -I${top_srcdir}/libpolys -I${top_builddir}/libpolys $(FACTORY_INCLUDES)  $(GMP_CPPFLAGS) $(NTL_CPPFLAGS) $(FLINT_CFLAGS)
     18AM_CPPFLAGS = -I${top_srcdir} -I${top_builddir} -I${top_srcdir}/kernel \
     19              -I${top_builddir}/kernel -I${top_srcdir}/libpolys \
     20              -I${top_builddir}/libpolys $(FACTORY_INCLUDES)  $(GMP_CPPFLAGS) \
     21              $(NTL_CPPFLAGS) $(FLINT_CFLAGS) -DDATA_PATH=\"$(datadir)\" \
     22              -DBIN_PATH=\"$(bindir)\" -I/usr/include/python2.7
    1923
    20 machinelearning_la_SOURCES = machinelearning.cc
     24machinelearning_la_SOURCES = machinelearning.cc mlpredict.c
    2125
    2226### if HAVE_PYTHON???
     
    3135endif
    3236endif
     37
     38TESTS                   = test_bufsize test_init_ml
     39check_PROGRAMS          = test_bufsize test_init_ml
     40
     41#test_bufsize_LDFLAGS   = -lpython3.6m
     42test_bufsize_LDFLAGS    = -lpython2.7
     43test_bufsize_SOURCES    = tests/test_bufsize.c mlpredict.c
     44test_bufsize_CFLAGS     = -Wall -Wextra -I/usr/include/python2.7
     45
     46#test_init_ml_LDFLAGS   = -lpython3.6m
     47test_init_ml_LDFLAGS    = -lpython2.7
     48test_init_ml_SOURCES    = tests/test_init_ml.c mlpredict.c
     49test_init_ml_CFLAGS     = -Wall -Wextra -I/usr/include/python2.7
     50
     51
     52nobase_dist_data_DATA   = \
     53        ml_python/__init__.py \
     54        ml_python/predictor_runner.py \
     55        ml_python/common/__init__.py \
     56        ml_python/common/constants.py \
     57        ml_python/common/keyword_vector.py \
     58        ml_python/common/lookuptable.py \
     59        ml_python/model/__init__.py \
     60        ml_python/model/predictor.py \
     61        ml_singular/extract.lib
  • Singular/dyn_modules/machinelearning/machinelearning.cc

    r50fb159 r133ae7  
    1 #include "kernel/mod2.h" // general settings/macros
    2 #include "Singular/ipid.h" // for SModulFunctions, leftv
    3 BOOLEAN hello(leftv result, leftv arg)
     1#include <readline/history.h>
     2
     3#include "kernel/mod2.h"
     4#include "Singular/ipid.h"
     5
     6#include "mlpredict.h"
     7
     8BOOLEAN predictHelp(leftv result, leftv arg)
    49{
    5         result->rtyp=NONE; // set the result type
    6         PrintS("hello world\n");
    7         return FALSE; // return FALSE: no error
     10        char *buffer[5];
     11        int lengths[5];
     12        char filename[15] = "~/.history";
     13        int i;
     14        lists L = (lists)omAllocBin(slists_bin);
     15
     16        buffer[0] = NULL;
     17        buffer[1] = NULL;
     18        buffer[2] = NULL;
     19        buffer[3] = NULL;
     20        buffer[4] = NULL;
     21
     22        if (write_history(NULL)) {
     23                printf("Failed to write history\n");
     24                return TRUE;
     25        }
     26
     27        if (!ml_initialise()) {
     28                Print("Initialise of ml failed.");
     29                PrintLn();
     30                /* Notify singular that an error occured */
     31                return TRUE;
     32        }
     33
     34        ml_make_prediction(filename, buffer, lengths, _omStrDup);
     35
     36        L->Init(5);
     37
     38        for (i = 0; i < 5; i++) {
     39                //printf("prediction %d: %s\n", i, buffer[i]);
     40                L->m[i].rtyp = STRING_CMD;
     41                L->m[i].data = buffer[i];
     42        }
     43
     44        // pass the resultant list to the res datastructure
     45        result->rtyp=LIST_CMD;
     46        result->data=(void *)L;
     47
     48        ml_finalise();
     49        return FALSE;
     50
     51        //result->rtyp=NONE; // set the result type
    852}
     53
    954extern "C" int mod_init(SModulFunctions* psModulFunctions)
    1055{
    1156        // this is the initialization routine of the module
    12         // adding the routine hello:
     57        // adding the routine predictHelp:
    1358        psModulFunctions->iiAddCproc(
    1459                        (currPack->libname? currPack->libname: ""),
    15                         // the library name,
    16                         // rely on the loader to set it in currPack->libname
    17                         "hello",// the name for the singular interpreter
     60                        "predictHelp",// for the singular interpreter
    1861                        FALSE, // should enter the global name space
    19                         hello); // the C/C++ routine
     62                        predictHelp); // the C/C++ routine
    2063        return 1;
    2164}
  • Singular/iparith.cc

    r50fb159 r133ae7  
    5050#include "kernel/polys.h"
    5151#include "kernel/ideals.h"
    52 
    53 #include "machine_learning/mlpredict.h"
    5452
    5553#include "Singular/mod_lib.h"
     
    77987796  return setOption(res,v);
    77997797}
    7800 
    7801 
    7802 static BOOLEAN jjPREDHELP0(leftv res, leftv)
    7803 {
    7804         char *buffer[5];
    7805         int lengths[5];
    7806         char filename[15] = "~/.history";
    7807         int i;
    7808         lists L = (lists)omAllocBin(slists_bin);
    7809 
    7810         buffer[0] = NULL;
    7811         buffer[1] = NULL;
    7812         buffer[2] = NULL;
    7813         buffer[3] = NULL;
    7814         buffer[4] = NULL;
    7815 
    7816         if(write_history(NULL)) {
    7817                 printf("Failed to write history\n");
    7818                 return TRUE;
    7819         }
    7820 
    7821         if (!ml_initialise()) {
    7822                 Print("Initialise of ml failed.");
    7823                 PrintLn();
    7824                 /* Notify singular that an error occured */
    7825                 return TRUE;
    7826         }
    7827 
    7828         ml_make_prediction(filename, buffer, lengths, _omStrDup);
    7829 
    7830         L->Init(5);
    7831 
    7832         for (i = 0; i < 5; i++) {
    7833                 //printf("prediction %d: %s\n", i, buffer[i]);
    7834                 L->m[i].rtyp = STRING_CMD;
    7835                 L->m[i].data = buffer[i];
    7836         }
    7837 
    7838         // pass the resultant list to the res datastructure
    7839         res->data=(void *)L;
    7840 
    7841         ml_finalise();
    7842         return FALSE;
    7843 }
    7844 
    7845 
    78467798
    78477799
  • Singular/table.h

    r50fb159 r133ae7  
    948948,{D(jjCALL2ARG),  CNUMBER_CMD,     CNUMBER_CMD,         2      , ALLOW_NC |ALLOW_RING}
    949949,{D(jjOPTION_PL), OPTION_CMD,      STRING_CMD/*or set by p*/,-1, ALLOW_NC |ALLOW_RING}
    950 ,{D(jjPREDHELP0), PREDHELP_CMD,    LIST_CMD,            0      , ALLOW_NC |ALLOW_RING}
    951950,{D(jjCALL2ARG),  REDUCE_CMD,      IDEAL_CMD/*or set by p*/,  2, ALLOW_NC |ALLOW_RING}
    952951,{D(jjCALL3ARG),  REDUCE_CMD,      IDEAL_CMD/*or set by p*/,  3, ALLOW_NC |ALLOW_RING}
     
    11571156  { "poly",        0, POLY_CMD ,          RING_DECL},
    11581157  { "polyBucket",  0, BUCKET_CMD ,        RING_DECL},
    1159   { "predictHelp", 0, PREDHELP_CMD ,      CMD_M},
    11601158  { "preimage",    0, PREIMAGE_CMD ,      CMD_13},
    11611159  { "prime",       0, PRIME_CMD ,         CMD_1},
  • Singular/tok.h

    r50fb159 r133ae7  
    152152  PARSTR_CMD,
    153153  PFAC_CMD,
    154   PREDHELP_CMD,
    155154  PRIME_CMD,
    156155  PRINT_CMD,
  • configure.ac

    r50fb159 r133ae7  
    232232
    233233AC_CONFIG_SUBDIRS([libpolys])
    234 
    235 AC_CONFIG_SUBDIRS([machine_learning])
    236234
    237235AC_CONFIG_FILES([Makefile])
Note: See TracChangeset for help on using the changeset viewer.