Révision 34

sollyaIntegration-4.0/src/sollyaLibOpenIssues.txt (revision 34)
1

  
2

  
3

  
4

  
5
General ideas
6
-------------
7
Replace "affectation" by assignment.
8

  
9

  
10
idea 1
11
In the parameter lists in the header file, add a variable name: it documents
12
the function as well.
13

  
14
Typos
15
-----
16

  
17
Page 211, last paragraph:
18
replace "the elements N of arg" by "the N elements of arg"
0 19

  
sollyaIntegration-4.0/src/taylorModel-01.c (revision 34)
1
/** @file taylorModel-01.c
2
 * taylorModel-01: check the taylorform function.
3
 *
4
 * @author S.T.
5
 * @date 2012-11-21
6
 *
7
 */
8
/******************************************************************************/
9
/* Headers, applying the "particular to general" convention.*/
10

  
11
#include "pobyso4/pobyso.h"
12

  
13
/* includes of local headers */
14

  
15
/* includes of project headers */
16

  
17
/* includes of system headers */
18
#include <stdlib.h>
19
#include <gmp.h>
20
#include <sollya.h>
21
#include <setjmp.h>
22
#include <string.h>
23
/* Other declarations */
24

  
25
/* Internal prototypes */
26

  
27
/* Types, constants and macros definitions */
28
#define NUM_ARGS 5
29
#define VARIABLE_NAME_STRING "x"
30
#define RADIX 10
31
/* Global variables */
32

  
33
/* Functions */
34
int
35
main(int argc, char** argv)
36
{
37
  //jmp_buf recover;
38
  sollya_obj_t functionObj      = NULL;
39
  char *freeVariableName        = NULL;
40
  char *functionString          = NULL;
41
  char buffer[20];
42
  char* endptr[1];
43
  unsigned int degree           = 0;
44
  double point                  = 0.0;
45
  sollya_obj_t degreeSo;
46
  sollya_obj_t pointSo;
47
  sollya_obj_t tf;
48
  sollya_obj_t *tfAsArray       = NULL;
49
  int numTfElements             = 0;
50
  int tfIsEndElliptic           = 0;
51
  sollya_obj_t polySo;
52

  
53

  
54
  /* check the command line arguments */
55
  if (argc < NUM_ARGS)
56
  {
57
    fprintf(stderr,
58
            "\n\nusage: %s functionString freeVariableName degree point\n\n",
59
            argv[0]);
60
    fprintf(stderr,
61
            "\tfunctionString: the expression to create a node from.\n");
62
    fprintf(stderr,
63
            "\t\tmust be in quotes (e. g. \"cos(x)\");\n");
64
    fprintf(stderr,
65
            "\tfreeVariableName: the name of the free variable;\n");
66
    fprintf(stderr,
67
            "\t\t(e. g. x (no quotes needed));\n");
68
    fprintf(stderr,
69
            "\tdegree: the degree of the polynomial;\n");
70
    fprintf(stderr,
71
            "\tpoint: the point where the Taylor expansion is to be considered.\n");
72
    fprintf(stderr,"\n\n");
73
    return(1);
74
  }
75

  
76
  buffer[0] ='\0';
77

  
78
  functionString    = argv[1];
79
  freeVariableName  = argv[2];
80
  if (*(argv[3]) == '-')
81
    {
82
      fprintf(stderr,
83
              "\n\n%s: the degree (%s) can not be negative.\n",
84
              argv[0],
85
              argv[3]);
86
      fprintf(stderr,
87
              "Aborting the program.\n\n");
88
      return(1);
89
    }
90

  
91
  degree = strtoul(argv[3], endptr, 10);
92
  /* For a completly safe conversion *endptr must point to a 0 char value
93
     (not the '0' but the '\0' char value!). */
94
  if (**endptr != '\0')
95
  {
96
    fprintf(stderr,
97
            "\n\n%s: could not safely convert the \"%s\" string into an int.\n",
98
            argv[0],
99
            argv[3]);
100
    fprintf(stderr,
101
            "Aborting the program!");
102
    return(1);
103
  }
104
  point = strtod(argv[4], endptr);
105
  /* For a completly safe conversion *endptr must point to a 0 char value
106
     (not the '0' but the '\0' char value!). */
107
  if (**endptr != '\0')
108
  {
109
    fprintf(stderr,
110
            "\n\n%s: could not safely convert the \"%s\" string into double.\n",
111
            argv[0],
112
            argv[4]);
113
    fprintf(stderr,
114
            "Aborting the program!");
115
    return(1);
116
  }
117
  /* Debug printing. */
118
  fprintf(stdout,
119
          "%s: function: %s\n", argv[0], functionString);
120
  fprintf(stdout,
121
          "%s: variable name: %s\n", argv[0], freeVariableName);
122
  fprintf(stdout,
123
          "%s: degree: %d\n", argv[0], degree);
124
  fprintf(stdout,
125
          "%s: point : %f\n", argv[0], point);
126
  fprintf(stdout, "\n");
127
  /* Initialize Sollya. */
128
  sollya_lib_init();
129

  
130
  /* Set the free variable name. */
131
  sollya_lib_name_free_variable(freeVariableName);
132
  if (strcmp(sollya_lib_get_free_variable_name(), freeVariableName))
133
  {
134
    fprintf(stderr, "Could not set \"%s\" as the variable name. Aborting!\n",
135
                      freeVariableName);
136
    sollya_lib_close();
137
    return(1);
138
  }
139
  /* Parse the function string. */
140
  functionObj = pobyso_parse_string(functionString);
141
  if (sollya_lib_obj_is_error(functionObj))
142
  {
143
    fprintf(stderr, "%s: could not parse \"%s\". Aborting!\n", argv[0], functionString);
144
    sollya_lib_close();
145
    return(1);
146
  }
147
  sollya_lib_fprintf(stdout, "%s: function: %b\n", argv[0], functionObj );
148
  pobyso_autoprint(functionObj, NULL);
149
  /* Create the degree object. */
150
  degreeSo = sollya_lib_constant_from_uint64(degree);
151
  pobyso_autoprint(degreeSo, NULL);
152
  /* Create the point object. */
153
  pointSo = sollya_lib_constant_from_double(point);
154
  pobyso_autoprint(pointSo, NULL);
155

  
156
  tf = sollya_lib_taylorform(functionObj, degreeSo, pointSo, NULL);
157
  pobyso_autoprint(tf, NULL);
158

  
159
  if (sollya_lib_obj_is_list(tf))
160
  {
161
    fprintf(stdout, "%s: is a list.\n", argv[0]);
162
  }
163
  if (! sollya_lib_get_list_elements(&tfAsArray, &numTfElements, &tfIsEndElliptic, tf))
164
  {
165
    fprintf(stderr, "%s: convertion of tf to array failed. Aborting!\n",
166
            argv[0]);
167
    /* TODO: clean up. */
168
    sollya_lib_close();
169
    return(1);
170
  }
171
  fprintf(stdout, "tfAsArray address: %p\n", tfAsArray);
172
  fprintf(stdout, "tf is end-elliptic: %d\n", tfIsEndElliptic);
173
  polySo = tfAsArray[0];
174
  fprintf(stdout, "PolySo address: %p\n", polySo);
175
  fprintf(stdout, "PolySo is a function: %d\n", sollya_lib_obj_is_function(polySo));
176
  pobyso_autoprint(polySo, NULL);
177
  pobyso_autoprint(tf, NULL);
178

  
179
  polySo = sollya_lib_get_object_list_head(tf);
180
  //fprintf(stdout, "PolySo is a function: %d\n", sollya_lib_obj_is_function(polySo));
181
  sollya_lib_clear_obj(degreeSo);
182
  sollya_lib_clear_obj(functionObj);
183

  
184
#if 0
185
  fprintf(stderr, "Name of variable: %s\n", getNameOfVariable());
186
  if (functionNode->nodeType == VARIABLE)
187
  {
188
    fprintf(stderr, "Node type is VARIABLE.\n");
189
    if (getNameOfVariable != NULL)
190
    {
191
      if (strcmp(freeVariableName, getNameOfVariable()))
192
      {
193
        fprintf(stderr, "Could not parse %s. Aborting!\n", functionString);
194
        finishTool();
195
        return(1);
196
      }
197
    }
198
  }
199

  
200
  variableNode      = makeVariable();
201

  
202
  powNode = makePow(variableNode, makeConstantDouble(3.0));
203
  functionDiffNode  = differentiate(functionNode);
204
  fprintf(stderr, "\tfunctionNode tree...\n");
205
  fprintTree(stderr, functionNode);
206
  fprintf(stderr, "\n");
207
  fprintf(stderr, "\t...end functionNode tree.\n");
208
  fprintf(stderr, "\n");
209
  fprintf(stderr, "\tfunctionDiffNode tree...\n");
210
  fprintTree(stderr,functionDiffNode);
211
  fprintf(stderr, "\n");
212
  fprintf(stderr, "\t...end functionDiffNode tree.\n");
213
  fprintf(stderr, "\n\tvariableNode tree...\n");
214
  fprintTree(stderr, variableNode);
215
  fprintf(stderr, "\n");
216
  fprintf(stderr, "\t...end variableNode tree.\n");
217
  fprintf(stderr, "\n\tpowNode tree...\n");
218
  fprintTree(stderr, powNode);
219
  fprintf(stderr, "\n");
220
  fprintf(stderr, "\t...end powNode tree.\n");
221

  
222
  free_memory(variableNode);
223
  free_memory(functionNode);
224
  free_memory(functionDiffNode);
225
#endif
226

  
227
  sollya_lib_close();
228
  return(0);
229
} /* End main */
0 230

  
sollyaIntegration-4.0/src/Makefile (revision 34)
1
CC           = gcc
2
CFLAGS       = -Wall -g -I /warehouse/storres/root/include
3
LDLIB        = -L /warehouse/storres/root/lib -lsollya -lfplll -lmpfi -lmpfr -lgmp -lxml2 -lz -lstdc++ -lm -ldl   #-Wl,--verbose
4

  
5
OBJS         = pobyso/src/pobyso.o
6
INCS         = pobyso/src/pobyso.h 
7
SOURCES      = $(INCS) \
8
               createObj-01.c \
9
               taylorModel-01.c \
10
               pobyso4/pobyso.c
11

  
12
TEST_DRIVER  = # CUnit test driver binary program
13
TEST_DIR     = test
14
TEST_SOURCES = $(TEST_DIR)/$(TEST_DRIVER).c \
15
               # Add the suites definition sources
16

  
17
ALL_TARGETS = createObj-01 taylorModel-01
18

  
19
SCRATCH_PRG := $(patsubst %.c,%,$(wildcard *.c))
20
SCRATCH_ALL := $(SCRATCH_PRG)
21

  
22
LAST_ARCH_FILE = lastArch.txt
23

  
24
ARCH := $(shell uname -m)
25

  
26
DUMMY := $(shell touch $(LAST_ARCH_FILE))
27

  
28
LAST_ARCH := $(shell cat $(LAST_ARCH_FILE))
29

  
30
ifneq ($(LAST_ARCH), $(ARCH))
31
  DUMMY := $(shell echo $(ARCH) > $(LAST_ARCH_FILE))
32
  DUMMY := $(shell $(MAKE) clean) 
33
endif
34

  
35
ifeq (x86_64, $(ARCH))
36
  CFLAGS := -m64 $(CFLAGS)
37
  # LDLIB :=
38
endif
39

  
40
ifeq (ppc64, $(ARCH))
41
  CFLAGS := -m64 $(CFLAGS)
42
  # LDLIB :=
43
endif
44

  
45
ifeq (i686, $(ARCH))
46
  # CFLAGS := $(CFLAGS)
47
  # LDLIB :=
48
endif
49

  
50
# -------------------------------------------------------------------------
51

  
52
default: all
53
# Remove all implicit (suffix) rules. No need to remove pattern rules.
54
# Just redefine them.
55
.SUFFIXES:
56
# Keep the OBJS we want to link with user code.
57
.PRECIOUS: $(OBJS)
58

  
59
all: $(ALL_TARGETS)
60
test: $(TEST_DRIVER)
61

  
62
% : %.o $(OBJS)
63
	$(CC) $(CFLAGS) -o $@ $< $(OBJS) $(LDLIB)
64

  
65
%.o : %.c $(INCS)
66
	$(CC) $(CFLAGS) -c -o $@ $<
67

  
68
$(TEST_DRIVER) : 
69
	make -C test
70
	cp test/$(TEST_DRIVER) .
71
# -------------------------------------------------------------------------
72

  
73
.PHONY: clean scratch
74

  
75
clean:
76
	@rm -f $(ALL_TARGETS) $(TEST_DRIVER)
77
	@rm -f *.o a.out $(OBJS)
78
	@rm -f *~ *% #*#
79
	@make -C $(TEST_DIR) clean
80
	@make -C pobyso clean
81

  
82
scratch: clean
83
	rm -f $(SCRATCH_ALL)
84

  
85
# Change the documentation configuration and path accordingly.
86
documentation: pobyso.doxyconf $(SOURCES)
87
	doxygen pobyso.doxyconf
0 88

  
sollyaIntegration-4.0/src/createObj-01.c (revision 34)
1
/** @file createObj-01.c
2
 * CreateObj-01: create a function for an expression given on the command line.
3
 *
4
 * @author S.T.
5
 * @date 2012-11-21
6
 *
7
 */
8
/******************************************************************************/
9
/* Headers, applying the "particular to general" convention.*/
10

  
11
#include "pobyso4/pobyso.h"
12

  
13
/* includes of local headers */
14

  
15
/* includes of project headers */
16

  
17
/* includes of system headers */
18
#include <gmp.h>
19
#include <sollya.h>
20
#include <setjmp.h>
21
#include <string.h>
22
/* Other declarations */
23

  
24
/* Internal prototypes */
25

  
26
/* Types, constants and macros definitions */
27
#define NUM_ARGS 3
28
#define VARIABLE_NAME_STRING "x"
29
#define RADIX 10
30
/* Global variables */
31

  
32
/* Functions */
33
int
34
main(int argc, char** argv)
35
{
36
  //jmp_buf recover;
37
  sollya_obj_t functionObj      = NULL;
38
  sollya_obj_t curVerbLevel     = NULL;
39
  char *freeVariableName        = NULL;
40
  char *functionString          = NULL;
41
  char *initialFreeVariableName = NULL;
42
  char buffer[20];
43

  
44

  
45
  /* check the command line arguments */
46
  if (argc < NUM_ARGS)
47
  {
48
    fprintf(stderr,
49
            "\n\nusage: %s expressionString freeVariableName\n\n",
50
            argv[0]);
51
    fprintf(stderr,
52
            "\texpressionString: the expression to create a node from.\n");
53
    fprintf(stderr,
54
            "\t\tmust be in quotes (e. g. \"cos(x)\");\n");
55
    fprintf(stderr,
56
            "\tfreeVariableName: the name of the free variable;\n");
57
    fprintf(stderr,
58
            "\t\t(e. g. x (no quotes needed));\n");
59
    fprintf(stderr,"\n\n");
60
    return(1);
61
  }
62

  
63
  buffer[0] ='\0';
64

  
65
  functionString    = argv[1];
66
  freeVariableName  = argv[2];
67

  
68
  /* Debug printing. */
69
  fprintf(stdout,
70
          "%s: function: %s\n", argv[0], functionString);
71
  fprintf(stdout,
72
          "%s: variable name: %s\n", argv[0], freeVariableName);
73
  fprintf(stdout, "\n");
74
  /* Initialize Sollya. */
75
  sollya_lib_init();
76

  
77
  initialFreeVariableName = sollya_lib_get_free_variable_name();
78
  if (initialFreeVariableName == NULL)
79
  {
80
    fprintf(stderr, "%s: could not get the name of the free variable. Aborting!\n",
81
                    argv[0]);
82
    sollya_lib_close();
83
    return(1);
84

  
85
  }
86

  
87
  fprintf(stderr, "%s: name of variable (before any assignment): %s\n",
88
                  argv[0],
89
                  initialFreeVariableName);
90

  
91
  /* Set the free variable name. */
92
  sollya_lib_name_free_variable(freeVariableName);
93
  if (strcmp(sollya_lib_get_free_variable_name(), freeVariableName))
94
  {
95
    fprintf(stderr, "Could not set \"%s\" as the variable name. Aborting!\n",
96
                      freeVariableName);
97
    sollya_lib_close();
98
    return(1);
99
  }
100
  /* Parse the function string. */
101
  pobyso_set_verbosity_off(&curVerbLevel);
102
  functionObj = pobyso_parse_string(functionString);
103
  if (sollya_lib_obj_is_error(functionObj))
104
  {
105
    fprintf(stderr, "%s: could not parse \"%s\". Aborting!\n", argv[0], functionString);
106
    sollya_lib_close();
107
    return(1);
108
  }
109
  sollya_lib_fprintf(stdout, "%s: function: %b\n", argv[0], functionObj );
110
  pobyso_autoprint(functionObj, NULL);
111
  sollya_lib_clear_obj(functionObj);
112

  
113
  if (sollya_lib_obj_is_function(curVerbLevel))
114
  {
115
    pobyso_autoprint(curVerbLevel, NULL);
116
    fprintf(stdout, " is a function.\n");
117
  }
118
  pobyso_autoprint(curVerbLevel, NULL);
119
  pobyso_set_verbosity_to(curVerbLevel);
120
  sollya_lib_clear_obj(curVerbLevel);
121

  
122
  strncat(buffer, functionString, strlen(functionString) - 1);
123
  functionObj = pobyso_parse_string(buffer);
124
  if (sollya_lib_obj_is_error(functionObj))
125
  {
126
    fprintf(stderr, "%s: could not parse \"%s\". Aborting!\n", argv[0], functionString);
127
    sollya_lib_close();
128
    return(1);
129
  }
130
  /* Attic from previous versions. */
131
#if 0
132
  fprintf(stderr, "Name of variable: %s\n", getNameOfVariable());
133
  if (functionNode->nodeType == VARIABLE)
134
  {
135
    fprintf(stderr, "Node type is VARIABLE.\n");
136
    if (getNameOfVariable != NULL)
137
    {
138
      if (strcmp(freeVariableName, getNameOfVariable()))
139
      {
140
        fprintf(stderr, "Could not parse %s. Aborting!\n", functionString);
141
        finishTool();
142
        return(1);
143
      }
144
    }
145
  }
146

  
147
  variableNode      = makeVariable();
148

  
149
  powNode = makePow(variableNode, makeConstantDouble(3.0));
150
  functionDiffNode  = differentiate(functionNode);
151
  fprintf(stderr, "\tfunctionNode tree...\n");
152
  fprintTree(stderr, functionNode);
153
  fprintf(stderr, "\n");
154
  fprintf(stderr, "\t...end functionNode tree.\n");
155
  fprintf(stderr, "\n");
156
  fprintf(stderr, "\tfunctionDiffNode tree...\n");
157
  fprintTree(stderr,functionDiffNode);
158
  fprintf(stderr, "\n");
159
  fprintf(stderr, "\t...end functionDiffNode tree.\n");
160
  fprintf(stderr, "\n\tvariableNode tree...\n");
161
  fprintTree(stderr, variableNode);
162
  fprintf(stderr, "\n");
163
  fprintf(stderr, "\t...end variableNode tree.\n");
164
  fprintf(stderr, "\n\tpowNode tree...\n");
165
  fprintTree(stderr, powNode);
166
  fprintf(stderr, "\n");
167
  fprintf(stderr, "\t...end powNode tree.\n");
168

  
169
  free_memory(variableNode);
170
  free_memory(functionNode);
171
  free_memory(functionDiffNode);
172
#endif
173

  
174
  sollya_lib_close();
175
  return(0);
176
} /* End main */
0 177

  

Formats disponibles : Unified diff