Changeset 4b6d98 in git


Ignore:
Timestamp:
Jul 21, 2017, 6:17:15 PM (7 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
99c34cc0dbf214fef21abb247bd17d346ebe019c
Parents:
71274174f2b57cffff35fa4ea6f31e63d6456b56
Message:
skeleton for julia-cf, p2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/juliacf.cc

    r712741 r4b6d98  
    2323
    2424#ifdef HAVE_JULIA
    25 
    26 // Private interface should be hidden!!!
     25#include <julia.h>
     26
     27struct jcf_struct
     28{
     29  jl_value_t *val;
     30  long pos;
     31}
     32typedef struct jcf_struct * jcf_number;
     33
     34// julia helper routines:
     35//
     36number jcfNew(jl_value_t* v, const coeffs cf)
     37{
     38  jcf_number r=(jcf_number)omAlloc(sizeof(jcf_struct));
     39  r->val=v;
     40  // ????
     41  return (number)r;
     42}
     43
     44void jcfFree(jcf_number n,  const coeffs cf)
     45{
     46  // ???
     47}
    2748
    2849#ifdef LDEBUG
     
    3051#endif
    3152
    32 /// Get a mapping function from src into the domain of this type: n_R
    33 static nMapFunc jcfSetMap(const coeffs src, const coeffs dst);
    34 
    3553static void jcfCoeffWrite (const coeffs r, BOOLEAN /*details*/)
    3654{
    37   assume( getCoeffType(r) == n_R );
    38   PrintS("Float()");  /* R */
     55  PrintS("juliacf");
    3956}
    4057
    4158
    4259static BOOLEAN jcfGreaterZero (number k, const coeffs r)
    43 {
    44 }
    45 
    46 static number jcfMult (number a,number b, const coeffs r)
    4760{
    4861}
     
    5366static number jcfInit (long i, const coeffs r)
    5467{
     68  jl_value_t *ii = jl_box_int64(i);
     69  return jcfNew(ii,r);
    5570}
    5671
     
    6075static long jcfInt(number &n, const coeffs r)
    6176{
    62 }
    63 
    64 static int jcfSize(number n, const coeffs)
    65 {
    66 }
    67 
     77  jcf_number aa=(jcf_number)n;
     78  if (jl_is_int64(aa->val))
     79  {
     80    long l=jl_unbox_int64(aa->val);
     81    return l;
     82  }
     83  return 0;
     84}
     85
     86static void jcfDelete)(number * a, const coeffs r)
     87{
     88  jcf_number aa=(jcf_number)(*a);
     89  jcfFree(aa,r);
     90  *a=NULL;
     91}
    6892static number jcfAdd (number a, number b, const coeffs r)
    6993{
     94  jcf_number aa=(jcf_number)a;
     95  jcf_number bb=(jcf_number)b;
     96  jl_function_t *func = jl_get_function(jl_base_module, "+");
     97  return jcfNew(jl_call2(func, aa->val, bb->val),r);
    7098}
    7199
    72100static number jcfSub (number a, number b, const coeffs r)
    73101{
     102  jcf_number aa=(jcf_number)a;
     103  jcf_number bb=(jcf_number)b;
     104  jl_function_t *func = jl_get_function(jl_base_module, "-");
     105  return jcfNew(jl_call2(func, aa->val, bb->val),r);
     106}
     107
     108static number jcfMult (number a,number b, const coeffs r)
     109{
     110  jcf_number aa=(jcf_number)a;
     111  jcf_number bb=(jcf_number)b;
     112  jl_function_t *func = jl_get_function(jl_base_module, "-");
     113  return jcfNew(jl_call2(func, aa->val, bb->val),r);
     114}
     115
     116static number jcfDiv (number a,number b, const coeffs r)
     117{
     118  jcf_number aa=(jcf_number)a;
     119  jcf_number bb=(jcf_number)b;
     120  jl_function_t *func = jl_get_function(jl_base_module, "/");
     121  return jcfNew(jl_call2(func, aa->val, bb->val),r);
    74122}
    75123
    76124static BOOLEAN jcfIsZero (number  a, const coeffs r)
    77125{
     126  jcf_number aa=(jcf_number)a;
     127  jl_value_t *ii = jl_box_int64(0);
     128  jl_function_t *func = jl_get_function(jl_base_module, "==");
     129  jl_value_t *res=jl_call2(func, aa->val, ii);
     130  if (jl_unbox_bool(res)) return TRUE;
     131  else                    return FALSE;
    78132}
    79133
    80134static BOOLEAN jcfIsOne (number a, const coeffs r)
    81135{
     136  jcf_number aa=(jcf_number)a;
     137  jl_value_t *ii = jl_box_int64(1);
     138  jl_function_t *func = jl_get_function(jl_base_module, "==");
     139  jl_value_t *res=jl_call2(func, aa->val, ii);
     140  if (jl_unbox_bool(res)) return TRUE;
     141  else                    return FALSE;
    82142}
    83143
    84144static BOOLEAN jcfIsMOne (number a, const coeffs r)
    85145{
    86 }
    87 
    88 static number jcfDiv (number a,number b, const coeffs r)
    89 {
     146  jcf_number aa=(jcf_number)a;
     147  jl_value_t *ii = jl_box_int64(-1);
     148  jl_function_t *func = jl_get_function(jl_base_module, "==");
     149  jl_value_t *res=jl_call2(func, aa->val, ii);
     150  if (jl_unbox_bool(res)) return TRUE;
     151  else                    return FALSE;
    90152}
    91153
    92154static number jcfInvers (number c, const coeffs r)
    93155{
     156  jl_value_t *ii = jl_box_int64(1);
     157  jcf_number cc=(jcf_number)c;
     158  jl_function_t *func = jl_get_function(jl_base_module, "/");
     159  return jcfNew(jl_call2(func, ii, cc->val),r);
    94160}
    95161
    96162static number jcfNeg (number c, const coeffs r)
    97163{
     164  // inplace negate:
     165  jl_value_t *ii = jl_box_int64(-1);
     166  jcf_number cc=(jcf_number)c;
     167  jl_function_t *func = jl_get_function(jl_base_module, "*");
     168  cc->val=jl_call2(func, ii, cc->val);
     169  return (number)cc;
    98170}
    99171
    100172static BOOLEAN jcfGreater (number a,number b, const coeffs r)
    101173{
     174  jcf_number aa=(jcf_number)a;
     175  jcf_number bb=(jcf_number)b;
     176  jl_function_t *func = jl_get_function(jl_base_module, ">");
     177  jl_value_t *res=jl_call2(func, aa->val, bb->val);
     178  if (jl_unbox_bool(res)) return TRUE;
     179  else                    return FALSE;
    102180}
    103181
    104182static BOOLEAN jcfEqual (number a,number b, const coeffs r)
    105183{
     184  jcf_number aa=(jcf_number)a;
     185  jcf_number bb=(jcf_number)b;
     186  jl_function_t *func = jl_get_function(jl_base_module, "==");
     187  jl_value_t *res=jl_call2(func, aa->val, bb->val);
     188  if (jl_unbox_bool(res)) return TRUE;
     189  else                    return FALSE;
    106190}
    107191
    108192static void jcfWrite (number a, const coeffs r)
    109193{
     194  jcf_number aa=(jcf_number)a;
     195  jl_function_t *func = jl_get_function(jl_base_module, "string");
     196  jl_value_t *res=jl_call1(func, aa->val);
     197  // ???
     198  // char *s=jl_unbox_charptr(res);
     199  // StringAppendS(s);
    110200}
    111201
     
    118208static const char * jcfRead (const char *s, number *a, const coeffs r)
    119209{
    120 
     210  int i=1;
     211  s=eati(s,&i);
     212  *a=jcfInit (i,r);
     213  return s;
    121214}
    122215
     
    127220static number jcfCopy(number a, const coeffs cf)
    128221{
     222  jcf_number aa=(jcf_number)a;
     223  return jcfNew(aa->val,r);
    129224}
    130225
     
    144239#endif
    145240
    146 static number jcfMapP(number from, const coeffs aRing, const coeffs r)
    147 {
    148 }
    149 
    150 static number jcfMapLongR(number from, const coeffs aRing, const coeffs r)
    151 {
    152 }
    153 
    154 static number jcfMapC(number from, const coeffs aRing, const coeffs r)
    155 {
    156 }
    157 
    158 
    159 static number jcfMapQ(number from, const coeffs aRing, const coeffs r)
    160 {
    161 }
    162 
    163 static number jcfMapZ(number from, const coeffs aRing, const coeffs r)
    164 {
    165 }
    166 
    167241static nMapFunc jcfSetMap(const coeffs src, const coeffs dst)
    168242{
     
    172246static char* jcfCoeffString(const coeffs r)
    173247{
    174   return omStrDup("Float()");
     248  return omStrDup("juliacf");
    175249}
    176250
     
    193267  n->cfInit = jcfInit;
    194268  n->cfInt  = jcfInt;
     269  n->cfDelete=jcfDelete;
    195270  n->cfAdd   = jcfAdd;
    196271  n->cfSub   = jcfSub;
  • m4/julia-check.m4

    r712741 r4b6d98  
    66AC_ARG_ENABLE(julia,
    77 AS_HELP_STRING([--enable-julia], [Enables interface for Singular to julia]),
    8  [ENABLE_JULIA="$enableval"], [ENABLE_JULIA=""])
     8 [ENABLE_JULIA="$enableval"], [ENABLE_JULIA="no"])
    99
    1010AC_MSG_CHECKING(whether to check for julia interface)
Note: See TracChangeset for help on using the changeset viewer.