diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index ed1a683b6..9b686f590 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -6,7 +6,22 @@ on: workflow_dispatch: jobs: - KhiCAS: +# KhiCAS: +# runs-on: ubuntu-latest +# steps: +# - run: sudo apt-get update && sudo apt-get install wget gdb gcc g++ libgmp-dev libmpfr-dev libmpfi-dev libpari-dev libgsl0-dev libxext-dev libpng-dev libjpeg-dev libreadline-dev libncurses5-dev mesa-common-dev libx11-dev libxt-dev libxft-dev libntl-dev libgl1-mesa-dev libgl-dev libao-dev hevea debhelper libfltk1.3-dev build-essential git imagemagick libx11-dev libxext-dev libfreetype6-dev libpng-dev libjpeg-dev pkg-config gcc-arm-none-eabi binutils-arm-none-eabi dfu-util texinfo autoconf-archive -y +# +# - uses: actions/checkout@v1 +# with: +# submodules: true +# - run: make -C apps/KhiCAS clean +# - run: make KhiCAS_rebuild +# - run: ./tool/archive KhiCAS.tar KhiCAS +# - uses: actions/upload-artifact@master +# with: +# name: KhiCAS +# path: KhiCAS.tar + Golly: runs-on: ubuntu-latest steps: - run: sudo apt-get update && sudo apt-get install wget gdb gcc g++ libgmp-dev libmpfr-dev libmpfi-dev libpari-dev libgsl0-dev libxext-dev libpng-dev libjpeg-dev libreadline-dev libncurses5-dev mesa-common-dev libx11-dev libxt-dev libxft-dev libntl-dev libgl1-mesa-dev libgl-dev libao-dev hevea debhelper libfltk1.3-dev build-essential git imagemagick libx11-dev libxext-dev libfreetype6-dev libpng-dev libjpeg-dev pkg-config gcc-arm-none-eabi binutils-arm-none-eabi dfu-util texinfo autoconf-archive -y @@ -14,13 +29,26 @@ jobs: - uses: actions/checkout@v1 with: submodules: true - - run: make -C apps/KhiCAS cleanall - - run: make KhiCAS_rebuild - - run: ./tool/archive KhiCAS.tar KhiCAS + - run: make Golly_rebuild + - run: ./tool/archive Golly.tar Golly - uses: actions/upload-artifact@master with: - name: KhiCAS - path: KhiCAS.tar + name: Golly + path: Golly.tar + Fractal: + runs-on: ubuntu-latest + steps: + - run: sudo apt-get update && sudo apt-get install wget gdb gcc g++ libgmp-dev libmpfr-dev libmpfi-dev libpari-dev libgsl0-dev libxext-dev libpng-dev libjpeg-dev libreadline-dev libncurses5-dev mesa-common-dev libx11-dev libxt-dev libxft-dev libntl-dev libgl1-mesa-dev libgl-dev libao-dev hevea debhelper libfltk1.3-dev build-essential git imagemagick libx11-dev libxext-dev libfreetype6-dev libpng-dev libjpeg-dev pkg-config gcc-arm-none-eabi binutils-arm-none-eabi dfu-util texinfo autoconf-archive -y + + - uses: actions/checkout@v1 + with: + submodules: true + - run: make Fractal_rebuild + - run: ./tool/archive Fractal.tar Fractal + - uses: actions/upload-artifact@master + with: + name: Fractal + path: Fractal.tar BadApple: runs-on: ubuntu-latest steps: @@ -163,4 +191,4 @@ jobs: path: UnitCircle.tar env: - ACCEPT_OFFICIAL_TOS: 1 \ No newline at end of file + ACCEPT_OFFICIAL_TOS: 1 diff --git a/apps/Fractal/Makefile b/apps/Fractal/Makefile new file mode 100644 index 000000000..c255b9fe6 --- /dev/null +++ b/apps/Fractal/Makefile @@ -0,0 +1,15 @@ +API=../../api +CC=arm-none-eabi-gcc +OBJCOPY=arm-none-eabi-objcopy +AR=arm-none-eabi-ar +CFLAGS=-DNDEBUG -ggdb3 -I$(API) -O3 -mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard -fno-common -fdata-sections -ffunction-sections -fno-exceptions -flto -fwhole-program +LDFLAGS=-Wl,-L$(API) -Wl,--gc-sections -Wl,--entry=entrypoint --specs=nosys.specs -nostartfiles -Wl,-Ur -lapi -lm + +%.o: %.c + $(CC) $(CFLAGS) -c $< + +app.elf: main.o peripherals.o menu.o + $(CC) $^ -o $@ $(CFLAGS) $(LDFLAGS) + +clean: + rm -f *.elf *.o diff --git a/apps/Fractal/app.elf b/apps/Fractal/app.elf new file mode 100644 index 000000000..27d8763f2 Binary files /dev/null and b/apps/Fractal/app.elf differ diff --git a/apps/Fractal/app.icon b/apps/Fractal/app.icon new file mode 100644 index 000000000..99d803009 Binary files /dev/null and b/apps/Fractal/app.icon differ diff --git a/apps/Fractal/icon.png b/apps/Fractal/icon.png new file mode 100644 index 000000000..78f5dbec5 Binary files /dev/null and b/apps/Fractal/icon.png differ diff --git a/apps/Fractal/inc/menu.h b/apps/Fractal/inc/menu.h new file mode 100644 index 000000000..964e17e3f --- /dev/null +++ b/apps/Fractal/inc/menu.h @@ -0,0 +1,16 @@ +#ifndef MENU_H +#define MENU_H + +#include "extapp_api.h" +#include "peripherals.h" + +typedef struct { + char *value; + int cursor; + int max; + int x_pos; +} input_t; + +void menu(int *MAX_ITER, double complex *c, int *quit); + +#endif \ No newline at end of file diff --git a/apps/Fractal/inc/peripherals.h b/apps/Fractal/inc/peripherals.h new file mode 100644 index 000000000..f9b85da02 --- /dev/null +++ b/apps/Fractal/inc/peripherals.h @@ -0,0 +1,26 @@ +#ifndef CHIPEE_PERIPHERALS_H_ +#define CHIPEE_PERIPHERALS_H_ + +#include +#include +#include +#include +#include +#include + +#define BGCOL 0x0000 + +extern long long unsigned int keymappings[16]; +extern int keymappings_await[16]; + +void clearscreen(); +void waitForKeyPressed(); +void waitForKeyReleased(); +void waitForKeyReleasedTimeout(int timeout); +uint16_t makeColor(int iter, int max); +uint16_t rgb_16(uint16_t r, uint16_t g, uint16_t b); +char scancodeToCharFull(uint64_t scancode); +char scancodeToCharNbr(uint64_t scancode); +double complex parse_complex(const char *str); + +#endif diff --git a/apps/Fractal/main.c b/apps/Fractal/main.c new file mode 100644 index 000000000..313c63efa --- /dev/null +++ b/apps/Fractal/main.c @@ -0,0 +1,47 @@ +#include +#include +#include +#include +#include +#include "extapp_api.h" + +#include "inc/peripherals.h" +#include "inc/menu.h" + +void extapp_main(void) +{ + waitForKeyReleased(); + int quit = 0; + + int SIZE_X = 320, SIZE_Y = 240; + int MAX_ITER; + double complex c; + + menu(&MAX_ITER, &c, &quit); + if (quit) return; + clearscreen(); + + for (int i = -(SIZE_X - SIZE_Y) / 2; i < SIZE_X - (SIZE_X - SIZE_Y) / 2; i++) + { + for (int j = 0; j < SIZE_Y; j++) + { + double x = -1.5 + (3.0 * i) / SIZE_Y; + double y = -1.5 + (3.0 * j) / SIZE_Y; + double complex z = x + y * I; + int iter = 0; + while (cabs(z) < 2 && iter < MAX_ITER) + { + z = z * z + c; + iter++; + } + uint16_t color = makeColor(iter, MAX_ITER); + extapp_pushRectUniform(i + (SIZE_X - SIZE_Y) / 2, j, 1, 1, color); + } + } + + waitForKeyReleased(); + waitForKeyPressed(); + waitForKeyReleased(); + + return; +} diff --git a/apps/Fractal/menu.c b/apps/Fractal/menu.c new file mode 100644 index 000000000..76882d739 --- /dev/null +++ b/apps/Fractal/menu.c @@ -0,0 +1,84 @@ +#include "inc/menu.h" + +#define DEFAULT rgb_16(166, 166, 166) +#define SELECTED 0xFFFF +#define NOPTIONS 2 + +void menu(int *MAX_ITER, double complex *c, int *quit) +{ + int lselect = 0; + input_t inputs[NOPTIONS]; + inputs[0] = (input_t){.cursor = 0, .max = 30, .value = calloc(31, sizeof(char)), .x_pos = 65}; + inputs[1] = (input_t){.cursor = 0, .max = 3, .value = calloc(4, sizeof(char)), .x_pos = 135}; + uint64_t previous_scancode = 0; + + clearscreen(); + + extapp_pushRectUniform(0, 0, 320, 18, rgb_16(50, 50, 50)); + extapp_drawTextSmall("FRACTAL", 140, 4, 0xFFFF, rgb_16(50, 50, 50), 0); + + extapp_drawTextLarge(lselect == 0 ? "> c =" : " c =", 5, 40, lselect == 0 ? SELECTED : DEFAULT, BGCOL, 0); + extapp_drawTextLarge(lselect == 1 ? "> Max. iter:" : " Max. iter:", 5, 65, lselect == 1 ? SELECTED : DEFAULT, BGCOL, 0); + extapp_drawTextSmall(inputs[0].value, inputs[0].x_pos, 44, DEFAULT, BGCOL, 0); + extapp_drawTextSmall(inputs[1].value, inputs[1].x_pos, 69, SELECTED, BGCOL, 0); + extapp_drawTextLarge("", 270, 200, DEFAULT, BGCOL, 0); + extapp_drawTextSmall("Toujours en noir et blanc", 5, 227, DEFAULT, BGCOL, 0); + + while (true) + { + for (int i = 0; i < NOPTIONS; i++) + { + inputs[i].value[inputs[i].cursor] = '\0'; + } + + extapp_drawTextLarge(lselect == 0 ? "> c =" : " c =", 5, 40, lselect == 0 ? SELECTED : DEFAULT, BGCOL, 0); + extapp_drawTextLarge(lselect == 1 ? "> Max. iter:" : " Max. iter:", 5, 65, lselect == 1 ? SELECTED : DEFAULT, BGCOL, 0); + extapp_drawTextSmall(inputs[0].value, inputs[0].x_pos, 44, lselect == 0 ? SELECTED : DEFAULT, BGCOL, 0); + extapp_drawTextSmall(inputs[1].value, inputs[1].x_pos, 69, lselect == 1 ? SELECTED : DEFAULT, BGCOL, 0); + + uint64_t scancode = extapp_scanKeyboard(); + + if (scancode != 0 && scancode != previous_scancode) + { + if (scancode & SCANCODE_Up) lselect = (lselect - 1 + NOPTIONS) % NOPTIONS; + else if (scancode & SCANCODE_Down) lselect = (lselect + 1) % NOPTIONS; + else if (scancode & SCANCODE_Back) { + *quit = 1; + break; + } + else if (scancode & SCANCODE_OK || scancode & SCANCODE_EXE) break; + else if (scancode & SCANCODE_Backspace && inputs[lselect].cursor > 0) + { + inputs[lselect].cursor--; + inputs[lselect].value[inputs[lselect].cursor] = '\0'; + extapp_pushRectUniform(inputs[lselect].x_pos + 7 * inputs[lselect].cursor, 44 + lselect * 25, 100, 18, BGCOL); + } + else if (inputs[lselect].cursor < inputs[lselect].max) + { + char _c = lselect == 1 ? scancodeToCharNbr(scancode) : scancodeToCharFull(scancode); + if (_c != '\0') + { + inputs[lselect].value[inputs[lselect].cursor] = _c; + inputs[lselect].cursor++; + extapp_pushRectUniform(inputs[lselect].x_pos + 7 * inputs[lselect].cursor, 44 + lselect * 25, 100, 18, BGCOL); + extapp_drawTextSmall(inputs[lselect].value, inputs[lselect].x_pos, 44 + lselect * 25, SELECTED, BGCOL, 0); + } + } + } + + previous_scancode = scancode; + + extapp_msleep(10); + } + + waitForKeyPressed(); + waitForKeyReleased(); + + *MAX_ITER = atoi(inputs[1].value); + if (*MAX_ITER < 1) + *MAX_ITER = 100; + *c = parse_complex(inputs[0].value); + + free(inputs[0].value); + free(inputs[1].value); +} \ No newline at end of file diff --git a/apps/Fractal/peripherals.c b/apps/Fractal/peripherals.c new file mode 100644 index 000000000..5afe7c749 --- /dev/null +++ b/apps/Fractal/peripherals.c @@ -0,0 +1,192 @@ +#include "inc/peripherals.h" +#include "extapp_api.h" +#include + +/** + * clearscreen: clear the screen + */ +void clearscreen() +{ + // Draw a rectangle to fill all the screen + extapp_pushRectUniform(0, 0, 320, 240, BGCOL); +} + +/** + * waitForKeyPressed: wait for a key to be pressed + */ +void waitForKeyPressed() +{ + // Scan the keyboard until we get a pressed key + while (!extapp_scanKeyboard()) + { + // Sleep 10 milliseconds + extapp_msleep(10); + } +} + +/** + * waitForKeyReleased: wait for no keys pressed + */ +void waitForKeyReleased() +{ + // Scan the keyboard until we get no keys pressed + while (extapp_scanKeyboard()) + { + extapp_msleep(10); + } +} + +/** + * waitForKeyReleasedTimeout: wait for no keys pressed, but with a timeout + * @param timeout int + */ +void waitForKeyReleasedTimeout(int timeout) +{ + // Scan the keyboard until we get no keys pressed, but exit if the timeout reached + while (extapp_scanKeyboard() && timeout > 0) + { + // Sleep 10 milliseconds + extapp_msleep(10); + // Decrease the timeout of 10 milliseconds + timeout -= 10; + } +} + +/** + * makeColor: convert RGB color to 16B color + * @param iter nth iteration + * @param max maximum iteration for the fractal + */ +uint16_t makeColor(int iter, int max) +{ + int intensity = (iter * 255) / max; + + uint16_t color = (intensity >> 3) << 11 | (intensity >> 2) << 5 | intensity >> 3; + + return color; +} + +/** + * rgb_16: convert RGB color to 16B color + * @param r red value + * @param g green value + * @param b blue value + */ +uint16_t rgb_16(uint16_t r, uint16_t g, uint16_t b) +{ + uint16_t color = (r >> 3) << 11 | (g >> 2) << 5 | b >> 3; + return color; +} + +/** + * scancodeToChar: convert a scancode to a char (all numeric keyboard) + * @param scancode scancode obtained from extapp_scanKeyboard() + */ +char scancodeToCharFull(uint64_t scancode) +{ + switch (scancode) + { + case SCANCODE_Zero: + return '0'; + case SCANCODE_One: + return '1'; + case SCANCODE_Two: + return '2'; + case SCANCODE_Three: + return '3'; + case SCANCODE_Four: + return '4'; + case SCANCODE_Five: + return '5'; + case SCANCODE_Six: + return '6'; + case SCANCODE_Seven: + return '7'; + case SCANCODE_Eight: + return '8'; + case SCANCODE_Nine: + return '9'; + case SCANCODE_Minus: + return '-'; + case SCANCODE_Plus: + return '+'; + case SCANCODE_Dot: + return '.'; + case SCANCODE_Imaginary: + return 'i'; + default: + return '\0'; // Return null character for unrecognized scancode + } +} + +/** + * scancodeToChar: convert a scancode to a char (numbers only) + * @param scancode scancode obtained from extapp_scanKeyboard() + */ +char scancodeToCharNbr(uint64_t scancode) +{ + switch (scancode) + { + case SCANCODE_Zero: + return '0'; + case SCANCODE_One: + return '1'; + case SCANCODE_Two: + return '2'; + case SCANCODE_Three: + return '3'; + case SCANCODE_Four: + return '4'; + case SCANCODE_Five: + return '5'; + case SCANCODE_Six: + return '6'; + case SCANCODE_Seven: + return '7'; + case SCANCODE_Eight: + return '8'; + case SCANCODE_Nine: + return '9'; + default: + return '\0'; // Return null character for unrecognized scancode + } +} + +double complex parse_complex(const char *str) +{ + double real = 0.0, imag = 0.0; + char *endptr; + + // Étape 1 : Extraire la partie réelle + real = strtod(str, &endptr); + + // Étape 2 : Vérifier si une partie imaginaire existe + if (*endptr == '+' || *endptr == '-') + { + // Avancer au-delà du signe + const char *imag_start = endptr; + + // Extraire la partie imaginaire + imag = strtod(imag_start, &endptr); + + // Vérifier si le caractère suivant est 'i' ou 'j' + if (*endptr == 'i' || *endptr == 'j') + { + // Tout est valide, continuer + } + else + { + fprintf(stderr, "Erreur : Format de nombre complexe invalide.\n"); + return 0.0 + 0.0 * I; // Retourner un nombre complexe nul en cas d'erreur + } + } + else if (*endptr == 'i' || *endptr == 'j') + { + // Cas spécial : Pas de partie réelle, seulement une partie imaginaire + imag = real; // La valeur extraite est en fait la partie imaginaire + real = 0.0; + } + + // Retourner le nombre complexe + return real + imag * I; +} \ No newline at end of file diff --git a/apps/Fractal/sources.mak b/apps/Fractal/sources.mak new file mode 100644 index 000000000..335be597f --- /dev/null +++ b/apps/Fractal/sources.mak @@ -0,0 +1,5 @@ +app_external_src += $(addprefix $(EXTAPP_PATH)/,\ + main.c \ + peripherals.c \ + menu.c \ +) diff --git a/apps/Golly/Makefile b/apps/Golly/Makefile new file mode 100644 index 000000000..bfc401878 --- /dev/null +++ b/apps/Golly/Makefile @@ -0,0 +1,15 @@ +API=../../api +CC=arm-none-eabi-gcc +OBJCOPY=arm-none-eabi-objcopy +AR=arm-none-eabi-ar +CFLAGS=-DNDEBUG -ggdb3 -I$(API) -Os -mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard -fno-common -fdata-sections -ffunction-sections -fno-exceptions +LDFLAGS=-Wl,-L$(API) -Wl,--gc-sections -Wl,--entry=entrypoint --specs=nosys.specs -nostartfiles -Wl,-Ur -lapi -lm + +%.o: %.c + $(CC) $(CFLAGS) -c $< + +app.elf: main.o peripherals.o runningMode.o pausedMode.o + $(CC) $^ -o $@ $(CFLAGS) $(LDFLAGS) + +clean: + rm -f *.elf *.o diff --git a/apps/Golly/app.elf b/apps/Golly/app.elf new file mode 100644 index 000000000..514d1bdfd Binary files /dev/null and b/apps/Golly/app.elf differ diff --git a/apps/Golly/app.icon b/apps/Golly/app.icon new file mode 100644 index 000000000..4f16cb60e Binary files /dev/null and b/apps/Golly/app.icon differ diff --git a/apps/Golly/icon.png b/apps/Golly/icon.png new file mode 100644 index 000000000..a0627e51f Binary files /dev/null and b/apps/Golly/icon.png differ diff --git a/apps/Golly/inc/pausedMode.h b/apps/Golly/inc/pausedMode.h new file mode 100644 index 000000000..bd1e84c94 --- /dev/null +++ b/apps/Golly/inc/pausedMode.h @@ -0,0 +1,4 @@ +#include "peripherals.h" + +void handlePausedMode(Cell(*cells)[COLUMNS], coord_t *coord, bool *running, bool *paused, int *speed, bool *isEditingWorld, uint64_t *previous_scancode); +void handleEditingWorld(Cell(*cells)[COLUMNS], coord_t *coord, bool *running, bool *paused, int *speed, bool *isEditingWorld, uint64_t *previous_scancode); \ No newline at end of file diff --git a/apps/Golly/inc/peripherals.h b/apps/Golly/inc/peripherals.h new file mode 100644 index 000000000..b10c0e9bf --- /dev/null +++ b/apps/Golly/inc/peripherals.h @@ -0,0 +1,37 @@ +#ifndef CHIPEE_PERIPHERALS_H_ +#define CHIPEE_PERIPHERALS_H_ + +#include +#include +#include +#include + +#define SIZE 5 +#define ROWS (320 / SIZE) +#define COLUMNS (240 / SIZE) + +typedef struct { + int nthGen; + bool isAlive; +} Cell; + +typedef struct { + int x; + int y; +} coord_t; + +extern long long unsigned int keymappings[16]; +extern int keymappings_await[16]; + +void clearscreen(); +void waitForKeyPressed(); +void waitForKeyReleased(); +void waitForKeyReleasedTimeout(int timeout); +void drawCellsColor(Cell cells[ROWS][COLUMNS]); +void drawCellsMono(Cell cells[ROWS][COLUMNS]); +void initCells(Cell (*cells)[COLUMNS]); +int countNeighbors(Cell cells[ROWS][COLUMNS], int x, int y); +void drawCursor(Cell cells[ROWS][COLUMNS], coord_t coord); +uint16_t getColor(Cell cell); + +#endif diff --git a/apps/Golly/inc/runningMode.h b/apps/Golly/inc/runningMode.h new file mode 100644 index 000000000..3eb46a3c9 --- /dev/null +++ b/apps/Golly/inc/runningMode.h @@ -0,0 +1,3 @@ +#include "peripherals.h" + +void handleRunningMode(Cell(*cells)[COLUMNS], Cell(*newCells)[COLUMNS], bool *paused, int *speed, int *nGen, uint64_t *previous_scancode); \ No newline at end of file diff --git a/apps/Golly/main.c b/apps/Golly/main.c new file mode 100644 index 000000000..d4d3f7a29 --- /dev/null +++ b/apps/Golly/main.c @@ -0,0 +1,51 @@ +#include +#include +#include +#include "extapp_api.h" + +#include "inc/peripherals.h" +#include "inc/pausedMode.h" +#include "inc/runningMode.h" + +void extapp_main(void) +{ + waitForKeyReleased(); + clearscreen(); + + bool running = true; + bool paused = true; + bool isEditingWorld = false; + int nGen = 0; + int speed = 1; + coord_t coord = {ROWS/2, COLUMNS/2}; + uint64_t previous_scancode = 0; + + Cell(*cells)[COLUMNS] = malloc(ROWS * sizeof(*cells)); + Cell(*newCells)[COLUMNS] = malloc(ROWS * sizeof(*newCells)); + + if (!cells || !newCells) return; + + initCells(cells); + + // for (int i = 0; i < 500; i++) + // { + // int x = rand() % ROWS; + // int y = rand() % COLUMNS; + // cells[x][y].isAlive = true; + // } + + drawCellsColor(cells); + drawCursor(cells, coord); + + while (running) + { + if (!paused && !isEditingWorld) handleRunningMode(cells, newCells, &paused, &speed, &nGen, &previous_scancode); + else if (paused && !isEditingWorld) handlePausedMode(cells, &coord, &running, &paused, &speed, &isEditingWorld, &previous_scancode); + else if (paused && isEditingWorld) handleEditingWorld(cells, &coord, &running, &paused, &speed, &isEditingWorld, &previous_scancode); + } + + free(cells); + free(newCells); + + return; +} diff --git a/apps/Golly/pausedMode.c b/apps/Golly/pausedMode.c new file mode 100644 index 000000000..f91a5cc3b --- /dev/null +++ b/apps/Golly/pausedMode.c @@ -0,0 +1,90 @@ +#include "inc/pausedMode.h" +#include "extapp_api.h" + +// Gestion du mode édition (paused) +void handlePausedMode(Cell (*cells)[COLUMNS], coord_t *coord, bool *running, bool *paused, int *speed, bool *isEditingWorld, uint64_t *previous_scancode) +{ + uint64_t scancode = extapp_scanKeyboard(); + if (*previous_scancode != scancode && scancode != 0) + { + switch (scancode) + { + case SCANCODE_Home: + *running = false; // Quitter le programme + return; + case SCANCODE_Back: + *paused = false; // Démarrer la simulation + break; + case SCANCODE_Left: + coord->x = (coord->x - 1 + ROWS) % ROWS; + drawCellsMono(cells); + drawCursor(cells, *coord); + break; + case SCANCODE_Right: + coord->x = (coord->x + 1) % ROWS; + drawCellsMono(cells); + drawCursor(cells, *coord); + break; + case SCANCODE_Up: + coord->y = (coord->y - 1 + COLUMNS) % COLUMNS; + drawCellsMono(cells); + drawCursor(cells, *coord); + break; + case SCANCODE_Down: + coord->y = (coord->y + 1) % COLUMNS; + drawCellsMono(cells); + drawCursor(cells, *coord); + break; + case SCANCODE_OK: + cells[coord->x][coord->y].isAlive = !cells[coord->x][coord->y].isAlive; + cells[coord->x][coord->y].nthGen = cells[coord->x][coord->y].isAlive ? 1 : 0; + drawCellsMono(cells); + drawCursor(cells, *coord); + break; + case SCANCODE_Zero: + initCells(cells); + drawCellsMono(cells); + drawCursor(cells, *coord); + *coord = (coord_t){0, 0}; + *speed = 1; + break; + case SCANCODE_Toolbox: + *isEditingWorld = true; + break; + } + } + *previous_scancode = scancode; + + extapp_msleep(20); +} + +void handleEditingWorld(Cell (*cells)[COLUMNS], coord_t *coord, bool *running, bool *paused, int *speed, bool *isEditingWorld, uint64_t *previous_scancode) +{ + /** + * @brief Fonction de gestion du mode édition (Toolbox) + * Paramètres modifiables : + * - type de monde (fermé, torique, etc.) + * - règles de vie (règles de Conway, etc.) + * - nombre maximal pour le calcul de couleurs + */ + uint64_t scancode = extapp_scanKeyboard(); + if (*previous_scancode != scancode && scancode != 0) + { + switch (scancode) + { + case SCANCODE_Home: + *running = false; // Quitter le programme + return; + case SCANCODE_Back: + *paused = true; // Démarrer la simulation + *isEditingWorld = false; + break; + case SCANCODE_Toolbox: + *isEditingWorld = false; + break; + } + *previous_scancode = scancode; + + extapp_msleep(20); + } +} \ No newline at end of file diff --git a/apps/Golly/peripherals.c b/apps/Golly/peripherals.c new file mode 100644 index 000000000..7b239ad9e --- /dev/null +++ b/apps/Golly/peripherals.c @@ -0,0 +1,144 @@ +#include "inc/peripherals.h" +#include "extapp_api.h" +#include + +/** + * init_display: clear the screen + */ +void clearscreen() +{ + // Draw a rectangle to fill all the screen + extapp_pushRectUniform(0, 0, 320, 240, 0); +} + +/** + * waitForKeyPressed: wait for a key to be pressed + */ +void waitForKeyPressed() +{ + // Scan the keyboard until we get a pressed key + while (!extapp_scanKeyboard()) + { + // Sleep 10 milliseconds + extapp_msleep(10); + } +} + +/** + * waitForKeyReleased: wait for no keys pressed + */ +void waitForKeyReleased() +{ + // Scan the keyboard until we get no keys pressed + while (extapp_scanKeyboard()) + { + extapp_msleep(10); + } +} + +/** + * waitForKeyReleasedTimeout: wait for no keys pressed, but with a timeout + * @param timeout int + */ +void waitForKeyReleasedTimeout(int timeout) +{ + // Scan the keyboard until we get no keys pressed, but exit if the timeout reached + while (extapp_scanKeyboard() && timeout > 0) + { + // Sleep 10 milliseconds + extapp_msleep(10); + // Decrease the timeout of 10 milliseconds + timeout -= 10; + } +} + +uint16_t rgb_16(uint8_t r, uint8_t g, uint8_t b) +{ + // Convert RGB to 16-bit color + return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3); +} + +/** + * getColor: get the color of a cell + * @param cell Cell + */ +uint16_t getColor(Cell cell) +{ + return !cell.isAlive ? 0x0000 : (cell.nthGen>5 ? 0xF000 : rgb_16(41*cell.nthGen + 50, 0, -41*cell.nthGen + 255)); +} + +/** + * initCells: init all cells to starting point + * @param cells Cell* +*/ +void initCells(Cell (*cells)[COLUMNS]) +{ + for (int i = 0; i < ROWS; i++) + { + for (int j = 0; j < COLUMNS; j++) + { + cells[i][j].nthGen = 0; + cells[i][j].isAlive = false; + } + } +} + +/** + * drawCellsColor: draw the cells on the screen + * @param cells Cell + */ +void drawCellsColor(Cell cells[ROWS][COLUMNS]) +{ + // Draw the cells on the screen + for (int i = 0; i < ROWS; i++) + { + for (int j = 0; j < COLUMNS; j++) + { + extapp_pushRectUniform(i * SIZE, j * SIZE, SIZE, SIZE, getColor(cells[i][j])); + } + } +} + +/** + * drawCellsMono: draw the cells on the screen + * @param cells Cell + */ +void drawCellsMono(Cell cells[ROWS][COLUMNS]) +{ + // Draw the cells on the screen + for (int i = 0; i < ROWS; i++) + { + for (int j = 0; j < COLUMNS; j++) + { + extapp_pushRectUniform(i * SIZE, j * SIZE, SIZE, SIZE, cells[i][j].isAlive ? 0xFFFF : 0x0000); + } + } +} + +int countNeighbors(Cell cells[ROWS][COLUMNS], int x, int y) +{ + // Count the number of alive neighbors + int count = 0; + for (int i = -1; i <= 1; i++) + { + for (int j = -1; j <= 1; j++) + { + if (i == 0 && j == 0) + continue; + int nx = (x + i + ROWS) % ROWS; + int ny = (y + j + COLUMNS) % COLUMNS; + if (nx < 0 || nx >= ROWS || ny < 0 || ny >= COLUMNS) + continue; + if (cells[nx][ny].isAlive) + count++; + } + } + return count; +} + +void drawCursor(Cell cells[ROWS][COLUMNS], coord_t coord) +{ + // Draw the cursor on the screen + extapp_pushRectUniform(coord.x * SIZE, coord.y * SIZE, SIZE, SIZE, 0xFF00); + extapp_pushRectUniform(coord.x * SIZE + 1, coord.y * SIZE + 1, SIZE - 2, SIZE - 2, cells[coord.x][coord.y].isAlive ? 0xFFFF : 0x0000); +} \ No newline at end of file diff --git a/apps/Golly/runningMode.c b/apps/Golly/runningMode.c new file mode 100644 index 000000000..7f5c71259 --- /dev/null +++ b/apps/Golly/runningMode.c @@ -0,0 +1,69 @@ +#include "inc/runningMode.h" +#include "extapp_api.h" + +void handleRunningMode(Cell (*cells)[COLUMNS], Cell (*newCells)[COLUMNS], bool *paused, int *speed, int *nGen, uint64_t *previous_scancode) +{ + uint64_t scancode = extapp_scanKeyboard(); + if (scancode != 0 && scancode != *previous_scancode) + { + switch (scancode) + { + case SCANCODE_Home: + *paused = true; // Arrêter la simulation + return; + case SCANCODE_Back: + *paused = true; + drawCellsMono(cells); + waitForKeyReleased(); + return; + case SCANCODE_Plus: + *speed = (*speed < 5) ? (*speed + 1) : *speed; + break; + case SCANCODE_Minus: + *speed = (*speed > 1) ? (*speed - 1) : *speed; + break; + case SCANCODE_Zero: + initCells(cells); + *paused = true; + *speed = 1; + drawCellsColor(cells); + break; + } + } + + drawCellsColor(cells); + + // Mise à jour des cellules + for (int i = 0; i < ROWS; i++) + { + for (int j = 0; j < COLUMNS; j++) + { + int aliveNeighbors = countNeighbors(cells, i, j); + if (cells[(i + ROWS) % ROWS][(j + COLUMNS) % COLUMNS].isAlive) + { + newCells[(i + ROWS) % ROWS][(j + COLUMNS) % COLUMNS].isAlive = (aliveNeighbors == 2 || aliveNeighbors == 3); + newCells[(i + ROWS) % ROWS][(j + COLUMNS) % COLUMNS].nthGen = cells[(i + ROWS) % ROWS][(j + COLUMNS) % COLUMNS].nthGen + 1; + } + else + { + newCells[(i + ROWS) % ROWS][(j + COLUMNS) % COLUMNS].isAlive = (aliveNeighbors == 3); + newCells[(i + ROWS) % ROWS][(j + COLUMNS) % COLUMNS].nthGen = 1; + } + } + } + + // Copie des nouvelles cellules dans l'ancien tableau + for (int i = 0; i < ROWS; i++) + { + for (int j = 0; j < COLUMNS; j++) + { + cells[i][j].isAlive = newCells[i][j].isAlive; + cells[i][j].nthGen = newCells[i][j].nthGen; + } + } + + extapp_msleep(-20 * (*speed) + 100); + (*nGen)++; + + *previous_scancode = scancode; +} diff --git a/apps/Golly/sources.mak b/apps/Golly/sources.mak new file mode 100644 index 000000000..6b376fcc8 --- /dev/null +++ b/apps/Golly/sources.mak @@ -0,0 +1,6 @@ +app_external_src += $(addprefix $(EXTAPP_PATH)/,\ + main.c \ + peripherals.c \ + runningMode.c \ + pausedMode.c \ +) diff --git a/apps/KhiCAS/Makefile b/apps/KhiCAS/Makefile index 5c336ee6b..d0b546749 100644 --- a/apps/KhiCAS/Makefile +++ b/apps/KhiCAS/Makefile @@ -5,52 +5,14 @@ AR=arm-none-eabi-ar CFLAGS=-DNDEBUG -ggdb3 -I$(API) -Os -mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard -fno-common -fdata-sections -ffunction-sections -fno-exceptions -fno-strict-aliasing -fno-common -fno-threadsafe-statics LDFLAGS=-Wl,-L$(API) -Wl,--gc-sections -Wl,--entry=entrypoint --specs=nano.specs -nostartfiles -Wl,-Ur -lc -lstdc++ -lm -lapi -lnosys -# Use the same shell for all the commands of a recipe. It applies to all the recipes of the Makefile. -.ONESHELL: - %.o: %.cpp $(CC) $(CFLAGS) -c $< -o $@ app.elf: src/main.o src/lib/libgiac.a src/lib/libmpfi.a src/lib/libmpfr.a src/lib/libgmp.a src/lib/libmicropy.a $(CC) $^ -o $@ $(CFLAGS) $(LDFLAGS) -libDirectory: - mkdir -p src/lib - mkdir -p src/include - -src/lib/libgmp.a src/include/gmp.h: libDirectory - cd src/gmp-6.2.1 -# Rebuild the Makefile because cleanall removed it. - ./configure --host=arm-none-eabi --disable-assembly CFLAGS="-Os -fdata-sections -ffunction-sections -DNDEBUG -mthumb -march=armv7e-m -mfloat-abi=hard -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -fno-strict-aliasing --specs=nosys.specs" -# Build the library. - make -# Copy the library to the build directory. - cp .libs/libgmp.a ../lib/ - cp gmp.h ../include/gmp.h - -src/lib/libmpfi.a src/include/mpfi.h: src/lib/libmpfr.a src/include/mpfr.h src/lib/libgmp.a src/include/gmp.h libDirectory - cd src/mpfi-1.5.4 -# Rebuild the Makefile because cleanall removed it. - autoreconf -# Quick and dirty hack for github pages to work -# Setup symlinks manually - mkdir -p build-aux - mkdir -p m4 - - ln -sf /usr/share/libtool/build-aux/ltmain.sh build-aux/ltmain.sh - ln -sf /usr/share/automake-1.16/missing build-aux/missing - ln -sf /usr/share/automake-1.16/config.sub build-aux/config.sub - ln -sf /usr/share/automake-1.16/compile build-aux/compile - ln -sf /usr/share/automake-1.16/config.guess build-aux/config.guess - ln -sf /usr/share/automake-1.16/test-driver build-aux/test-driver - ln -sf /usr/share/automake-1.16/install-sh build-aux/install-sh - ln -sf /usr/share/automake-1.16/ar-lib build-aux/ar-lib - ln -sf /usr/share/automake-1.16/depcomp build-aux/depcomp - ln -sf /usr/share/aclocal/ltoptions.m4 m4/ltoptions.m4 - ln -sf /usr/share/aclocal/ltsugar.m4 m4/ltsugar.m4 - ln -sf /usr/share/aclocal/libtool.m4 m4/libtool.m4 - ln -sf /usr/share/aclocal/lt~obsolete.m4 m4/lt~obsolete.m4 - ln -sf /usr/share/aclocal/ltversion.m4 m4/ltversion.m4 +src/lib/libgmp.a src/lib/libmpfi.a src/lib/libmpfr.a src/lib/libmicropy.a src/include/gmp.h src/include/mpfi.h src/include/mpfr.h: + ./buildDeps ./configure --with-mpfr=$(shell pwd)/src/ --with-gmp=$(shell pwd)/src/ --host=arm-none-eabi CFLAGS="-Os -fdata-sections -ffunction-sections -DNDEBUG -mthumb -march=armv7e-m -mfloat-abi=hard -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -fno-strict-aliasing --specs=nosys.specs" @@ -89,17 +51,3 @@ src/lib/libgiac.a: src/lib/libgmp.a src/lib/libmpfi.a src/lib/libmpfr.a src/incl clean: rm -f *.elf src/*.o src/include/*.h src/lib/*.a - -cleanall: clean -# Clean all the build directories. - cd src/gmp-6.2.1 - make distclean - cd ../mpfr-4.1.0 - make distclean - cd ../mpfi-1.5.4 - make distclean - rm aclocal.m4 - cd ../micropython-1.12/numworks - make clean - cd ../../giac-1.6.0/src - rm -f *.o *.a diff --git a/apps/KhiCAS/app.elf b/apps/KhiCAS/app.elf deleted file mode 100644 index c78186864..000000000 Binary files a/apps/KhiCAS/app.elf and /dev/null differ diff --git a/apps/KhiCAS/buildDeps b/apps/KhiCAS/buildDeps index fdc3d0558..82afa4924 100755 --- a/apps/KhiCAS/buildDeps +++ b/apps/KhiCAS/buildDeps @@ -5,35 +5,25 @@ set -e function build { ( cd src/gmp-6.2.1 - make distclean ./configure --host=arm-none-eabi --disable-assembly CFLAGS="$2" make -j $(nproc) cp .libs/libgmp.a ../lib/ cp gmp.h ../include/gmp.h + #make distclean ) ( cd src/mpfr-4.1.0 - # We need to configure the Makefile to can clean the build directory before building ./configure --with-gmp=../ --host=arm-none-eabi --disable-shared CFLAGS="$2" - # Autoreconf is required, becaise the version may have changed - autoreconf - make distclean - # Now, we need to reconfigure the Makefile, because the distclean command above removed the Makefile - ./configure --with-gmp=../ --host=arm-none-eabi --disable-shared CFLAGS="$2" - autoreconf - # Now, we can build the library make -j $(nproc) - # Copy the library to the correct location cp src/.libs/libmpfr.a ../lib/ - # Copy the header files to the correct location cp src/mpfr.h ../include/mpfr.h + #make distclean ) ( cd src/mpfi-1.5.4 - make distclean - autoreconf + # autoreconf # Quick and dirty hack for github pages to work # Setup symlinks manually mkdir -p build-aux @@ -56,16 +46,10 @@ function build { ./configure --with-mpfr=$(pwd)/../ --with-gmp=$(pwd)/../ --host=arm-none-eabi CFLAGS="$2" - # Remove aclocal.m4, because it will create conflicts with the system version - rm aclocal.m4 - # Reconfigure the project, to recreate aclocal.m4 - autoreconf - # Build the library make -j $(nproc) - # Copy the library to the correct location cp src/.libs/libmpfi.a ../lib/ - # Copy the header files to the correct location cp src/mpfi.h ../include/mpfi.h + #make distclean #rm -r build-aux #rm -r m4 @@ -73,14 +57,9 @@ function build { ( cd src/micropython-1.12/numworks - make clean - # We need to use a script to build MicroPython, because the make command crashes in MicroPython because it tries to link without the required libraries ./mklib ) } -echo "buildDeps is deprecated. Use Makefile instead." -exit 1 - # build n0100 "-Os -fdata-sections -ffunction-sections -DNDEBUG -mthumb -march=armv7e-m -mfloat-abi=hard -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -fno-strict-aliasing --specs=nosys.specs" build n0110 "-Os -fdata-sections -ffunction-sections -DNDEBUG -mthumb -march=armv7e-m -mfloat-abi=hard -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -fno-strict-aliasing --specs=nosys.specs" diff --git a/apps/KhiCAS/buildGiac b/apps/KhiCAS/buildGiac index 2a3a973de..2863ca520 100755 --- a/apps/KhiCAS/buildGiac +++ b/apps/KhiCAS/buildGiac @@ -12,9 +12,6 @@ function build { ) } -echo "buildGiac is deprecated. Use Makefile instead." -exit 1 - #build n0100 build n0110 #build simulator diff --git a/apps/KhiCAS/src/giac-1.6.0/aclocal.m4 b/apps/KhiCAS/src/giac-1.6.0/aclocal.m4 deleted file mode 100644 index 9ca75aa71..000000000 --- a/apps/KhiCAS/src/giac-1.6.0/aclocal.m4 +++ /dev/null @@ -1,1027 +0,0 @@ -# generated automatically by aclocal 1.11.6 -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, -# Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, -[m4_warning([this file was generated for autoconf 2.69. -You have another version of autoconf. It may work, but is not guaranteed to. -If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically `autoreconf'.])]) - -# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software -# Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 1 - -# AM_AUTOMAKE_VERSION(VERSION) -# ---------------------------- -# Automake X.Y traces this macro to ensure aclocal.m4 has been -# generated from the m4 files accompanying Automake X.Y. -# (This private macro should not be called outside this file.) -AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.11' -dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to -dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11.6], [], - [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl -]) - -# _AM_AUTOCONF_VERSION(VERSION) -# ----------------------------- -# aclocal traces this macro to find the Autoconf version. -# This is a private macro too. Using m4_define simplifies -# the logic in aclocal, which can simply ignore this definition. -m4_define([_AM_AUTOCONF_VERSION], []) - -# AM_SET_CURRENT_AUTOMAKE_VERSION -# ------------------------------- -# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. -# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11.6])dnl -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) - -# AM_AUX_DIR_EXPAND -*- Autoconf -*- - -# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 1 - -# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to -# `$srcdir', `$srcdir/..', or `$srcdir/../..'. -# -# Of course, Automake must honor this variable whenever it calls a -# tool from the auxiliary directory. The problem is that $srcdir (and -# therefore $ac_aux_dir as well) can be either absolute or relative, -# depending on how configure is run. This is pretty annoying, since -# it makes $ac_aux_dir quite unusable in subdirectories: in the top -# source directory, any form will work fine, but in subdirectories a -# relative path needs to be adjusted first. -# -# $ac_aux_dir/missing -# fails when called from a subdirectory if $ac_aux_dir is relative -# $top_srcdir/$ac_aux_dir/missing -# fails if $ac_aux_dir is absolute, -# fails when called from a subdirectory in a VPATH build with -# a relative $ac_aux_dir -# -# The reason of the latter failure is that $top_srcdir and $ac_aux_dir -# are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is `.', but things will broke when you -# start a VPATH build or use an absolute $srcdir. -# -# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, -# iff we strip the leading $srcdir from $ac_aux_dir. That would be: -# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` -# and then we would define $MISSING as -# MISSING="\${SHELL} $am_aux_dir/missing" -# This will work as long as MISSING is not called from configure, because -# unfortunately $(top_srcdir) has no meaning in configure. -# However there are other variables, like CC, which are often used in -# configure, and could therefore not use this "fixed" $ac_aux_dir. -# -# Another solution, used here, is to always expand $ac_aux_dir to an -# absolute PATH. The drawback is that using absolute paths prevent a -# configured tree to be moved without reconfiguration. - -AC_DEFUN([AM_AUX_DIR_EXPAND], -[dnl Rely on autoconf to set up CDPATH properly. -AC_PREREQ([2.50])dnl -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` -]) - -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 9 - -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ(2.52)dnl - ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE])dnl -AC_SUBST([$1_FALSE])dnl -_AM_SUBST_NOTMAKE([$1_TRUE])dnl -_AM_SUBST_NOTMAKE([$1_FALSE])dnl -m4_define([_AM_COND_VALUE_$1], [$2])dnl -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([[conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]]) -fi])]) - -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, -# 2010, 2011 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 12 - -# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be -# written in clear, in which case automake, when reading aclocal.m4, -# will think it sees a *use*, and therefore will trigger all it's -# C support machinery. Also note that it means that autoscan, seeing -# CC etc. in the Makefile, will ask for an AC_PROG_CC use... - - -# _AM_DEPENDENCIES(NAME) -# ---------------------- -# See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "GCJ", or "OBJC". -# We try a few techniques and use that to set a single cache variable. -# -# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was -# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular -# dependency, and given that the user is not expected to run this macro, -# just rely on AC_PROG_CC. -AC_DEFUN([_AM_DEPENDENCIES], -[AC_REQUIRE([AM_SET_DEPDIR])dnl -AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl -AC_REQUIRE([AM_MAKE_INCLUDE])dnl -AC_REQUIRE([AM_DEP_TRACK])dnl - -ifelse([$1], CC, [depcc="$CC" am_compiler_list=], - [$1], CXX, [depcc="$CXX" am_compiler_list=], - [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], UPC, [depcc="$UPC" am_compiler_list=], - [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) - -AC_CACHE_CHECK([dependency style of $depcc], - [am_cv_$1_dependencies_compiler_type], -[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - rm -rf conftest.dir - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_$1_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` - fi - am__universal=false - m4_case([$1], [CC], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac], - [CXX], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac]) - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok `-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_$1_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_$1_dependencies_compiler_type=none -fi -]) -AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) -AM_CONDITIONAL([am__fastdep$1], [ - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) -]) - - -# AM_SET_DEPDIR -# ------------- -# Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES -AC_DEFUN([AM_SET_DEPDIR], -[AC_REQUIRE([AM_SET_LEADING_DOT])dnl -AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl -]) - - -# AM_DEP_TRACK -# ------------ -AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE(dependency-tracking, -[ --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors]) -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' - am__nodep='_no' -fi -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH])dnl -_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl -AC_SUBST([am__nodep])dnl -_AM_SUBST_NOTMAKE([am__nodep])dnl -]) - -# Generate code to set up dependency tracking. -*- Autoconf -*- - -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -#serial 5 - -# _AM_OUTPUT_DEPENDENCY_COMMANDS -# ------------------------------ -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[{ - # Autoconf 2.62 quotes --file arguments for eval, but not when files - # are listed without --file. Let's play safe and only enable the eval - # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac - shift - for mf - do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line - # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done - done -} -])# _AM_OUTPUT_DEPENDENCY_COMMANDS - - -# AM_OUTPUT_DEPENDENCY_COMMANDS -# ----------------------------- -# This macro should only be invoked once -- use via AC_REQUIRE. -# -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each `.P' file that we will -# need in order to bootstrap the dependency handling code. -AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], -[AC_CONFIG_COMMANDS([depfiles], - [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) - -# Do all the work for Automake. -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 16 - -# This macro actually does too much. Some checks are only needed if -# your package does certain things. But this isn't really a big deal. - -# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) -# AM_INIT_AUTOMAKE([OPTIONS]) -# ----------------------------------------------- -# The call with PACKAGE and VERSION arguments is the old style -# call (pre autoconf-2.50), which is being phased out. PACKAGE -# and VERSION should now be passed to AC_INIT and removed from -# the call to AM_INIT_AUTOMAKE. -# We support both call styles for the transition. After -# the next Automake release, Autoconf can make the AC_INIT -# arguments mandatory, and then we can depend on a new Autoconf -# release and drop the old call support. -AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.62])dnl -dnl Autoconf wants to disallow AM_ names. We explicitly allow -dnl the ones we care about. -m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl -AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -AC_REQUIRE([AC_PROG_INSTALL])dnl -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi -AC_SUBST([CYGPATH_W]) - -# Define the identity of the package. -dnl Distinguish between old-style and new-style calls. -m4_ifval([$2], -[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl - AC_SUBST([PACKAGE], [$1])dnl - AC_SUBST([VERSION], [$2])], -[_AM_SET_OPTIONS([$1])dnl -dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, - [m4_fatal([AC_INIT should be called with package and version arguments])])dnl - AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl - AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl - -_AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) - AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl - -# Some tools Automake needs. -AC_REQUIRE([AM_SANITY_CHECK])dnl -AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) -AM_MISSING_PROG(AUTOCONF, autoconf) -AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) -AM_MISSING_PROG(AUTOHEADER, autoheader) -AM_MISSING_PROG(MAKEINFO, makeinfo) -AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AM_PROG_MKDIR_P])dnl -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -AC_REQUIRE([AC_PROG_AWK])dnl -AC_REQUIRE([AC_PROG_MAKE_SET])dnl -AC_REQUIRE([AM_SET_LEADING_DOT])dnl -_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], - [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], - [_AM_PROG_TAR([v7])])]) -_AM_IF_OPTION([no-dependencies],, -[AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES(CC)], - [define([AC_PROG_CC], - defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl -AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES(CXX)], - [define([AC_PROG_CXX], - defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES(OBJC)], - [define([AC_PROG_OBJC], - defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl -]) -_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl -dnl The `parallel-tests' driver may need to know about EXEEXT, so add the -dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro -dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. -AC_CONFIG_COMMANDS_PRE(dnl -[m4_provide_if([_AM_COMPILER_EXEEXT], - [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl -]) - -dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not -dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further -dnl mangled by Autoconf and run in a shell conditional statement. -m4_define([_AC_COMPILER_EXEEXT], -m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) - - -# When config.status generates a header, we must update the stamp-h file. -# This file resides in the same directory as the config header -# that is generated. The stamp files are numbered to have different names. - -# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the -# loop where config.status creates the headers, so we can generate -# our stamp files there. -AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], -[# Compute $1's index in $config_headers. -_am_arg=$1 -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $_am_arg | $_am_arg:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) - -# Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, -# Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 1 - -# AM_PROG_INSTALL_SH -# ------------------ -# Define $install_sh. -AC_DEFUN([AM_PROG_INSTALL_SH], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac -fi -AC_SUBST(install_sh)]) - -# Copyright (C) 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 2 - -# Check whether the underlying file-system supports filenames -# with a leading dot. For instance MS-DOS doesn't. -AC_DEFUN([AM_SET_LEADING_DOT], -[rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null -AC_SUBST([am__leading_dot])]) - -# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 5 - -# AM_PROG_LEX -# ----------- -# Autoconf leaves LEX=: if lex or flex can't be found. Change that to a -# "missing" invocation, for better error output. -AC_DEFUN([AM_PROG_LEX], -[AC_PREREQ(2.50)dnl -AC_REQUIRE([AM_MISSING_HAS_RUN])dnl -AC_REQUIRE([AC_PROG_LEX])dnl -if test "$LEX" = :; then - LEX=${am_missing_run}flex -fi]) - -# Check to see how 'make' treats includes. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 4 - -# AM_MAKE_INCLUDE() -# ----------------- -# Check to see how make treats includes. -AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from `make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) - -# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- - -# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 6 - -# AM_MISSING_PROG(NAME, PROGRAM) -# ------------------------------ -AC_DEFUN([AM_MISSING_PROG], -[AC_REQUIRE([AM_MISSING_HAS_RUN]) -$1=${$1-"${am_missing_run}$2"} -AC_SUBST($1)]) - - -# AM_MISSING_HAS_RUN -# ------------------ -# Define MISSING if not defined so far and test if it supports --run. -# If it does, set am_missing_run to use it, otherwise, to nothing. -AC_DEFUN([AM_MISSING_HAS_RUN], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([missing])dnl -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - AC_MSG_WARN([`missing' script is too old or missing]) -fi -]) - -# Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, -# Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 1 - -# AM_PROG_MKDIR_P -# --------------- -# Check for `mkdir -p'. -AC_DEFUN([AM_PROG_MKDIR_P], -[AC_PREREQ([2.60])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, -dnl while keeping a definition of mkdir_p for backward compatibility. -dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. -dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of -dnl Makefile.ins that do not define MKDIR_P, so we do our own -dnl adjustment using top_builddir (which is defined more often than -dnl MKDIR_P). -AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl -case $mkdir_p in - [[\\/$]]* | ?:[[\\/]]*) ;; - */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; -esac -]) - -# Helper functions for option handling. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software -# Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 5 - -# _AM_MANGLE_OPTION(NAME) -# ----------------------- -AC_DEFUN([_AM_MANGLE_OPTION], -[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) - -# _AM_SET_OPTION(NAME) -# -------------------- -# Set option NAME. Presently that only means defining a flag for this option. -AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) - -# _AM_SET_OPTIONS(OPTIONS) -# ------------------------ -# OPTIONS is a space-separated list of Automake options. -AC_DEFUN([_AM_SET_OPTIONS], -[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) - -# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) -# ------------------------------------------- -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -AC_DEFUN([_AM_IF_OPTION], -[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) - -# Check to make sure that the build environment is sane. -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 5 - -# AM_SANITY_CHECK -# --------------- -AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) -# Just in case -sleep 1 -echo timestamp > conftest.file -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[[\\\"\#\$\&\'\`$am_lf]]*) - AC_MSG_ERROR([unsafe absolute working directory name]);; -esac -case $srcdir in - *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; -esac - -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken -alias in your environment]) - fi - - test "$[2]" = conftest.file - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! -Check your system clock]) -fi -AC_MSG_RESULT(yes)]) - -# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 1 - -# AM_PROG_INSTALL_STRIP -# --------------------- -# One issue with vendor `install' (even GNU) is that you can't -# specify the program used to strip binaries. This is especially -# annoying in cross-compiling environments, where the build's strip -# is unlikely to handle the host's binaries. -# Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in `make install-strip', and initialize -# STRIPPROG with the value of the STRIP variable (set by the user). -AC_DEFUN([AM_PROG_INSTALL_STRIP], -[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be `maybe'. -if test "$cross_compiling" != no; then - AC_CHECK_TOOL([STRIP], [strip], :) -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" -AC_SUBST([INSTALL_STRIP_PROGRAM])]) - -# Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 3 - -# _AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- -# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. -# This macro is traced by Automake. -AC_DEFUN([_AM_SUBST_NOTMAKE]) - -# AM_SUBST_NOTMAKE(VARIABLE) -# -------------------------- -# Public sister of _AM_SUBST_NOTMAKE. -AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) - -# Check how to create a tarball. -*- Autoconf -*- - -# Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 2 - -# _AM_PROG_TAR(FORMAT) -# -------------------- -# Check how to create a tarball in format FORMAT. -# FORMAT should be one of `v7', `ustar', or `pax'. -# -# Substitute a variable $(am__tar) that is a command -# writing to stdout a FORMAT-tarball containing the directory -# $tardir. -# tardir=directory && $(am__tar) > result.tar -# -# Substitute a variable $(am__untar) that extract such -# a tarball read from stdin. -# $(am__untar) < result.tar -AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AC_SUBST([AMTAR], ['$${TAR-tar}']) -m4_if([$1], [v7], - [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], - [m4_case([$1], [ustar],, [pax],, - [m4_fatal([Unknown tar format])]) -AC_MSG_CHECKING([how to create a $1 tar archive]) -# Loop over all known methods to create a tar archive until one works. -_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' -_am_tools=${am_cv_prog_tar_$1-$_am_tools} -# Do not fold the above two line into one, because Tru64 sh and -# Solaris sh will not grok spaces in the rhs of `-'. -for _am_tool in $_am_tools -do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; - do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break - - # tar/untar a dummy directory, and stop if the command works - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi -done -rm -rf conftest.dir - -AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) -AC_MSG_RESULT([$am_cv_prog_tar_$1])]) -AC_SUBST([am__tar]) -AC_SUBST([am__untar]) -]) # _AM_PROG_TAR - -m4_include([m4/codeset.m4]) -m4_include([m4/gettext.m4]) -m4_include([m4/glibc2.m4]) -m4_include([m4/glibc21.m4]) -m4_include([m4/iconv.m4]) -m4_include([m4/intdiv0.m4]) -m4_include([m4/intmax.m4]) -m4_include([m4/inttypes-pri.m4]) -m4_include([m4/inttypes.m4]) -m4_include([m4/inttypes_h.m4]) -m4_include([m4/isc-posix.m4]) -m4_include([m4/lcmessage.m4]) -m4_include([m4/lib-ld.m4]) -m4_include([m4/lib-link.m4]) -m4_include([m4/lib-prefix.m4]) -m4_include([m4/libtool.m4]) -m4_include([m4/longdouble.m4]) -m4_include([m4/longlong.m4]) -m4_include([m4/ltoptions.m4]) -m4_include([m4/ltsugar.m4]) -m4_include([m4/ltversion.m4]) -m4_include([m4/lt~obsolete.m4]) -m4_include([m4/nls.m4]) -m4_include([m4/po.m4]) -m4_include([m4/printf-posix.m4]) -m4_include([m4/progtest.m4]) -m4_include([m4/signed.m4]) -m4_include([m4/size_max.m4]) -m4_include([m4/stdint_h.m4]) -m4_include([m4/uintmax_t.m4]) -m4_include([m4/ulonglong.m4]) -m4_include([m4/wchar_t.m4]) -m4_include([m4/wint_t.m4]) -m4_include([m4/xsize.m4]) -m4_include([acinclude.m4]) diff --git a/apps/KhiCAS/src/giac-1.6.0/src/alg_ext.cc b/apps/KhiCAS/src/giac-1.6.0/src/alg_ext.cc index b24a5fa6a..a34c71087 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/alg_ext.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/alg_ext.cc @@ -120,13 +120,19 @@ namespace giac { return true; } + gen makeline(const gen & a,const gen &b){ + return gen(makevecteur(a,b),_LINE__VECT); + } + vecteur galoisconj(const vecteur & v,GIAC_CONTEXT){ vecteur res; if (galoisconj_cached(v,res)) return res; gen g=symb_horner(v,vx_var); +#ifndef FXCG if (pari_galoisconj(g,res,contextptr)) return res; +#endif if (int(v.size())>MAX_COMMON_ALG_EXT_ORDER_SIZE) return res; // factor v over rootof(v) if degree is small g=_factors(makesequence(g,rootof(g,contextptr)),contextptr); @@ -728,10 +734,10 @@ namespace giac { if (!rootof_trylock()){ if (lvptr){ gen vexpr=r2e(v,vecteur(lvptr->begin()+1,lvptr->end()),contextptr); - symbolic_rootof_list()[vexpr]=gaa+k*gbb; + symbolic_rootof_list()[vexpr]=k*gaa+gbb; } else - symbolic_rootof_list()[v]=gaa+k*gbb; + symbolic_rootof_list()[v]=k*gaa+gbb; rootof_unlock(); } } @@ -1326,6 +1332,7 @@ namespace giac { static define_unary_function_eval (__max_algext,&max_algext,_max_algext_s); define_unary_function_ptr5( at_max_algext ,alias_at_max_algext,&__max_algext,0,true); +#ifndef FXCG // set_timeout(), set_timeout(15), set_timeout(20,30) gen set_timeout(const gen & args,GIAC_CONTEXT){ gen g=args; @@ -1362,7 +1369,8 @@ namespace giac { static const char _set_timeout_s []="set_timeout"; static define_unary_function_eval (__set_timeout,&set_timeout,_set_timeout_s); define_unary_function_ptr5( at_set_timeout ,alias_at_set_timeout,&__set_timeout,0,true); - +#endif + static vecteur sturm(const gen & g){ if (g.type!=_POLY) return vecteur(1,g); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/alg_ext.h b/apps/KhiCAS/src/giac-1.6.0/src/alg_ext.h index 4a64d3de2..21c6a641b 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/alg_ext.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/alg_ext.h @@ -30,6 +30,7 @@ namespace giac { struct unary_function_ptr; struct symbolic; + gen makeline(const gen & a,const gen &b); bool proot_cached(const vecteur & v,double eps,vecteur & res); bool proot_cache(const vecteur & v,double eps,const vecteur & res); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/config.h b/apps/KhiCAS/src/giac-1.6.0/src/config.h index ea739610e..5188900a4 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/config.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/config.h @@ -455,7 +455,7 @@ #define PACKAGE_NAME "giac" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "giac 1.7.0" +#define PACKAGE_STRING "giac 1.9.0" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "giac" @@ -464,7 +464,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.7.0" +#define PACKAGE_VERSION "1.9.0" /* Define if exists and defines unusable PRI* macros. */ /* #undef PRI_MACROS_BROKEN */ @@ -506,7 +506,7 @@ /* #undef USE_OPENGL32 */ /* Version number of package */ -#define VERSION "1.7.0" +#define VERSION "1.9.0" /* Define to 1 if the X Window System is missing or not being used. */ #define X_DISPLAY_MISSING 1 diff --git a/apps/KhiCAS/src/giac-1.6.0/src/config.h~ b/apps/KhiCAS/src/giac-1.6.0/src/config.h~ new file mode 100755 index 000000000..ea739610e --- /dev/null +++ b/apps/KhiCAS/src/giac-1.6.0/src/config.h~ @@ -0,0 +1,542 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define if header is available */ +#define C11_UNORDERED_MAP 1 + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +/* #undef CRAY_STACKSEG_END */ + +/* Define to 1 if using `alloca.c'. */ +#define C_ALLOCA 1 + +/* Set if debugging is enabled */ +#define DEBUG_SUPPORT /**/ + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +#define ENABLE_NLS 1 + +/* Define if header is aviailable */ +#define EXT_HASH_MAP 1 + +/* Define if header is aviailable */ +#define HASH_MAP 1 + +/* Define to 1 if you have `alloca', as a function or macro. */ +/* #undef HAVE_ALLOCA */ + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +/* #undef HAVE_ALLOCA_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ARGZ_H 1 + +/* Define to 1 if you have the `asprintf' function. */ +/* #undef HAVE_ASPRINTF */ + +/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the + CoreFoundation framework. */ +/* #undef HAVE_CFLOCALECOPYCURRENT */ + +/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in + the CoreFoundation framework. */ +/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */ + +/* Define if the GNU dcgettext() function is already present or preinstalled. + */ +/* #undef HAVE_DCGETTEXT */ + +/* Define to 1 if you have the declaration of `feof_unlocked', and to 0 if you + don't. */ +#define HAVE_DECL_FEOF_UNLOCKED 1 + +/* Define to 1 if you have the declaration of `fgets_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_FGETS_UNLOCKED 0 + +/* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you + don't. */ +#define HAVE_DECL_GETC_UNLOCKED 1 + +/* Define to 1 if you have the declaration of `_snprintf', and to 0 if you + don't. */ +#define HAVE_DECL__SNPRINTF 0 + +/* Define to 1 if you have the declaration of `_snwprintf', and to 0 if you + don't. */ +#define HAVE_DECL__SNWPRINTF 0 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Define to 1 if you have the `fwprintf' function. */ +/* #undef HAVE_FWPRINTF */ + +/* Define to 1 if you have the `getcwd' function. */ +/* #undef HAVE_GETCWD */ + +/* Define to 1 if you have the `getegid' function. */ +/* #undef HAVE_GETEGID */ + +/* Define to 1 if you have the `geteuid' function. */ +/* #undef HAVE_GETEUID */ + +/* Define to 1 if you have the `getgid' function. */ +/* #undef HAVE_GETGID */ + +/* Define to 1 if you have the `getpagesize' function. */ +/* #undef HAVE_GETPAGESIZE */ + +/* Define to 1 if you have the `getpid' function. */ +/* #undef HAVE_GETPID */ + +/* Define to 1 if you have the `getpwuid' function. */ +/* #undef HAVE_GETPWUID */ + +/* Define if the GNU gettext() function is already present or preinstalled. */ +/* #undef HAVE_GETTEXT */ + +/* Define to 1 if you have the `getuid' function. */ +/* #undef HAVE_GETUID */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GMPXX_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GMP_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GSL_GSL_BLAS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GSL_GSL_EIGEN_H */ + +/* Define if you have the iconv() function. */ +/* #undef HAVE_ICONV */ + +/* Define if you have the 'intmax_t' type in or . */ +#define HAVE_INTMAX_T 1 + +/* Define if exists and doesn't clash with . */ +#define HAVE_INTTYPES_H 1 + +/* Define if exists, doesn't clash with , and + declares uintmax_t. */ +#define HAVE_INTTYPES_H_WITH_UINTMAX 1 + +/* Define if you have and nl_langinfo(CODESET). */ +/* #undef HAVE_LANGINFO_CODESET */ + +/* Define if your file defines LC_MESSAGES. */ +/* #undef HAVE_LC_MESSAGES */ + +/* Define to 1 if you have the `ao' library (-lao). */ +/* #undef HAVE_LIBAO */ + +/* Define to 1 if you have the `blas' library (-lblas). */ +/* #undef HAVE_LIBBLAS */ + +/* Define to 1 if you have the `cocoa' library (-lcocoa). */ +/* #undef HAVE_LIBCOCOA */ + +/* Define to 1 if you have the `dl' library (-ldl). */ +/* #undef HAVE_LIBDL */ + +/* Define to 1 if you have the `fltk' library (-lfltk). */ +/* #undef HAVE_LIBFLTK */ + +/* Define to 1 if you have the `fltk_gl' library (-lfltk_gl). */ +/* #undef HAVE_LIBFLTK_GL */ + +/* Define to 1 if you have the `fltk_images' library (-lfltk_images). */ +/* #undef HAVE_LIBFLTK_IMAGES */ + +/* Now defined if fltk is available */ +/* #undef HAVE_LIBFLVW */ + +/* Define to 1 if you have the `fontconfig' library (-lfontconfig). */ +/* #undef HAVE_LIBFONTCONFIG */ + +/* Define to 1 if you have the `gc' library (-lgc). */ +/* #undef HAVE_LIBGC */ + +/* Define to 1 if you have the `gfortran' library (-lgfortran). */ +/* #undef HAVE_LIBGFORTRAN */ + +/* Define to 1 if you have the `GL' library (-lGL). */ +/* #undef HAVE_LIBGL */ + +/* Define to 1 if you have the `gmp' library (-lgmp). */ +#define HAVE_LIBGMP + +/* Define to 1 if you have the `gmpxx' library (-lgmpxx). */ +/* #undef HAVE_LIBGMPXX */ + +/* Define to 1 if you have the `gsl' library (-lgsl). */ +/* #undef HAVE_LIBGSL */ + +/* Define to 1 if you have the `gslcblas' library (-lgslcblas). */ +/* #undef HAVE_LIBGSLCBLAS */ + +/* Define to 1 if you have the `intl' library (-lintl). */ +/* #undef HAVE_LIBINTL */ + +/* Define to 1 if you have the `intl.dll' library (-lintl.dll). */ +/* #undef HAVE_LIBINTL_DLL */ + +/* Define to 1 if you have the `jpeg' library (-ljpeg). */ +/* #undef HAVE_LIBJPEG */ + +/* Define to 1 if you have the `lapack' library (-llapack). */ +/* #undef HAVE_LIBLAPACK */ + +/* Define to 1 if you have the `m' library (-lm). */ +/* #undef HAVE_LIBM */ + +/* Define to 1 if you have the `mpfi' library (-lmpfi). */ +#define HAVE_LIBMPFI 1 + +/* Define to 1 if you have the `mpfr' library (-lmpfr). */ +#define HAVE_LIBMPFR 1 + +/* Define to 1 if you have the `ntl' library (-lntl). */ +/* #undef HAVE_LIBNTL */ + +/* Define to 1 if you have the `pari' library (-lpari). */ +/* #undef HAVE_LIBPARI */ + +/* Define to 1 if you have the `png' library (-lpng). */ +/* #undef HAVE_LIBPNG */ + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +/* #undef HAVE_LIBPTHREAD */ + +/* Define to 1 if you have the `readline' library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `rt' library (-lrt). */ +/* #undef HAVE_LIBRT */ + +/* Define to 1 if you have the `tommath' library (-ltommath). */ +/* #undef HAVE_LIBTOMMATH */ + +/* Define to 1 if you have the `X11' library (-lX11). */ +/* #undef HAVE_LIBX11 */ + +/* Define to 1 if you have the `Xext' library (-lXext). */ +/* #undef HAVE_LIBXEXT */ + +/* Define to 1 if you have the `Xft' library (-lXft). */ +/* #undef HAVE_LIBXFT */ + +/* Define to 1 if you have the `Xinerama' library (-lXinerama). */ +/* #undef HAVE_LIBXINERAMA */ + +/* Define to 1 if you have the `z' library (-lz). */ +/* #undef HAVE_LIBZ */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define if you have the 'long double' type. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define if you have the 'long long' type. */ +/* #undef HAVE_LONG_LONG */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MALLOC_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mempcpy' function. */ +/* #undef HAVE_MEMPCPY */ + +/* Define to 1 if you have a working `mmap' system call. */ +/* #undef HAVE_MMAP */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MPFI_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MPFR_H 1 + +/* Define to 1 if you have the `mpfr_set_str_raw' function. */ +/* #define HAVE_MPFR_SET_STR_RAW 1 */ + +/* Define to 1 if you have the `munmap' function. */ +/* #undef HAVE_MUNMAP */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NL_TYPES_H */ + +/* Set if getcwd() function is NOT available */ +#define HAVE_NO_CWD 1 + +/* Set if getpwuid() function is NOT available */ +#define HAVE_NO_HOME_DIRECTORY 1 + +/* Set if pwd.h is NOT available */ +/* #undef HAVE_NO_PWD_H */ + +/* Set if getpid() function is NOT available */ +#define HAVE_NO_SIGNAL_H 1 + +/* Set if system() function is NOT available */ +#define HAVE_NO_SYSTEM 1 + +/* Set if is NOT available */ +/* #undef HAVE_NO_SYS_RESOURCE_WAIT_H */ + +/* Set if is NOT available */ +/* #undef HAVE_NO_SYS_TIMES_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PARI_PARI_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PNG_H */ + +/* Define if your printf() function supports format strings with positions. */ +#define HAVE_POSIX_PRINTF 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `putenv' function. */ +/* #undef HAVE_PUTENV */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_READLINE_HISTORY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_READLINE_READLINE_H */ + +/* Define to 1 if you have the `setenv' function. */ +/* #undef HAVE_SETENV */ + +/* Define to 1 if you have the `setlocale' function. */ +/* #undef HAVE_SETLOCALE */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `snprintf' function. */ +/* #undef HAVE_SNPRINTF */ + +/* Set to enable semi-classical routines */ +/* #undef HAVE_SSCL */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SSTREAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define if exists, doesn't clash with , and declares + uintmax_t. */ +#define HAVE_STDINT_H_WITH_UINTMAX 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stpcpy' function. */ +/* #undef HAVE_STPCPY */ + +/* Define to 1 if you have the `strcasecmp' function. */ +/* #undef HAVE_STRCASECMP */ + +/* Define to 1 if you have the `strdup' function. */ +/* #undef HAVE_STRDUP */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strtoul' function. */ +/* #undef HAVE_STRTOUL */ + +/* Define to 1 if you have the `sysconf' function. */ +/* #undef HAVE_SYSCONF */ + +/* Define to 1 if you have the `system' function. */ +/* #undef HAVE_SYSTEM */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +// #define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the `tgetent' function. */ +/* #undef HAVE_TGETENT */ + +/* Define to 1 if you have the header file. */ +#define HAVE_TOMMATH_H 1 + +/* Define to 1 if you have the `tsearch' function. */ +/* #undef HAVE_TSEARCH */ + +/* Define if you have the 'uintmax_t' type in or . */ +#define HAVE_UINTMAX_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the 'unsigned long long' type. */ +/* #undef HAVE_UNSIGNED_LONG_LONG */ + +/* Define if you have the 'wchar_t' type. */ +#define HAVE_WCHAR_T 1 + +/* Define to 1 if you have the `wcslen' function. */ +/* #undef HAVE_WCSLEN */ + +/* Define if you have the 'wint_t' type. */ +#define HAVE_WINT_T 1 + +/* Define to 1 if you have the `__argz_count' function. */ +/* #undef HAVE___ARGZ_COUNT */ + +/* Define to 1 if you have the `__argz_next' function. */ +/* #undef HAVE___ARGZ_NEXT */ + +/* Define to 1 if you have the `__argz_stringify' function. */ +/* #undef HAVE___ARGZ_STRINGIFY */ + +/* Define to 1 if you have the `__fsetlocking' function. */ +/* #undef HAVE___FSETLOCKING */ + +/* Define as const if the declaration of iconv() needs const. */ +/* #undef ICONV_CONST */ + +/* Define if integer division by zero raises signal SIGFPE. */ +#define INTDIV0_RAISES_SIGFPE 0 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "giac" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "giac" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "giac 1.7.0" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "giac" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.7.0" + +/* Define if exists and defines unusable PRI* macros. */ +/* #undef PRI_MACROS_BROKEN */ + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* Define as the maximum value of type 'size_t', if the system doesn't define + it. */ +/* #undef SIZE_MAX */ + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#define STACK_DIRECTION 0 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if header is available */ +#define UNORDERED_MAP 1 + +/* Replace GMP by tommath */ +/* #define USE_GMP_REPLACEMENTS */ + +/* Defined if fltk has OpenGL enabled */ +/* #undef USE_OPENGL32 */ + +/* Version number of package */ +#define VERSION "1.7.0" + +/* Define to 1 if the X Window System is missing or not being used. */ +#define X_DISPLAY_MISSING 1 + +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +/* #undef YYTEXT_POINTER */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define as the type of the result of subtracting two pointers, if the system + doesn't define it. */ +/* #undef ptrdiff_t */ + +/* Define to empty if the C compiler doesn't support this keyword. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to unsigned long or unsigned long long if and + don't define. */ +/* #undef uintmax_t */ diff --git a/apps/KhiCAS/src/giac-1.6.0/src/derive.cc b/apps/KhiCAS/src/giac-1.6.0/src/derive.cc index ddddfda55..f982f70a7 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/derive.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/derive.cc @@ -808,6 +808,8 @@ namespace giac { step_infolevel(contextptr)=savestep; gprintf(step_extrema1,gettext("Derivative of %gen with respect to %gen is %gen\nSolving %gen with respect to %gen answer %gen"),makevecteur(arg,var,d,deq,var,s.type==_VECT?change_subtype(s,_SEQ__VECT):s),contextptr); calc_mode(c,contextptr); + if (c==1 && s.type==_VECT) + s.subtype=0; vecteur ls=lidnt(s); for (int i=0;i=1 && range.front().type==_VECT){ + range=*range.front()._VECTptr; + if (range.size()==2 && range[0]==minus_inf && range[1]==plus_inf){ + gen periode; + if (is_periodic(f,x,periode,contextptr)){ + gen hyp=symb_and(symbolic(at_superieur_egal,makesequence(x,0)),symbolic(at_inferieur_egal,makesequence(x,periode))); + *logptr(contextptr) << "Periodic function. Auto assume" << hyp << "\n"; + giac_assume(hyp,contextptr); + } + } + } + } gen _domain(const gen & args,GIAC_CONTEXT){ if (is_undef(args)) return args; - if (args.type!=_VECT || args.subtype!=_SEQ__VECT) - return domain(args,vx_var,0,contextptr); + if (args.type!=_VECT || args.subtype!=_SEQ__VECT){ + gen xval=assumeeval(vx_var,contextptr); + domain_auto_assume(args,vx_var,contextptr); + gen res=domain(args,vx_var,0,contextptr); + restorepurge(xval,vx_var,contextptr); + return res; + } vecteur v=*args._VECTptr; if (v.size()<2) return gensizeerr(contextptr); @@ -1123,7 +1145,11 @@ namespace giac { v.push_back(0); if (v[2].type!=_INT_) return gensizeerr(contextptr); - return domain(v[0],v[1],v[2].val,contextptr); + gen xval=assumeeval(vx_var,contextptr); + domain_auto_assume(v[0],v[1],contextptr); + gen res=domain(v[0],v[1],v[2].val,contextptr); + restorepurge(xval,vx_var,contextptr); + return res; } static const char _domain_s []="domain"; static define_unary_function_eval (__domain,&_domain,_domain_s); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/dispatch.h b/apps/KhiCAS/src/giac-1.6.0/src/dispatch.h index 70f054a33..6b1f0bc76 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/dispatch.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/dispatch.h @@ -476,10 +476,10 @@ namespace giac { }; enum color_values { -#ifdef KHICAS +#if defined KHICAS || defined GIAC_HAS_STO_38 _BLACK=0, _RED=0xf800, - _GREEN=0x0400, + _GREEN=0x07e0, _YELLOW=0xffe0, _BLUE=0x001f, _MAGENTA=0xf81f, @@ -488,18 +488,21 @@ namespace giac { #else // KHICAS #ifdef GIAC_HAS_STO_38 _WHITE=0, + _RED=0xff0000, + _GREEN=0xff00, + _YELLOW=0xffff00, + _BLUE=0xff, + _MAGENTA=0xff00ff, + _CYAN=0xffff, + _BLACK=7, #else _BLACK=0, -#endif _RED=1, _GREEN=2, _YELLOW=3, _BLUE=4, _MAGENTA=5, _CYAN=6, -#ifdef GIAC_HAS_STO_38 - _BLACK=7, -#else _WHITE=7, #endif #endif // KHICAS @@ -618,6 +621,18 @@ namespace giac { _GT_ACYCLIC = 159, // acyclic _KDE_BANDWIDTH = 160, // bandwidth _KDE_BINS = 161, // bins + _NLP_METHOD = 162, + _NLP_TOLERANCE = 163, + _NLP_VERBOSE = 164, + _ANN_HALF_MSE = 165, // MSE + _ANN_CROSS_ENTROPY = 166, // cross_entropy + _ANN_LOG_LOSS = 167, // log_loss + _ANN_BLOCK_SIZE = 168, // block_size + _ANN_MOMENTUM = 169, // momentum + _ANN_TOPOLOGY = 170, // topology + _ANN_LEARNING_RATE = 171, // learning_rate + _ANN_WEIGHT_DECAY = 172, // weight_decay + _ANN_RELU = 173, // ReLU }; enum mupad_operator { diff --git a/apps/KhiCAS/src/giac-1.6.0/src/gausspol.cc b/apps/KhiCAS/src/giac-1.6.0/src/gausspol.cc index e3b2966f6..09806b689 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/gausspol.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/gausspol.cc @@ -6052,7 +6052,17 @@ namespace giac { } for (it=newp._POLYptr->coord.begin();it!=itend;++it){ if (it->value.type==_EXT) + it->value=ext_reduce(it->value); +#if 1 // added for f:=(-40*a_t^4*6*sqrt(6)+100*a_t^4*6+230*a_t^4*sqrt(6)-576*a_t^4-20*i*a_t^3*sqrt(-(2*sqrt(6))^2+25)*6-(-100*i)*a_t^3*sqrt(-(2*sqrt(6))^2+25)*sqrt(6)-120*i*a_t^3*sqrt(-(2*sqrt(6))^2+25)-20*i*a_t*sqrt(-(2*sqrt(6))^2+25)*6-(-100*i)*a_t*sqrt(-(2*sqrt(6))^2+25)*sqrt(6)-120*i*a_t*sqrt(-(2*sqrt(6))^2+25)+40*6*sqrt(6)-100*6-230*sqrt(6)+576)/(198*sqrt(6)-485);g:=factor(f);normal(f-g); + if (it->value.type==_EXT){ + if (the_ext.type==_EXT) + common_EXT(*(it->value._EXTptr+1),*(the_ext._EXTptr+1),0,context0); it->value=ext_reduce(it->value); + the_ext=ext_reduce(the_ext); + if (the_ext.type==_FRAC) + the_ext=the_ext._FRACptr->num; + } +#endif } gen bn2=1; lcmdeno(*newp._POLYptr,bn2); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/gen.cc b/apps/KhiCAS/src/giac-1.6.0/src/gen.cc index c2318db91..b31190771 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/gen.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/gen.cc @@ -64,7 +64,7 @@ using namespace std; #include "csturm.h" #include "sparse.h" #if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS -inline bool is_graphe(const giac::gen &g,std::string &disp_out,const giac::context *){ return false; } +inline bool is_graphe(const giac::gen &g){ return false; } #else #include "graphtheory.h" #endif @@ -3384,6 +3384,8 @@ namespace giac { return makemod(_MODptr->conj(contextptr),*(_MODptr+1)); case _EXT: return algebraic_EXTension(_EXTptr->conj(contextptr),*(_EXTptr+1)); + case _POLY: + return apply(*_POLYptr,contextptr,giac_conj); default: return gentypeerr(gettext("Conj")); } @@ -4669,7 +4671,7 @@ namespace giac { if (a.type==_INT_){ longlong tmp=((longlong) a.val+b.val); a.val=(int)tmp; - if (a.val==tmp) + if (a.val==tmp && tmp!=-2147483648) return a; return a=tmp; } @@ -5475,7 +5477,7 @@ namespace giac { if (a.type==_INT_){ longlong tmp=((longlong) a.val-b.val); a.val=(int)tmp; - if (a.val==tmp) + if (a.val==tmp && tmp!=-2147483648) return a; return a=tmp; } @@ -6025,7 +6027,7 @@ namespace giac { if (ab>>31) tmp=ab; #else - if (tmp.val!=ab) + if (tmp.val!=ab || tmp==-2147483648) tmp=ab; #endif return; @@ -9037,7 +9039,7 @@ namespace giac { #ifdef HAVE_LIBMPFR // FIXME?? try to avoid rounding error with more digits if (fabs(approx._DOUBLE_val)<1e-5 && (a-b).type!=_FRAC){ - gen tmp=accurate_evalf(eval(a-b,1,contextptr),1000); + gen tmp=accurate_evalf(eval(a-b,1,contextptr),1100); // 1100 bits exceeds double precision, if a and b are equal up to double precision, this will be rounded to 0.0 tmp=evalf_double(tmp,1,contextptr); if (tmp.type==_DOUBLE_) approx=tmp; @@ -9723,9 +9725,9 @@ namespace giac { return _SYMBptr->sommet(f(i,contextptr),contextptr); vecteur lid(lidnt(*this)); if (lid.size()==1 && !has_algebraic_program(*this)){ - if (lid.front()==vx_var) + if (lid.front()==vx_var || lid.front()==t__IDNT_e || lid.front()==x__IDNT_e) // suspect something like P:=x^3+1 then P(2) - *logptr(contextptr) << "Warning, evaluating univariate expression of x(value) like if expression was a function.\nYou should write subst(" << *this << "," << lid.front() << "," << i << ")" << '\n'; + *logptr(contextptr) << "Warning, evaluating univariate expression like if expression was a function.\nYou should write subst(" << *this << "," << lid.front() << "," << i << ")" << '\n'; else return gensizeerr("Expression used like a function "+this->print(contextptr)+"\nYou should write subst("+this->print(contextptr)+","+lid.front().print(contextptr)+","+i.print(contextptr)+")"); return subst(*this,lid.front(),i,false,contextptr); @@ -14181,6 +14183,8 @@ void sprint_double(char * s,double d){ return "lp_heuristic"; case _NLP_PRESOLVE: return "nlp_presolve"; + case _NLP_METHOD: + return "nlp_method"; case _NLP_SAMPLES: return "nlp_samples"; case _NLP_INTEGER: @@ -14193,6 +14197,10 @@ void sprint_double(char * s,double d){ return "nlp_binaryvariables"; case _NLP_NONNEGINT: return "nlp_nonnegint"; + case _NLP_TOLERANCE: + return "nlp_tolerance"; + case _NLP_VERBOSE: + return "nlp_verbose"; case _NLP_FEAS_TOL: return "nlp_feasibilitytolerance"; case _NLP_INT_TOL: @@ -14231,6 +14239,24 @@ void sprint_double(char * s,double d){ return "bandwidth"; case _KDE_BINS: return "bins"; + case _ANN_LEARNING_RATE: + return "learning_rate"; + case _ANN_WEIGHT_DECAY: + return "weight_decay"; + case _ANN_RELU: + return "ReLU"; + case _ANN_HALF_MSE: + return "MSE"; + case _ANN_CROSS_ENTROPY: + return "cross_entropy"; + case _ANN_LOG_LOSS: + return "log_loss"; + case _ANN_BLOCK_SIZE: + return "block_size"; + case _ANN_MOMENTUM: + return "momentum"; + case _ANN_TOPOLOGY: + return "topology"; } } if (subtype==_INT_MUPADOPERATOR){ @@ -14424,7 +14450,7 @@ void sprint_double(char * s,double d){ case _VECT: if (subtype==_GRAPH__VECT){ string s; - if (is_graphe(*this,s,contextptr)) + if (is_graphe(*this)) return '"'+s+'"'; } return print_VECT(*_VECTptr,subtype,contextptr); @@ -16797,7 +16823,7 @@ void sprint_double(char * s,double d){ if (is3d(last)){ int worker=0; worker=EM_ASM_INT_V({ - if (typeof(UI.disable3d) !== 'undefined' && UI.disable3d) + if (typeof(UI)!=="undefined" && typeof(UI.disable3d) !== 'undefined' && UI.disable3d) return UI.disable3d; if (Module.worker) return 1; else return 0; }); @@ -16836,7 +16862,7 @@ void sprint_double(char * s,double d){ #ifdef KHICAS // replace ],[ by ][ if (last.is_symb_of_sommet(at_pnt)){ if (os_shell || nspirelua) - xcas::displaygraph(g,&C); + xcas::displaygraph(g,gp,&C); S="Graphic_object"; } else { @@ -16878,12 +16904,12 @@ void sprint_double(char * s,double d){ #if !defined GIAC_GGB #if defined EMCC || defined EMCC2 double add_evalf=EM_ASM_DOUBLE_V({ - if (typeof(UI.add_evalf)!="undefined") + if (typeof(UI)!=="undefined" && typeof(UI.add_evalf)!="undefined") return UI.add_evalf*1.0; return 1.0; }), js_bigint=EM_ASM_DOUBLE_V({ - if (typeof(UI.js_bigint)!="undefined") + if (typeof(UI)!=="undefined" && typeof(UI.js_bigint)!="undefined") return UI.js_bigint*1.0; return 0.0; }); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/gen.cc~ b/apps/KhiCAS/src/giac-1.6.0/src/gen.cc~ new file mode 100755 index 000000000..e53d4200b --- /dev/null +++ b/apps/KhiCAS/src/giac-1.6.0/src/gen.cc~ @@ -0,0 +1,16947 @@ +// -*- mode:C++ ; compile-command: "g++ -I.. -I../include -DHAVE_CONFIG_H -DIN_GIAC -DGIAC_GENERIC_CONSTANTS -fno-strict-aliasing -g -c gen.cc -Wall" -*- +#include "giacPCH.h" +#ifdef KHICAS +#include "kdisplay.h" +#if defined DEVICE && !defined NSPIRE_NEWLIB +size_t stackptr=0x20036000; +#else +size_t stackptr=0xffffffffffffffff; +#endif +#endif + +#ifdef NSPIRE_NEWLIB +#include +#endif + +/* + * Copyright (C) 2001,14 B. Parisse, Institut Fourier, 38402 St Martin d'Heres + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +using namespace std; +#if !defined NSPIRE && !defined FXCG && !defined KHICAS +#include +#include +#endif +#define __USE_ISOC9X 1 +#include +#include +#include +#include +#include +#include +// #include +#include "gen.h" +#include "gausspol.h" +#include "identificateur.h" +#include "poly.h" +#include "usual.h" +#include "input_lexer.h" +#include "sym2poly.h" +#include "vecteur.h" +#include "modpoly.h" +#include "alg_ext.h" +#include "prog.h" +#include "rpn.h" +#include "plot.h" +#include "intg.h" +#include "subst.h" +#include "derive.h" +#include "threaded.h" +#include "maple.h" +#include "solve.h" +#include "csturm.h" +#include "sparse.h" +#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS +inline bool is_graphe(const giac::gen &g,std::string &disp_out,const giac::context *){ return false; } +#else +#include "graphtheory.h" +#endif +#include "giacintl.h" +#ifdef RTOS_THREADX +extern "C" uint32_t mainThreadStack[]; +#endif +#ifdef HAVE_PTHREAD_H +#include +#endif + +#ifdef EMCC_BIND +#include +#endif + +#if (defined EMCC || defined EMCC2) && !defined GIAC_GGB + +#if 0 // def EMCC_GLUT +#include +#else +#include "SDL/SDL.h" +#include +#include +//#include "SDL/SDL_image.h" +#include "SDL/SDL_opengl.h" +#endif + +#include "opengl.h" +#endif + +#ifdef USE_GMP_REPLACEMENTS +#undef HAVE_GMPXX_H +#undef HAVE_LIBMPFR +#endif + +#ifndef NO_NAMESPACE_GIAC +namespace giac { +#endif // ndef NO_NAMESPACE_GIAC + +#ifdef FXCG +#define ALLOCSMALL +#endif + +#ifdef ALLOCSMALL + + // 32 bytes structure: 4096/32=128 slots of memory + struct eight_int { + int i1,i2,i3,i4,i5,i6,i7,i8; + }; + + struct eleven_int { + int i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11; + }; + + struct six_int { + int i1,i2,i3,i4,i5,i6 +#ifdef FXCG + ,i7,i8 +#endif + ; + }; + + struct four_int { + int i1,i2,i3,i4; + }; + + // ALLOCA constants must be multiples of 2*32 +#if 0 // def FXCG + const int ALLOC24=10*32; + const int ALLOC32=8*32; + const int ALLOC16=8*32; + static unsigned int freeslot24[ALLOC24/32]={ + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, + }; + static unsigned int freeslot16[ALLOC16/32]={ + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, + //0xffffffff, 0xffffffff + }; + static unsigned int freeslot32[ALLOC32/32]={ + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, + //0xffffffff, 0xffffffff + }; + // does not work after OFF/ON + static four_int * tab16=(four_int *) 0xe5200000; + static six_int * tab24=(six_int *) 0xe5007000; + static eight_int * tab32=(eight_int *) 0xe5017000; +#else + const int ALLOC24=32*32; + const int ALLOC32=28*32; + const int ALLOC16=32*32; + //#define ALLOC44 16*32 + static unsigned int freeslot24[ALLOC24/32]={ + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + }; + static unsigned int freeslot16[ALLOC16/32]={ + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + }; + static unsigned int freeslot32[ALLOC32/32]={ + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + //0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + }; +#ifdef ALLOC44 + static unsigned int freeslot44[ALLOC44/32]={ + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + //0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + //0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + //0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + //0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + }; + static eleven_int tab44[ALLOC44]; +#endif + + static eight_int tab32[ALLOC32]; + static six_int tab24[ALLOC24]; + static four_int tab16[ALLOC16]; +#endif + + + unsigned freeslotpos(unsigned n){ + unsigned r=1; + if ( (n<<16)==0 ){ + r+= 16; + n>>=16; + } + if ( (n<<24)==0 ) { + r+= 8; + n>>=8; + } + if ( (n<<28)==0 ) { + r+= 4; + n>>=4; + } + if ( (n<<30)==0 ) { + r+= 2; + n>>=2; + } + r -= n&1; + return r; + } + + static void* allocfast(size_t size){ + int i,pos; + if (size==24){ + for (i=0;i= (size_t) &tab24[0]) && + ((size_t)obj < (size_t) &tab24[ALLOC24]) ){ + int pos= ((size_t)obj -((size_t) &tab24[0]))/sizeof(six_int); + freeslot24[pos/32] |= (1 << (pos%32)); + return; + } + if ( ((size_t)obj>=(size_t) &tab16[0] ) && + ((size_t)obj<(size_t) &tab16[ALLOC16] ) ){ + * (unsigned *) obj= 0; + int pos= ((size_t)obj -((size_t) &tab16[0]))/sizeof(four_int); + freeslot16[pos/32] |= (1 << (pos%32)); + return; + } +#ifdef ALLOC44 + if ( ((size_t)obj>=(size_t) &tab44[0] ) && + ((size_t)obj<(size_t) &tab44[ALLOC44] ) ){ + * (unsigned *) obj= 0; + int pos= ((size_t)obj -((size_t) &tab44[0]))/sizeof(eleven_int); + freeslot44[pos/32] |= (1 << (pos%32)); + return; + } +#endif + if ( ((size_t)obj>=(size_t) &tab32[0]) && + ((size_t)obj<(size_t) &tab32[ALLOC32]) ){ + int pos= ((size_t)obj -((size_t) &tab32[0]))/sizeof(eight_int); + freeslot32[pos/32] |= (1 << (pos%32)); + } + else + free(obj); + } + unsigned hamdist(unsigned val){ + size_t res=0; + if (!val) return res; + for (int i=0;i<32;++i){ + res += ((val >>i) & 1); + } + return res; + } + + size_t freeslotmem(){ + size_t res=0; + for (int i=0;ire=0; + ptr->im=0; + deletefast(ptr); + } +#endif + +#if defined(SMARTPTR64) || !defined(ALLOCSMALL) + inline void deletesymbolic(ref_symbolic * ptr){ + delete ptr ; + } +#else + static void deletesymbolic(ref_symbolic * ptr){ + ptr->s.feuille=0; + deletefast(ptr); + } +#endif + +#if defined(SMARTPTR64) || !defined(IMMEDIATE_VECTOR) || !defined(ALLOCSMALL) + void delete_ref_vecteur(ref_vecteur * ptr){ + delete ptr ; + } +#else + void delete_ref_vecteur(ref_vecteur * ptr){ + ptr->v.clear(); + deletefast(ptr); + } +#endif + + /* + unsigned control_c_counter=0; + unsigned control_c_counter_mask=0xff; + */ + +#ifdef HAVE_LIBPTHREAD + pthread_mutex_t mpfr_mutex = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_t locale_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + + void sprintfdouble(char * ch,const char * format,double d){ +#ifdef FXCG + sprint_double(ch,d); // no format +#else +#ifdef NSPIRE + dtostr(d,8,ch); // FIXME! +#else +#if defined(EMCC) || defined(EMCC2) + sprintf(ch,format,d); +#else + my_sprintf(ch,format,d); +#endif +#endif +#endif + } + + // bool is_inevalf=false; + + static string last_evaled_function(GIAC_CONTEXT){ + const char * last =last_evaled_function_name(contextptr); + if (!last) + return ""; + string res; + bool paren=true; + if (abs_calc_mode(contextptr)==38 && !strcmp(last,"sqrt")) + res="√"; + else { + string tmp=unlocalize(autosimplify(contextptr)); + if (tmp!=last) + res=last; + else + paren=false; + } + if (paren) res +="("; + const gen * lastarg= last_evaled_argptr(contextptr); + if (lastarg){ + if (strcmp(last,"try_catch")==0 && lastarg->type==_VECT && !lastarg->_VECTptr->empty()){ // workaround for optimizations on some operations like * + res = lastarg->_VECTptr->front().print(contextptr); + paren = false; + } + else + res += lastarg->print(contextptr); + } + if (paren) res += ")"; + debug_struct * dbg = debug_ptr(contextptr); + if (!dbg->sst_at_stack.empty()){ + res += gettext(" in "); + gen pos=dbg->args_stack.back(); + string tmp; + if (pos.type==_VECT && pos._VECTptr->size()>=2){ + vecteur v(pos._VECTptr->begin()+1,pos._VECTptr->end()); + if (v.size()==1){ + if (v.front().type==_VECT && v.front()._VECTptr->empty()) + tmp=pos._VECTptr->front().print(contextptr)+"()"; + else + tmp=pos._VECTptr->front().print(contextptr)+"("+v.front().print(contextptr)+")"; + } + else + tmp = pos._VECTptr->front().print(contextptr)+"("+gen(v,_SEQ__VECT).print(contextptr)+")"; + } + else + tmp = pos.print(contextptr); + res += tmp; + res += gettext(" instruction #"); + res += print_INT_(dbg->current_instruction); + res += gettext(" error, try debug(")+tmp+")"; + } + else + res += ' '; + return res+"\n "; + } + +#ifdef NO_STDEXCEPT // FIXME + void settypeerr(GIAC_CONTEXT){ + gentypeerr(contextptr); + } + + void setsizeerr(GIAC_CONTEXT){ + gensizeerr(contextptr); + } + + void setdimerr(GIAC_CONTEXT){ + gendimerr(contextptr); + } + + void settypeerr(const string & s){ + gentypeerr(s); + } + + void setsizeerr(const string & s){ + gensizeerr(s); + } + + void setdimerr(const string & s){ + gendimerr(s); + } + + void divisionby0err(const gen & e,GIAC_CONTEXT){ + gendivisionby0err(e,contextptr); + } + + void cksignerr(const gen & e,GIAC_CONTEXT){ + gencksignerr(e,contextptr); + } + + void invalidserieserr(const string & s,GIAC_CONTEXT){ + geninvalidserieserr(s,contextptr); + } + + void toofewargs(const string & s,GIAC_CONTEXT){ + gentoofewargs(s,contextptr); + } + + void toomanyargs(const string & s,GIAC_CONTEXT){ + gentoomanyargs(s,contextptr); + } + + void maxordererr(GIAC_CONTEXT){ + genmaxordererr(contextptr); + } + + void setstabilityerr(GIAC_CONTEXT){ + genstabilityerr(contextptr); + } +#else + void settypeerr(GIAC_CONTEXT){ + throw(std::runtime_error(last_evaled_function(contextptr)+gettext("Bad Argument Type"))); + } + + void setsizeerr(GIAC_CONTEXT){ + throw(std::runtime_error(last_evaled_function(contextptr)+gettext("Bad Argument Value"))); + } + + void setdimerr(GIAC_CONTEXT){ + throw(std::runtime_error(last_evaled_function(contextptr)+gettext("Invalid dimension"))); + } + + void settypeerr(const string & s){ + throw(std::runtime_error(s+gettext(" Error: Bad Argument Type"))); + } + + void setsizeerr(const string & s){ + throw(std::runtime_error(s+gettext(" Error: Bad Argument Value"))); + } + + void setdimerr(const string & s){ + throw(std::runtime_error(s+gettext(" Error: Invalid dimension"))); + } + + void divisionby0err(const gen & e,GIAC_CONTEXT){ + throw(std::runtime_error(last_evaled_function(contextptr)+gettext("Division of ") + e.print(contextptr)+ gettext(" by 0"))); + } + + void cksignerr(const gen & e,GIAC_CONTEXT){ + throw(std::runtime_error(last_evaled_function(contextptr)+gettext("Unable to check sign: ")+e.print(contextptr))); + } + + void invalidserieserr(const string & s,GIAC_CONTEXT){ + throw(std::runtime_error(last_evaled_function(contextptr)+gettext("Invalid series expansion: ")+s)); + } + + void toofewargs(const string & s,GIAC_CONTEXT){ + throw(std::runtime_error(last_evaled_function(contextptr)+gettext("Too few arguments: ")+s)); + } + + void toomanyargs(const string & s,GIAC_CONTEXT){ + throw(std::runtime_error(last_evaled_function(contextptr)+gettext("Too many arguments: ")+s)); + } + + void maxordererr(GIAC_CONTEXT){ + throw(std::runtime_error(last_evaled_function(contextptr)+gettext("Max order (")+gen(max_series_expansion_order).print(contextptr)+gettext(") exceeded or non unidirectional series"))); + } + + void setstabilityerr(GIAC_CONTEXT){ + throw(std::runtime_error(last_evaled_function(contextptr)+gettext("calculation size limit exceeded"))); + } +#endif // NO_STDEXCEPT + + gen undeferr(const string & s){ +#if defined(EMCC) || defined(EMCC2) + CERR << s << '\n'; +#endif +#if defined NSPIRE || defined FXCG + wait_1ms(1); +#else +#ifdef GIAC_HAS_STO_38 + usleep(10); +#else +#ifndef __MINGW_H + usleep(1000); +#endif +#endif +#endif +#if !defined NO_STDEXCEPT && !defined EMCC + if (debug_infolevel!=-5) + throw(std::runtime_error(s)); +#endif + gen res(string2gen(s,false)); + res.subtype=-1; + return res; + } + + gen gentypeerr(GIAC_CONTEXT){ + return undeferr(last_evaled_function(contextptr)+gettext("Error: Bad Argument Type")); + } + + void gentypeerr(gen & g,GIAC_CONTEXT){ + g=undeferr(last_evaled_function(contextptr)+gettext("Error: Bad Argument Type")); + } + + gen gensizeerr(GIAC_CONTEXT){ + return undeferr(last_evaled_function(contextptr)+gettext("Error: Bad Argument Value")); + } + + void gensizeerr(gen & g,GIAC_CONTEXT){ + g=undeferr(last_evaled_function(contextptr)+gettext("Error: Bad Argument Value")); + } + + gen gendimerr(GIAC_CONTEXT){ + return undeferr(last_evaled_function(contextptr)+gettext("Error: Invalid dimension")); + } + + void gendimerr(gen & g,GIAC_CONTEXT){ + g=undeferr(last_evaled_function(contextptr)+gettext("Error: Invalid dimension")); + } + + gen gentypeerr(const string & s){ + return undeferr(s+gettext(" Error: Bad Argument Type")); + } + + void gentypeerr(const char * ch,gen & g){ + g=undeferr(string(gettext(ch))+gettext(" Error: Bad Argument Type")); + } + + gen gensizeerr(const string & s){ + return undeferr(s+gettext(" Error: Bad Argument Value")); + } + + void gensizeerr(const char * ch,gen & g){ + g=undeferr(string(gettext(ch))+gettext(" Error: Bad Argument Value")); + } + + gen gendimerr(const string & s){ + return undeferr(s+gettext(" Error: Invalid dimension")); + } + + void gendimerr(const char * ch,gen & g){ + g=undeferr(string(gettext(ch))+gettext(" Error: Invalid dimension")); + } + + gen gendivisionby0err(const gen & e,GIAC_CONTEXT){ + return undeferr(last_evaled_function(contextptr)+gettext("Error: Division of ") + e.print(contextptr)+ gettext(" by 0")); + } + + gen gencksignerr(const gen & e,GIAC_CONTEXT){ + return undeferr(last_evaled_function(contextptr)+gettext("Error: Unable to check sign: ")+e.print(contextptr)); + } + + gen geninvalidserieserr(const string & s,GIAC_CONTEXT){ + *logptr(contextptr) << undeferr(last_evaled_function(contextptr)+gettext("Error: Invalid series expansion: ")+s) << '\n'; + return undef; + } + + gen gentoofewargs(const string & s,GIAC_CONTEXT){ + return undeferr(last_evaled_function(contextptr)+gettext("Error: Too few arguments: ")+s); + } + + gen gentoomanyargs(const string & s,GIAC_CONTEXT){ + return undeferr(last_evaled_function(contextptr)+gettext("Error: Too many arguments: ")+s); + } + + gen genmaxordererr(GIAC_CONTEXT){ + return undeferr(last_evaled_function(contextptr)+gettext("Error: Max order (")+gen(max_series_expansion_order).print(contextptr)+gettext(") exceeded or non unidirectional series")); + } + + gen genstabilityerr(GIAC_CONTEXT){ + return undeferr(last_evaled_function(contextptr)+gettext("Error: calculation size limit exceeded")); + } + + // void parseerror(){ + // throw(std::runtime_error("Parse error")); + // } + + enum { debugtype=_CPLX }; +#define debugtypeptr _CPLXptr + + /* Constructors, destructors, copy */ + gen vector2vecteur(const vecteur & v){ + gen g=v.back()-v.front(); + if (g.type!=_VECT) + return makenewvecteur(re(g,context0),im(g,context0)); + return g; + } + + gen gen::change_subtype(int newsubtype){ + subtype=newsubtype; + return *this; + } + + gen change_subtype(const gen & g,int newsubtype){ + gen g_(g); + g_.subtype=newsubtype; + return g_; + } + + int * complex_display_ptr(const gen & g) { + if (g.type!=_CPLX) + return 0; + return (int *)(g._CPLXptr)-1; + } + + gen::gen(long i) { +#ifdef COMPILE_FOR_STABILITY + control_c(); +#endif +#ifdef SMARTPTR64 + * ((ulonglong * ) this)=0; +#endif + val=(int)i; + // longlong temp=val; + if (val==i && val!=1<<31){ +#ifndef SMARTPTR64 + type=_INT_; + subtype=0; +#endif + } + else { +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_mpz_t(64)) << 16; +#else + __ZINTptr = new ref_mpz_t(64); +#endif + type =_ZINT; + subtype=0; + // convert longlong to mpz_t + bool signe=(i<0); + if (signe) + i=-i; + unsigned int i1=sizeof(long)==4?0:i>>32; + unsigned int i2=(unsigned int)i; + mpz_set_ui(*_ZINTptr,i1); + mpz_mul_2exp(*_ZINTptr,*_ZINTptr,32); + mpz_add_ui(*_ZINTptr,*_ZINTptr,i2); + if (signe) + mpz_neg(*_ZINTptr,*_ZINTptr); + } + } + + gen::gen(longlong i) { +#ifdef COMPILE_FOR_STABILITY + control_c(); +#endif +#ifdef SMARTPTR64 + * ((ulonglong * ) this)=0; +#endif + val=(int)i; + // longlong temp=val; + if (val==i && val!=1<<31){ +#ifndef SMARTPTR64 + type=_INT_; + subtype=0; +#endif + } + else { +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_mpz_t(64)) << 16; +#else + __ZINTptr = new ref_mpz_t(64); +#endif + type =_ZINT; + subtype=0; + // convert longlong to mpz_t + bool signe=(i<0); + if (signe) + i=-i; + unsigned int i1=i>>32; + unsigned int i2=(unsigned int)i; + mpz_set_ui(*_ZINTptr,i1); + mpz_mul_2exp(*_ZINTptr,*_ZINTptr,32); + mpz_add_ui(*_ZINTptr,*_ZINTptr,i2); + if (signe) + mpz_neg(*_ZINTptr,*_ZINTptr); + /* + longlong lbase=65536; + long base=65536; + longlong i1=i/lbase; + long i2=i1/lbase; // i2=i/2^32 + //COUT << "Initialization of " << _ZINTptr << '\n' ; + mpz_init_set_si(*_ZINTptr,i2); + mpz_mul_ui(*_ZINTptr,*_ZINTptr,base); // i/2^32 * 2^16 + long i2mod=i1 % lbase; + if (i2mod>0) + mpz_add_ui(*_ZINTptr,*_ZINTptr,i2mod); + else + mpz_sub_ui(*_ZINTptr,*_ZINTptr,-i2mod); // i/2^16 + mpz_mul_ui(*_ZINTptr,*_ZINTptr,base); // i/2^16 * 2^16 + long i1mod = i % lbase; + if (i1mod>0) + mpz_add_ui(*_ZINTptr,*_ZINTptr,i1mod); + else + mpz_sub_ui(*_ZINTptr,*_ZINTptr,-i1mod); // i + */ + } + } + + gen::gen(longlong i,int nbits) { +#ifdef COMPILE_FOR_STABILITY + control_c(); +#endif +#ifdef SMARTPTR64 + * ((ulonglong * ) this)=0; +#endif + val=(int)i; + // longlong temp=val; + if (val==i && val!=1<<31){ +#ifndef SMARTPTR64 + type=_INT_; + subtype=0; +#endif + } + else { +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_mpz_t(nbits)) << 16; +#else + __ZINTptr = new ref_mpz_t(nbits); +#endif + type =_ZINT; + subtype=0; + // convert longlong to mpz_t + bool signe=(i<0); + if (signe) + i=-i; + unsigned int i1=i>>32; + unsigned int i2=(unsigned int)i; + mpz_set_ui(*_ZINTptr,i1); + mpz_mul_2exp(*_ZINTptr,*_ZINTptr,32); + mpz_add_ui(*_ZINTptr,*_ZINTptr,i2); + if (signe) + mpz_neg(*_ZINTptr,*_ZINTptr); + } + } + +#ifdef INT128 + gen::gen(int128_t i) { +#ifdef COMPILE_FOR_STABILITY + control_c(); +#endif +#ifdef SMARTPTR64 + * ((ulonglong * ) this)=0; +#endif + val=i; + // longlong temp=val; + if (val==i && val!=1<<31){ +#ifndef SMARTPTR64 + type=_INT_; + subtype=0; +#endif + } + else { +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_mpz_t(128)) << 16; +#else + __ZINTptr = new ref_mpz_t(128); +#endif + type =_ZINT; + subtype=0; + bool signe=(i<0); + if (signe) + i=-i; +#if !defined(USE_GMP_REPLACEMENTS) && !defined BF2GMP_H + mpz_import(*_ZINTptr,4/* count*/,-1/*1 for least significant first*/,4/* sizeof unsigned*/,0,0,&i); + // CERR << gen(*_ZINTptr) ; +#else + unsigned int i3= i; + i = i>>32; + unsigned int i2= i; + i = i>>32; + unsigned int i1= i; + i = i>>32; + // convert to mpz_t + if (i1 || i){ + mpz_set_ui(*_ZINTptr,(unsigned int) i); + mpz_mul_2exp(*_ZINTptr,*_ZINTptr,32); + mpz_add_ui(*_ZINTptr,*_ZINTptr,i1); + mpz_mul_2exp(*_ZINTptr,*_ZINTptr,32); + mpz_add_ui(*_ZINTptr,*_ZINTptr,i2); + } + else + mpz_set_ui(*_ZINTptr,i2); + mpz_mul_2exp(*_ZINTptr,*_ZINTptr,32); + mpz_add_ui(*_ZINTptr,*_ZINTptr,i3); +#endif + if (signe) + mpz_neg(*_ZINTptr,*_ZINTptr); + // CERR << " " << gen(*_ZINTptr) << '\n' ; + } + } +#endif + + gen::gen(const mpz_t & m) { + if (int(mpz_sizeinbase(m,2))>MPZ_MAXLOG2){ + type=0; +#if 1 + *this=undef; +#else + *this=mpz_sgn(m)==-1?minus_inf:plus_inf; +#endif + return; + } +#ifdef COMPILE_FOR_STABILITY + control_c(); +#endif +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_mpz_t(m)) << 16; +#else + __ZINTptr= new ref_mpz_t(m); +#endif +#ifdef KHICAS + if ((size_t) _ZINTptr > stackptr) + ctrl_c=interrupted=true; +#endif + type =_ZINT; + subtype=0; + } + +#if defined HAVE_GMPXX_H && !defined USE_GMP_REPLACEMENTS + gen::gen(const mpz_class & m){ + int l=mpz_sizeinbase(m.get_mpz_t(),2); + if (l<32){ + type = _INT_; + val = mpz_get_si(m.get_mpz_t()); + } + else { +#ifdef SMARTPTR64 + ref_mpz_t * ptr=new ref_mpz_t; + mpz_set(ptr->z,m.get_mpz_t()); + * ((ulonglong * ) this) = ulonglong(ptr) << 16; +#else + __ZINTptr= new ref_mpz_t(); +#ifdef KHICAS + if ((size_t) _ZINTptr > stackptr) + ctrl_c=interrupted=true; +#endif + mpz_set(__ZINTptr->z,m.get_mpz_t()); +#endif + type =_ZINT; + } + subtype=0; + } +#endif + + gen::gen(const identificateur & s){ +#ifdef COMPILE_FOR_STABILITY + control_c(); +#endif +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_identificateur(s)) << 16; +#else + __IDNTptr= new ref_identificateur(s); +#endif + type=_IDNT; + subtype=0; + } + +#if defined(SMARTPTR64) || !defined(IMMEDIATE_VECTOR) || !defined(ALLOCSMALL) + ref_vecteur * new_ref_vecteur(const vecteur & v){ + return new ref_vecteur(v); + } +#else + ref_vecteur * new_ref_vecteur(const vecteur & v){ + ref_vecteur * ptr=(ref_vecteur *) allocfast(sizeof(ref_vecteur)); + ptr->ref_count=1; + *(unsigned *)&ptr->v=0; + *((unsigned *)&ptr->v+1)=0; + *((unsigned *)&ptr->v+2)=0; + *((unsigned *)&ptr->v+3)=0; + *((unsigned *)&ptr->v+4)=0; + *((unsigned *)&ptr->v+5)=0; + *((unsigned *)&ptr->v+6)=0; + ptr->v=v; + return ptr; + } +#endif + + gen::gen(const vecteur & v,short int s) + { +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_vecteur(v)) << 16; +#else + __VECTptr= new_ref_vecteur(v); +#endif +#ifdef KHICAS + if (v.size()>1 && + ( (size_t) _VECTptr > stackptr || + (size_t) _VECTptr->begin() > stackptr) + ) + ctrl_c=interrupted=true; +#endif + type=_VECT; + subtype=(signed char)s; + } + + gen::gen(ref_vecteur * vptr,short int s){ +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(vptr) << 16; +#else + __VECTptr= vptr; +#endif + type=_VECT; + subtype=(signed char)s; +#ifdef KHICAS + if (_VECTptr->size()>1 && + ( (size_t) _VECTptr > stackptr || + (size_t) _VECTptr->begin() > stackptr) + ) + ctrl_c=interrupted=true; +#endif + } + +#if defined(SMARTPTR64) || !defined(ALLOCSMALL) + ref_symbolic * new_ref_symbolic(const symbolic & s){ + return new ref_symbolic(s); + } +#else + ref_symbolic * new_ref_symbolic(const symbolic & s){ + ref_symbolic * ptr=(ref_symbolic *) allocfast(sizeof(ref_symbolic)); + ptr->ref_count=1; + * (unsigned *) &ptr->s.sommet = 0; + ptr->s.feuille.type=0; + ptr->s=s; + return ptr; + } +#endif + + gen::gen(const symbolic & s){ +#ifdef COMPILE_FOR_STABILITY + control_c(); +#endif +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new_ref_symbolic(s)) << 16; +#else + __SYMBptr = new_ref_symbolic(s) ; +#endif + type = _SYMB; + subtype = 0; +#ifdef KHICAS + if (_SYMBptr->sommet!=at_restart && _SYMBptr->sommet!=at_purge && (size_t) _SYMBptr > stackptr) + ctrl_c=interrupted=true; +#endif + } + + gen::gen(ref_symbolic * sptr){ +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(sptr) << 16; +#else + __SYMBptr = sptr; +#endif + type = _SYMB; + subtype = 0; +#ifdef KHICAS + if (_SYMBptr->sommet!=at_restart && _SYMBptr->sommet!=at_purge && (size_t) _SYMBptr > stackptr) + ctrl_c=interrupted=true; +#endif + } + + gen::gen(ref_identificateur * sptr){ +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(sptr) << 16; +#else + __IDNTptr = sptr; +#endif + type = _IDNT; + subtype = 0; + } + + gen::gen(const gen_user & g){ +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_gen_user(g)) << 16; +#else + __USERptr = new ref_gen_user(g) ; +#endif + type = _USER; + subtype=0; + } + + gen::gen(ref_gen_user * sptr){ +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(sptr) << 16; +#else + __USERptr = sptr; +#endif + type = _USER; + subtype = 0; + } + +#ifdef ALLOC44 + ref_eqwdata * new_ref_eqwdata(const eqwdata & e){ + ref_eqwdata * ptr=(ref_eqwdata *) allocfast(sizeof(ref_eqwdata)); + ptr->ref_count=1; + *(unsigned *)&ptr->e=0; + *((unsigned *)&ptr->e+1)=0; + *((unsigned *)&ptr->e+2)=0; + *((unsigned *)&ptr->e+3)=0; + *((unsigned *)&ptr->e+4)=0; + *((unsigned *)&ptr->e+5)=0; + *((unsigned *)&ptr->e+6)=0; + *((unsigned *)&ptr->e+7)=0; + *((unsigned *)&ptr->e+8)=0; + *((unsigned *)&ptr->e+9)=0; + ptr->e=e; + return ptr; + } +#endif + + gen::gen(const eqwdata & g){ +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_eqwdata(g)) << 16; +#else +#ifdef ALLOC44 + __EQWptr = new_ref_eqwdata(g); +#else + __EQWptr = new ref_eqwdata(g); +#endif +#endif + type = _EQW; + subtype=0; + } + + gen::gen(const grob & g){ +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_grob(g)) << 16; +#else + __GROBptr = new ref_grob(g); +#endif + type = _GROB; + subtype=0; + } + + gen makemap(){ + gen g; +#ifdef SMARTPTR64 + * ((ulonglong * ) &g) = ulonglong(new ref_gen_map) << 16; +#else +#if 1 // def NSPIRE + g.__MAPptr = new ref_gen_map; +#else + g.__MAPptr = new ref_gen_map(ptr_fun(islesscomplexthanf)); +#endif +#endif + g.type=_MAP; + g.subtype=0; + return g; + } + + gen::gen(const gen_map & s){ +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_gen_map(s)) << 16; +#else + __MAPptr = new ref_gen_map(s) ; +#endif + type = _MAP; + subtype = 0; + } + + gen::gen(const polynome & p){ + subtype=0; + if (p.coord.empty()){ + type = _INT_; + val = 0; + } + else { + if (Tis_constant(p) && is_atomic(p.coord.front().value) ){ + type = _INT_; + * this = p.coord.front().value; + } + else { +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new Tref_tensor(p)) << 16; +#else + __POLYptr = new Tref_tensor(p) ; +#endif +#ifdef KHICAS + if ((size_t) _POLYptr > stackptr) + ctrl_c=interrupted=true; +#endif + type = _POLY; + } + } + } + + gen::gen(const fraction & p){ + subtype=0; + if (is_undef(p.num) || is_undef(p.den)){ + type=_INT_; + *this=undef; + return; + } + if (is_inf(p.den)){ + type=_INT_; + val=0; + if (is_inf(p.num)) + *this=undef; + return; + } + if (is_exactly_zero(p.num)){ + type=_INT_; + val=0; + return; + } + if (is_one(p.den)){ + type=_INT_; + *this = p.num; + return; + } + if (is_minus_one(p.den)){ + type=_INT_; + *this = -p.num; + } + else { +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new Tref_fraction(p)) << 16; +#else + __FRACptr = new Tref_fraction(p) ; +#endif + type = _FRAC; + } + } + + gen::gen(Tref_tensor * pptr){ +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(pptr) << 16; +#else + __POLYptr = pptr ; +#endif +#ifdef KHICAS + if ((size_t) _POLYptr > stackptr) + ctrl_c=interrupted=true; +#endif + subtype=0; + type = _POLY; + } + + // WARNING coerce *mptr to an int if possible, in this case delete mptr + // Pls do not use this constructor unless you know exactly what you do!! + gen::gen(ref_mpz_t * mptr){ + int l=mpz_sizeinbase(mptr->z,2); + // if (l<17){ + if (l<32){ + type = _INT_; + val = mpz_get_si(mptr->z); + // COUT << "Destruction by mpz_t * " << *mptr << '\n'; + delete mptr; + } + else { + if (l>MPZ_MAXLOG2){ + type=0; +#if 1 + *this=undef; +#else + *this=(mpz_sgn(mptr->z)==-1)?minus_inf:plus_inf; +#endif + delete mptr; + return; + } +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(mptr) << 16; +#else + __ZINTptr = mptr; +#endif +#ifdef KHICAS + if ((size_t) _ZINTptr > stackptr) + ctrl_c=interrupted=true; +#endif + type =_ZINT; + } + subtype=0; + // COUT << *this << '\n'; + } + + // WARNING coerce *mptr to an int if possible, in this case delete mptr + // Pls do not use this constructor unless you know exactly what you do!! + bool ref_mpz_t2gen(ref_mpz_t * mptr,gen & g){ + if (g.type>_DOUBLE_){ + g=mptr; + return true; + } + int l=mpz_sizeinbase(mptr->z,2); + // if (l<17){ + if (l<32){ + g.type=_INT_; + g.subtype=0; + g.val = mpz_get_si(mptr->z); + // COUT << "Destruction by mpz_t * " << *mptr << '\n'; + return false; + } + else { + if (l>MPZ_MAXLOG2){ + g.type=0; +#if 1 + g=undef; +#else + g=(mpz_sgn(mptr->z)==-1)?minus_inf:plus_inf; +#endif + return false; + } +#ifdef SMARTPTR64 + * ((ulonglong * ) &g) = ulonglong(mptr) << 16; +#else + g.__ZINTptr = mptr; +#endif + g.type =_ZINT; + g.subtype=0; + return true; + } + } + + gen::gen(const my_mpz& z){ + int l=mpz_sizeinbase(z.ptr,2); + if (l<32){ + type = _INT_; + val = mpz_get_si(z.ptr); + } + else { + if (l>MPZ_MAXLOG2){ + type=0; +#if 1 + *this=undef; +#else + *this=(mpz_sgn(z.ptr)==-1)?minus_inf:plus_inf; +#endif + return; + } +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_mpz_t(z.ptr)) << 16; +#else + __ZINTptr = new ref_mpz_t(z.ptr); +#endif +#ifdef KHICAS + if ((size_t) _ZINTptr > stackptr) + ctrl_c=interrupted=true; +#endif + type =_ZINT; + } + subtype=0; + } + + gen::gen(const gen & e) { + if (e.type>_DOUBLE_ && e.type!=_FLOAT_ +#ifndef SMARTPTR64 + && e.type!=_FUNC +#endif + ) { + if ( +#ifdef SMARTPTR64 + (*((ulonglong *) &e) >> 16) +#else + e.__ZINTptr +#endif + ){ + ref_count_t * rc=(ref_count_t *)&e.ref_count(); + if (*rc!=-1) + ++(*rc); + } + } +#ifdef DOUBLEVAL + _DOUBLE_val = e._DOUBLE_val; +#else + * ((longlong *) this) = *((longlong * ) &e); +#endif +#ifndef SMARTPTR64 + __ZINTptr=e.__ZINTptr; +#endif + type=e.type; + subtype=e.subtype; + } + + inline ref_complex * new_ref_complex(gen a,gen b){ +#if defined(SMARTPTR64) || !defined(ALLOCSMALL) + return new ref_complex(a,b); +#else + ref_complex * ptr= (ref_complex *) allocfast(sizeof(ref_complex)); + ptr->ref_count=1; + ptr->display=0; + ptr->re.type=0; + ptr->re=a; + ptr->im.type=0; + ptr->im=b; + return ptr; +#endif + } + + gen::gen(int a,int b) { + subtype=0; + if (!b){ + type=_INT_; + val=a; + } + else { +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_complex(a,b)) << 16; +#else + __CPLXptr = new_ref_complex(a,b); +#endif + type =_CPLX; + subtype=0; + } + } + +#ifndef DOUBLEVAL + gen::gen(double d){ + opaque_double_copy(&d,this); type=_DOUBLE_; + }; +#endif + + gen::gen(double a,double b){ + subtype=0; + // COUT << a << " " << b << " " << epsilon << '\n'; + if (fabs(b)<1e-12*fabs(a)){ +#ifdef DOUBLEVAL + _DOUBLE_val=a; +#else + *((double *) this) = a; +#endif + type=_DOUBLE_; + } + else { +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_complex(a,b)) << 16; +#else +#if 0 //def FXCG + __CPLXptr = new ref_complex(a,b); +#else + __CPLXptr = new_ref_complex(a,b); +#endif +#endif + type =_CPLX; + subtype=3; + } + } + + gen::gen(const gen & a,const gen & b) { // a and b must be type <2! + if ( (a.type>=_CPLX && a.type!=_FLOAT_) || (b.type>=_CPLX && b.type!=_FLOAT_) ){ + type=0; + *this=a+cst_i*b; // gentypeerr(gettext("complex constructor")); + return; + } + if (is_exactly_zero(b)){ + if (a.type==_FLOAT_){ + type=0; + *this=a; + } + else { + type=a.type; + switch (type ) { + case _INT_: + val=a.val; + subtype=0; + break; + case _DOUBLE_: +#ifdef DOUBLEVAL + _DOUBLE_val = a._DOUBLE_val; +#else + *((double *) this) = a._DOUBLE_val; + type=_DOUBLE_; +#endif + break; + case _ZINT: +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_mpz_t(*a._ZINTptr)) << 16; +#else + __ZINTptr=new ref_mpz_t(a.__ZINTptr->z); // a is a _ZINT +#endif + type=_ZINT; + subtype=0; + break; + case _REAL: + subtype=0; +#ifdef SMARTPTR64 +#ifndef NO_RTTI + if (real_interval * ptr=dynamic_cast(a._REALptr)){ + * ((ulonglong * ) this) = ulonglong(new ref_real_interval(*ptr)) << 16; + subtype=1; + } + else +#endif + * ((ulonglong * ) this) = ulonglong(new ref_real_object(*a._REALptr)) << 16; +#else +#ifndef NO_RTTI + if (real_interval * ptr=dynamic_cast(a._REALptr)){ + __REALptr=(ref_real_object *) new ref_real_interval(*ptr); + subtype=1; + } + else +#endif + __REALptr=new ref_real_object(a.__REALptr->r); +#endif + type=_REAL; + break; + default: + type=0; + *this=gentypeerr(gettext("complex constructor")); + } + } + } + else { +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_complex(a,b)) << 16; +#else + __CPLXptr = new_ref_complex(a,b); +#endif + type =_CPLX; + subtype= (a.type==_DOUBLE_) + (b.type==_DOUBLE_)*2; + } + } + gen::gen(const complex & c) { +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_complex(c)) << 16; +#else + __CPLXptr = new ref_complex(c); +#endif + type=_CPLX; + subtype=3; + } + + double gen::DOUBLE_val() const { +#ifdef DOUBLEVAL + return _DOUBLE_val; +#else + return opaque_double_val(this); +#endif + } + + giac_float gen::FLOAT_val() const { +#ifdef DOUBLEVAL + return _FLOAT_val; +#else + longlong r = * (longlong *)(this) ; + // * (unsigned char *) (&r) = 0; +#ifdef BCD + return * (giac_float *)(&r); +#else + return giac_float(* (double *)(&r)); +#endif // BCD +#endif // DOUBLEVAL + } + + gen gen::makegen(int i) const { + switch (type){ + case _INT_: case _ZINT: case _CPLX: + return gen(i); + case _VECT: + return vecteur(1,i); + case _USER: + return _USERptr->makegen(i); + default: + return gensizeerr(gettext("makegen of type ")+print(context0)); + } + } + + complex gen2complex_d(const gen & e){ + if (e.type==_CPLX){ + if (e.subtype==3) + return complex((*e._CPLXptr)._DOUBLE_val,(*(e._CPLXptr+1))._DOUBLE_val); + gen ee=e.evalf_double(1,context0); // ok + if (ee.type==_DOUBLE_) return complex(ee._DOUBLE_val,0); + if (ee.type!=_CPLX){ +#ifndef NO_STDEXCEPT + setsizeerr(gettext("complex")); +#endif + return complex(nan(),nan()); + } + return complex((*ee._CPLXptr)._DOUBLE_val,(*(ee._CPLXptr+1))._DOUBLE_val); + } + if (e.type==_DOUBLE_) + return complex(e._DOUBLE_val,0); + if (e.type==_INT_) + return complex(e.val,0); + if (e.type==_ZINT) + return complex(e.evalf(1,context0)._DOUBLE_val,0); // ok +#ifndef NO_STDEXCEPT + setsizeerr(gettext("complex")); +#endif + return complex(nan(),nan()); + } + + gen::gen(const sparse_poly1 & p){ + if (p.empty()){ + type=0; + subtype=0; + val=0; + } + else { + if (is_undef(p.front().exponent)){ + type=0; + *this=undef; + } + else { +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_sparse_poly1(p)) << 16; +#else + __SPOL1ptr= new ref_sparse_poly1(p); +#endif +#ifdef KHICAS + if ((size_t) _SPOL1ptr > stackptr) + ctrl_c=interrupted=true; +#endif + subtype=0; + type=_SPOL1; + } + } + } + + gen::gen(const unary_function_ptr * f,int nargs){ +#if defined SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_unary_function_ptr(*f)) << 16; +#else + _FUNC_ = (size_t) (* (size_t*) f); + // __FUNCptr= new ref_unary_function_ptr(f); +#endif + type=_FUNC; + subtype=nargs; + } + + gen::gen(const unary_function_ptr & f,int nargs){ +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_unary_function_ptr(f)) << 16; +#else + _FUNC_ = (size_t)(* (size_t *) &f); + // __FUNCptr= new ref_unary_function_ptr(f); +#endif + type=_FUNC; + subtype=nargs; + } + + gen::gen(const giac_float & f){ +#ifdef DOUBLEVAL + _FLOAT_val=f; +#else +#ifdef BCD + *((giac_float *) this) = f; +#else // BCD + *((double *) this) = f; +#endif // BCD +#endif // DOUBLEVAL + type=_FLOAT_; + } + +#ifdef BCD + gen::gen(accurate_bcd_float * b){ + giac_float f=fUnExpand(b); +#ifdef DOUBLEVAL + _FLOAT_val=f; +#else + *((giac_float *) this) = f; +#endif // DOUBLEVAL + type=_FLOAT_; + } +#endif // BCD + + void gen::delete_gen() { + switch (type) { +#ifdef SMARTPTR64 + case _ZINT: + delete (ref_mpz_t *) (* ((ulonglong * ) this) >> 16); + break; + case _REAL: { + ref_real_object * ptr=(ref_real_object *) (* ((ulonglong * ) this) >> 16); +#ifndef NO_RTTI + if (dynamic_cast(&ptr->r)) + delete (ref_real_interval *) ptr; + else +#endif + delete ptr; + break; + } + case _CPLX: + delete (ref_complex *) (* ((ulonglong * ) this) >> 16); + break; + case _IDNT: + delete (ref_identificateur *) (* ((ulonglong * ) this) >> 16); + break; + case _VECT: + delete (ref_vecteur *) (* ((ulonglong * ) this) >> 16); + break; + case _SYMB: + delete (ref_symbolic *) (* ((ulonglong * ) this) >> 16); + break; + case _USER: + delete (ref_gen_user *) (* ((ulonglong * ) this) >> 16); + break; + case _EXT: + delete (ref_algext *) (* ((ulonglong * ) this) >> 16); + break; + case _MOD: + delete (ref_modulo *) (* ((ulonglong * ) this) >> 16); + break; + case _POLY: + delete (ref_polynome *) (* ((ulonglong * ) this) >> 16); + break; + case _FRAC: + delete (ref_fraction *) (* ((ulonglong * ) this) >> 16); + break; + case _SPOL1: + delete (ref_sparse_poly1 *) (* ((ulonglong * ) this) >> 16); + break; + case _STRNG: + delete (ref_string *) (* ((ulonglong * ) this) >> 16); + break; + case _FUNC: + delete (ref_unary_function_ptr *) (* ((ulonglong * ) this) >> 16); + break; + case _MAP: + delete (ref_gen_map *) (* ((ulonglong * ) this) >> 16); + break; + case _EQW: + delete (ref_eqwdata *) (* ((ulonglong * ) this) >> 16); + break; + case _GROB: + delete (ref_grob *) (* ((ulonglong * ) this) >> 16); + break; + case _POINTER_: + if (subtype==_FL_WIDGET_POINTER && fl_widget_delete_function) + fl_widget_delete_function(_POINTER_val); + if (subtype==_BUFFER_POINTER) + ; // free((ref_void_pointer *) (* ((ulonglong * ) this) >> 16)); + else + delete (ref_void_pointer *) (* ((ulonglong * ) this) >> 16); + break; +#else // SMARTPTR64 + case _ZINT: + delete __ZINTptr; + break; + case _REAL: { + ref_real_object * ptr=__REALptr; +#ifndef NO_RTTI + if (dynamic_cast(&ptr->r)) + delete (ref_real_interval *) __REALptr; + else +#endif + delete __REALptr; + break; + } + case _CPLX: + deletecomplex(__CPLXptr); // delete __CPLXptr; + break; + case _IDNT: + delete __IDNTptr; + break; + case _VECT: + delete_ref_vecteur(__VECTptr); // delete __VECTptr; + break; + case _SYMB: + deletesymbolic(__SYMBptr); // delete __SYMBptr; + break; + case _USER: + delete __USERptr; + break; + case _EXT: + delete __EXTptr; + break; + case _MOD: + delete __MODptr; + break; + case _POLY: + delete __POLYptr; + break; + case _FRAC: + delete __FRACptr; + break; + case _SPOL1: + delete __SPOL1ptr; + break; + case _STRNG: + delete __STRNGptr; + break; +#ifdef SMARTPTR64 + case _FUNC: + delete __FUNCptr; + break; +#endif + case _MAP: + delete __MAPptr; + break; + case _EQW: +#ifdef ALLOC44 + __EQWptr->e.g=0; + deletefast(__EQWptr); +#else + delete __EQWptr; +#endif + break; + case _GROB: + delete __GROBptr; + break; + case _POINTER_: + if (subtype==_FL_WIDGET_POINTER && fl_widget_delete_function) + fl_widget_delete_function(_POINTER_val); + delete __POINTERptr; + break; +#endif // SMARTPTR64 + default: +#ifndef NO_STDEXCEPT + settypeerr(gettext("Gen Destructor")); +#endif + ; + } + } + + void delete_ptr(signed char subtype,short int type_save,ref_mpz_t * ptr_save) { +#if 0 // def COMPILE_FOR_STABILITY // commented (D.Alm) The call to delete_ptr() would sometimes get cancelled if ctrl_c was being set, which could cause the "Stopped by user interruption." exception somehow to be fired twice, with the second time not being caught properly by my exception handling code. + control_c(); +#endif + if (ptr_save && type_save!=_FLOAT_&& ptr_save->ref_count!=-1 && !--(ptr_save->ref_count)){ + switch (type_save) { + case _ZINT: + delete ptr_save; + break; + case _REAL: { + ref_real_object * ptr=(ref_real_object *) ptr_save; +#ifndef NO_RTTI + if (dynamic_cast(&ptr->r)) + delete (ref_real_interval *) ptr; + else +#endif + delete ptr; + break; + } + case _CPLX: + deletecomplex((ref_complex *) ptr_save); + break; + case _IDNT: + delete (ref_identificateur *) ptr_save ; + break; + case _SYMB: + deletesymbolic( (ref_symbolic *) ptr_save); + break; + case _USER: + delete (ref_gen_user *) ptr_save; + break; + case _EXT: + delete (ref_algext * ) ptr_save; + break; + case _MOD: + delete (ref_modulo * ) ptr_save; + break; + case _VECT: + delete_ref_vecteur((ref_vecteur *) ptr_save); // delete (ref_vecteur *) ptr_save; + break; + case _POLY: + delete (ref_polynome *) ptr_save; + break; + case _FRAC: + delete (ref_fraction *) ptr_save; + break; + case _SPOL1: + delete (ref_sparse_poly1 *) ptr_save; + break; + case _STRNG: + delete (ref_string *) ptr_save; + break; +#ifdef SMARTPTR64 + case _FUNC: + delete (ref_unary_function_ptr *) ptr_save; + break; +#endif + case _MAP: + delete (ref_gen_map *) ptr_save; + break; + case _EQW: +#ifdef ALLOC44 + ((ref_eqwdata *) ptr_save)->e.g=0; + deletefast(ptr_save); +#else + delete (ref_eqwdata *) ptr_save; +#endif + break; + case _GROB: + delete (ref_grob *) ptr_save; + break; + case _POINTER_: + if (subtype==_FL_WIDGET_POINTER && fl_widget_delete_function) + fl_widget_delete_function( ((ref_void_pointer *)ptr_save)->p); + delete (ref_void_pointer *) ptr_save; + break; + case _FLOAT_: + break; + default: +#ifndef NO_STDEXCEPT + settypeerr(gettext("Gen Operator =")); +#endif + ; + } + } + } + + + double gen::to_double(GIAC_CONTEXT) const { + if (type==_DOUBLE_) + return _DOUBLE_val; + if (type==_INT_) + return double(val); + gen tmp=evalf_double(1,contextptr); + if (tmp.type==_DOUBLE_) + return tmp._DOUBLE_val; +#ifdef NAN + return NAN; +#else + double d=1.0; + d=d-d/double(1ULL<<53); + return d*2.0/d; +#endif + } + + bool gen::is_vector_of_size(size_t n) const { + return type==_VECT && _VECTptr->size()==n; + } + + bool gen::is_identificateur_with_name(const char * s) const { + return type==_IDNT && strcmp(_IDNTptr->id_name,s)==0; + } + + + int gen::to_int() const { + switch (type ) { + case _INT_: + return val; + case _ZINT: + return mpz_get_si(*_ZINTptr); + case _CPLX: + return _CPLXptr->to_int() ; + default: +#ifndef NO_STDEXCEPT + settypeerr(gettext("To_int")); +#endif + return 0; + } + return 0; + } + + void gen::uncoerce(size_t s) { + if (type==_INT_){ + int tmp =val; +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_mpz_t(s)) << 16; +#else + __ZINTptr = new ref_mpz_t(s); +#endif + type=_ZINT; + mpz_set_si(*_ZINTptr,tmp); + } + } + + gen _FRAC2_SYMB(const fraction & f){ + if (is_one(f.num)) + return symb_inv(f.den); + if (is_minus_one(f.num)) + return -symb_inv(f.den); + return symbolic(at_prod,makesequence(f.num,symb_inv(f.den))); + } + + gen _FRAC2_SYMB(const gen & e){ +#ifdef DEBUG_SUPPORT + if (e.type!=_FRAC) setsizeerr(gettext("gen.cc/_FRAC2_SYMB")); +#endif + return _FRAC2_SYMB(*e._FRACptr); + } + + gen _FRAC2_SYMB(const gen & n,const gen & d){ + return symbolic(at_prod,makesequence(n,symb_inv(d))); + } + + + /* Eval, evalf */ + gen evalf_VECT(const vecteur & v,int subtype,int level,const context * contextptr){ + // bool save_is_inevalf=is_inevalf; + // is_inevalf=true; + vecteur w; + vecteur::const_iterator it=v.begin(), itend=v.end(); + w.reserve(itend-it); + for (;it!=itend;++it){ + gen tmp=it->evalf(level,contextptr); + if (subtype){ + if ((subtype==_SEQ__VECT)&&(tmp.type==_VECT) && (tmp.subtype==_SEQ__VECT)){ + const_iterateur jt=tmp._VECTptr->begin(),jtend=tmp._VECTptr->end(); + for (;jt!=jtend;++jt) + w.push_back(*jt); + } + else { + if ((subtype!=_SET__VECT) || (!equalposcomp(w,tmp))) + w.push_back(tmp); + } + } + else + w.push_back(tmp); + } + // is_inevalf=save_is_inevalf; + return gen(w,subtype); + } + + + bool eval_VECT(const gen & g,gen & evaled,int subtype,int level,const context * contextptr){ + // const vecteur & v = *g._VECTptr; + gen tmp; + const gen * ansptr; + ref_vecteur * vptr; + const_iterateur it=g._VECTptr->begin(),itend=g._VECTptr->end(),jt,jtend; + if (subtype!=_SET__VECT && subtype!=_SEQ__VECT){ + for (;it!=itend;++it){ + if (it->in_eval(level,evaled,contextptr)) + break; + } + if (it==itend) + return false; + } + vptr = new_ref_vecteur(0); + vptr->v.reserve(itend-g._VECTptr->begin()); + if (subtype!=_SET__VECT && subtype!=_SEQ__VECT){ + for (jt=g._VECTptr->begin();jt!=it;++jt) + vptr->v.push_back(*jt); + if (evaled.type==_VECT && evaled.subtype==_SEQ__VECT){ + jt=evaled._VECTptr->begin(); jtend=evaled._VECTptr->end(); + for (;jt!=jtend;++jt){ + if ((subtype!=_SET__VECT) || (!equalposcomp(vptr->v,*jt))) + vptr->v.push_back(*jt); + } + } + else { + if ( subtype!=_SET__VECT || (!equalposcomp(vptr->v,evaled))) + vptr->v.push_back(evaled); + } + ++it; + } + evaled=gen(vptr,subtype); + for (;it!=itend;++it){ + if (it->is_symb_of_sommet(at_comment)) + continue; + ansptr=(it->in_eval(level,tmp,contextptr))?&tmp:&*it; + if (ansptr->type==_VECT && ansptr->subtype==_SEQ__VECT){ + jt=ansptr->_VECTptr->begin(); jtend=ansptr->_VECTptr->end(); + for (;jt!=jtend;++jt){ + if ((subtype!=_SET__VECT) || (!equalposcomp(vptr->v,*jt))) + vptr->v.push_back(*jt); + } + } + else { + if ( subtype!=_SET__VECT || (!equalposcomp(vptr->v,*ansptr))) + vptr->v.push_back(*ansptr); + } + } + // CERR << "End " << v << " " << w << '\n'; + return true; + } + + // evalf a real fraction + gen evalf_FRAC(const fraction & f,GIAC_CONTEXT){ + gen n(f.num),d(f.den); + if (n.type==_INT_ && d.type==_INT_) + return evalf(n,1,contextptr)/evalf(d,1,contextptr); + if (is_zero(n)) + return evalf(n,0,contextptr); + bool npos=is_positive(n,contextptr),dpos=is_positive(d,contextptr); + bool neg=npos?!dpos:dpos; + if (!npos) + n=-n; + if (!dpos) + d=-d; + bool inf1=is_greater(d,n,contextptr); +#ifdef FXCG + gen m=gen(longlong(1)<<61); + gen md=gen(1.0)/m; +#else +#ifdef BCD + static gen m=gen(longlong(100000000000000)); +#else + static gen m=gen(longlong(1)<<61); +#endif + static gen md=gen(1.0)/m; +#endif + if (absint(sizeinbase2(n)-sizeinbase2(d))>=53){ + gen a=inf1?iquo(d,n):iquo(n,d); + gen res=evalf(a,1,contextptr); + if (neg) res=-res; + return inf1?inv(res,contextptr):res; + } + gen a=inf1?iquo(d*m,n):iquo(n*m,d); + gen res=evalf(a,1,contextptr); + if (neg) res=-res; + res = md*res; + return inf1?inv(res,contextptr):res; + } + + // evaluate _FUNCndary in RPN mode, f must be of type _FUNC + static gen rpneval_FUNC(const gen & f,GIAC_CONTEXT){ + // int s=history_out(contextptr).size(); + int nargs=giacmax(f.subtype,0); + if (!nargs){ + gen res=(*f._FUNCptr)(gen(history_out(contextptr),_RPN_STACK__VECT),contextptr); + if ( (res.type!=_VECT) || (res.subtype!=_RPN_STACK__VECT)) + res=gen(makenewvecteur(res),_RPN_STACK__VECT); + history_out(contextptr)=*res._VECTptr; + history_in(contextptr)=history_out(contextptr); + return res; + } + vecteur v(nargs); + for (int i=nargs-1;i>=0;--i){ + v[i]=history_out(contextptr).back(); + history_out(contextptr).pop_back(); + history_in(contextptr).pop_back(); + } + if (nargs==1) + return (*f._FUNCptr)(v.front(),contextptr); + else + return (*f._FUNCptr)(v,contextptr); + } + + static bool evalcomment(const vecteur & v,gen &evaled,int level,const context * contextptr){ + const_iterateur it=v.begin(),itend=v.end(); + for (;it!=itend;++it){ + if ( (it->type!=_SYMB) || (it->_SYMBptr->sommet!=at_comment) ) + break; + } + if (it+1==itend){ + evaled=it->eval(level,contextptr); + return true; + } + if (it!=itend){ + gen partial=vecteur(it,itend); + if (eval_VECT(partial,evaled,_SEQ__VECT,level,contextptr)) + return true; + else { + evaled=partial; + return true; + } + } + evaled=zero; + return true; + } + + bool check_not_assume(const gen & not_evaled,gen & evaled, bool evalf_after,const context * contextptr){ + if ( evaled.type==_VECT && evaled.subtype==_ASSUME__VECT ){ + if ( evalf_after && evaled._VECTptr->size()==2 && (evaled._VECTptr->back().type<=_CPLX || evaled._VECTptr->back().type==_FRAC || evaled._VECTptr->back().type==_FLOAT_) ){ + evaled=evaled._VECTptr->back().evalf(1,contextptr); + return true; + } + if (not_evaled.type==_IDNT && evaled._VECTptr->size()==1 && evaled._VECTptr->front().type==_INT_){ + gen tmp=not_evaled; + tmp.subtype=evaled._VECTptr->front().val; + evaled=tmp; + return true; + } + return false; + } + else { + if (evalf_after && evaled.type!=_IDNT){ + gen res; + if (has_evalf(evaled,res,0,contextptr)){ + evaled=res; + return true; + } + } + return &evaled!=¬_evaled; + } + return false; + } + +#if 0 + gen gen::eval(int level,const context * contextptr) const{ + // CERR << "eval " << *this << " " << level << '\n'; + gen res; + // return in_eval(level,res,contextptr)?res:*this; + if (in_eval(level,res,contextptr)) + return res; + else + return *this; + } +#endif + + static bool in_eval_mod(const gen & g,gen & evaled,int level,GIAC_CONTEXT){ + evaled=makemod(g._MODptr->eval(level,contextptr),(g._MODptr+1)->eval(level,contextptr)); + return true; + } + + static bool in_eval_user(const gen & g,gen & evaled,int level,GIAC_CONTEXT){ + evaled=g._USERptr->eval(level,contextptr); + return true; + } + + static bool in_eval_func(const gen & g,gen * evaledptr,GIAC_CONTEXT){ + if (rpn_mode(contextptr) && (history_out(contextptr).size()>=unsigned(g.subtype))) + *evaledptr=rpneval_FUNC(g,contextptr); + else { + if (g.subtype) + return false; + else + *evaledptr=(*g._FUNCptr)(gen(vecteur(0),_SEQ__VECT),contextptr); + } + return true; + } + + static bool in_eval_idnt(const gen & g,gen & evaled,int level,GIAC_CONTEXT){ + identificateur * gptr=g._IDNTptr; + if (strcmp(gptr->id_name,string_pi)==0 || strcmp(gptr->id_name,string_euler_gamma)==0 ) + return false; + if (!contextptr && g.subtype==_GLOBAL__EVAL) + evaled=global_eval(*gptr,level); + else { + if (!gptr->in_eval(level-1,g,evaled,contextptr)) + return false; + } + if ( evaled.type!=_VECT || evaled.subtype!=_ASSUME__VECT ){ + if (evaled.is_symb_of_sommet(at_program)) + lastprog_name(gptr->id_name,contextptr); + return true; + } + return check_not_assume(g,evaled,false,contextptr); + } + + static bool in_eval_vect(const gen & g,gen & evaled,int level,GIAC_CONTEXT){ +#ifdef HAVE_LIBMPFI + if (g.subtype==_INTERVAL__VECT && g._VECTptr->size()==2){ + // convert to MPFI real_interval + gen l=eval(g._VECTptr->front(),level,contextptr),u=eval(g._VECTptr->back(),level,contextptr); + if (is_strictly_greater(l,u,contextptr)){ + swapgen(l,u); + } + bool lexact=is_integer(l),uexact=is_integer(u); + gen ul=u-l; + if (is_exactly_zero(ul)){ + if (u.type==_REAL) + ul=int(mpfr_get_prec(u._REALptr->inf)); + else + ul=int(3.2*decimal_digits(contextptr)); + } + else { + ul=u-l; + ul=2*ul/(abs(u,contextptr)+abs(l,contextptr)); + ul=ln(abs(evalf(ul,1,contextptr),contextptr),contextptr); + ul=-_ceil(ul/ln(evalf(2,1,contextptr),contextptr),contextptr); + } + int nbits=53; + if (ul.type==_INT_ && ul.val>48){ + nbits=ul.val+4; + l=accurate_evalf(l,nbits); + u=accurate_evalf(u,nbits); + } + else { + l=evalf(l,level,contextptr); u=evalf(u,level,contextptr); + } + if (l.type==_DOUBLE_ && u.type==_REAL) + u=evalf_double(u,1,contextptr); + if (u.type==_DOUBLE_ && l.type==_REAL) + l=evalf_double(l,1,contextptr); + if (l.type==_DOUBLE_){ + // adjust mantissa of l down and mantissa of u up + double epsilon=7e-15; // 2^(-47) + if (!lexact) + l=(1.+(l._DOUBLE_val>0?(-epsilon):(epsilon)))*l; + if (!uexact) + u=(1.+(u._DOUBLE_val>0?(epsilon):(-epsilon)))*u; + } + else { // do the same for MPFR + gen epsilon=pow(plus_two,nbits-2,contextptr); // nbits-3? + epsilon=fraction(1,epsilon); + if (!lexact){ + if (is_positive(l,contextptr)) + l=(1-epsilon)*l; + else + l=(1+epsilon)*l; + } + if (!uexact){ + if (is_positive(u,contextptr)) + u=(1+epsilon)*u; + else + u=(1-epsilon)*u; + } + } + if ( (l.type==_DOUBLE_ && u.type==_DOUBLE_) || + (l.type==_REAL && u.type==_REAL) ){ + mpfi_t interv; + mpfi_init(interv); + mpfi_set_prec(interv,nbits); + if (l.type==_DOUBLE_) + mpfi_interv_d(interv,l._DOUBLE_val,u._DOUBLE_val); + else + mpfi_interv_fr(interv,l._REALptr->inf,u._REALptr->inf); + evaled=gen(real_interval(interv)); + mpfi_clear(interv); + return true; + } + } +#endif + if (g.subtype==_SPREAD__VECT){ + makespreadsheetmatrice(*g._VECTptr,contextptr); + spread_eval(*g._VECTptr,contextptr); + return false; + } + if (g.subtype==_TABLE__VECT){ + eval_VECT(g,evaled,g.subtype,level,contextptr); + evaled=_table(evaled,contextptr); + return true; + } + if (g.subtype==_FOLDER__VECT || g.subtype==_RGBA__VECT) + return false; + if ( (g.subtype==_SEQ__VECT) && (!g._VECTptr->empty()) && (g._VECTptr->front().type==_SYMB) + && (g._VECTptr->front().is_symb_of_sommet(at_comment)) + && (g._VECTptr->back().type==_SYMB) + && (g._VECTptr->back().is_symb_of_sommet(at_return)) + ){ + return evalcomment(*g._VECTptr,evaled,level,contextptr); + } + if (g._VECTptr->size()==1 && g._VECTptr->front().is_symb_of_sommet(at_interval)) + return in_eval_vect(gen(makevecteur(g._VECTptr->front()[1],g._VECTptr->front()[2]),_INTERVAL__VECT),evaled,1,contextptr); + return eval_VECT(g,evaled,g.subtype,level,contextptr); + } + + bool gen::in_eval(int level,gen & evaled,const context * contextptr) const{ +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) { + interrupted = true; ctrl_c=false; + *logptr(contextptr) << "Stopped in in_eval" << '\n'; + gensizeerr(gettext("Stopped by user interruption."),evaled); + return true; + } + if (!level) + return false; + switch (type) { + case _INT_: case _DOUBLE_: case _FLOAT_: case _ZINT: case _REAL: case _CPLX: case _POLY: case _FRAC: case _SPOL1: case _EXT: case _STRNG: case _MAP: case _EQW: case _GROB: case _POINTER_: + return false; + case _IDNT: + return in_eval_idnt(*this,evaled,level,contextptr); + case _VECT: + return in_eval_vect(*this,evaled,level,contextptr); + case _SYMB: + if (subtype==_SPREAD__SYMB) + return false; + { + symbolic * sptr=_SYMBptr; + unary_function_ptr & Sommet=sptr->sommet; + const gen & feuille=sptr->feuille; + bool is_ifte=false,is_of_local_ifte_bloc=false,is_plus=Sommet==at_plus,is_prod=false,is_pow=false; + if (is_plus || (is_prod=(Sommet==at_prod)) || (is_pow=(Sommet==at_pow)) || (is_of_local_ifte_bloc=(Sommet==at_of || Sommet==at_local || (is_ifte=Sommet==at_ifte) || Sommet==at_bloc)) ){ + int & elevel=eval_level(contextptr); + short int slevel=elevel; + // Check if we are not far from stack end +#ifdef RTOS_THREADX + if ((void *)&slevel<= (void *)&mainThreadStack[2048]){ + if ((void *)&slevel<= (void *)&mainThreadStack[1024]){ + gensizeerr(gettext("Too many recursion levels"),evaled); // two many recursion levels + return true; + } + evaled=nr_eval(*this,level,contextptr); + return true; + } +#else // rtos +#if !defined(WIN32) && defined(HAVE_PTHREAD_H) && defined HAVE_LIBPTHREAD + void * stackaddr; + if (contextptr && (stackaddr=thread_param_ptr(contextptr)->stackaddr)){ + // CERR << &slevel << " " << thread_param_ptr(contextptr)->stackaddr << '\n'; + if ( ((size_t) &slevel) < ((size_t) stackaddr)+65536){ + if ( ((size_t) &slevel) < ((size_t) stackaddr)+8192){ + gensizeerr(gettext("Too many recursion levels"),evaled); // two many recursion levels + return true; + } + *logptr(contextptr) << gettext("Running non recursive evaluator") << '\n'; + evaled=nr_eval(*this,level,contextptr); + return true; + } + } else +#endif // pthread + { + debug_struct * dbgptr=debug_ptr(contextptr); + if ( int(dbgptr->sst_at_stack.size()) >= MAX_RECURSION_LEVEL){ + if ( int(dbgptr->sst_at_stack.size()) >= MAX_RECURSION_LEVEL+10){ + gensizeerr(gettext("Too many recursions)"),evaled); + return true; + } +#ifdef KHICAS + if (warn_nr){ + *logptr(contextptr) << gettext("Running non recursive evaluator") << '\n'; + warn_nr=false; + } +#else + *logptr(contextptr) << gettext("Running non recursive evaluator") << '\n'; +#endif + evaled=nr_eval(*this,level,contextptr); + return true; + } + } +#endif // rtos + const vecteur * vptr; + if ( (is_plus ||is_prod || is_pow) && feuille.type==_VECT && (vptr=feuille._VECTptr)->size()==2){ + const gen & vptrfront=vptr->front(); + const gen & vptrback=vptr->back(); + gen a; + if (!vptrfront.in_eval(level,a,contextptr)) + a=vptrfront; + if (a.type!=_VECT || a.subtype!=_SEQ__VECT){ + if (!vptrback.in_eval(level,evaled,contextptr)) + evaled=vptrback; + if (evaled.type!=_VECT || evaled.subtype!=_SEQ__VECT){ + if (is_plus) evaled=operator_plus(a,evaled,contextptr); + else { + if (is_prod) evaled=operator_times(a,evaled,contextptr); + else evaled=pow(a,evaled,contextptr); + } + elevel=slevel; + return true; + } + } + } + if (is_of_local_ifte_bloc){ + elevel=level; + evaled=feuille; // FIXME must also set eval_level to level + } + else { + if (!feuille.in_eval(level,evaled,contextptr)) + evaled=feuille; + } + if (is_ifte) + evaled=ifte(evaled,true,contextptr); + else + evaled=(*Sommet.ptr())(evaled,contextptr); + elevel=slevel; + } + else + evaled=sptr->eval(level,contextptr); + return true; + } + case _USER: + return in_eval_user(*this,evaled,level,contextptr); + case _MOD: + return in_eval_mod(*this,evaled,level,contextptr); + case _FUNC: + return in_eval_func(*this,&evaled,contextptr); + default: + gentypeerr("Eval",evaled) ; + return false; + } + return false; + } + + polynome apply( const polynome & p, const gen_op & f){ + polynome res(p.dim); + std::vector< monomial > :: const_iterator it=p.coord.begin(),itend=p.coord.end(); + res.coord.reserve(itend-it); + for (;it!=itend;++it){ + gen tmp(f(it->value)); + if (!is_zero(tmp,context0)) + res.coord.push_back(monomial(tmp,it->index)); + } + return res; + } + + polynome apply( const polynome & p, const context * contextptr, gen (* f) (const gen &, const context *)){ + polynome res(p.dim); + std::vector< monomial > :: const_iterator it=p.coord.begin(),itend=p.coord.end(); + res.coord.reserve(itend-it); + for (;it!=itend;++it){ + gen tmp(f(it->value,contextptr)); + if (!is_zero(tmp,contextptr)) + res.coord.push_back(monomial(tmp,it->index)); + } + return res; + } + + static gen set_precision(const gen & g,int nbits){ + if (nbits<45) + return evalf_double(g,1,context0); +#ifdef HAVE_LIBMPFR + return real_object(g,nbits); +#else + gen tmp=evalf_double(g,1,context0); + gen G=g; + if (tmp.type==_DOUBLE_ && tmp._DOUBLE_val!=0) + round2(G,int(nbits-std::log(absdouble(tmp._DOUBLE_val))/std::log(2.0))); + return evalf_double(G,1,context0); +#endif + } + + gen accurate_evalf(const gen & g,int nbits){ + if (g.type==_FRAC && g._FRACptr->num.type==_VECT) + return inv(accurate_evalf(g._FRACptr->den,nbits),context0)*accurate_evalf(g._FRACptr->num,nbits); + if (g.type==_VECT) + return gen(accurate_evalf(*g._VECTptr,nbits),g.subtype); + gen r,i;reim(g,r,i,context0); // only called for numeric values + if (is_zero(i,context0)) + return set_precision(r,nbits); + else + return gen(set_precision(r,nbits),set_precision(i,nbits)); + } + + vecteur accurate_evalf(const vecteur & v,int nbits){ + vecteur res(v); + iterateur it=res.begin(),itend=res.end(); + for (;it!=itend;++it) + *it = accurate_evalf(*it,nbits); + return res; + } + + gen evalf(const gen & e,int level,const context * contextptr){ + return e.evalf(level,contextptr); + } + + gen no_context_evalf(const gen & e){ + gen tmp; + if (has_evalf(e,tmp,1,context0)) + return tmp; + else + return e; + } + + static const double double0_15[]={0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0}; + static double _int2double(unsigned i){ + if (i<16) + return double0_15[i]; + else + return _int2double(i/16)*16.0+double0_15[i%16]; + } + // double(int) does not seem to work under GNUWINCE + double int2double(int i){ + if (i<0){ +#if defined WIN32 && !defined __CYGWIN__ // INT_MAX not defined with cygwin + if (i<-INT_MAX) return -1.0-INT_MAX; +#else + if (i<-RAND_MAX) return -1.0-RAND_MAX; +#endif + return -_int2double(-i); + } + else + return _int2double(i); + } + + + gen gen::evalf(int level,const context * contextptr) const{ + // CERR << "evalf " << *this << " " << level << '\n'; +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) { + interrupted = true; ctrl_c=false; + return gensizeerr(gettext("Stopped by user interruption.")); + } + if (level==0) + return *this; + gen evaled; + if (in_evalf(level,evaled,contextptr)) + return evaled; + else + return *this; + } + + gen m_pi(GIAC_CONTEXT){ + int nbits=digits2bits(decimal_digits(contextptr)); + return m_pi(nbits); + } + + gen m_pi(int nbits){ +#ifdef HAVE_LIBMPFR + if (nbits>48){ +#ifdef HAVE_LIBPTHREAD + int locked=pthread_mutex_lock(&mpfr_mutex); +#else // HAVE_LIBPTHREAD + int locked=0; +#endif + if (!locked) + mpfr_set_default_prec(nbits); + mpfr_t pi; + mpfr_init(pi); + mpfr_const_pi(pi,MPFR_RNDN); +#ifdef HAVE_LIBPTHREAD + if (!locked) + pthread_mutex_unlock(&mpfr_mutex); +#endif + gen res=real_object(pi); + mpfr_clear(pi); + return res; + } +#endif +#if 0 // def BCD + return fpi(); +#else + return M_PI; +#endif + } + + gen m_gamma(int nbits){ +#ifdef HAVE_LIBMPFR + if (nbits>15){ +#ifdef HAVE_LIBPTHREAD + int locked=pthread_mutex_lock(&mpfr_mutex); +#else // HAVE_LIBPTHREAD + int locked=0; +#endif + if (!locked) + mpfr_set_default_prec(nbits); + mpfr_t euler_gamma; + mpfr_init(euler_gamma); +#ifdef BF2GMP_H + mpfr_set_str(euler_gamma,"0.5772156649015328606065120900824024310421593359399235988057672348848677267776646709369470632917467495146314472498070824809605040144865428362241739976449235362535003337429373377376739427925952582470949160087352039481656708532331517766115286211995015079847937450857057400299213547861466940296043254215190587755352",nbits,MPFR_RNDN); +#else + mpfr_const_euler(euler_gamma,MPFR_RNDN); +#endif +#ifdef HAVE_LIBPTHREAD + if (!locked) + pthread_mutex_unlock(&mpfr_mutex); +#endif + gen res=real_object(euler_gamma); + mpfr_clear(euler_gamma); + return res; + } +#endif + return .577215664901533; + } + + gen m_gamma(GIAC_CONTEXT){ + int nbits=digits2bits(decimal_digits(contextptr)); + return m_gamma(nbits); + } + + static bool approx_pnt(int level,const gen & g,gen & evaled,const context * contextptr){ + vecteur v=*g._SYMBptr->feuille._VECTptr; + if (!v[0].in_evalf(level,evaled,contextptr)) + return false; + v[0]=evaled; + evaled=symbolic(at_pnt,gen(v,g._SYMBptr->feuille.subtype)); + return true; + } + + static bool has_evalf(const identificateur & g,int subtype,gen & res,int level,GIAC_CONTEXT){ + if (strcmp(g.id_name,string_pi)==0){ + res=m_pi(contextptr); + return true; + } + gen tmp=g; + tmp.subtype=subtype; + tmp=tmp.evalf(level,contextptr); + if (tmp.type==_IDNT || tmp.type==_SYMB) + return false; + return has_evalf(tmp,res,0,contextptr); + } + + bool has_evalf(const gen & g,gen & res,int level,GIAC_CONTEXT){ + switch (g.type){ + case _DOUBLE_: case _FLOAT_: case _REAL: + res=g; + return true; + case _INT_: case _ZINT: case _CPLX: + res=evalf(g,1,contextptr); + return true; + case _IDNT: + return has_evalf(*g._IDNTptr,g.subtype,res,level,contextptr); + case _SYMB: + if (has_evalf(g._SYMBptr->feuille,res,level,contextptr)){ + res=g._SYMBptr->sommet(res,contextptr); + if (res.type==_INT_ || res.type==_ZINT) + res=evalf(res,1,contextptr); + return res.type==_DOUBLE_ || res.type==_FLOAT_ || res.type==_CPLX || res.type==_REAL; + } + else + return false; + } + if (g.type==_EXT){ + gen a,b; + if (has_evalf(*g._EXTptr,a,level,contextptr) && has_evalf(*(g._EXTptr+1),b,level,contextptr)){ + a=alg_evalf(a,b,contextptr); + return a.type==_EXT?false:has_evalf(a,res,level,contextptr); + } + return false; + } + if (g.type==_FRAC){ + if (is_cinteger(g._FRACptr->num) && is_cinteger(g._FRACptr->den)){ + return g.in_evalf(1,res,contextptr); + } + gen num,den; + if (has_evalf(g._FRACptr->num,num,level,contextptr) && has_evalf(g._FRACptr->den,den,level,contextptr)){ + res=num/den; + return true; + } + else + return false; + } + if (g.type!=_VECT) + return false; + if (g.subtype==_ASSUME__VECT && !g._VECTptr->empty()){ + res=g._VECTptr->back(); + return true; + } + vecteur v; + const_iterateur it=g._VECTptr->begin(),itend=g._VECTptr->end(); + v.reserve(itend-it); + for (;it!=itend;++it){ + if (!has_evalf(*it,res,level,contextptr)) + return false; + v.push_back(res); + } + res=gen(v,g.subtype); + return true; + } + + bool gen::in_evalf(int level,gen & evaled,const context * contextptr) const{ + if (!level) + return false; + switch (type) { + case _REAL: +#if 0 // ndef NO_RTTI // infinite recursion with has_evalf and real intervals + if (real_interval * ptr=dynamic_cast(_REALptr)){ + evaled=real_object(ptr->inf); + return true; + } +#endif + return false; + case _DOUBLE_: case _FLOAT_: case _STRNG: case _MAP: case _EQW: case _GROB: case _POINTER_: + return false; + case _INT_: + if (subtype) + return false; + if (decimal_digits(contextptr)>14){ + evaled=real_object(*this,digits2bits(decimal_digits(contextptr))); + return true; + } +#if 0 // def BCD + evaled=giac_float(val); +#else + evaled=int2double(val); +#endif + return true; + case _ZINT: +#if 0 // def BCD + evaled=giac_float(_ZINTptr); +#else + if (decimal_digits(contextptr)>14) + evaled=real_object(*this,digits2bits(decimal_digits(contextptr))); + else + evaled=mpz_get_d(*_ZINTptr); +#endif + return true; + case _CPLX: + evaled=gen(_CPLXptr->evalf(level,contextptr),(_CPLXptr+1)->evalf(level,contextptr)); + return true; + case _USER: + evaled=_USERptr->evalf(level,contextptr); + return true; + case _IDNT: + if (strcmp(_IDNTptr->id_name,string_pi)==0){ + evaled=m_pi(contextptr); + return true; + } + if (strcmp(_IDNTptr->id_name,string_euler_gamma)==0){ + evaled=m_gamma(contextptr); + return true; + } + if (!contextptr && subtype==_GLOBAL__EVAL) + evaled=global_evalf(*_IDNTptr,level-1); + else { + if (!_IDNTptr->in_eval(level-1,*this,evaled,contextptr)) + return false; + } + return check_not_assume(*this,evaled,true,contextptr); + case _VECT: + evaled=evalf_VECT(*_VECTptr,subtype,level,contextptr); + return true; + case _SYMB: + if (subtype==_SPREAD__SYMB) + return false; + if (_SYMBptr->sommet==at_pow && _SYMBptr->feuille._VECTptr->back().type==_INT_){ + evaled=pow(_SYMBptr->feuille._VECTptr->front().evalf(level,contextptr),_SYMBptr->feuille._VECTptr->back(),contextptr); + return true; + } + if (_SYMBptr->sommet==at_integrate || (_SYMBptr->sommet==at_int && xcas_mode(contextptr)!=3)){ + evaled=_gaussquad(_SYMBptr->feuille,contextptr); // FIXME: take care of precision (romberg if >14 digits?) + return true; + } + if (_SYMBptr->sommet==at_rootof){ + evaled=approx_rootof(_SYMBptr->feuille.evalf(level,contextptr),contextptr); + return true; + } + if (_SYMBptr->sommet==at_cell) + return false; + if (_SYMBptr->sommet==at_pnt && _SYMBptr->feuille.type==_VECT && !_SYMBptr->feuille._VECTptr->empty()) + return approx_pnt(level,*this,evaled,contextptr); + evaled=_SYMBptr->evalf(level,contextptr); + return true; + case _FRAC: +#ifdef HAVE_LIBMPFR + if (decimal_digits(contextptr)>14) + evaled=rdiv(_FRACptr->num.evalf(level,contextptr),_FRACptr->den.evalf(level,contextptr),contextptr); + else +#endif + { + if (is_zero(_FRACptr->num.im(contextptr)) && is_zero(_FRACptr->den.im(contextptr))) + evaled=evalf_FRAC(*_FRACptr,contextptr); + else + evaled=re(contextptr).evalf(1,contextptr)+cst_i*im(contextptr).evalf(1,contextptr); + } + return true; +#ifdef HAVE_LIBMPFR + if (decimal_digits(contextptr)<=14) + evaled=set_precision(re(contextptr),60).evalf_double(1,contextptr)+cst_i*set_precision(im(contextptr),60).evalf_double(1,contextptr); + else +#endif + evaled=rdiv(_FRACptr->num.evalf(level,contextptr),_FRACptr->den.evalf(level,contextptr),contextptr); + return true; + case _FUNC: + return in_eval_func(*this,&evaled,contextptr); + case _MOD: case _ROOT: + return false; // replace in RPN mode + case _EXT: + evaled=alg_evalf(_EXTptr->eval(level,contextptr),(_EXTptr+1)->eval(level,contextptr),contextptr); + return true; + case _POLY: + evaled=apply(*_POLYptr,no_context_evalf); + return true; + default: + evaled=gentypeerr(gettext("Evalf")) ; + return false; + } + return false; + } + + gen real2int(const gen & g,GIAC_CONTEXT){ + if (g.type==_REAL){ + if (is_strictly_positive(-g,contextptr)) + return -real2int(-g,contextptr); + if (is_zero(g)) + return 0; +#ifdef BF2GMP_H + ref_mpz_t * m=new ref_mpz_t; + mpz_init(m->z); + mpz_set(m->z,g._REALptr->inf); + bf_rint(&m->z,BF_RNDD); + return gen(m); +#else +#ifdef HAVE_LIBMPFR + ref_mpz_t * m=new ref_mpz_t; + int n=int(mpfr_get_z_exp(m->z,g._REALptr->inf)); + gen res(m->z); + if (n>=0) + return res*pow(plus_two,gen(n),contextptr); + return _iquo(makesequence(res,pow(plus_two,gen(-n),contextptr)),contextptr); +#else + return g; +#endif // MPFR +#endif // BF2GMP_H + } + if (g.type!=_VECT) + return g; + return apply(g,real2int,contextptr); + } + + gen real2double(const gen & g){ + if (g.type==_REAL) + return g._REALptr->evalf_double(); + if (g.type==_FLOAT_) + return get_double(g._FLOAT_val); + if (g.type!=_VECT) + return g; + return apply(g,real2double); + } + + gen gen::evalf_double(int level,const context * contextptr) const{ + if (type==_DOUBLE_) + return *this; + if (type==_INT_ && subtype==_INT_BOOLEAN) + return double(val); + gen g; + if (has_evalf(*this,g,level,contextptr)){ + if (g.type==_CPLX) + return gen(real2double(*g._CPLXptr),real2double(*(g._CPLXptr+1))); + else + return real2double(g); + } + else + return *this; + } + + gen evalf2double_nock(const gen & g0,int level,const context * contextptr){ + if (g0.type==_INT_) + return double(g0.val); + if (g0.type==_DOUBLE_) + return g0; + if (g0.is_symb_of_sommet(at_program)) + return g0; + if (g0.type==_FLOAT_ || g0.type==_FRAC || g0.type==_ZINT || g0.type==_REAL) + return evalf_double(g0,1,contextptr); + if (storcl_38 && level && g0.type==_IDNT){ + if (!strcmp(g0._IDNTptr->id_name,"pi")) + return M_PI; + gen res; +// if (storcl_38(res,0,g0._IDNTptr->id_name,undef,false,contextptr)) return evalf2double_nock(res,level-1,contextptr); + } + if (g0.type==_VECT){ + ref_vecteur *vptr = new_ref_vecteur(*g0._VECTptr); + iterateur it=vptr->v.begin(),itend=vptr->v.end(); + for (;it!=itend;++it) + *it=evalf2double_nock(*it,level,contextptr); + return gen(vptr,g0.subtype); + } + if (is_inf(g0)||is_undef(g0)) + return g0; + if (g0.type==_SYMB){ + unary_function_ptr & s =g0._SYMBptr->sommet; + gen f =g0._SYMBptr->feuille; + if (s==at_integrate && f._VECTptr->size()==4) + return _gaussquad(f,contextptr); + if (f.type==_VECT && !s.quoted()){ + if (s==at_plus){ + double res(0); + gen tmp; + iterateur it=f._VECTptr->begin(),itend=f._VECTptr->end(); + for (;it!=itend;++it){ + tmp=evalf2double_nock(*it,level,contextptr); + if (tmp.type!=_DOUBLE_) + break; + res=res+tmp._DOUBLE_val; + } + if (it==itend) + return res; + } + if (s==at_prod){ + double res(1); + gen tmp; + iterateur it=f._VECTptr->begin(),itend=f._VECTptr->end(); + for (;it!=itend;++it){ + tmp=evalf2double_nock(*it,level,contextptr); + if (tmp.type!=_DOUBLE_) + break; + res=res*tmp._DOUBLE_val; + } + if (it==itend) + return res; + } + if (f._VECTptr->size()==2){ + gen tmp1=evalf2double_nock(f._VECTptr->front(),level,contextptr); + gen tmp2=f._VECTptr->back(); + if (tmp1.type==_DOUBLE_ && tmp2.type==_INT_ && s==at_pow) + return std::pow(tmp1._DOUBLE_val,double(tmp2.val)); + tmp2=evalf2double_nock(tmp2,level,contextptr); + if (s==at_pow) + return pow(tmp1,tmp2,contextptr); + if (s==at_division) + return rdiv(tmp1,tmp2,contextptr); + if (s==at_minus) + return operator_minus(tmp1,tmp2,contextptr); + tmp1=s(gen(makenewvecteur(tmp1,tmp2),f.subtype),contextptr); + if (tmp1.type<_IDNT || tmp1.type==_FRAC) + tmp1=evalf2double_nock(tmp1,1,contextptr); + return tmp1; + } + } + if (s.quoted()) { + if (s==at_quote) + return f; + f=s(f,contextptr); + if (f.type<_IDNT || f.type==_FRAC || (f.type==_SYMB && contains(f,cst_pi)) ) + f=evalf2double_nock(f,1,contextptr); + return f; + } + f=s(evalf2double_nock(f,level,contextptr),contextptr); + if (f.type<_IDNT || f.type==_FRAC) + f=evalf2double_nock(f,1,contextptr); + return f; + } + if (g0.type==_CPLX){ + if (g0._CPLXptr->type==_DOUBLE_ && (g0._CPLXptr+1)->type==_DOUBLE_){ +#if 1 + // maybe we should round complex numbers that are close to reals? + if (fabs((g0._CPLXptr+1)->_DOUBLE_val)<1e-12*fabs(g0._CPLXptr->_DOUBLE_val)) + return g0._CPLXptr->_DOUBLE_val; +#endif + return g0; + } + return evalf2double_nock(*g0._CPLXptr,1,contextptr)+cst_i*evalf2double_nock(*(g0._CPLXptr+1),1,contextptr); + } + gen g=evalf(g0,level,contextptr); + if (g.type==_FLOAT_) + return evalf_double(g,1,contextptr); + if (g.type==_CPLX) + return evalf2double_nock(*g._CPLXptr,1,contextptr)+cst_i*evalf2double_nock(*(g._CPLXptr+1),1,contextptr); + return g; + } + + + gen gen::evalf2double(int level,const context * contextptr) const{ + /* + gen g=evalf(level,contextptr); + return g.evalf_double(level,contextptr); + */ + return evalf2double_nock(*this,level,contextptr); + } + + gen chk_inf_nan(const gen & g0){ + if (g0.type==_FLOAT_){ + if (fis_nan(g0._FLOAT_val)) + return undeferr(gettext("Undefined")); + if (fis_inf_notmax(g0._FLOAT_val)) + return undeferr(gettext("Infinity error")); + return g0; + } + if (is_undef(g0)){ + if (g0.type==_STRNG) + return g0; + if (g0.type==_VECT && !g0._VECTptr->empty()) + return g0._VECTptr->front(); + return undeferr(gettext("Undefined")); + } + if (is_inf(g0)) + return undeferr(gettext("Infinity error")); + return g0; + } + + gen evalf2bcd_nock(const gen & g0,int level,const context * contextptr){ + if (g0.type==_FLOAT_) + return g0; + if (g0.type==_FRAC) + return evalf_FRAC(*g0._FRACptr,contextptr); + if (g0.type==_INT_) + return giac_float(g0.val); + // FIXME _ZINT should be converted without being evalf-ed to double +#ifdef BCD + if (g0.type==_ZINT) + return giac_float(g0._ZINTptr); +#endif + if (storcl_38 && level && g0.type==_IDNT){ +#ifdef BCD + if (!strcmp(g0._IDNTptr->id_name,"pi")) + return fpi(); +#endif + gen res; + if (storcl_38(res,0,g0._IDNTptr->id_name,undef,false,contextptr,NULL,false)) + return evalf2bcd_nock(res,level-1,contextptr); + } + if (g0.type==_VECT){ + ref_vecteur *vptr = new_ref_vecteur(*g0._VECTptr); + iterateur it=vptr->v.begin(),itend=vptr->v.end(); + for (;it!=itend;++it) + *it=evalf2bcd_nock(*it,level,contextptr); + return gen(vptr,g0.subtype); + } + if (is_inf(g0)||is_undef(g0)) + return g0; + if (g0.type==_SYMB){ + /* + if (g0._SYMBptr->sommet==at_unit){ + gen f = g0._SYMBptr->feuille; + if (f.type==_VECT && f._VECTptr->size()==2){ + f=gen(makevecteur(evalf2bcd_nock(f._VECTptr->front(),level,contextptr),f._VECTptr->back()),f.subtype); + return symbolic(at_unit,f); + } + else + return g0; + } + */ + unary_function_ptr & s =g0._SYMBptr->sommet; + gen f =g0._SYMBptr->feuille; + if (s==at_integrate && f._VECTptr->size()==4) + return _gaussquad(f,contextptr); + if (f.type==_VECT && !s.quoted()){ + if (s==at_plus){ + giac_float res(0); + gen tmp; + iterateur it=f._VECTptr->begin(),itend=f._VECTptr->end(); + for (;it!=itend;++it){ + tmp=evalf2bcd_nock(*it,level,contextptr); + if (tmp.type!=_FLOAT_) + break; + res=res+tmp._FLOAT_val; + } + if (it==itend) + return res; + } + if (s==at_prod){ + giac_float res(1); + gen tmp; + iterateur it=f._VECTptr->begin(),itend=f._VECTptr->end(); + for (;it!=itend;++it){ + tmp=evalf2bcd_nock(*it,level,contextptr); + if (tmp.type!=_FLOAT_) + break; + res=res*tmp._FLOAT_val; + } + if (it==itend) + return res; + } + if (f._VECTptr->size()==2){ + gen tmp1=evalf2bcd_nock(f._VECTptr->front(),level,contextptr); + gen tmp2=f._VECTptr->back(); + if (tmp1.type==_FLOAT_ && tmp2.type==_INT_ && s==at_pow) + return fpow(tmp1._FLOAT_val,giac_float(tmp2.val)); + tmp2=evalf2bcd_nock(tmp2,level,contextptr); + if (s==at_pow) + return pow(tmp1,tmp2,contextptr); + if (s==at_division) + return rdiv(tmp1,tmp2,contextptr); + if (s==at_minus) + return operator_minus(tmp1,tmp2,contextptr); + tmp1=s(gen(makenewvecteur(tmp1,tmp2),f.subtype),contextptr); + if (tmp1.type<_IDNT || tmp1.type==_FRAC) + tmp1=evalf2bcd_nock(tmp1,1,contextptr); + return tmp1; + } + } + if (s.quoted()) { + if (s==at_quote) + return f; + f=s(f,contextptr); + if (f.type<_IDNT || f.type==_FRAC) + f=evalf2bcd_nock(f,1,contextptr); + return f; + } + f=s(evalf2bcd_nock(f,level,contextptr),contextptr); + if (f.type<_IDNT || f.type==_FRAC) + f=evalf2bcd_nock(f,1,contextptr); + return f; + } + if (g0.type==_CPLX){ + if (g0._CPLXptr->type==_FLOAT_ && (g0._CPLXptr+1)->type==_FLOAT_) + return g0; + return evalf2bcd_nock(*g0._CPLXptr,1,contextptr)+cst_i*evalf2bcd_nock(*(g0._CPLXptr+1),1,contextptr); + } + gen g=evalf(g0,level,contextptr); + if (g.type==_DOUBLE_) + return giac_float(g._DOUBLE_val); + if (g.type==_CPLX) + return evalf2bcd_nock(*g._CPLXptr,1,contextptr)+cst_i*evalf2bcd_nock(*(g._CPLXptr+1),1,contextptr); + return g; + } + + gen evalf2bcd(const gen & g0,int level,const context * contextptr){ + return chk_inf_nan(evalf2bcd_nock(g0,level,contextptr)); + } + + bool poly_is_real(const polynome & p){ + vector< monomial >::const_iterator it=p.coord.begin(),itend=p.coord.end(); + for (;it!=itend;++it){ + if (!it->value.is_real(0)) // context is 0 since coeff do not depend on + return false; + } + return true; + } + + bool vect_is_real(const vecteur & v,GIAC_CONTEXT){ + const_iterateur it=v.begin(),itend=v.end(); + for (;it!=itend;++it){ + if (!it->is_real(contextptr)) + return false; + } + return true; + } + + /* Checking */ + bool gen::is_real(GIAC_CONTEXT) const { + switch (type) { + case _INT_: case _DOUBLE_: case _FLOAT_: case _ZINT: case _REAL: + return true; + case _CPLX: + return (is_zero(*(_CPLXptr+1),contextptr)); + case _POLY: + return poly_is_real(*_POLYptr); + case _VECT: + return vect_is_real(*_VECTptr,contextptr); + default: + return is_zero(im(contextptr),contextptr); + } + } + + bool gen::is_approx() const { + switch(type){ + case _DOUBLE_: case _FLOAT_: case _REAL: + return true; + case _CPLX: + return subtype==3 || (_CPLXptr->is_approx() && (_CPLXptr+1)->is_approx()); + case _VECT: + return has_num_coeff(*this); + default: + return false; + } + } + + bool gen::is_cinteger() const { + switch (type ) { + case _INT_: case _ZINT: + return true; + case _CPLX: + return _CPLXptr->is_integer() && (_CPLXptr+1)->is_integer(); + default: + return false; + } + } + + bool gen::is_integer() const { + switch (type ) { + case _INT_: case _ZINT: + return true; + case _CPLX: + return is_exactly_zero(*(_CPLXptr+1)) && _CPLXptr->is_integer(); + default: + return false; + } + } + + bool _VECT_is_constant(const vecteur & v){ + const_iterateur it=v.begin(),itend=v.end(); + for (;it!=itend;++it) + if (!(it->is_constant())) + return false; + return true; + } + + bool gen::is_constant() const { + switch (type ) { + case _INT_: case _DOUBLE_: case _FLOAT_: case _REAL: case _ZINT: case _CPLX: + return true; + case _VECT: + return _VECT_is_constant(*this->_VECTptr); + case _EXT: + return _EXTptr->is_constant() && (_EXTptr+1)->is_constant(); + case _POLY: + return Tis_constant(*_POLYptr) && _POLYptr->coord.front().value.is_constant(); + default: + return false; + } + } + + bool is_atomic(const gen & e){ + return e.type<_POLY || e.type==_FLOAT_ || e.type==_USER; + } + + static gen giac_conj(const gen & g,GIAC_CONTEXT){ + return conj(g,contextptr); + } + + static gen giac_re(const gen & g,GIAC_CONTEXT){ + return re(g,contextptr); + } + + static gen giac_im(const gen & g,GIAC_CONTEXT){ + return im(g,contextptr); + } + + static vecteur _VECTconj(const vecteur & a,GIAC_CONTEXT){ + vecteur res; + vecteur::const_iterator it=a.begin(),itend=a.end(); + for (;it!=itend;++it) + res.push_back(it->conj(contextptr)); + return res; + } + + // the complex pointed by res is modified despite being declared const + static gen adjust_complex_display(const gen & res,const gen & a,const gen & b){ + int * target = complex_display_ptr(res); + int * aptr = complex_display_ptr(a); + int * bptr = complex_display_ptr(b); + if (target && aptr && bptr) + *target = *aptr & *bptr; + return res; + } + + // the complex pointed by res is modified despite being declared const + static gen adjust_complex_display(const gen & res,const gen & a){ + int * target = complex_display_ptr(res); + int * aptr = complex_display_ptr(a); + if (target && aptr) + *target = *aptr ; + return res; + } + + // change complex display type (in-place, true if changed, false otherwise) + // modifies complex, vecteur and symbolics + int adjust_complex_display(gen & res,int value){ + if (res.type==_CPLX){ + if (value==3) + return 1; + res=gen(*res._CPLXptr,*(res._CPLXptr+1)); + int * target = complex_display_ptr(res); + if (value==2) + *target = 1 - (*target); + else + * target = value; + return 1; + } + if (res.type==_VECT){ + vecteur v(*res._VECTptr); + int n=int(v.size()); + int r=0; + for (int i=0;ifeuille; + int r=adjust_complex_display(f,value); + if (!r || value==3) + return r; + res=symbolic(res._SYMBptr->sommet,f); + return r; + } + + gen gen::conj(GIAC_CONTEXT) const { + switch (type ) { + case _INT_: case _DOUBLE_: case _FLOAT_: case _ZINT: case _REAL: case _STRNG: + return *this; + case _CPLX: + return adjust_complex_display(gen(*_CPLXptr,-(*(_CPLXptr+1))),*this); + case _VECT: + return gen(_VECTconj(*_VECTptr,contextptr),subtype); + case _MAP: + return apply(*this,giac_conj,contextptr); + case _USER: + return _USERptr->conj(contextptr); + case _IDNT: + if (is_assumed_real(*this,contextptr)) + return *this; + /* if ( (_IDNTptr->value) && (is_zero(_IDNTptr->value->im(),contextptr)) ) + return *this; */ + return new_ref_symbolic(symbolic(at_conj,*this)); + case _SYMB: + if (_SYMBptr->sommet==at_conj) + return _SYMBptr->feuille; + if (_SYMBptr->sommet==at_re || _SYMBptr->sommet==at_im) + return *this; + if (_SYMBptr->sommet==at_polar_complex && _SYMBptr->feuille.type==_VECT && _SYMBptr->feuille._VECTptr->size()==2){ + vecteur v=*_SYMBptr->feuille._VECTptr; + v[1]=-v[1]; + return symbolic(at_polar_complex,gen(v,_SEQ__VECT)); + } + if (_SYMBptr->sommet==at_rootof){ + gen a; + if (has_evalf(*this,a,1,contextptr) && is_zero(a.im(contextptr),contextptr)) + return *this; + if (_SYMBptr->feuille.type==_VECT && _SYMBptr->feuille._VECTptr->size()==2){ + vecteur tmp=*_SYMBptr->feuille._VECTptr; + if (lidnt(tmp[1]).empty()){ + vecteur w=*tmp[1]._VECTptr; + gen P; + if (conj_in_nf(w,P,contextptr)){ + // P is a rootof such that conj(rootof(w))=P + gen c=horner(tmp[0].conj(contextptr),P); + c=normal(c,contextptr); + return c; + } + } + } + } + if (equalposcomp(plot_sommets,_SYMBptr->sommet) || equalposcomp(analytic_sommets,_SYMBptr->sommet) || _SYMBptr->sommet==at_surd || _SYMBptr->sommet==at_erf || _SYMBptr->sommet==at_division) + return new_ref_symbolic(symbolic(_SYMBptr->sommet,_SYMBptr->feuille.conj(contextptr))); + else + return new_ref_symbolic(symbolic(at_conj,*this)); + case _FRAC: + return fraction(_FRACptr->num.conj(contextptr),_FRACptr->den.conj(contextptr)); + case _MOD: + return makemod(_MODptr->conj(contextptr),*(_MODptr+1)); + case _EXT: + return algebraic_EXTension(_EXTptr->conj(contextptr),*(_EXTptr+1)); + default: + return gentypeerr(gettext("Conj")); + } + return 0; + } + + static vecteur _VECTre(const vecteur & a,GIAC_CONTEXT){ + vecteur res; + vecteur::const_iterator it=a.begin(),itend=a.end(); + for (;it!=itend;++it) + res.push_back(it->re(contextptr)); + return res; + } + + vecteur pascal_next_line(const vecteur & v){ + if (v.empty()) + return vecteur(1,plus_one); + const_iterateur it=v.begin(),itend=v.end(); + gen current(*it); + vecteur w; + w.reserve(itend-it+1); + w.push_back(current); + for (++it;it!=itend;++it){ + w.push_back(*it+current); + current=*it; + } + w.push_back(plus_one); + return w; + } + + vecteur pascal_nth_line(int n){ + n=absint(n); + vecteur v(1,plus_one); + for (int i=0;isize()==2){ + i=f._VECTptr->back(); + f=f._VECTptr->front(); + r=f*cos(i,contextptr); + i=f*sin(i,contextptr); + return; + } + if (u==at_division){ + reim(f[0]*inv(f[1],contextptr),r,i,contextptr); + return ; + } + if (u==at_sqrt){ + reim(pow(f,plus_one_half,contextptr),r,i,contextptr); + return; + } + if (u==at_prod){ + if (f.type!=_VECT){ + reim(f,r,i,contextptr); + return; + } + vecteur v(*f._VECTptr); + if (v.empty()){ + r=plus_one; + i=0; + return; + } + if (v.size()==1){ + reim(v.front(),r,i,contextptr); + return; + } + // cut v in 2 parts and recursive call + // re(a*b)=re(a)*re(b)-im(a)*im(b) + const_iterateur it=v.begin(),itend=v.end(); + const_iterateur itm=it+(itend-it+1)/2; + gen a(new_ref_symbolic(symbolic(u,vecteur(it,itm)))); + gen b(new_ref_symbolic(symbolic(u,vecteur(itm,itend)))); + gen ra,rb,ia,ib; + reim(a,ra,ia,contextptr); + reim(b,rb,ib,contextptr); + r=ra*rb-ia*ib; + i=ra*ib+ia*rb; + return; + } + if (u==at_surd && is_integer(f._VECTptr->back())){ + reim(f._VECTptr->front(),r,i,contextptr); + if (is_zero(i,contextptr)){ + r=_surd(makesequence(r,f._VECTptr->back()),contextptr); + return; + } + } + if (u==at_derive && f.type==_VECT && !f._VECTptr->empty()){ + vecteur v=*f._VECTptr; + reim(v.front(),r,i,contextptr); + v.front()=r; + r=symbolic(at_derive,gen(v,f.subtype)); + if (is_zero(i)) + return; + v.front()=i; + i=symbolic(at_derive,gen(v,f.subtype)); + return; + } + if (u==at_pow){ + gen e=f._VECTptr->front(),expo=f._VECTptr->back(); + if (expo.type==_INT_){ + int n=expo.val; + if (n==0){ + r=1; + i=0; + return; + } + reim(e,r,i,contextptr); + if (n==1) + return ; + if (is_zero(i,contextptr)){ + r=pow(r,n); + return; + } + if (is_zero(r,contextptr)){ + if (n%2){ + r=zero; + i=pow(i,n); + if (n%4==3) + i=-i; + return; + } + r=pow(i,n); + i=0; + if (n%4==2) + r=-r; + return; + } + bool n_pos=(n>0); + if (!n_pos){ + reim(inv(pow(e,-n),contextptr),r,i,contextptr); + return; + } + vecteur v=pascal_nth_line(n); + vecteur sommer,sommei; + gen signer=1; + const_iterateur it=v.begin(); + for (int j=0;j<=n;j+=2){ + sommer.push_back(signer*(*it)*pow(r,n-j)*pow(i,j)); + ++it; + ++it; + signer=-signer; + } + it=v.begin(); + gen signei=1; + ++it; + for (int j=1;j<=n;j+=2){ + sommei.push_back(signei*(*it)*pow(r,n-j)*pow(i,j)); + ++it; + ++it; + signei=-signei; + } + r=new_ref_symbolic(symbolic(at_plus,sommer)); + i=new_ref_symbolic(symbolic(at_plus,sommei)); + return ; + } // end integer exponent + if ( is_zero(im(expo,contextptr),contextptr) && is_zero(im(e,contextptr),contextptr) ){ + if (!is_integer(expo) && is_positive(-e,contextptr)){ + r=pow(-e,expo,contextptr)*cos(cst_pi*expo,contextptr); + i=pow(-e,expo,contextptr)*sin(cst_pi*expo,contextptr); + } + else { + r=s; + i=0; + } + return; + } + if (is_zero(im(expo,contextptr),contextptr)){ + reim(e,r,i,contextptr); + gen abse=normal(pow(r,2,contextptr)+pow(i,2,contextptr),contextptr); + gen arge=arg(e,contextptr); + arge=expo*arge; + abse=sqrt(abse,contextptr); + abse=pow(abse,expo,contextptr); + r=abse*cos(arge,contextptr); + i=abse*sin(arge,contextptr); + return; + } + } + if (u==at_rootof && f.type==_VECT && f._VECTptr->size()==2){ + vecteur tmp=*f._VECTptr; + // check that the rootof is really real + if (tmp[1].type==_VECT){ + int nrealposroot=1; + if (lidnt(tmp[1]).empty()){ + vecteur w=*tmp[1]._VECTptr; + gen pol(symb_horner(w,vx_var)); + nrealposroot=sturmab(pol,vx_var,0,plus_inf,contextptr); + if (nrealposroot==0 && is_zero(im(tmp[1],contextptr))){ + // complex, perhaps the conjugate is in the same nf + gen P; + if (conj_in_nf(w,P,contextptr)){ + // P is a rootof such that conj(rootof(w))=P + gen c=horner(conj(tmp[0],contextptr),P); + r=normal((s+c)/2,contextptr); + i=normal((s-c)/2/cst_i,contextptr); + return; + } + } + } + if (nrealposroot>0){ + reim(tmp[0],r,i,contextptr); + r=algtrim(r); + if (r.type==_VECT){ + tmp[0]=r; + r=new_ref_symbolic(symbolic(u,gen(tmp,f.subtype))); + } + i=algtrim(i); + if (i.type==_VECT){ + tmp[0]=i; + i=new_ref_symbolic(symbolic(u,gen(tmp,f.subtype))); + } + return; + } + } + } + gen ref,imf; + if (u==at_integrate){ + if (f.type!=_VECT){ + reim(f,ref,imf,contextptr); + r=symbolic(at_integrate,ref); + i=is_exactly_zero(imf)?zero:symbolic(at_integrate,imf); + return; + } + vecteur v=*f._VECTptr; + if (v.size()<=2 || (v.size()>=4 && is_exactly_zero(im(v[2],contextptr)) && is_exactly_zero(im(v[3],contextptr)))){ + f=v[0]; + reim(f,ref,imf,contextptr); + v[0]=ref; + r=is_exactly_zero(ref)?zero:symbolic(at_integrate,gen(v,_SEQ__VECT)); + v[0]=imf; + i=is_exactly_zero(imf)?zero:symbolic(at_integrate,gen(v,_SEQ__VECT)); + return; + } + } + reim(f,ref,imf,contextptr); + if (is_zero(imf,contextptr) && equalposcomp(reim_op,u)){ + r=s; i=0; return; + } + if (u==at_ln){ // FIXME?? might recurse + if (do_lnabs(contextptr)){ + r=ln(abs(f,contextptr),contextptr); + i=arg(f,contextptr); + } + else { + r=s; i=0; + } + return ; + } + if (u==at_tan){ + reim(rdiv(sin(f,contextptr),cos(f,contextptr),contextptr),r,i,contextptr); + return; + } + if (u==at_tanh){ + reim(rdiv(sinh(f,contextptr),cosh(f,contextptr),contextptr),r,i,contextptr); + return; + } + if ((u==at_asin || u==at_acos) && is_zero(imf,contextptr) && is_greater(1,f,contextptr) && is_greater(f,-1,contextptr)){ + r=s; i=0; return; + } + if (u==at_inv){ + gen tmp=inv(pow(ref,2)+pow(imf,2),contextptr); + r=ref*tmp; + i=-imf*tmp; + return; + } + if (u==at_exp) { + // FIXME?? exp might recurse + r=exp(ref,contextptr)*cos(imf,contextptr); + i=exp(ref,contextptr)*sin(imf,contextptr); + return; + } + if (u==at_cos){ + r=cosh(imf,contextptr)*cos(ref,contextptr); + i=-sinh(imf,contextptr)*sin(ref,contextptr); + return; + } + if (u==at_sin){ + r=cosh(imf,contextptr)*sin(ref,contextptr); + i=sinh(imf,contextptr)*cos(ref,contextptr); + return; + } + if (u==at_cosh){ + r=cos(imf,contextptr)*cosh(ref,contextptr); + i=sin(imf,contextptr)*sinh(ref,contextptr); + return; + } + if (u==at_sinh){ + r=cos(imf,contextptr)*sinh(ref,contextptr); + i=sin(imf,contextptr)*cosh(ref,contextptr); + return; + } + if (u==at_floor || u==at_ceil || u==at_round){ + r=u(ref,contextptr); + i=u(imf,contextptr); + return; + } + if (u==at_Si && is_zero(imf)){ + r=_Si(ref,contextptr); return; + } + if (u==at_Ei && is_zero(imf)){ + r=_Ei(ref,contextptr); return; + } + if (u==at_Ci && is_zero(imf) && is_greater(ref,0,contextptr)){ + r=_Ci(ref,contextptr); return; + } + if (u==at_erf){ // works for analytic functions + gen conjf=symbolic(u,ref-cst_i*imf); + r=(s+conjf)/2; + i=-cst_i*(s-conjf)/2; + return; + } + r=new_ref_symbolic(symbolic(at_re,gen(s))); + i=new_ref_symbolic(symbolic(at_im,gen(s))); + } + + static void reim_poly(const polynome & p,gen & r,gen & i,GIAC_CONTEXT){ + polynome R(p.dim),I(p.dim); + vector< monomial >::const_iterator it=p.coord.begin(),itend=p.coord.end(); + for (;it!=itend;++it){ + reim(it->value,r,i,contextptr); + if (!is_zero(r,contextptr)) + R.coord.push_back(monomial(r,it->index)); + if (!is_zero(i,contextptr)) + I.coord.push_back(monomial(i,it->index)); + } + r=R; + i=I; + } + + static void reim_vect(const vecteur & v,gen & r,gen & i,int subtype,GIAC_CONTEXT){ + const_iterateur it=v.begin(),itend=v.end(); + vecteur R,I; + R.reserve(itend-it); + I.reserve(itend-it); + for (;it!=itend;++it){ + reim(*it,r,i,contextptr); + R.push_back(r); + I.push_back(i); + } + if (subtype==_POLY1__VECT){ + R=trim(R,0); + I=trim(I,0); + } + r=gen(R,subtype); + i=gen(I,subtype); + } + + static void reim_spol(const sparse_poly1 & p,gen & r,gen & i,GIAC_CONTEXT){ + sparse_poly1 R,I; + sparse_poly1::const_iterator it=p.begin(),itend=p.end(); + for (;it!=itend;++it){ + reim(it->coeff,r,i,contextptr); + if (!is_zero(r,contextptr)) + R.push_back(monome(r,it->exponent)); + if (!is_zero(i,contextptr)) + I.push_back(monome(i,it->exponent)); + } + r=R; + i=I; + } + + static gen frac_reim(const gen & n,const gen & d,bool findre,GIAC_CONTEXT){ + gen dbar(conj(d,contextptr)),tmp(n*dbar); + tmp=findre?re(tmp,contextptr):im(tmp,contextptr); + return tmp/(d*dbar); + } + + // compute simultaneously real and imaginary part + void reim(const gen & g,gen & r,gen & i,GIAC_CONTEXT){ + switch (g.type ) { + case _INT_: case _DOUBLE_: case _FLOAT_: case _ZINT: case _REAL: case _STRNG: + r=g; + i=0; + break; + case _CPLX: + r=*g._CPLXptr; + i=*(g._CPLXptr+1); + break; + case _VECT: + reim_vect(*g._VECTptr,r,i,g.subtype,contextptr); + break; + case _IDNT: + if (is_assumed_real(g,contextptr)){ + r=g; + i=0; + } + else { + r=new_ref_symbolic(symbolic(at_re,g)); + i=new_ref_symbolic(symbolic(at_im,g)); + } + break; + case _SYMB: + if (equalposcomp(plot_sommets,g._SYMBptr->sommet)){ + reim(g._SYMBptr->feuille,r,i,contextptr); + r=new_ref_symbolic(symbolic(g._SYMBptr->sommet,r)); + i=new_ref_symbolic(symbolic(g._SYMBptr->sommet,i)); + } + else { + if (expand_re_im(contextptr)) + symb_reim(*g._SYMBptr,r,i,contextptr); + else { + r=new_ref_symbolic(symbolic(at_re,g)); + i=new_ref_symbolic(symbolic(at_im,g)); + } + } + break; + case _USER: + r=g._USERptr->re(contextptr); + i=g._USERptr->im(contextptr); + break; + case _FRAC: + r=frac_reim(g._FRACptr->num,g._FRACptr->den,true,contextptr); + i=frac_reim(g._FRACptr->num,g._FRACptr->den,false,contextptr); + break; + case _MOD: + reim(*g._MODptr,r,i,contextptr); + r=makemod(r,*(g._MODptr+1)); + i=makemod(i,*(g._MODptr+1)); + break; + case _EXT: + reim(*g._EXTptr,r,i,contextptr); + r=algebraic_EXTension(r,*(g._EXTptr+1)); + i=algebraic_EXTension(i,*(g._EXTptr+1)); + break; + case _POLY: + reim_poly(*g._POLYptr,r,i,contextptr); + break; + case _SPOL1: + reim_spol(*g._SPOL1ptr,r,i,contextptr); + break; + default: + r=gentypeerr(gettext("reim")); + i=r; + } + } + + static gen symb_re(const symbolic & s,GIAC_CONTEXT){ + unary_function_ptr u=s.sommet; + gen f=s.feuille; + if ( (u==at_re) || (u==at_im) || (u==at_abs) )// re(re), re(im), re(abs) + return s; + if (u==at_conj) + return re(f,contextptr); + if (u==at_plus) + return _plus(re(f,contextptr),contextptr); + if (u==at_neg) + return -re(f,contextptr); + if (u==at_pow){ + gen e=f._VECTptr->front(),expo=f._VECTptr->back(); + if (expo.type==_INT_){ + int n=expo.val; + if (n==0) + return plus_one; + // ? compute conj and use 1/2*(z+-zbar)? + gen r=re(e,contextptr); + if (n==1) + return r; + gen i=im(e,contextptr); + if (n==2) + return pow(r,2)-pow(i,2); + if (is_zero(i,contextptr)) + return pow(r,n); + if (is_zero(r,contextptr)){ + if (n%2) + return zero; + if (n%4==2) + return -pow(i,n); + else + return pow(i,n); + } + bool n_pos=(n>0); + if (!n_pos) + return re(inv(pow(e,-n),contextptr),contextptr); + vecteur v=pascal_nth_line(n); + vecteur somme; + gen signe=plus_one; + const_iterateur it=v.begin(); //,itend=v.end(); + for (int j=0;j<=n;j+=2){ + somme.push_back(signe*(*it)*pow(r,n-j)*pow(i,j)); + ++it; + ++it; + signe=-signe; + } + gen res=new_ref_symbolic(symbolic(at_plus,somme)); + return res; + } // end integer exponent + if ( is_zero(im(expo,contextptr),contextptr) && is_zero(im(e,contextptr),contextptr) ){ + gen sgn=atan_tan_no_floor(contextptr)?1:sign(e,contextptr); // workaround for int(sqrt(x+sqrt(x))) + if (!is_integer(expo)){ + if (sgn==-1) + return pow(-e,expo,contextptr)*cos(cst_pi*expo,contextptr); + if (sgn!=1) + return symbolic(at_re,s); + } + return s; + } + } + if (u==at_ln) // FIXME?? might recurse + return ln(abs(f,contextptr),contextptr); + gen r,i; + symb_reim(s,r,i,contextptr); + return r; + } + + gen no_context_re(const gen & a){ + return re(a,context0); + } + + gen no_context_im(const gen & a){ + return im(a,context0); + } + + gen no_context_conj(const gen & a){ + return conj(a,context0); + } + + gen gen::re(GIAC_CONTEXT) const { + switch (type ) { + case _INT_: case _DOUBLE_: case _FLOAT_: case _ZINT: case _REAL: case _STRNG: + return *this; + case _CPLX: + return *_CPLXptr; + case _VECT: + return gen(subtype==_POLY1__VECT?trim(_VECTre(*_VECTptr,contextptr),0):_VECTre(*_VECTptr,contextptr),subtype); + case _MAP: + return apply(*this,giac_re,contextptr); + case _IDNT: + if (is_assumed_real(*this,contextptr)) + return *this; + if ( (_IDNTptr->value) && (is_zero(_IDNTptr->value->im(contextptr),contextptr)) ) + return *this; + return new_ref_symbolic(symbolic(at_re,*this)); + case _SYMB: + if (equalposcomp(plot_sommets,_SYMBptr->sommet)) + return new_ref_symbolic(symbolic(_SYMBptr->sommet,_SYMBptr->feuille.re(contextptr))); + if (expand_re_im(contextptr)) + return symb_re(*_SYMBptr,contextptr); + else + return new_ref_symbolic(symbolic(at_re,*this)); + case _USER: + return _USERptr->re(contextptr); + case _FRAC: + return frac_reim(_FRACptr->num,_FRACptr->den,true,contextptr); + case _MOD: + return makemod(_MODptr->re(contextptr),*(_MODptr+1)); + case _EXT: + return algebraic_EXTension(_EXTptr->re(contextptr),*(_EXTptr+1)); + case _POLY: + return apply(*_POLYptr,contextptr,giac_re); + default: + return gentypeerr(gettext("Re")); + } + return 0; + } + + static vecteur _VECTim(const vecteur & a,GIAC_CONTEXT){ + vecteur res; + vecteur::const_iterator it=a.begin(),itend=a.end(); + for (;it!=itend;++it) + res.push_back(it->im(contextptr)); + return res; + } + + static gen symb_im(const symbolic & s,GIAC_CONTEXT){ + unary_function_ptr u=s.sommet; + gen f=s.feuille; + if ( (u==at_re) || (u==at_im) || (u==at_abs) )// im of a real + return zero; + if (u==at_conj) + return -im(f,contextptr); + if (u==at_plus) + return _plus(im(f,contextptr),contextptr); + if (u==at_neg) + return -im(f,contextptr); + if (u==at_pow){ + gen e=f._VECTptr->front(),expo=f._VECTptr->back(); + if (expo.type==_INT_) { + // ? compute conj and use 1/2*(z+-zbar)? + gen r=re(e,contextptr); + gen i=im(e,contextptr); + int n=f._VECTptr->back().val; + if (n==0) + return zero; + if (is_zero(i,contextptr)) + return zero; + if (is_zero(r,contextptr)){ + if (n%2==0) + return zero; + if (n%4==1) + return pow(i,n); + else + return -pow(i,n); + } + bool n_pos=(n>0); + if (!n_pos) + return im(inv(pow(e,-n),contextptr),contextptr); + vecteur v=pascal_nth_line(n); + vecteur somme; + gen signe=plus_one; + const_iterateur it=v.begin(); // ,itend=v.end(); + ++it; + for (int j=1;j<=n;j+=2){ + somme.push_back(signe*(*it)*pow(r,n-j)*pow(i,j)); + ++it; + ++it; + signe=-signe; + } + gen res=new_ref_symbolic(symbolic(at_plus,somme)); + return res; + } // end integer exponent + if ( is_zero(im(expo,contextptr),contextptr) && is_zero(im(e,contextptr),contextptr) ){ + // e must also be positive for non-integral power + if (!is_integer(expo)){ + gen sgn=atan_tan_no_floor(contextptr)?1:sign(e,contextptr); // workaround for int(sqrt(x+sqrt(x))) + if (sgn==-1) + return pow(-e,expo,contextptr)*sin(cst_pi*expo,contextptr); + if (sgn!=1) + return symbolic(at_im,s); + } + return zero; + } + } + if (u==at_ln) + return arg(f,contextptr); + gen r,i; + symb_reim(s,r,i,contextptr); + return i; + } + + gen gen::im(GIAC_CONTEXT) const { + switch (type) { + case _INT_: case _DOUBLE_: case _FLOAT_: case _ZINT: case _REAL: case _STRNG: + return 0; + case _CPLX: + return *(_CPLXptr+1); + case _VECT: + return gen(subtype==_POLY1__VECT?trim(_VECTim(*_VECTptr,contextptr),0):_VECTim(*_VECTptr,contextptr),subtype); + case _MAP: + return apply(*this,giac_im,contextptr); + case _IDNT: + if (is_inf(*this) || is_undef(*this)) + return undef; + if (is_assumed_real(*this,contextptr)) + return zero; + if ( (_IDNTptr->value) && (is_zero(_IDNTptr->value->im(contextptr),contextptr)) ) + return zero; + return new_ref_symbolic(symbolic(at_im,*this)); + case _SYMB: + if (equalposcomp(plot_sommets,_SYMBptr->sommet)) + return new_ref_symbolic(symbolic(_SYMBptr->sommet,_SYMBptr->feuille.im(contextptr))); + if (expand_re_im(contextptr)) + return symb_im(*_SYMBptr,contextptr); + else + return new_ref_symbolic(symbolic(at_im,*this)); + case _USER: + return _USERptr->im(contextptr); + case _FRAC: + return frac_reim(_FRACptr->num,_FRACptr->den,false,contextptr); + case _MOD: + return makemod(_MODptr->im(contextptr),*(_MODptr+1)); + case _EXT: + return algebraic_EXTension(_EXTptr->im(contextptr),*(_EXTptr+1)); + case _POLY: + return apply(*_POLYptr,contextptr,giac_im); + default: + return gentypeerr(gettext("Im")); + } + return 0; + } + + static gen _VECTabs(const vecteur & a,GIAC_CONTEXT){ + gen res(0); + vecteur::const_iterator it=a.begin(), itend=a.end(); + for (;it!=itend;++it){ + res=max(res,abs(*it,contextptr),contextptr); + } + return res; + } + + static gen linfnorm(const vecteur & a,GIAC_CONTEXT){ + gen res(0); + vecteur::const_iterator it=a.begin(), itend=a.end(); + for (;it!=itend;++it){ + res=max(res,linfnorm(*it,contextptr),contextptr); + } + return res; + } + + static gen real_abs(const gen & s,GIAC_CONTEXT){ + gen tmp=evalf_double(s,1,contextptr); + if (tmp.type==_DOUBLE_){ + if (tmp._DOUBLE_val>epsilon(contextptr)) + return s; + if (tmp._DOUBLE_val<-epsilon(contextptr)) + return -s; + if (has_num_coeff(s)) + return 0.0; + else { +#ifdef HAVE_LIBMPFR + tmp=accurate_evalf(s,ABS_NBITS_EVALF+10)*pow(2,ABS_NBITS_EVALF,contextptr); + if (!is_greater(1,abs(tmp,contextptr),contextptr)){ + if (is_positive(tmp,contextptr)) + return s; + return -s; + } +#else + return 0; +#endif + } + } + if (tmp.type==_FLOAT_){ + if (tmp._FLOAT_val>epsilon(contextptr)) + return s; + if (tmp._FLOAT_val<-epsilon(contextptr)) + return -s; + return 0.0; + } + int j=sturmsign(s,false,contextptr); + if (!j || j==-2) + return new_ref_symbolic(symbolic(at_abs,gen(s))); + return j*s; + } + + static gen idnt_abs(const gen & s,GIAC_CONTEXT){ + if (is_inf(s)) + return plus_inf; + if (is_undef(s)) + return s; + if (!eval_abs(contextptr) || has_num_coeff(s)) + return new_ref_symbolic(symbolic(at_abs,s)); + gen r,i; + reim(s,r,i,contextptr); + if (is_zero(i,contextptr)) + return real_abs(s,contextptr); + else { + if (i.type==_SYMB + && !lop(i,at_im).empty() // was i._SYMBptr->sommet==at_im, changed 3 jan 2021 for abs(2*(sqrt(x+sqrt(x))-(sqrt(x)))-1); + && !lop(r,at_re).empty() + ) + return new_ref_symbolic(symbolic(at_abs,s)); + gen r2i2=pow(r,2)+pow(i,2); + if (has_op(r2i2,*at_cos) || has_op(r2i2,*at_sin)){ + r2i2=_tlin(r2i2,contextptr); // _tcollect? + vecteur l=lvar(r2i2); + unsigned count=0; + for (unsigned i=0;i=2) + r2i2=_tcollect(r2i2,contextptr); + } + return sqrt(r2i2,contextptr); + } + } + + static gen symb_abs(const symbolic & s,GIAC_CONTEXT){ + unary_function_ptr u=s.sommet; + gen f=s.feuille; + if (u==at_abs) // abs(abs) + return s; + if (u==at_neg) + return abs(f,contextptr); + if (!complex_mode(contextptr)){ + if (u==at_ln) + return real_abs(s,contextptr); + if (!has_i(s)){ + if (u==at_exp || ( (u==at_sqrt && is_positive(f,contextptr)) || (u==at_pow && f[1]==plus_one_half && is_positive(f[0],contextptr)) ) ) + return s; + // if (calc_mode(contextptr)==1 && u==at_pow && f.type==_VECT && f._VECTptr->size()==2 && f._VECTptr->back()==plus_one_half && is_positive(f[0],contextptr)) return s; + } + } + else { + if (do_lnabs(contextptr) && u==at_ln) + return new_ref_symbolic(symbolic(at_abs,s)); + if (u==at_exp) + return exp(re(f,contextptr),contextptr); + } + if ( (u==at_pow) && (is_zero(im(f._VECTptr->back(),contextptr),contextptr))){ + gen fback=f._VECTptr->back(); + if (fback.type==_INT_ && (fback.val % 2==0)) + return pow(abs(f._VECTptr->front(),contextptr),fback,contextptr); + return new_ref_symbolic(symbolic(u,makesequence(abs(f._VECTptr->front(),contextptr),f._VECTptr->back()))); + } + if (u==at_inv) + return inv(abs(f,contextptr),contextptr); + if (u==at_prod) + return new_ref_symbolic(symbolic(u,apply(f,contextptr,abs))); + return idnt_abs(s,contextptr); + } + + gen abs(const gen & a,GIAC_CONTEXT){ + switch (a.type ) { + case _INT_: + return(absint(a.val)); + case _ZINT: + if (mpz_sgn(*a._ZINTptr)<0) + return(-a); + else + return(a); + case _REAL: + return a._REALptr->abs(); + case _CPLX: +#ifdef GIAC_HAS_STO_38 + if (a._CPLXptr->type==_FLOAT_ && (a._CPLXptr+1)->type==_FLOAT_) + { + HP_gen r; + cAbs_g(gen2HP(*a._CPLXptr), gen2HP(*(a._CPLXptr+1)), &r); + return HP2gen(r); + } +#endif + if (a.subtype==3){ + gen * aptr=a._CPLXptr; + double ar=aptr->_DOUBLE_val,ai=(aptr+1)->_DOUBLE_val; + double z=std::abs(ar)+std::abs(ai); ar/=z; ai/=z; + return z*std::sqrt(ar*ar+ai*ai); + // return gen(std::sqrt(ar*ar+ai*ai)); + } + return sqrt(sq(*a._CPLXptr)+sq(*(a._CPLXptr+1)),contextptr) ; + case _DOUBLE_: + return fabs(a._DOUBLE_val); + case _FLOAT_: + return fabs(a._FLOAT_val); + case _VECT: + if (a.subtype==_POINT__VECT || a.subtype==_GGBVECT) + return _l2norm(a,contextptr); + return _VECTabs(*a._VECTptr,contextptr); + case _IDNT: + return idnt_abs(a,contextptr); + case _SYMB: + if (is_equal(a)) + return apply_to_equal(a,abs,contextptr); + if (a.is_symb_of_sommet(at_pnt)){ + if (is3d(a)) + return _l2norm(_coordonnees(a,contextptr),contextptr); + return abs(_affixe(a,contextptr),contextptr); + } + return symb_abs(*a._SYMBptr,contextptr); + case _USER: + return a._USERptr->abs(contextptr); + case _FRAC: + if (is_integer(a._FRACptr->num) && is_integer(a._FRACptr->den)) + return fraction(abs(a._FRACptr->num,contextptr),abs(a._FRACptr->den,contextptr)); + return rdiv(abs(a._FRACptr->num,contextptr),abs(a._FRACptr->den,contextptr),contextptr); + default: + return gentypeerr(gettext("Abs")); + } + return 0; + } + + gen linfnorm(const gen & a,GIAC_CONTEXT){ // L^inf norm is |re|+|im| for a complex + switch (a.type ) { + case _INT_: + return(absint(a.val)); + case _ZINT: + if (mpz_sgn(*a._ZINTptr)<0) + return(-a); + else + return(a); + case _CPLX: + return(abs(*a._CPLXptr,contextptr)+abs(*(a._CPLXptr+1),contextptr)) ; + case _DOUBLE_: + return fabs(a._DOUBLE_val); + case _FLOAT_: + return fabs(a._FLOAT_val); + case _FRAC: + return linfnorm(a._FRACptr->num)/linfnorm(a._FRACptr->den); + case _VECT: + return _VECTabs(*a._VECTptr,contextptr); + case _USER: + return a._USERptr->abs(contextptr); + case _IDNT: case _SYMB: + return new_ref_symbolic(symbolic(at_abs,a)); + default: + return gentypeerr(gettext("Linfnorm")); + } + return 0; + } + + // workaround for intervals + static bool is_zero_or_contains(const gen & g,GIAC_CONTEXT){ +#ifdef NO_RTTI + return is_zero(g,contextptr); +#else + if (is_zero(g,contextptr)) + return true; + if (g.type!=_REAL) + return false; + if (real_interval * ptr=dynamic_cast(g._REALptr)) + return ptr->maybe_zero(); + return false; +#endif + } + + gen arg_CPLX(const gen & a,GIAC_CONTEXT){ + gen realpart=normal(a.re(contextptr),contextptr), + imagpart=normal(a.im(contextptr),contextptr); + if (realpart.type==_FLOAT_ && imagpart.type==_FLOAT_){ +#ifdef GIAC_HAS_STO_38 + //grad + return atan2f(realpart._FLOAT_val,imagpart._FLOAT_val,angle_mode(contextptr)); +#else + return atan2f(realpart._FLOAT_val,imagpart._FLOAT_val,angle_radian(contextptr)); +#endif + } + if (is_zero_or_contains(realpart,contextptr)){ + if (is_zero_or_contains(imagpart,contextptr)) + return undef; + return (cst_pi_over_2-atan(realpart/imagpart,contextptr))*sign(imagpart,contextptr); + } + if (is_zero_or_contains(imagpart,contextptr)) + return (1-sign(realpart,contextptr))*cst_pi_over_2+atan(imagpart/realpart,contextptr); + if ( (realpart.type==_DOUBLE_ || realpart.type==_FLOAT_) || (imagpart.type==_DOUBLE_ || imagpart.type==_FLOAT_) ) + return eval(atan(rdiv(imagpart,realpart,contextptr),contextptr)+(1-sign(realpart,contextptr))*sign(imagpart,contextptr)*evalf_double(cst_pi_over_2,1,contextptr),1,contextptr); + else + return atan(rdiv(imagpart,realpart,contextptr),contextptr)+(1-sign(realpart,contextptr))*sign(imagpart,contextptr)*cst_pi_over_2; + } + + static gen _VECTarg(const vecteur & a,GIAC_CONTEXT){ + vecteur res; + vecteur::const_iterator it=a.begin(), itend=a.end(); + for (;it!=itend;++it){ + res.push_back(arg(*it,contextptr)); + } + return res; + } + + gen arg(const gen & a,GIAC_CONTEXT){ + if (a.type==_CPLX && a._CPLXptr->type==_DOUBLE_ && (a._CPLXptr+1)->type==_DOUBLE_){ + double d=atan2((a._CPLXptr+1)->_DOUBLE_val,a._CPLXptr->_DOUBLE_val); + if (angle_radian(contextptr)) + return d; + int mode = angle_mode(contextptr); + if(mode == 1) //if was in degrees + return 180*d/M_PI; + else + return 200 * d / M_PI; + } + if (!angle_radian(contextptr)){ + //grad + int mode = get_mode_set_radian(contextptr); //get current mode + gen res=evalf(arg(a,contextptr),1,contextptr); + angle_mode(mode,contextptr); //set back to either degree or grads + if(mode == 1) //if was in degrees + return 180*res/cst_pi; + else + return 200 * res / cst_pi; + } + if (a.is_symb_of_sommet(at_pow)){ + gen af=a._SYMBptr->feuille; + if (af.type==_VECT && af._VECTptr->size()==2){ + gen res=im(ln(af._VECTptr->front(),contextptr)*af._VECTptr->back(),contextptr); + return _smod(makesequence(res,cst_two_pi),contextptr); + } + } + if (a.is_symb_of_sommet(at_exp)) + return _smod(makesequence(im(a._SYMBptr->feuille,contextptr),cst_two_pi),contextptr); + if (a.is_symb_of_sommet(at_prod)){ + const gen & af=a._SYMBptr->feuille; + if (af.type==_VECT){ + const_iterateur it=af._VECTptr->begin(),itend=af._VECTptr->end(); + gen res; + int nonzero=0; + for (;it!=itend;++it){ + gen tmp(arg(*it,contextptr)); + if (!is_zero(tmp,contextptr)){ + res += tmp; + ++nonzero; + } + } + if (nonzero>1) + return _smod(makesequence(res,cst_two_pi),contextptr); + return res; + } + } + if (is_equal(a)) + return apply_to_equal(a,arg,contextptr); + switch (a.type ) { + case _INT_: case _ZINT: case _FLOAT_: case _REAL: + if (is_positive(a,contextptr)) + return 0; + else + return cst_pi; + case _DOUBLE_: + return a._DOUBLE_val>=0?0.0:M_PI; + case _CPLX: + return arg_CPLX(a,contextptr); + case _VECT: + return _VECTarg(*a._VECTptr,contextptr); + case _IDNT: + case _SYMB: + // if ( is_zero(im(a,contextptr),contextptr) || (evalf(a,eval_level(contextptr),contextptr).type==_CPLX) ) + return arg_CPLX(a,contextptr); + // return new symbolic(at_arg,a); + case _USER: + return a._USERptr->arg(contextptr); + case _FRAC: + return arg(a._FRACptr->num*conj(a._FRACptr->den,contextptr),contextptr); + default: + return gentypeerr(gettext("Arg")); + } + return 0; + } + + gen gen::squarenorm(GIAC_CONTEXT) const { + switch (type ) { + case _INT_: case _DOUBLE_: case _FLOAT_: case _ZINT: case _REAL: + return (*this) * (*this); + case _CPLX: + return ( (*_CPLXptr)*(*_CPLXptr)+(*(_CPLXptr+1)*(*(_CPLXptr+1))) ); + case _FRAC: + return fraction(_FRACptr->num.squarenorm(contextptr),_FRACptr->den.squarenorm(contextptr)); + default: + { + gen a,b; + reim(*this,a,b,contextptr); + return a*a+b*b; + } + } + } + + gen sq(const gen & a){ + return a*a; + } + + int gen::bindigits() const{ + int res,valeur; + switch (type ) { + case _INT_: + res=0; + valeur=val; + for (;valeur;res++) + valeur = valeur >> 1; + return res; + case _ZINT: + return mpz_sizeinbase(*_ZINTptr,2)+1; + case _CPLX: + return giacmax(_CPLXptr->bindigits(),(_CPLXptr+1)->bindigits() ) ; + default: +#ifndef NO_STDEXCEPT + settypeerr(gettext("Bindigits")); +#endif + return 0; + } + return 0; + } + + static gen addpoly(const gen & th, const gen & other){ + if ((th.type!=_POLY) || (other.type!=_POLY)){ +#ifndef NO_STDEXCEPT + settypeerr(gettext("addpoly")); +#endif + return gentypeerr(gettext("addpoly")); + } + // Tensor addition + vector< monomial >::const_iterator a=th._POLYptr->coord.begin(); + vector< monomial >::const_iterator a_end=th._POLYptr->coord.end(); + if (a == a_end) { + return other; + } + vector< monomial >::const_iterator b=other._POLYptr->coord.begin(); + vector< monomial >::const_iterator b_end=other._POLYptr->coord.end(); + if (b==b_end){ + return th; + } + ref_polynome * resptr=new ref_polynome(th._POLYptr->dim); + Add_gen(a,a_end,b,b_end,resptr->t.coord,th._POLYptr->is_strictly_greater); + return resptr; + } + + polynome addpoly(const polynome & p,const gen & c){ + if (is_exactly_zero(c)) + return p; + polynome pcopy(p); + if ( (!p.coord.empty()) && p.coord.back().index.is_zero() ) { + pcopy.coord.back().value = pcopy.coord.back().value + c; + if (is_exactly_zero(pcopy.coord.back().value)) + pcopy.coord.pop_back(); + } + else + pcopy.coord.push_back(monomial(c,pcopy.dim)); + return pcopy; + } + + gen chkmod(const gen& a,const gen & b){ + if ( (b.type!=_MOD) || ((a.type==_MOD) && (*(a._MODptr+1)==*(b._MODptr+1)) )) + return a; + return makemodquoted(a,*(b._MODptr+1)); + } + gen makemod(const gen & a,const gen & b){ + if (a.type==_VECT) + return apply1st(a,b,makemod); + if (a.type==_POLY){ + polynome res(a._POLYptr->dim); + vector< monomial >::const_iterator it=a._POLYptr->coord.begin(),itend=a._POLYptr->coord.end(); + res.coord.reserve(itend-it); + for (;it!=itend;++it){ + gen tmp=makemod(it->value,b); + if (!is_exactly_zero(tmp)) + res.coord.push_back(monomial(tmp,it->index)); + } + return res; + } + if (a.type==_MOD){ + if (is_exactly_zero(b)) // unmodularize + return *a._MODptr; + if (*(a._MODptr+1)==b) // avoid e.g. 7 % 5 % 5 + return a; + } + if (a.type==_USER) + return a; + if (is_exactly_zero(b)) + return a; + if (a.type==_DOUBLE_ || a.type==_REAL || a.type==_FLOAT_) + return gensizeerr(context0); + gen res=makemodquoted(0,0); + if ( (b.type==_INT_) || (b.type==_ZINT) ) + *res._MODptr=smod(a,b); + else { + if (b.type!=_VECT){ + res=0; +#ifdef NO_STDEXCEPT + return gensizeerr(gettext("Bad mod:")+b.print(context0)); +#else + setsizeerr(gettext("Bad mod:")+b.print(context0)); +#endif + } + if (a.type==_VECT) + *res._MODptr=(*a._VECTptr)%(*b._VECTptr); + else + *res._MODptr=a; + } + *(res._MODptr+1)=b; + return res; + } + + gen makemodquoted(const gen & a,const gen & b){ + gen res; +#ifdef SMARTPTR64 + * ((ulonglong * ) &res) = ulonglong(new ref_modulo(a,b)) << 16; +#else + res.__MODptr=new ref_modulo(a,b); +#endif + res.type=_MOD; + return res; + } + + static gen modadd(const ref_modulo * a,const ref_modulo *b){ + if (a->modulo!=b->modulo){ +#ifndef NO_STDEXCEPT + setsizeerr(gettext("Mod are different")); +#endif + } + return makemod(a->n+b->n,a->modulo); + } + + static gen modsub(const ref_modulo * a,const ref_modulo *b){ +#ifndef NO_STDEXCEPT + if (a->modulo!=b->modulo) + setsizeerr(gettext("Mod are different")); +#endif + return makemod(a->n-b->n,a->modulo); + } + + static gen modmul(const ref_modulo * a,const ref_modulo *b){ +#ifndef NO_STDEXCEPT + if (a->modulo!=b->modulo) + setsizeerr(gettext("Mod are different")); +#endif + return makemod(a->n*b->n,a->modulo); + } + + static gen modinv(const gen & a){ + gen modu=*(a._MODptr+1); + if ( ( (modu.type==_INT_) || (modu.type==_ZINT) ) && + a._MODptr->is_cinteger() ) + return makemod(invmod(*a._MODptr,modu),modu); + if (modu.type==_VECT){ + modpoly polya,u,v,d; + if (a._MODptr->type!=_VECT) + polya.push_back(*a._MODptr); + else + polya=*a._MODptr->_VECTptr; + egcd(polya,*modu._VECTptr,0,u,v,d); + if (d.size()!=1){ +#ifndef NO_STDEXCEPT + setsizeerr(gettext("Not invertible")); +#endif + return 0; + } + return makemod(u/d.front(),modu); + } + return fraction(makemod(plus_one,*(a._MODptr+1)),a); + } + + // a and b must be dense univariate polynomials + // WARNING: may modify a in place (suitable inside a += operator) + static gen addgen_poly(const gen & a,const gen & b,bool inplace=false){ + vecteur & av=*a._VECTptr; + vecteur & bv=*b._VECTptr; + if (inplace){ + /* + int as=av.size(),bs=bv.size(); + if (asempty()?0:res; + } + + gen & operator_plus_eq(gen &a,const gen & b,GIAC_CONTEXT){ +#if defined(EMCC) || defined(EMCC2) + a=operator_plus(a,b,contextptr); + return a; +#endif + if (a.type==b.type){ + + if (a.type==_DOUBLE_){ +#ifdef DOUBLEVAL + a._DOUBLE_val += b._DOUBLE_val; return a; +#else + *((double *) &a) += *((double *) &b); + a.type = _DOUBLE_; + return a; +#endif + } + if (a.type==_FLOAT_){ +#ifdef DOUBLEVAL + a._FLOAT_val += b._FLOAT_val; return a; +#else + *((giac_float *) &a) += *((giac_float *) &b); + a.type = _FLOAT_; + return a; +#endif + } + if (a.type==_INT_){ + longlong tmp=((longlong) a.val+b.val); + a.val=(int)tmp; + if (a.val==tmp && tmp!=-2147483648) + return a; + return a=tmp; + } + if (a.type==_ZINT && a.ref_count()==1){ + mpz_t * ptr=a._ZINTptr; + mpz_add(*ptr,*ptr,*b._ZINTptr); + if (mpz_sizeinbase(*ptr,2)<32){ + return a=mpz_get_si(*ptr); + } + return a; + } + if (a.type==_VECT && a.subtype==_POLY1__VECT && a.ref_count()==1){ + if (addgen_poly(a,b,true)._VECTptr->empty()) + a=0; + return a; + } + } + if (a.type==_ZINT && b.type==_INT_ && a.ref_count()==1){ + mpz_t * ptr=a._ZINTptr; + if (b.val<0) + mpz_sub_ui(*ptr,*ptr,-b.val); + else + mpz_add_ui(*ptr,*ptr,b.val); + if (mpz_sizeinbase(*ptr,2)<32){ + return a=gen(*ptr); + } + return a; + } + // if (!( (++control_c_counter) & control_c_counter_mask)) +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) { + interrupted = true; ctrl_c=false; + return a=gensizeerr(gettext("Stopped by user interruption.")); + } + return a=operator_plus(a,b,contextptr); + } + + static gen ck_evalf_double(const gen & g,GIAC_CONTEXT){ + gen tmp=evalf_double(g,1,contextptr); + if (tmp.type<=_CPLX) + return tmp; + return gensizeerr(contextptr); + } + + gen operator_plus(const gen & a,const gen & b,unsigned t,GIAC_CONTEXT){ + static bool warnextend=true; + // if (!( (++control_c_counter) & control_c_counter_mask)) +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) { + interrupted = true; ctrl_c=false; + return gensizeerr(gettext("Stopped by user interruption.")); + } + register ref_mpz_t * e; + switch ( t ) { + case _ZINT__ZINT: + e =new ref_mpz_t; + mpz_add(e->z,*a._ZINTptr,*b._ZINTptr); + return e; + case _DOUBLE___DOUBLE_: + return a._DOUBLE_val+b._DOUBLE_val; + case _FLOAT___FLOAT_: + return a._FLOAT_val+b._FLOAT_val; + case _VECT__VECT: + if (// abs_calc_mode(contextptr)==38 && + (a.subtype==_MATRIX__VECT ||b.subtype==_MATRIX__VECT)){ + if (!ckmatrix(a) || !ckmatrix(b)) + return gensizeerr(contextptr); + if (a._VECTptr->size()!=b._VECTptr->size() || a._VECTptr->front()._VECTptr->size()!=b._VECTptr->front()._VECTptr->size()) + return gendimerr(contextptr); + } + if (a.subtype==_POLY1__VECT) + return addgen_poly(a,b); + if (a.subtype==_PNT__VECT) + return gen(makenewvecteur(a._VECTptr->front()+b,a._VECTptr->back()),a.subtype); + if (a.subtype!=_POINT__VECT && equalposcomp((int *) _GROUP__VECT_subtype,a.subtype)) + return sym_add(a,b,contextptr); + if (b.subtype!=_POINT__VECT && equalposcomp((int *)_GROUP__VECT_subtype,b.subtype)) + return sym_add(b,a,contextptr); + if (a.subtype==_POINT__VECT && b.subtype==_POINT__VECT) + return gen(addvecteur(*a._VECTptr,*b._VECTptr),0); + if (a.subtype==0 && b.subtype==0 && python_compat(contextptr)==2) + return mergevecteur(*a._VECTptr,*b._VECTptr); + if (warnextend && a.subtype==0 && b.subtype==0 && python_compat(contextptr)){ + warnextend=false; + alert(gettext("Warning + is vector addition, run list1.extend(list2) for list concatenation"),contextptr); + } + return gen(addvecteur(*a._VECTptr,*b._VECTptr),a.subtype?a.subtype:b.subtype); + case _MAP__MAP: + { + int arows,acols,an,brows,bcols,bn; + if ( (is_sparse_matrix(a,arows,acols,an) && is_sparse_matrix(b,brows,bcols,bn)) || (is_sparse_vector(a,arows,an) && is_sparse_vector(b,brows,bn)) ){ + gen_map res; + gen g(res); + sparse_add(*a._MAPptr,*b._MAPptr,*g._MAPptr); + return g; + } + } + case _INT___ZINT: + e = new ref_mpz_t; + if (a.val<0) + mpz_sub_ui(e->z,*b._ZINTptr,-a.val); + else + mpz_add_ui(e->z,*b._ZINTptr,a.val); + return e; + case _ZINT__INT_: + e = new ref_mpz_t; + if (b.val<0) + mpz_sub_ui(e->z,*a._ZINTptr,-b.val); + else + mpz_add_ui(e->z,*a._ZINTptr,b.val); + return e; + case _DOUBLE___INT_: + return a._DOUBLE_val+b.val; + case _INT___DOUBLE_: + return a.val+b._DOUBLE_val; + case _FLOAT___DOUBLE_: + return a._FLOAT_val+giac_float(b._DOUBLE_val); + case _FLOAT___INT_: + return a._FLOAT_val+giac_float(b.val); + case _FLOAT___FRAC: + return a+evalf2bcd(b,1,contextptr); + case _DOUBLE___FRAC: + return a+ck_evalf_double(b,contextptr); + case _INT___FLOAT_: + return b._FLOAT_val+giac_float(a.val); + case _DOUBLE___FLOAT_: + return b._FLOAT_val+giac_float(a._DOUBLE_val); + case _DOUBLE___ZINT: + return a._DOUBLE_val+mpz_get_d(*b._ZINTptr); + case _DOUBLE___REAL: + return a._DOUBLE_val+real2double(*b._REALptr); + case _REAL__DOUBLE_: + return b._DOUBLE_val+real2double(*a._REALptr); + case _ZINT__DOUBLE_: + return b._DOUBLE_val+mpz_get_d(*a._ZINTptr); + case _CPLX__INT_: + if (b.val==0) return a; + case _CPLX__ZINT: case _CPLX__DOUBLE_: case _CPLX__FLOAT_: case _CPLX__REAL: + return gen(*a._CPLXptr+b,*(a._CPLXptr+1)); + case _INT___CPLX: + if (a.val==0) return b; + case _ZINT__CPLX: case _FLOAT___CPLX: case _DOUBLE___CPLX: case _REAL__CPLX: + return gen(a+*b._CPLXptr,*(b._CPLXptr+1)); + case _CPLX__CPLX: { + gen * aptr=a._CPLXptr, *bptr=b._CPLXptr; + if (aptr->type==_DOUBLE_ && (aptr+1)->type==_DOUBLE_ && bptr->type ==_DOUBLE_ && (bptr+1)->type ==_DOUBLE_) + return adjust_complex_display(gen(aptr->_DOUBLE_val + bptr->_DOUBLE_val, (aptr+1)->_DOUBLE_val + (bptr+1)->_DOUBLE_val),a,b); + return adjust_complex_display(gen(*aptr + *bptr, *(aptr+1) + *(bptr+1)),a,b); + } + case _POLY__POLY: + return addpoly(a,b); + case _FRAC__FRAC: + return (*a._FRACptr)+(*b._FRACptr); + case _FRAC__FLOAT_: + return evalf2bcd(a,1,contextptr)+b; + case _INT___FRAC: case _ZINT__FRAC: + return a+(*b._FRACptr); + case _FRAC__INT_: case _FRAC_ZINT: + return (*a._FRACptr)+b; + case _FRAC__DOUBLE_: + return ck_evalf_double(a,contextptr)+b; + case _SPOL1__SPOL1: + return spadd(*a._SPOL1ptr,*b._SPOL1ptr,contextptr); + case _EXT__EXT: + return ext_add(a,b,contextptr); + case _STRNG__STRNG: + if (is_undef(a)) return a; + if (is_undef(b)) return b; + return string2gen('"'+(*a._STRNGptr)+(*b._STRNGptr)+'"'); + case _POLY__INT_: case _POLY__ZINT: case _POLY__DOUBLE_: case _POLY__FLOAT_: case _POLY__CPLX: case _POLY__MOD: case _POLY__USER: case _POLY__REAL: + return addpoly(*a._POLYptr,b); + case _INT___POLY: case _ZINT__POLY: case _DOUBLE___POLY: case _FLOAT___POLY: case _CPLX__POLY: case _MOD__POLY: case _USER__POLY: case _REAL__POLY: + return addpoly(*b._POLYptr,a); + case _MOD__MOD: +#ifdef SMARTPTR64 + return modadd( (ref_modulo *) (* ((ulonglong * ) &a) >> 16),(ref_modulo *) (* ((ulonglong * ) &b) >> 16)); +#else + return modadd(a.__MODptr,b.__MODptr); +#endif + case _REAL__REAL: + return (*a._REALptr)+(*b._REALptr); + case _IDNT__IDNT: + if (a==unsigned_inf && b==unsigned_inf) + return undef; + if (b==undef) + return b; + if (a==undef || a==unsigned_inf) + return a; + if (b==unsigned_inf) + return b; + return new_ref_symbolic(symbolic(at_plus,makesequence(a,b))); + case _VECT__MAP: + { + int brows,bcols,an; + if (is_sparse_matrix(b,brows,bcols,an)){ + matrice B; + if (!convert(*b._MAPptr,B)) + return gendimerr(contextptr); + return a+B; + } + } + case _MAP__VECT: + { + int arows,acols,an; + if (is_sparse_matrix(a,arows,acols,an)){ + matrice A; + if (!convert(*a._MAPptr,A)) + return gendimerr(contextptr); + return A+b; + } + } + default: + if (a.type==_INT_ && a.val==0 && b.type!=_STRNG) + return b; + if (b.type==_INT_ && b.val==0 && a.type!=_STRNG) + return a; + if (is_undef(a)) + return a; + if (is_undef(b)) + return b; + if (a.type==_FLOAT_){ + if (is_inf(a)) + return a; + if (b.type==_VECT) + return sym_add(b,a,contextptr); + gen b1; + if (has_evalf(b,b1,1,contextptr) && b.type!=b1.type) + return operator_plus(a,b1,contextptr); + return operator_plus(evalf_double(a,1,contextptr),b,contextptr); + } + if (b.type==_FLOAT_){ + if (is_inf(b)) + return b; + if (a.type==_VECT) + return sym_add(a,b,contextptr); + gen a1; + if (has_evalf(a,a1,1,contextptr) && a.type!=a1.type) + return operator_plus(a1,b,contextptr); + return operator_plus(a,evalf_double(b,1,contextptr),contextptr); + } + if (a.type==_STRNG) + return string2gen(*a._STRNGptr+b.print(contextptr),false); + if (b.type==_STRNG) + return string2gen(a.print(contextptr)+*b._STRNGptr,false); + if (a.type==_SPOL1) + return spadd(*a._SPOL1ptr,gen2spol1(b),contextptr); + if (b.type==_SPOL1) + return spadd(gen2spol1(a),*b._SPOL1ptr,contextptr); + if (a.type==_USER) + return (*a._USERptr)+b; + if (b.type==_USER) + return (*b._USERptr)+a; + if (a.type==_REAL) + return a._REALptr->addition(b,contextptr); + if (b.type==_REAL){ + return b._REALptr->addition(a,contextptr); + } + return sym_add(a,b,contextptr); + } + } + + gen operator_plus (const gen & a,const gen & b,GIAC_CONTEXT){ + register unsigned t=(a.type<< _DECALAGE) | b.type; + if (!t) + return((longlong) a.val+b.val); + return operator_plus(a,b,t,contextptr); + } + + gen operator + (const gen & a,const gen & b){ + register unsigned t=(a.type<< _DECALAGE) | b.type; + if (!t) + return ((longlong) a.val+b.val); + return operator_plus(a,b,t,context0); + } + + // specialization of Tfraction operator + + Tfraction operator + (const Tfraction & a,const Tfraction &b){ + if (is_one(a.den)) + return(Tfraction (a.num+b)); + if (is_one(b.den)) + return(Tfraction (b.num+a)); + gen da(a.den),db(b.den); + gen den=simplify3(da,db),num; + if (a.num.type==_POLY && b.num.type==_POLY && db.type==_POLY && da.type==_POLY) + num=foisplus(*a.num._POLYptr,*db._POLYptr,*b.num._POLYptr,*da._POLYptr); + else + num=foisplus(a.num,db,b.num,da) ; // (a.num*db+b.num*da); + if (den.type==_FRAC){ + num=num * den._FRACptr->den; + den=den._FRACptr->num; + } + if (is_exactly_zero(num)) + return Tfraction(num,1); + simplify3(num,den); + if (den.type==_CPLX){ // 3 jan 2020, avoid complex denominator + gen & a=*den._CPLXptr; + gen & b=*(den._CPLXptr+1); + num=num*gen(a,-b); + den=a*a+b*b; + } + den=den*da*db; + return Tfraction (num,den); + } + + + static gen symbolic_plot_makevecteur(const unary_function_ptr & u,const gen & e,bool project,GIAC_CONTEXT){ + if ( (u!=at_pnt) || (e.type!=_VECT) || (e.subtype!=_PNT__VECT) ) + return symbolic(u,e); + // e is a curve or a pnt + vecteur w(*e._VECTptr); + if ( (w.size()!=2) && (w.size()!=3)) + return symbolic(u,e); + gen a0(w[0]); + gen a1(w[1]); + if ( a1.type==_VECT && a1._VECTptr->size()==3 ) + return symbolic(u,gen(makenewvecteur(a0,a1,a1._VECTptr->back()),_PNT__VECT)); + if ( a1.type==_VECT && a1._VECTptr->size()==2 ){ + if (project){ + // we must project a0 + gen param=a1._VECTptr->back(); // v= [ pnt() t ] + if (param.type==_VECT){ + vecteur v=*param._VECTptr; + v[1]=projection(v[0],a0,contextptr); + if (is_undef(v[1])) + return v[1]; + a0=remove_at_pnt(parameter2point(v,contextptr)); // same + a1=makenewvecteur(a1._VECTptr->front(),v); + } + } + else + a1=a1._VECTptr->front(); + } + return symbolic(u,gen(makenewvecteur(a0,a1),_PNT__VECT)); + } + + gen sym_add(const gen & a,const gen & b,GIAC_CONTEXT){ +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) { + interrupted = true; ctrl_c=false; + return gensizeerr(gettext("Stopped by user interruption.")); + } + bool adeuxpoints=a.is_symb_of_sommet(at_deuxpoints); + if ( (a.is_symb_of_sommet(at_interval) || adeuxpoints)&& a._SYMBptr->feuille.type==_VECT && a._SYMBptr->feuille._VECTptr->size()==2) + return symbolic(a._SYMBptr->sommet,makesequence(a._SYMBptr->feuille._VECTptr->front()+b,a._SYMBptr->feuille._VECTptr->back()+b)); // removed +(adeuxpoints?minus_one:zero) otherwise slicing like v[1:4] does not work + if (a.is_symb_of_sommet(at_unit)){ + if (is_zero(b)) + return a; + if (equalposcomp(lidnt(b),cst_pi)!=0) + return sym_add(a,evalf(b,1,contextptr),contextptr); + if (b.is_symb_of_sommet(at_unit)){ + vecteur & va=*a._SYMBptr->feuille._VECTptr; + vecteur & vb=*b._SYMBptr->feuille._VECTptr; + if (va[1]==vb[1]) + return new_ref_symbolic(symbolic(at_unit,makenewvecteur(operator_plus(va[0],vb[0],contextptr),va[1]))); + gen g=mksa_reduce(vb[1]/va[1],contextptr); + gen tmp=chk_not_unit(g); + if (is_undef(tmp)) return tmp; + return new_ref_symbolic(symbolic(at_unit,makenewvecteur(operator_plus(va[0],operator_times(g,vb[0],contextptr),contextptr),va[1]))); + } + if (lidnt(b).empty()){ + gen g=mksa_reduce(a,contextptr); + gen tmp=chk_not_unit(g); + if (is_undef(tmp)) return tmp; + return g+b; + } + } + if (b.is_symb_of_sommet(at_unit)){ + if (is_zero(a)) + return b; + if (equalposcomp(lidnt(a),cst_pi)!=0) + return sym_add(evalf(a,1,contextptr),b,contextptr); + if (lidnt(a).empty()){ + gen g=mksa_reduce(b,contextptr); + gen tmp=chk_not_unit(g); + if (is_undef(tmp)) return tmp; + return a+g; + } + } + if (a.is_approx()){ + gen b1; + if (has_evalf(b,b1,1,contextptr) && (b.type!=b1.type || b!=b1)){ +#ifdef HAVE_LIBMPFR + if (a.type==_REAL){ + gen b2; +#if defined HAVE_LIBMPFI && !defined NO_RTTI + if (real_interval * ptr=dynamic_cast(a._REALptr)) + b2=convert_interval(b,mpfi_get_prec(ptr->infsup),contextptr); + else +#endif + b2=accurate_evalf(b,mpfr_get_prec(a._REALptr->inf)); + if (b2.is_approx()) + return a+b2; + } + if (a.type==_CPLX && a._CPLXptr->type==_REAL){ + gen b2; +#if defined HAVE_LIBMPFI && !defined NO_RTTI + if (real_interval * ptr=dynamic_cast(a._CPLXptr->_REALptr)) + b2=convert_interval(b,mpfi_get_prec(ptr->infsup),contextptr); + else +#endif + b2=accurate_evalf(b,mpfr_get_prec(a._CPLXptr->_REALptr->inf)); + if (b2.is_approx()) + return a+b2; + } +#endif + return a+b1; + } + } + if (b.is_approx()){ + gen a1; + if (has_evalf(a,a1,1,contextptr) && (a.type!=a1.type || a!=a1)){ +#ifdef HAVE_LIBMPFR + if (b.type==_REAL){ + gen a2; +#if defined HAVE_LIBMPFI && !defined NO_RTTI + if (real_interval * ptr=dynamic_cast(b._REALptr)) + a2=convert_interval(a,mpfi_get_prec(ptr->infsup),contextptr); + else +#endif + a2=accurate_evalf(a,mpfr_get_prec(b._REALptr->inf)); + if (a2.is_approx()) + return a2+b; + } + if (b.type==_CPLX && b._CPLXptr->type==_REAL){ + gen a2; +#if defined HAVE_LIBMPFI && !defined NO_RTTI + if (real_interval * ptr=dynamic_cast(b._CPLXptr->_REALptr)) + a2=convert_interval(a,mpfi_get_prec(ptr->infsup),contextptr); + else +#endif + a2=accurate_evalf(a,mpfr_get_prec(b._CPLXptr->_REALptr->inf)); + if (a2.is_approx()) + return a2+b; + } +#endif + return a1+b; + } + } + if ( (a.type==_SYMB) && equalposcomp(plot_sommets,a._SYMBptr->sommet) ){ + if ( (b.type==_SYMB) && equalposcomp(plot_sommets,b._SYMBptr->sommet) ) + return a._SYMBptr->feuille._VECTptr->front()+b._SYMBptr->feuille._VECTptr->front(); + else { + if (b.type==_VECT) + return translation(b,a,contextptr); + gen a_(a); + if (a.is_symb_of_sommet(at_curve) && a._SYMBptr->feuille.type==_VECT && a._SYMBptr->feuille._VECTptr->size()==2 && a._SYMBptr->feuille._VECTptr->front().type==_VECT){ + // adjust param and cartesian eq + vecteur v=*a._SYMBptr->feuille._VECTptr->front()._VECTptr; + if (v.size()==7) + v[6] += b; + if (v.size()>=6){ + v[5]=subst(v[5],makevecteur(x__IDNT_e,y__IDNT_e),makevecteur(x__IDNT_e-re(b,contextptr),y__IDNT_e-im(b,contextptr)),false,contextptr); + a_=symbolic(at_curve,gen(makevecteur(gen(v,a._SYMBptr->feuille._VECTptr->front().subtype),a._SYMBptr->feuille._VECTptr->back()),a._SYMBptr->feuille.subtype)); + } + } + return symbolic_plot_makevecteur( a_._SYMBptr->sommet,a_._SYMBptr->feuille+b,true,contextptr); + } + } + if ( (b.type==_SYMB) && equalposcomp(plot_sommets,b._SYMBptr->sommet) ){ + if (a.type==_VECT) + return translation(a,b,contextptr); + return symbolic_plot_makevecteur(b._SYMBptr->sommet,b._SYMBptr->feuille+a,true,contextptr); + } + gen var1,var2,res1,res2; + if (is_algebraic_program(a,var1,res1)){ + if (is_algebraic_program(b,var2,res2)){ + if (var1!=var2 && is_constant_wrt(res2,var1,contextptr)){ + res2=subst(res2,var2,var1,false,contextptr); + var2=var1; + } + if (var1==var2) + return symbolic(at_program,gen(makevecteur(var1,0,operator_plus(res1,res2,contextptr)),_SEQ__VECT)); + } + if (!is_constant_wrt(b,var1,contextptr)) + *logptr(contextptr) << "Warning function+constant with constant dependent of mute variable" << '\n'; + return symbolic(at_program,gen(makevecteur(var1,0,operator_plus(res1,b,contextptr)),_SEQ__VECT)); + } + if (is_algebraic_program(b,var2,res2)){ + if (!is_constant_wrt(a,var2,contextptr)) + *logptr(contextptr) << "Warning constant+function with constant dependent of mute variable" << '\n'; + return symbolic(at_program,gen(makevecteur(var2,0,operator_plus(a,res2,contextptr)),_SEQ__VECT)); + } + if (a.type==_VECT){ + if (is_zero(b,contextptr)) + return a; + if (a.subtype==_LIST__VECT) + return apply1st(a,b,contextptr,operator_plus); + vecteur res=*a._VECTptr; + if (res.empty()) + return b; + if (a.subtype==_VECTOR__VECT && a._VECTptr->size()==2){ + if (b.type==_VECT && b._VECTptr->size()==2){ + vecteur & bv=*b._VECTptr; + if (b.subtype==_VECTOR__VECT && res.front()==bv.back()) + return _vector(gen(makenewvecteur(bv.front(),bv.back()+res.back()-res.front()),_SEQ__VECT),contextptr); + return _vector(gen(makenewvecteur(res.front(),res.back()+bv.back()-bv.front()),_SEQ__VECT),contextptr); + } + return _point(b+res.back()-res.front(),contextptr); + } + if (b.type==_VECT && b.subtype==_VECTOR__VECT && b._VECTptr->size()==2) + return a+vector2vecteur(*b._VECTptr); + if (a.subtype==_POINT__VECT && a._VECTptr->size()==3 && b.type!=_VECT){ + gen reb,imb; reim(b,reb,imb,contextptr); + res[0] += reb; + res[1] += imb; + return res; + } + if (equalposcomp((int *)_GROUP__VECT_subtype,a.subtype)){ // add to each element + iterateur it=res.begin(),itend=res.end(); + for (;it!=itend;++it) + *it=*it+b; + return gen(res,a.subtype); + } + if (a.subtype==_PNT__VECT){ + res.front()=res.front()+b; + return gen(res,_PNT__VECT); + } + if (a.subtype!=_POLY1__VECT && ckmatrix(a)){ // matrix+cst + int s=int(res.size()); + if (unsigned(s)==res.front()._VECTptr->size()){ + for (int i=0;ifeuille) + return chkmod(zero,a); + if (a.is_symb_of_sommet(at_neg) && b==a._SYMBptr->feuille) + return chkmod(zero,b); + if (is_exactly_zero(a)) + return b; + if (is_exactly_zero(b)) + return a; + if (a.type==_STRNG) + return string2gen(*a._STRNGptr+b.print(context0),false); + if (b.type==_STRNG) + return string2gen(a.print(context0)+*b._STRNGptr,false); + if (a.type==_FRAC){ + if ( (b.type!=_SYMB) && (b.type!=_IDNT) ) + return (*a._FRACptr)+b; + if (b.is_symb_of_sommet(at_neg)) + return a-b._SYMBptr->feuille; + if (b.is_symb_of_sommet(at_inv) && is_cinteger(b._SYMBptr->feuille)) + return (*a._FRACptr)+fraction(1,b._SYMBptr->feuille); + if (b.is_symb_of_sommet(at_prod) && b._SYMBptr->feuille.type==_VECT){ + const vecteur & bf=*b._SYMBptr->feuille._VECTptr; + if (bf.size()==2 && is_integer(bf[0]) && bf[1].is_symb_of_sommet(at_inv) && is_cinteger(bf[1]._SYMBptr->feuille)) + return (*a._FRACptr)+fraction(bf[0],bf[1]._SYMBptr->feuille); + } + return sym_add(_FRAC2_SYMB(a),b,contextptr); + } + if (b.type==_FRAC){ + if ( (a.type!=_SYMB) && (a.type!=_IDNT) ) + return a+(*b._FRACptr); + if (a.is_symb_of_sommet(at_neg)) + return b-a._SYMBptr->feuille; + if (a.is_symb_of_sommet(at_inv) && is_cinteger(a._SYMBptr->feuille)) + return fraction(1,a._SYMBptr->feuille)+(*b._FRACptr); + if (a.is_symb_of_sommet(at_prod) && a._SYMBptr->feuille.type==_VECT){ + const vecteur & af=*a._SYMBptr->feuille._VECTptr; + if (af.size()==2 && is_integer(af[0]) && af[1].is_symb_of_sommet(at_inv) && is_cinteger(af[1]._SYMBptr->feuille)) + return fraction(af[0],af[1]._SYMBptr->feuille)+(*b._FRACptr); + } + return sym_add(a,_FRAC2_SYMB(b),contextptr); + } + if (a.type==_EXT){ + if (a.is_constant() && (b.type==_POLY)) + return addpoly(*b._POLYptr,a); + /* + if (b.type==_POLY && b.is_constant()) + return a+b._POLYptr->coord.front().value; + */ + else + return algebraic_EXTension(*a._EXTptr+b,*(a._EXTptr+1)); + } + if (b.type==_EXT){ + if (b.is_constant() && (a.type==_POLY)) + return addpoly(*a._POLYptr,b); + /* + if (a.type==_POLY && a.is_constant()) + return a._POLYptr->coord.front().value+b; + */ + else + return algebraic_EXTension(a+*b._EXTptr,*(b._EXTptr+1)); + } + int ia=is_inequality(a),ib=is_inequality(b); + if (ia){ + vecteur & va=*a._SYMBptr->feuille._VECTptr; + if (ia==ib || (ia==1 && ib)){ + if (ia==4) // <> + <> + return undef; + vecteur & vb=*b._SYMBptr->feuille._VECTptr; + return new_ref_symbolic(symbolic(b._SYMBptr->sommet,makesequence(va.front()+vb.front(),va.back()+vb.back()))); + } + if (ia==1 || !ib) // = + + return new_ref_symbolic(symbolic(a._SYMBptr->sommet,makesequence(va.front()+b,va.back()+b))); + if ( (ia==5 && ib==6) || (ia==6 && ib==5)){ + vecteur & vb=*b._SYMBptr->feuille._VECTptr; + return new_ref_symbolic(symbolic(at_superieur_strict,makesequence(va.front()+vb.front(),va.back()+vb.back()))); + } + } + if (ib) + return b+a; + if (a.is_symb_of_sommet(at_interval)){ + gen & f=a._SYMBptr->feuille; + if (f.type==_VECT && f._VECTptr->size()==2){ + vecteur & v=*f._VECTptr; + if (b.is_symb_of_sommet(at_interval)){ + gen & g=b._SYMBptr->feuille; + if (g.type==_VECT && g._VECTptr->size()==2){ + vecteur & w=*g._VECTptr; + return new_ref_symbolic(symbolic(at_interval,gen(makenewvecteur(w[0]+v[0],w[1]+v[1]),_SEQ__VECT))); + } + } + return new_ref_symbolic(symbolic(at_interval,gen(makenewvecteur(b+v[0],b+v[1]),_SEQ__VECT))); + } + } + if (b.is_symb_of_sommet(at_interval)) + return b+a; + /* if (xcas_mode(contextptr) && (a.type==_SYMB|| b.type==_SYMB) ) + return liste2symbolique(fusion2liste(symbolique2liste(a),symbolique2liste(b))); */ + if ((a.type==_SYMB) && (b.type==_SYMB)){ + if (a._SYMBptr->sommet==at_plus) { + if (b._SYMBptr->sommet==at_plus) + return new_ref_symbolic(symbolic(at_plus,gen(mergevecteur(*(a._SYMBptr->feuille._VECTptr),*(b._SYMBptr->feuille._VECTptr)),_SEQ__VECT))); + else + return new_ref_symbolic(symbolic(*a._SYMBptr,b)); + } + else { + if (b._SYMBptr->sommet==at_plus) + return new_ref_symbolic(symbolic(*(b._SYMBptr),a)); + else + return new_ref_symbolic(symbolic(at_plus,makesequence(a,b))); + } + } + if (b.type==_SYMB){ + if (b._SYMBptr->sommet==at_plus) + return new_ref_symbolic(symbolic(a,b._SYMBptr->sommet,b._SYMBptr->feuille)); + else + return new_ref_symbolic(symbolic(at_plus,makesequence(a,b))); + } + if (a.type==_SYMB){ + if ( a._SYMBptr->sommet==at_plus && a._SYMBptr->feuille.type==_VECT && a._SYMBptr->feuille._VECTptr->size()>1 && + ( (b==plus_one && a._SYMBptr->feuille._VECTptr->back()==minus_one) || (b==minus_one && a._SYMBptr->feuille._VECTptr->back()==plus_one) ) + ) + { + vecteur v=*a._SYMBptr->feuille._VECTptr; + v.pop_back(); + if (v.size()==1) + return v.front(); + else + return new_ref_symbolic(symbolic(at_plus,gen(v,a._SYMBptr->feuille.subtype))); + } + if (a._SYMBptr->sommet==at_plus) + return new_ref_symbolic(symbolic(*a._SYMBptr,b)); + else + return new_ref_symbolic(symbolic(at_plus,makesequence(a,b))); + } + if ( (a.type==_IDNT) || (b.type==_IDNT)) + return new_ref_symbolic(symbolic(at_plus,makesequence(a,b))); + if (a.type==_MOD) + return a+makemod(b,*(a._MODptr+1)); + if (b.type==_MOD) + return makemod(a,*(b._MODptr+1))+b; + return new_ref_symbolic(symbolic(at_plus,makesequence(a,b))); + // settypeerr(gettext("sym_add")); + } + + static gen subpoly(const gen & th, const gen & other){ + if ((th.type!=_POLY) || (other.type!=_POLY)){ +#ifndef NO_STDEXCEPT + settypeerr(gettext("subpoly")); +#endif + return gentypeerr(gettext("subpoly")); + } + vector< monomial >::const_iterator a=th._POLYptr->coord.begin(); + vector< monomial >::const_iterator a_end=th._POLYptr->coord.end(); + vector< monomial >::const_iterator b=other._POLYptr->coord.begin(); + vector< monomial >::const_iterator b_end=other._POLYptr->coord.end(); + if (b==b_end){ + return th; + } + ref_polynome * resptr=new ref_polynome(th._POLYptr->dim); + Sub_gen(a,a_end,b,b_end,resptr->t.coord,th._POLYptr->is_strictly_greater); + return resptr; + } + + polynome subpoly(const polynome & p,const gen & c){ + if (is_exactly_zero(c)) + return p; + polynome pcopy(p); + if ( (!p.coord.empty()) && p.coord.back().index.is_zero() ) { + pcopy.coord.back().value = pcopy.coord.back().value - c; + if (is_exactly_zero(pcopy.coord.back().value)) + pcopy.coord.pop_back(); + } + else + pcopy.coord.push_back(monomial(-c,pcopy.dim)); + return pcopy; + } + + static polynome subpoly(const gen & c,const polynome & p){ + if (is_exactly_zero(c)) + return -p; + polynome pcopy(-p); + if ( (!p.coord.empty()) && p.coord.back().index.is_zero() ) { + pcopy.coord.back().value = pcopy.coord.back().value + c; + if (is_exactly_zero(pcopy.coord.back().value)) + pcopy.coord.pop_back(); + } + else + pcopy.coord.push_back(monomial(c,pcopy.dim)); + return pcopy; + } + + static gen subgen_poly(const gen & a,const gen & b,bool inplace=false){ + vecteur & av=*a._VECTptr; + vecteur & bv=*b._VECTptr; + if (inplace){ + /* + int as=av.size(),bs=bv.size(); + if (asempty()?0:res; + } + + gen & operator_minus_eq (gen & a,const gen & b,GIAC_CONTEXT){ +#if defined(EMCC) || defined(EMCC2) + a=operator_minus(a,b,contextptr); + return a; +#endif + if (a.type==b.type){ +#ifdef SMARTPTR64 + if (*(ulonglong *)&a==*(ulonglong *)&b && a.type<=_CPLX) + return a=0; +#else + if (&a==&b && a.type<=_CPLX) + return a=0; +#endif + if (a.type==_DOUBLE_){ +#ifdef DOUBLEVAL + a._DOUBLE_val -= b._DOUBLE_val; return a; +#else + *((double *) &a) -= *((double *) &b); + a.type = _DOUBLE_; + return a; +#endif + } + if (a.type==_FLOAT_){ +#ifdef DOUBLEVAL + a._FLOAT_val -= b._FLOAT_val; return a; +#else + *((double *) &a) -= *((double *) &b); + a.type = _FLOAT_; + return a; +#endif + } + if (a.type==_INT_){ + longlong tmp=((longlong) a.val-b.val); + a.val=(int)tmp; + if (a.val==tmp && tmp!=-2147483648) + return a; + return a=tmp; + } + if (a.type==_ZINT && a.ref_count()==1){ + mpz_t * ptr=a._ZINTptr; + mpz_sub(*ptr,*ptr,*b._ZINTptr); + if (mpz_sizeinbase(*ptr,2)<32){ + return a=mpz_get_si(*ptr); + } + return a; + } + if (a.type==_VECT && a.subtype==_POLY1__VECT && a.ref_count()==1){ + if (subgen_poly(a,b,true)._VECTptr->empty()) + a=0; + return a; + } + } + if (a.type==_ZINT && b.type==_INT_ && a.ref_count()==1){ + mpz_t * ptr=a._ZINTptr; + if (b.val>0) + mpz_sub_ui(*ptr,*ptr,b.val); + else + mpz_add_ui(*ptr,*ptr,-b.val); + if (mpz_sizeinbase(*ptr,2)<32){ + return a=mpz_get_si(*ptr); + } + return a; + } + // if (!( (++control_c_counter) & control_c_counter_mask)) +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) { + interrupted = true; ctrl_c=false; + return a=gensizeerr(gettext("Stopped by user interruption.")); + } + return a=operator_minus(a,b,contextptr); + } + + gen operator_minus(const gen & a,const gen & b,unsigned t,GIAC_CONTEXT){ + // if (!( (++control_c_counter) & control_c_counter_mask)) +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) { + interrupted = true; ctrl_c=false; + return gensizeerr(gettext("Stopped by user interruption.")); + } + register ref_mpz_t * e; + switch ( t) { + case _ZINT__ZINT: + e = new ref_mpz_t; + mpz_sub(e->z,*a._ZINTptr,*b._ZINTptr); + return e; + case _DOUBLE___DOUBLE_: + return a._DOUBLE_val-b._DOUBLE_val; + case _FLOAT___FLOAT_: + return a._FLOAT_val-b._FLOAT_val; + case _VECT__VECT: + if (// abs_calc_mode(contextptr)==38 && + (a.subtype==_MATRIX__VECT ||b.subtype==_MATRIX__VECT)){ + if (!ckmatrix(a) || !ckmatrix(b)) + return gensizeerr(contextptr); + if (a._VECTptr->size()!=b._VECTptr->size() || a._VECTptr->front()._VECTptr->size()!=b._VECTptr->front()._VECTptr->size()) + return gendimerr(contextptr); + } + if (a.subtype==_POLY1__VECT) + return subgen_poly(a,b); + if (a.subtype==_PNT__VECT) + return gen(makenewvecteur(a._VECTptr->front()-b,a._VECTptr->back()),a.subtype); + if (a.subtype!=_POINT__VECT && equalposcomp((int *)_GROUP__VECT_subtype,a.subtype)) + return sym_sub(a,b,contextptr); + if (a.subtype==_POINT__VECT && b.subtype==_POINT__VECT) + return gen(subvecteur(*a._VECTptr,*b._VECTptr),0); + return gen(subvecteur(*a._VECTptr,*b._VECTptr),a.subtype); + case _MAP__MAP: + { + int arows,acols,an,brows,bcols,bn; + if ( (is_sparse_matrix(a,arows,acols,an) && is_sparse_matrix(b,brows,bcols,bn)) || (is_sparse_vector(a,arows,an) && is_sparse_vector(b,brows,bn)) ){ + gen_map res; + gen g(res); + sparse_sub(*a._MAPptr,*b._MAPptr,*g._MAPptr); + return g; + } + } + case _INT___ZINT: + e = new ref_mpz_t; + if (a.val<0) + mpz_add_ui(e->z,*b._ZINTptr,-a.val); + else + mpz_sub_ui(e->z,*b._ZINTptr,a.val); + mpz_neg(e->z,e->z); + return(e); + case _ZINT__INT_: + e = new ref_mpz_t; + if (b.val<0) + mpz_add_ui(e->z,*a._ZINTptr,-b.val); + else + mpz_sub_ui(e->z,*a._ZINTptr,b.val); + return(e); + case _INT___DOUBLE_: + return a.val-b._DOUBLE_val; + case _DOUBLE___INT_: + return a._DOUBLE_val-b.val; + case _INT___FLOAT_: + return giac_float(a.val)-b._FLOAT_val; + case _FLOAT___INT_: + return a._FLOAT_val-giac_float(b.val); + case _DOUBLE___FLOAT_: + return giac_float(a._DOUBLE_val)-b._FLOAT_val; + case _FLOAT___DOUBLE_: + return a._FLOAT_val-giac_float(b._DOUBLE_val); + case _FLOAT___FRAC: + return a-evalf2bcd(b,1,contextptr); + case _DOUBLE___FRAC: + return a-ck_evalf_double(b,contextptr); + case _FRAC__FLOAT_: + return evalf2bcd(a,1,contextptr)-b; + case _FRAC__DOUBLE_: + return ck_evalf_double(a,contextptr)-b; + case _ZINT__DOUBLE_: + return mpz_get_d(*a._ZINTptr)-b._DOUBLE_val; + case _DOUBLE___ZINT: + return a._DOUBLE_val-mpz_get_d(*b._ZINTptr); + case _DOUBLE___REAL: + return a._DOUBLE_val-real2double(*b._REALptr); + case _REAL__DOUBLE_: + return real2double(*a._REALptr)-b._DOUBLE_val; + case _CPLX__INT_: case _CPLX__ZINT: case _CPLX__DOUBLE_: case _CPLX__FLOAT_: case _CPLX__REAL: + return gen(*a._CPLXptr-b,*(a._CPLXptr+1)); + case _INT___CPLX: case _ZINT__CPLX: case _DOUBLE___CPLX: case _FLOAT___CPLX: case _REAL__CPLX: + return gen(a-*b._CPLXptr,-*(b._CPLXptr+1)); + case _CPLX__CPLX: + return adjust_complex_display(gen(*a._CPLXptr - *b._CPLXptr, *(a._CPLXptr+1) - *(b._CPLXptr+1)),a,b); + case _POLY__POLY: + return subpoly(a,b); + case _FRAC__FRAC: + return (*a._FRACptr)-(*b._FRACptr); + case _SPOL1__SPOL1: + return spsub(*a._SPOL1ptr,*b._SPOL1ptr,contextptr); + case _EXT__EXT: + return ext_sub(a,b,contextptr); + case _POLY__INT_: case _POLY__ZINT: case _POLY__DOUBLE_: case _POLY__FLOAT_: case _POLY__CPLX: case _POLY__MOD: case _POLY__REAL: case _POLY__USER: + return subpoly(*a._POLYptr,b); + case _INT___POLY: case _ZINT__POLY: case _DOUBLE___POLY: case _FLOAT___POLY: case _CPLX__POLY: case _MOD__POLY:case _USER__POLY: case _REAL__POLY: + return subpoly(a,*b._POLYptr); + case _MOD__MOD: +#ifdef SMARTPTR64 + return modsub( (ref_modulo *) (* ((ulonglong * ) &a) >> 16), (ref_modulo *) (* ((ulonglong * ) &b) >> 16) ); +#else + return modsub(a.__MODptr,b.__MODptr); +#endif + case _REAL__REAL: + return (*a._REALptr)-(*b._REALptr); + default: + if (is_undef(a)) + return a; + if (is_undef(b)) + return b; + if (a.type==_FLOAT_){ + gen b1; + if (b.type==_VECT) + return sym_sub(a,b,contextptr); + if (has_evalf(b,b1,1,contextptr) && b.type!=b1.type) + return operator_minus(a,b1,contextptr); + return operator_minus(evalf_double(a,1,contextptr),b,contextptr); + } + if (b.type==_FLOAT_){ + if (a.type==_VECT) + return sym_sub(a,b,contextptr); + gen a1; + if (has_evalf(a,a1,1,contextptr) && a.type!=a1.type) + return operator_minus(a1,b,contextptr); + return operator_minus(a,evalf_double(b,1,contextptr),contextptr); + } + if (a.type==_SPOL1) + return spsub(*a._SPOL1ptr,gen2spol1(b),contextptr); + if (b.type==_SPOL1) + return spsub(gen2spol1(a),*b._SPOL1ptr,contextptr); + if (a.type==_USER) + return (*a._USERptr)-b; + if (b.type==_USER) + return (-b)+a; + if (a.type==_REAL) + return a._REALptr->substract(b,contextptr); + if (b.type==_REAL) + return operator_plus(-(*b._REALptr),a,contextptr); + if (a.type==_STRNG) + return a; + return sym_sub(a,b,contextptr); + } + } + + gen operator_minus (const gen & a,const gen & b,GIAC_CONTEXT){ + register unsigned t=(a.type<< _DECALAGE) | b.type; + if (!t) + return((longlong) a.val-b.val); + return operator_minus(a,b,t,contextptr); + } + + gen operator - (const gen & a,const gen & b){ + register unsigned t=(a.type<< _DECALAGE) | b.type; + if (!t) + return((longlong) a.val-b.val); + return operator_minus(a,b,t,context0); + } + + gen sym_sub(const gen & a,const gen & b,GIAC_CONTEXT){ +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) { + interrupted = true; ctrl_c=false; + return gensizeerr(gettext("Stopped by user interruption.")); + } + if (a.is_symb_of_sommet(at_unit) || b.is_symb_of_sommet(at_unit)) + return a+(-b); + if ( a.is_approx()){ + gen b1; + if (has_evalf(b,b1,1,contextptr) && (b.type!=b1.type || b!=b1)){ +#ifdef HAVE_LIBMPFR + if (a.type==_REAL){ + gen b2=accurate_evalf(b,mpfr_get_prec(a._REALptr->inf)); + if (b2.is_approx()) + return a-b2; + } +#endif + return a-b1; + } + } + if ( b.is_approx()){ + gen a1; + if (has_evalf(a,a1,1,contextptr) && (a.type!=a1.type || a!=a1)){ +#ifdef HAVE_LIBMPFR + if (a.type==_REAL){ + gen a2=accurate_evalf(a,mpfr_get_prec(b._REALptr->inf)); + if (a2.is_approx()) + return a2-b; + } +#endif + return a1-b; + } + } + if ( (a.type==_SYMB) && equalposcomp(plot_sommets,a._SYMBptr->sommet) ){ + if ( (b.type==_SYMB) && equalposcomp(plot_sommets,b._SYMBptr->sommet) ) + return a._SYMBptr->feuille._VECTptr->front()-b._SYMBptr->feuille._VECTptr->front(); + else { + gen a_(a); + if (a.is_symb_of_sommet(at_curve) && a._SYMBptr->feuille.type==_VECT && a._SYMBptr->feuille._VECTptr->size()==2 && a._SYMBptr->feuille._VECTptr->front().type==_VECT){ + // adjust param and cartesian eq + vecteur v=*a._SYMBptr->feuille._VECTptr->front()._VECTptr; + if (v.size()==7) + v[6] -= b; + if (v.size()>=6){ + v[5]=subst(v[5],makevecteur(x__IDNT_e,y__IDNT_e),makevecteur(x__IDNT_e+re(b,contextptr),y__IDNT_e+im(b,contextptr)),false,contextptr); + a_=symbolic(at_curve,gen(makevecteur(gen(v,a._SYMBptr->feuille._VECTptr->front().subtype),a._SYMBptr->feuille._VECTptr->back()),a._SYMBptr->feuille.subtype)); + } + } + return symbolic_plot_makevecteur(a_._SYMBptr->sommet,a_._SYMBptr->feuille-b,true,contextptr); + } + } + if ( (b.type==_SYMB) && equalposcomp(plot_sommets,b._SYMBptr->sommet) ) + return sym_add(-b,a,contextptr); + gen var1,var2,res1,res2; + if (is_algebraic_program(a,var1,res1) && is_algebraic_program(b,var2,res2)){ + if (var1!=var2 && is_constant_wrt(res2,var1,contextptr)){ + res2=subst(res2,var2,var1,false,contextptr); + var2=var1; + } + if (var1==var2) + return symbolic(at_program,gen(makevecteur(var1,0,operator_minus(res1,res2,contextptr)),_SEQ__VECT)); + } + if (a.type==_VECT) + return sym_add(a,-b,contextptr); + if (b.type==_VECT) + return sym_add(-b,a,contextptr); + if (is_undef(a)) + return a; + if (is_undef(b)) + return b; + if (is_inf(a)){ + if (is_inf(b)){ + if ((a==plus_inf) && (b==minus_inf)) + return a; + if ((a==minus_inf) && (b==plus_inf)) + return a; + return undef; + } + else + return a; + } + if (a.type==_FRAC){ + if ( (b.type!=_SYMB) && (b.type!=_IDNT) ) + return (*a._FRACptr)-b; + if (b.is_symb_of_sommet(at_neg)) + return a+b._SYMBptr->feuille; + if (b.is_symb_of_sommet(at_inv) && is_cinteger(b._SYMBptr->feuille)) + return (*a._FRACptr)-fraction(1,b._SYMBptr->feuille); + return sym_sub(_FRAC2_SYMB(a),b,contextptr); + } + if (b.type==_FRAC){ + if ( (a.type!=_SYMB) && (a.type!=_IDNT) ) + return a-(*b._FRACptr); + if (a.is_symb_of_sommet(at_neg)) + return -(a._SYMBptr->feuille+b); + if (a.is_symb_of_sommet(at_inv) && is_cinteger(a._SYMBptr->feuille)) + return fraction(1,a._SYMBptr->feuille)-(*b._FRACptr); + return sym_sub(a,_FRAC2_SYMB(b),contextptr); + } + if (a.type==_EXT){ + if (a.is_constant() && (b.type==_POLY)) + return subpoly(a,*b._POLYptr); + else + return algebraic_EXTension(*a._EXTptr-b,*(a._EXTptr+1)); + } + if (b.type==_EXT){ + if (b.is_constant() && (a.type==_POLY)) + return subpoly(*a._POLYptr,b); + else + return algebraic_EXTension(a-*b._EXTptr,*(b._EXTptr+1)); + } + if (a==b) + return chkmod(zero,a); + if (is_inf(b)) + return -b; + if (is_exactly_zero(b)) + return a; + if (is_exactly_zero(a)) + return -b; + /* + if (a.type==_SYMB && a._SYMBptr->sommet==at_equal){ + vecteur & va=*a._SYMBptr->feuille._VECTptr; + if (b.type==_SYMB && b._SYMBptr->sommet==at_equal){ + vecteur & vb=*b._SYMBptr->feuille._VECTptr; + return new_ref_symbolic(symbolic(at_equal,makesequence(va.front()-vb.front(),va.back()-vb.back()))); + } + else + return new_ref_symbolic(symbolic(at_equal,makesequence(va.front()-b,va.back()-b))); + } + if (b.type==_SYMB && b._SYMBptr->sommet==at_equal){ + vecteur & vb=*b._SYMBptr->feuille._VECTptr; + return new_ref_symbolic(symbolic(at_equal,makesequence(a-vb.front(),a-vb.back()))); + } + */ + if (is_inequality(a) || is_inequality(b)) + return a+(-b); + if ((a.type==_SYMB) && (b.type==_SYMB)){ + if (a._SYMBptr->sommet==at_plus) { + if (b._SYMBptr->sommet==at_plus) + return new_ref_symbolic(symbolic(at_plus,gen(mergevecteur(*(a._SYMBptr->feuille._VECTptr),negvecteur(*(b._SYMBptr->feuille._VECTptr))),_SEQ__VECT))); + else + return new_ref_symbolic(symbolic(*a._SYMBptr,-b)); + } + else { + if (b._SYMBptr->sommet==at_plus) + return new_ref_symbolic(symbolic(*(-b)._SYMBptr,a)); + else + return new_ref_symbolic(symbolic(at_plus,makesequence(a,-b))); + } + } + if (b.type==_SYMB){ + if (b._SYMBptr->sommet==at_plus) + return new_ref_symbolic(symbolic(*(-b)._SYMBptr,a)); + else + return new_ref_symbolic(symbolic(at_plus,makesequence(a,-b))); + } + if (a.type==_SYMB){ + if (a._SYMBptr->sommet==at_plus) + return new_ref_symbolic(symbolic(*a._SYMBptr,-b)); + else + return new_ref_symbolic(symbolic(at_plus,makesequence(a,-b))); + } + if ((a.type==_IDNT) || (b.type==_IDNT)) + return new_ref_symbolic(symbolic(at_plus,makesequence(a,-b))); + if (a.type==_MOD) + return a-makemod(b,*(a._MODptr+1)); + if (b.type==_MOD) + return makemod(a,*(b._MODptr+1))-b; + return new_ref_symbolic(symbolic(at_plus,makesequence(a,-b))); + // settypeerr(gettext("sym_sub")); + } + + static vecteur negfirst(const vecteur & v){ + vecteur w(v); + if (!w.empty()) + w.front()=-w.front(); + return w; + } + + gen operator -(const gen & a){ + ref_mpz_t *e ; + switch (a.type ) { + case _INT_: + return(-a.val); + case _ZINT: + e=new ref_mpz_t; + mpz_neg(e->z,*a._ZINTptr); + return(e); + case _DOUBLE_: + return -(a._DOUBLE_val); + case _FLOAT_: + return -(a._FLOAT_val); + case _CPLX: { + const gen * aptr=a._CPLXptr; + if (a.subtype==3) + return adjust_complex_display(gen(-aptr->_DOUBLE_val,-(aptr+1)->_DOUBLE_val),a); + return adjust_complex_display(gen(-*aptr,-*(aptr+1)),a); + } + case _IDNT: + if ((a==undef) || (a==unsigned_inf)) + return a; + return new_ref_symbolic(symbolic(at_neg,a)); + case _SYMB: + if (a==plus_inf) + return minus_inf; + if (a==minus_inf) + return plus_inf; + if (a._SYMBptr->sommet==at_neg) + return a._SYMBptr->feuille; + if (a._SYMBptr->sommet==at_unit){ + // if (equalposcomp(lidnt(a),cst_pi)!=0) return -evalf(b,1,context0); + return new_ref_symbolic(symbolic(at_unit,makenewvecteur(-a._SYMBptr->feuille._VECTptr->front(),a._SYMBptr->feuille._VECTptr->back()))); + } + if (a._SYMBptr->sommet==at_plus) + return new_ref_symbolic(symbolic(at_plus,gen(negvecteur(*a._SYMBptr->feuille._VECTptr),_SEQ__VECT))); + if (a._SYMBptr->sommet==at_interval && a._SYMBptr->feuille.type==_VECT && a._SYMBptr->feuille._VECTptr->size()==2){ + return new_ref_symbolic(symbolic(at_interval,gen(makenewvecteur(-a._SYMBptr->feuille._VECTptr->back(),-a._SYMBptr->feuille._VECTptr->front()),_SEQ__VECT))); + } + if (equalposcomp(plot_sommets,a._SYMBptr->sommet)){ + return symbolic_plot_makevecteur(a._SYMBptr->sommet,-a._SYMBptr->feuille,false,context0); + } + if (a.is_symb_of_sommet(at_program)){ + gen a1,b; + if (is_algebraic_program(a,a1,b)) + return symbolic(at_program,gen(makevecteur(a1,0,-b),_SEQ__VECT)); + } + if (a._SYMBptr->sommet==at_equal || a._SYMBptr->sommet==at_equal2 || a._SYMBptr->sommet==at_different || a._SYMBptr->sommet==at_same) + return new_ref_symbolic(symbolic(a._SYMBptr->sommet,makesequence(-a._SYMBptr->feuille._VECTptr->front(),-a._SYMBptr->feuille._VECTptr->back()))); + if (is_inequality(a)) + return new_ref_symbolic(symbolic(a._SYMBptr->sommet,makesequence(-a._SYMBptr->feuille._VECTptr->back(),-a._SYMBptr->feuille._VECTptr->front()))); + return new_ref_symbolic(symbolic(at_neg,a)); + case _VECT: + if (a.subtype==_VECTOR__VECT && a._VECTptr->size()==2) + return gen(makenewvecteur(a._VECTptr->back(),a._VECTptr->front()),_VECTOR__VECT); + if (a.subtype==_PNT__VECT) + return gen(negfirst(*a._VECTptr),a.subtype); + return gen(negvecteur(*a._VECTptr),a.subtype); + case _MAP:{ + gen_map res; + gen g(res); + *g._MAPptr=*a._MAPptr; + sparse_neg(*g._MAPptr); + return g; + } + case _POLY: + return -(*a._POLYptr); + case _EXT: + return algebraic_EXTension(-(*a._EXTptr),*(a._EXTptr+1)); + case _USER: + return -(*a._USERptr); + case _MOD: + return makemod(-*a._MODptr,*(a._MODptr+1)); + case _FRAC: + return fraction(-(a._FRACptr->num),a._FRACptr->den); + case _SPOL1: + return spneg(*a._SPOL1ptr,context0); + case _STRNG: + if (is_undef(a)) return a; + return string2gen("-"+(*a._STRNGptr),false); + case _REAL: + return -*a._REALptr; + default: + return new_ref_symbolic(symbolic(at_neg,a)); + } + } + + static gen mulpoly(const gen & th,const gen & other){ + if ((th.type!=_POLY) || (other.type!=_POLY)){ +#ifndef NO_STDEXCEPT + settypeerr(gettext("mulpoly")); +#endif + return gentypeerr(gettext("mulpoly")); + } + vector< monomial >::const_iterator ita = th._POLYptr->coord.begin(); + vector< monomial >::const_iterator ita_end = th._POLYptr->coord.end(); + vector< monomial >::const_iterator itb = other._POLYptr->coord.begin(); + vector< monomial >::const_iterator itb_end = other._POLYptr->coord.end(); + // first some trivial cases + if (ita==ita_end) + return(th); + if (itb==itb_end) + return(other); + if (is_one(*th._POLYptr)) + return other; + if (is_one(*other._POLYptr)) + return th; + // Now look if length a=1 or length b=1, happens frequently + // think of x^3*y^2*z translated to internal form + int c1=int(th._POLYptr->coord.size()); + if (c1==1) + return other._POLYptr->shift(th._POLYptr->coord.front().index,th._POLYptr->coord.front().value); + int c2=int(other._POLYptr->coord.size()); + if (c2==1) + return th._POLYptr->shift(other._POLYptr->coord.front().index,other._POLYptr->coord.front().value); + ref_polynome * resptr = new ref_polynome(th._POLYptr->dim); + mulpoly(*th._POLYptr,*other._POLYptr,resptr->t,0); + return resptr; + } + + static vecteur multfirst(const gen & a,const vecteur & v){ + vecteur w(v); + if (!w.empty()) + w.front()=v.front()*a; + return w; + } + + static gen multgen_poly(const gen & a,const vecteur & b,int subtype){ + gen res(vecteur(0),subtype); + multvecteur(a,b,*res._VECTptr); + return res; + } + + static gen multgen_poly(const vecteur & a,const vecteur & b){ + gen res(vecteur(0), _POLY1__VECT); + operator_times(a,b,0,*res._VECTptr); + return res; + } + + // a*b -> tmp, modifies tmp in place + void type_operator_times(const gen & a,const gen &b,gen & tmp){ + register unsigned t=(a.type<< _DECALAGE) | b.type; +#if !defined(EMCC) && !defined(EMCC2) + if (tmp.type==_DOUBLE_ && t==_DOUBLE___DOUBLE_){ +#ifdef DOUBLEVAL + tmp._DOUBLE_val=a._DOUBLE_val*b._DOUBLE_val; +#else + *((double *) &tmp) = (*((double *) &a)) * (*((double *) &b)); + tmp.type = _DOUBLE_; +#endif + return ; + } +#endif + if (!t && tmp.type==_INT_ ){ + register longlong ab=longlong(a.val)*b.val; + tmp.val=(int)ab; +#if 1 + if (ab>>31) + tmp=ab; +#else + if (tmp.val!=ab || tmp==-2147483648) + tmp=ab; +#endif + return; + } + if (tmp.type==_ZINT && tmp.ref_count()==1){ + mpz_t * ptr=tmp._ZINTptr; + switch (t){ + case _INT___INT_: + tmp=longlong(a.val)*b.val; + return; + case _ZINT__ZINT: + mpz_mul(*ptr,*a._ZINTptr,*b._ZINTptr); + return ; + case _ZINT__INT_: + if (b.val<0){ + mpz_mul_ui(*ptr,*a._ZINTptr,-b.val); + mpz_neg(*ptr,*ptr); + } + else + mpz_mul_ui(*ptr,*a._ZINTptr,b.val); + return; + case _INT___ZINT: + if (a.val<0){ + mpz_mul_ui(*ptr,*b._ZINTptr,-a.val); + mpz_neg(*ptr,*ptr); + } + else + mpz_mul_ui(*ptr,*b._ZINTptr,a.val); + return; + } + } + tmp=a*b; + } + + bool is_int_zint_vecteur(const vecteur & m){ + const_iterateur it=m.begin(),itend=m.end(); + for (;it!=itend;++it){ + int t=it->type; + if (t!=_INT_ && t!=_ZINT) return false; + } + return true; + } + + void type_operator_plus_times(const gen & a,const gen & b,gen & c){ + register unsigned t=(a.type<< _DECALAGE) | b.type; +#if !defined(EMCC) && !defined(EMCC2) + if (c.type==_DOUBLE_ && t==_DOUBLE___DOUBLE_){ +#ifdef DOUBLEVAL + c._DOUBLE_val += a._DOUBLE_val*b._DOUBLE_val; +#else + *((double *) &c) += (*((double *) &a)) * (*((double *) &b)); + c.type = _DOUBLE_; +#endif + return ; + } +#endif + if (c.type==_ZINT && c.ref_count()==1){ + switch (t){ + case _ZINT__ZINT: + mpz_addmul(*c._ZINTptr,*a._ZINTptr,*b._ZINTptr); + return; + case _ZINT__INT_: + if (b.val<0) + mpz_submul_ui(*c._ZINTptr,*a._ZINTptr,-b.val); + else + mpz_addmul_ui(*c._ZINTptr,*a._ZINTptr,b.val); + return; + case _INT___ZINT: + if (a.val<0){ + mpz_submul_ui(*c._ZINTptr,*b._ZINTptr,-a.val); + } + else + mpz_addmul_ui(*c._ZINTptr,*b._ZINTptr,a.val); + return; + } + } + if (c.type==_EXT && a.type==_EXT && b.type==_EXT){ + if ((c._EXTptr+1)->type==_VECT && *(a._EXTptr+1)==*(c._EXTptr+1) && *(b._EXTptr+1)==*(c._EXTptr+1) && a._EXTptr->type==_VECT && b._EXTptr->type==_VECT && c._EXTptr->type==_VECT){ + vecteur & v = *(c._EXTptr+1)->_VECTptr; + if (v.size()==3 && v[0]==1 && v[1]==0 && a._EXTptr->_VECTptr->size()==2 && b._EXTptr->_VECTptr->size()==2 && c._EXTptr->_VECTptr->size()==2){ + gen a1=a._EXTptr->_VECTptr->front(),a0=a._EXTptr->_VECTptr->back(),b1=b._EXTptr->_VECTptr->front(),b0=b._EXTptr->_VECTptr->back(),c1=c._EXTptr->_VECTptr->front(),c0=c._EXTptr->_VECTptr->back(); + gen d1=a1*b0+a0*b1+c1,d0=a0*b0-v[2]*a1*b1+c0; + if (is_zero(d1)){ c=d0; return; } + gen d=new ref_vecteur(2); + d._VECTptr->front()=d1; + d._VECTptr->back()=d0; + if (c.ref_count()==1) + *c._EXTptr=d; + else + c=algebraic_EXTension(d,*(c._EXTptr+1)); + } + else { + gen d=new ref_vecteur; + vecteur ab,rem; + operator_times(*a._EXTptr->_VECTptr,*b._EXTptr->_VECTptr,0,ab); + addmodpoly(ab,*c._EXTptr->_VECTptr,*d._VECTptr); + if (c.ref_count()==1){ + DivRem(*d._VECTptr,v,0,ab,rem); // take remainder! + if (rem.size()<2){ if (rem.empty()) c=0; else c=rem.front();} + else { + //gen dbg=ext_reduce(d,*(c._EXTptr+1)); + d._VECTptr->swap(rem); + *c._EXTptr=d; + //if (dbg!=c) CERR << "error" << '\n'; + } + } + else + c=ext_reduce(d,*(c._EXTptr+1)); + } + return; + } + } + if (c.type==_VECT && c.ref_count()==1 && a.type==_VECT && b.type==_VECT && a._VECTptr->size()size()begin(),a._VECTptr->end(),b._VECTptr->begin(),b._VECTptr->end(),0,*c._VECTptr); + return; + } + gen g; + type_operator_times(a,b,g); + if (g.type==_ZINT) + swapgen(c,g); + c += g; + } + + void type_operator_minus_times(const gen & a,const gen & b,gen & c){ + register unsigned t=(a.type<< _DECALAGE) | b.type; +#if !defined(EMCC) && !defined(EMCC2) + if (c.type==_DOUBLE_ && t==_DOUBLE___DOUBLE_){ +#ifdef DOUBLEVAL + c._DOUBLE_val -= a._DOUBLE_val*b._DOUBLE_val; +#else + *((double *) &c) -= (*((double *) &a)) * (*((double *) &b)); + c.type = _DOUBLE_; +#endif + return ; + } +#endif + if (c.type==_ZINT && c.ref_count()==1){ + switch (t){ + case _ZINT__ZINT: + mpz_submul(*c._ZINTptr,*a._ZINTptr,*b._ZINTptr); + return; + case _ZINT__INT_: + if (b.val<0) + mpz_addmul_ui(*c._ZINTptr,*a._ZINTptr,-b.val); + else + mpz_submul_ui(*c._ZINTptr,*a._ZINTptr,b.val); + return; + case _INT___ZINT: + if (a.val<0){ + mpz_addmul_ui(*c._ZINTptr,*b._ZINTptr,-a.val); + } + else + mpz_submul_ui(*c._ZINTptr,*b._ZINTptr,a.val); + return; + } + } + gen g; + type_operator_times(a,b,g); + c -= g; + } + + static gen double_times_frac(const gen & a,const fraction & b,GIAC_CONTEXT){ + gen n=a*b.num,d=b.den; + return rdiv(n,d,contextptr); + } + + static gen mult_cplx(const gen & a,const gen & b,GIAC_CONTEXT){ + gen * aptr=a._CPLXptr,*bptr=b._CPLXptr; + unsigned t= (aptr->type | ((aptr+1)->type << 8) | (bptr->type << 16) | ((bptr+1)->type << 24)); + if (t==(_DOUBLE_ | (_DOUBLE_<<8) | (_DOUBLE_ <<16) | (_DOUBLE_ <<24))){ + double ar=aptr->_DOUBLE_val,ai=(aptr+1)->_DOUBLE_val, + br=bptr->_DOUBLE_val,bi=(bptr+1)->_DOUBLE_val; + return gen(ar*br-ai* bi, br*ai+ar*bi); + } + if (t==(_ZINT | (_ZINT<<8) | (_ZINT <<16) | (_ZINT <<24))){ + mpz_t & ax=*aptr->_ZINTptr; + mpz_t & ay=*((aptr+1)->_ZINTptr); + mpz_t & bx=*bptr->_ZINTptr; + mpz_t & by=*((bptr+1)->_ZINTptr); + // (ax+i*ay)*(bx+i*by)=ax*bx-ay*by+i*(ax*by+ay*bx) + // imaginary part is also (ax+ay)*(bx+by)-ax*bx-ay*by, Karatsuba trick + mpz_t axbx,ayby,r; +#if defined USE_GMP_REPLACEMENTS || defined BF2GMP_H + mpz_init(axbx); mpz_init(ayby); mpz_init(r); +#else + int n1=mpz_size(ax)+mpz_size(bx),n2=mpz_size(ay)+mpz_size(by); + mpz_init2(axbx,n1); mpz_init2(ayby,n2); mpz_init2(r,giacmax(n1,n2)+2); +#endif + mpz_mul(axbx,ax,bx); + mpz_add(r,ax,ay); + mpz_add(ayby,bx,by); // temporary use + mpz_mul(r,r,ayby); + mpz_sub(r,r,axbx); + mpz_mul(ayby,ay,by); + mpz_sub(r,r,ayby); + gen I=r; + mpz_sub(r,axbx,ayby); + gen R=r; + R=gen(R,I); + mpz_clear(r); mpz_clear(ayby); mpz_clear(axbx); + return R; + } +#if defined HAVE_LIBMPFR && !defined NO_RTTI + if (t==(_REAL | (_REAL<<8) | (_REAL <<16) | (_REAL <<24))){ + real_object & ax=*aptr->_REALptr; + real_object & ay=*((aptr+1)->_REALptr); + real_object & bx=*bptr->_REALptr; + real_object & by=*((bptr+1)->_REALptr); + if (!dynamic_cast(&ax) || + !dynamic_cast(&ay) || + !dynamic_cast(&bx) || + !dynamic_cast(&by) ){ + mpfr_t axbx,ayby,r; + int nbits=mpfr_get_prec(ax.inf); + nbits=giacmin(nbits,mpfr_get_prec(bx.inf)); + mpfr_init2(axbx,nbits); mpfr_init2(ayby,nbits); mpfr_init2(r,nbits); + mpfr_mul(axbx,ax.inf,bx.inf,MPFR_RNDN); + mpfr_add(r,ax.inf,ay.inf,MPFR_RNDN); + mpfr_add(ayby,bx.inf,by.inf,MPFR_RNDN); // temporary use + mpfr_mul(r,r,ayby,MPFR_RNDN); + mpfr_sub(r,r,axbx,MPFR_RNDN); + mpfr_mul(ayby,ay.inf,by.inf,MPFR_RNDN); + mpfr_sub(r,r,ayby,MPFR_RNDN); + gen I=real_object(r); + mpfr_sub(r,axbx,ayby,MPFR_RNDN); + gen R=real_object(r); + R=gen(R,I); + mpfr_clear(r); mpfr_clear(ayby); mpfr_clear(axbx); + return R; + } + } +#endif + return gen(*aptr * (*bptr) - *(aptr+1)* (*(bptr+1)), + (*bptr) * (*(aptr+1)) + *(bptr+1) * (*aptr)); + } + + static gen operator_times(const gen & a,const gen & b,unsigned t,GIAC_CONTEXT){ + static bool warnpy=true; + // COUT << a << "*" << b << '\n'; + // if (!( (++control_c_counter) & control_c_counter_mask)) +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) { + interrupted = true; ctrl_c=false; + return gensizeerr(gettext("Stopped by user interruption.")); + } + register ref_mpz_t * e; + switch (t) { + case _ZINT__ZINT: + e=new ref_mpz_t(GIAC_MPZ_INIT_SIZE); // ((mpz_size(*b._ZINTptr)+mpz_size(*b._ZINTptr))*mp_bits_per_limb); + mpz_mul(e->z,*a._ZINTptr,*b._ZINTptr); + return e; + case _DOUBLE___DOUBLE_: + return a._DOUBLE_val*b._DOUBLE_val; + case _FLOAT___FLOAT_: + return a._FLOAT_val*b._FLOAT_val; + case _INT___ZINT: + if (a.val==1) return b; + e=new ref_mpz_t(GIAC_MPZ_INIT_SIZE); // (mpz_size(*b._ZINTptr)*mp_bits_per_limb); + if (a.val<0){ + mpz_mul_ui(e->z,*b._ZINTptr,-a.val); + mpz_neg(e->z,e->z); + } + else + mpz_mul_ui(e->z,*b._ZINTptr,a.val); + return gen(e); + case _ZINT__INT_: + if (b.val==1) return a; + e=new ref_mpz_t(GIAC_MPZ_INIT_SIZE); // (mpz_size(*a._ZINTptr)*mp_bits_per_limb); + if (b.val<0){ + mpz_mul_ui(e->z,*a._ZINTptr,-b.val); + mpz_neg(e->z,e->z); + } + else + mpz_mul_ui(e->z,*a._ZINTptr,b.val); + return gen(e); + case _INT___DOUBLE_: + return a.val*b._DOUBLE_val; + case _DOUBLE___INT_: + return a._DOUBLE_val*b.val; + case _INT___FLOAT_: + return giac_float(a.val)*b._FLOAT_val; + case _FLOAT___INT_: + return a._FLOAT_val*giac_float(b.val); + case _DOUBLE___FLOAT_: + return giac_float(a._DOUBLE_val)*b._FLOAT_val; + case _FLOAT___DOUBLE_: + return a._FLOAT_val*giac_float(b._DOUBLE_val); + case _FLOAT___FRAC: case _DOUBLE___FRAC: + return double_times_frac(a,*b._FRACptr,contextptr); + case _FRAC__FLOAT_: case _FRAC__DOUBLE_: + return double_times_frac(b,*a._FRACptr,contextptr); + case _INT___FRAC: case _ZINT__FRAC: + return a*(*b._FRACptr); + case _FRAC__INT_: case _FRAC_ZINT: + return (*a._FRACptr)*b; + case _DOUBLE___ZINT: + return a._DOUBLE_val*mpz_get_d(*b._ZINTptr); + case _DOUBLE___REAL: + return a._DOUBLE_val*real2double(*b._REALptr); + case _REAL__DOUBLE_: + return b._DOUBLE_val*real2double(*a._REALptr); + case _ZINT__DOUBLE_: + return mpz_get_d(*a._ZINTptr)*b._DOUBLE_val; + case _CPLX__INT_: + if (b.val==1) return a; + case _CPLX__ZINT: case _CPLX__DOUBLE_: case _CPLX__FLOAT_: case _CPLX__REAL: + return gen(*a._CPLXptr*b,*(a._CPLXptr+1)*b); + case _INT___CPLX: + return a.val==1?b:gen(a*(*b._CPLXptr),a*(*(b._CPLXptr+1))); + case _ZINT__CPLX: case _DOUBLE___CPLX: case _FLOAT___CPLX: case _REAL__CPLX: + return is_one(a)?b:gen(a*(*b._CPLXptr),a*(*(b._CPLXptr+1))); + case _CPLX__CPLX: + return adjust_complex_display(mult_cplx(a,b,contextptr),a,b); +#if 1 //ndef GIAC_GGB + case _INT___STRNG:{ + if (b.subtype==-1) return b; + string res; + for (int i=0;i=0 && python_compat(contextptr)==2){ + vecteur res; + res.reserve(a._VECTptr->size()*b.val); + const_iterateur it,itend=a._VECTptr->end(); + int n=b.val; + for (int i=0;ibegin();it!=itend;++it) + res.push_back(*it); + } + return gen(res,a.subtype); + } + case _VECT__ZINT: case _VECT__DOUBLE_: case _VECT__FLOAT_: case _VECT__CPLX: case _VECT__SYMB: case _VECT__IDNT: case _VECT__POLY: case _VECT__EXT: case _VECT__MOD: case _VECT__FRAC: case _VECT__REAL: { + gen A(a),B(b); + if (A.is_approx() && !is_fully_numeric(B)) + B=evalf(b,1,contextptr); + else { + if (B.is_approx() && !is_fully_numeric(A)){ + A=evalf(a,1,contextptr); + if (A.type!=_VECT) + A=a; + } + } + // matrix * point -> point + if (B.is_symb_of_sommet(at_pnt)){ + gen tmp=complex2vecteur(remove_at_pnt(B),contextptr); + if (ckmatrix(A)){ + tmp=multmatvecteur(*A._VECTptr,*tmp._VECTptr); + return _point(tmp,contextptr); + } + if (A._VECTptr->size()==tmp._VECTptr->size()) + return dotvecteur(*A._VECTptr,*tmp._VECTptr); + } + if (A.subtype==_VECTOR__VECT && A._VECTptr->size()==2) + return vector2vecteur(*A._VECTptr)*B; + if (A.subtype==_PNT__VECT) + return gen(multfirst(B,*A._VECTptr),_PNT__VECT); + if (A.subtype==_POLY1__VECT){ + if (is_zero(B,contextptr)) + return B; + //if (b.type==_POLY) return a*(*b._POLYptr); + } + return multgen_poly(B,*A._VECTptr,A.subtype); // gen(multvecteur(b,*a._VECTptr),a.subtype); + } + case _INT___VECT: + if (a.val>=0 && python_compat(contextptr)==2) + return operator_times(b,a,contextptr); + if (warnpy && a.val>=0 && python_compat(contextptr)){ + alert(gettext("Python compatibility, integer*list will do vector multiplication, run list*integer to duplicate list"),contextptr); + warnpy=false; + } + case _ZINT__VECT: case _DOUBLE___VECT: case _FLOAT___VECT: case _CPLX__VECT: case _SYMB__VECT: case _IDNT__VECT: case _POLY__VECT: case _EXT__VECT: case _MOD__VECT: case _FRAC__VECT: case _REAL__VECT: { + gen A(a),B(b); + if (A.is_approx() && !is_fully_numeric(B)){ + B=evalf(b,1,contextptr); + if (B.type!=_VECT) + B=b; + } + else { + if (B.is_approx() && !is_fully_numeric(A)){ + A=evalf(a,1,contextptr); + } + } + if (A.is_symb_of_sommet(at_pnt)){ + gen tmp=complex2vecteur(remove_at_pnt(A),contextptr); + if (ckmatrix(B)) + return _point(multvecteurmat(*tmp._VECTptr,*B._VECTptr),contextptr); + if (tmp._VECTptr->size()==B._VECTptr->size()) + return dotvecteur(*tmp._VECTptr,*B._VECTptr,contextptr); + } + if (B.subtype==_VECTOR__VECT && B._VECTptr->size()==2) + return A*vector2vecteur(*B._VECTptr); + if (B.subtype==_PNT__VECT) + return gen(multfirst(A,*B._VECTptr),_PNT__VECT); + if (B.subtype==_POLY1__VECT){ + if (is_zero(A,contextptr)) + return A; + // if (a.type==_POLY) return b*(*a._POLYptr); + } + return multgen_poly(A,*B._VECTptr,B.subtype); // gen(multvecteur(a,*b._VECTptr),b.subtype); + } + case _VECT__VECT: { + gen A(a),B(b); + if (A.subtype==_SET__VECT && B.subtype==_SET__VECT){ + vecteur res; res.reserve(A._VECTptr->size()*B._VECTptr->size()); + const_iterateur at=A._VECTptr->begin(),aend=A._VECTptr->end(),bt=B._VECTptr->begin(),bend=B._VECTptr->end(); + for (;at!=aend;++at){ + for (bt=B._VECTptr->begin();bt!=bend;++bt){ + if (at->type==_VECT && at->subtype==_TUPLE__VECT){ + if (bt->type==_VECT && bt->subtype==_TUPLE__VECT){ + res.push_back(gen(mergevecteur(*at->_VECTptr,*bt->_VECTptr),_TUPLE__VECT)); + } + else { + vecteur tmp(*at->_VECTptr); + tmp.push_back(*bt); + res.push_back(gen(tmp,_TUPLE__VECT)); + } + } + else { + if (bt->type==_VECT && bt->subtype==_TUPLE__VECT){ + vecteur tmp(*bt->_VECTptr); + tmp.insert(tmp.begin(),*at); + res.push_back(gen(tmp,_TUPLE__VECT)); + } + else + res.push_back(gen(makevecteur(*at,*bt),_TUPLE__VECT)); + } + } + } + return gen(res,_SET__VECT); + } + // FIXME should not convert 0 in B if A has intervals + if (A.is_approx() && !is_fully_numeric(B)){ + bool done=false; +#if defined HAVE_LIBMPFI && !defined NO_RTTI + // workaround for lu e.g. a:=ranm(4,4); b:=convert(a,interval); p,l,u:=lu(b):; l*u; + if (!A._VECTptr->empty() && A._VECTptr->back().type==_VECT && !A._VECTptr->back()._VECTptr->empty() && A._VECTptr->back()._VECTptr->front().type==_REAL){ + if (real_interval * ptr=dynamic_cast(A._VECTptr->back()._VECTptr->front()._REALptr)){ + B=convert_interval(b,mpfi_get_prec(ptr->infsup),contextptr); + done=true; + } + } +#endif + if (!done) + B=evalf(b,1,contextptr); + if (B.type!=_VECT) + B=b; + } + else { + if (B.is_approx() && !is_fully_numeric(A)){ + A=evalf(a,1,contextptr); + if (A.type!=_VECT) + A=a; + } + } + if (// abs_calc_mode(contextptr)==38 && + (A.subtype==_MATRIX__VECT ||B.subtype==_MATRIX__VECT) && ckmatrix(A) && ckmatrix(B)){ + if (A._VECTptr->front()._VECTptr->size()!=B._VECTptr->size()) + return gendimerr(contextptr); + gen res(new ref_vecteur(0),_MATRIX__VECT); + mmult(*A._VECTptr,*B._VECTptr,*res._VECTptr); + return res; + } + if ( (A.subtype==_POLY1__VECT) || (B.subtype==_POLY1__VECT) ) + return multgen_poly(*A._VECTptr,*B._VECTptr); + if ( (A.subtype==_LIST__VECT) || (B.subtype==_LIST__VECT) ) + return matrix_apply(A,B,contextptr,operator_times); + if (A.subtype==_GGBVECT || (b.subtype==_GGBVECT && !ckmatrix(A))){ + gen res=dotvecteur(a,b); + if (res.type==_VECT) res.subtype=_GGBVECT; + return res; + } + { gen res=ckmultmatvecteur(*A._VECTptr,*B._VECTptr,contextptr); + if ( (calc_mode(contextptr)==1 || abs_calc_mode(contextptr)==38) && res.type==_VECT){ + res.subtype=B.subtype; + if (res.subtype==0) + res.subtype=A.subtype; + } + return res; + } + } + case _POLY__POLY: + return mulpoly(a,b); + case _FRAC__FRAC: + if (a._FRACptr->num.type==_EXT && b._FRACptr->num.type==_EXT) + return ((*a._FRACptr)*(*b._FRACptr)).normal(); + return (*a._FRACptr)*(*b._FRACptr); + case _SPOL1__SPOL1: + return spmul(*a._SPOL1ptr,*b._SPOL1ptr,contextptr); + case _EXT__EXT: + return ext_mul(a,b,contextptr); + case _MAP__MAP: + { + int arows,acols,an,brows,bcols,bn; + if (is_sparse_matrix(a,arows,acols,an) && is_sparse_matrix(b,brows,bcols,bn)){ + gen_map res; + gen g(res); + sparse_mult(*a._MAPptr,*b._MAPptr,*g._MAPptr); + return g; + } + } + case _MAP__VECT: + { + int arows,acols,an; + if (is_sparse_matrix(a,arows,acols,an)){ + if (acols>b._VECTptr->size()) + return gendimerr(contextptr); + if (ckmatrix(b)){ + vecteur A; + convert(*a._MAPptr,A); + return A*b; + } + smatrix as; + if (convert(*a._MAPptr,as)){ + vecteur res; + sparse_mult(as,*b._VECTptr,res); + return res; + } + gen_map res; + gen g(res); + if (!sparse_mult(*a._MAPptr,*b._VECTptr,*g._MAPptr)) + return gendimerr(contextptr); + // Should probably check if g is dense or not + return g; + } + } + case _VECT__MAP: + { + int brows,bcols,an; + if (is_sparse_matrix(b,brows,bcols,an)){ + if (brows>a._VECTptr->size()) + return gendimerr(contextptr); + if (ckmatrix(a)){ + vecteur B; + convert(*b._MAPptr,B); + return a*B; + } + smatrix bs; + if (convert(*b._MAPptr,bs)){ + vecteur res; + sparse_mult(*a._VECTptr,bs,res); + return res; + } + gen_map res; + gen g(res); + if (!sparse_mult(*a._VECTptr,*b._MAPptr,*g._MAPptr)) + return gendimerr(contextptr); + // Should probably check if g is dense or not + return g; + } + } + case _INT___MAP: case _ZINT__MAP: case _DOUBLE___MAP: case _FLOAT___MAP: case _CPLX__MAP: case _SYMB__MAP: case _IDNT__MAP: case _POLY__MAP: case _EXT__MAP: case _MOD__MAP: case _FRAC__MAP: case _REAL__MAP: { + if (is_one(a)) + return b; + int brows,bcols,bn; + if (is_sparse_matrix(b,brows,bcols,bn)){ + gen_map res; + gen g(res); + if (is_zero(a)) + return g; + *g._MAPptr=*b._MAPptr; + sparse_mult(a,*g._MAPptr); + return g; + } + break; + } + case _POLY__INT_: case _POLY__ZINT: case _POLY__DOUBLE_: case _POLY__FLOAT_: case _POLY__CPLX: case _POLY__USER: case _POLY__REAL: + if (is_one(b)) + return a; + return (*a._POLYptr) * b; + case _POLY__MOD: + return (*a._POLYptr) * b; + case _INT___POLY: case _ZINT__POLY: case _DOUBLE___POLY: case _FLOAT___POLY: case _CPLX__POLY: case _USER__POLY: case _REAL__POLY: + if (is_one(a)) + return b; + return a * (*b._POLYptr); + case _MOD__POLY: + return a * (*b._POLYptr); + case _MOD__MOD: +#ifdef SMARTPTR64 + return modmul( (ref_modulo *) (* ((ulonglong * ) &a) >> 16),(ref_modulo *) (* ((ulonglong * ) &b) >> 16) ); +#else + return modmul(a.__MODptr,b.__MODptr); +#endif + case _MOD__INT_: case _MOD__ZINT: + return makemod(*a._MODptr*b,*(a._MODptr+1)); + case _INT___MOD: case _ZINT__MOD: + return makemod(*b._MODptr*a,*(b._MODptr+1)); + case _REAL__REAL: + return (*a._REALptr)*(*b._REALptr); + default: + if (is_undef(a)) + return a; + if (is_undef(b)) + return b; + if (a.type==_FLOAT_){ + gen b1; + if (has_evalf(b,b1,1,contextptr)&& (b.type!=b1.type || b!=b1)) + return a*b1; + return operator_times(evalf_double(a,1,contextptr),b,contextptr); + } + if (b.type==_FLOAT_){ + gen a1; + if (has_evalf(a,a1,1,contextptr)&& (a.type!=a1.type || a!=a1)) + return a1*b; + return operator_times(a,evalf_double(b,1,contextptr),contextptr); + } + if (a.type==_SPOL1) + return spmul(*a._SPOL1ptr,gen2spol1(b),contextptr); + if (b.type==_SPOL1) + return spmul(gen2spol1(a),*b._SPOL1ptr,contextptr); + if (a.type==_USER) + return (*a._USERptr)*b; + if (b.type==_USER) + return (*b._USERptr)*a; + if (a.type==_REAL) + return a._REALptr->multiply(b,contextptr); + if (b.type==_REAL) + return b._REALptr->multiply(a,contextptr); + if (a.type==_STRNG || b.type==_STRNG) + return gensizeerr(contextptr); + return sym_mult(a,b,contextptr); + } + return undef; + } + + gen operator_times(const gen & a,const gen & b,GIAC_CONTEXT){ + register unsigned t=(a.type<< _DECALAGE) | b.type; + if (!t) + return gen((longlong) a.val*b.val); + return operator_times(a,b,t,contextptr); + } + + gen operator * (const gen & a,const gen & b){ + register unsigned t=(a.type<< _DECALAGE) | b.type; + if (!t) + return gen((longlong) a.val*b.val); + return operator_times(a,b,t,context0); + } + + bool has_i(const gen & g){ + if (g.type==_CPLX) + return true; + if (g.type==_FRAC) + return g._FRACptr->num.type==_CPLX || g._FRACptr->den.type==_CPLX; + if (g.type==_VECT){ + const_iterateur it=g._VECTptr->begin(),itend=g._VECTptr->end(); + for (;it!=itend;++it){ + if (has_i(*it)) + return true; + } + return false; + } + if (g.type==_SPOL1){ + sparse_poly1::const_iterator it=g._SPOL1ptr->begin(),itend=g._SPOL1ptr->end(); + for (;it!=itend;++it){ + if (has_i(it->coeff)) + return true; + } + return false; + } + if (g.type==_EXT) + return has_i(*g._EXTptr); + if (g.type!=_SYMB) + return false; + return has_i(g._SYMBptr->feuille); + } + + gen giac_pow(const gen & base,const gen & exponent,GIAC_CONTEXT){ + return pow(base,exponent,contextptr); + } + + // (-1)^n + static gen minus1pow(const gen & exponent,GIAC_CONTEXT,bool allow_recursion=true){ + if (exponent.type==_INT_) + return (exponent.val%2)?-1:1; + if (exponent.type==_ZINT){ + gen q,g=irem(exponent,2,q); + if (is_zero(g,contextptr)) + return 1; + return -1; + } + if (is_inf(exponent)) + return undef; + if (is_undef(exponent)) + return exponent; + if (exponent.is_symb_of_sommet(at_neg)){ + gen tmp=minus1pow(exponent._SYMBptr->feuille,contextptr); + if (is_assumed_integer(exponent,contextptr)) + return tmp; + //else return symb_inv(tmp); + } + if (exponent.is_symb_of_sommet(at_plus)){ + gen res(1); + gen & f=exponent._SYMBptr->feuille; + if (f.type!=_VECT) + return minus1pow(f,contextptr); + vecteur & v = *f._VECTptr; + int s=int(v.size()); + for (int i=0;ifeuille; + if (f.type==_VECT){ + vecteur & v = *f._VECTptr; + int i,s=int(v.size()); + bool even=false,perhapsone=true; + gen num=1,den=1; + for (i=0;ifeuille; + else + num=num*v[i]; + if (is_integer(v[i]) && is_zero(smod(v[i],2),contextptr)) + even=true; + if (!is_assumed_integer(v[i],contextptr)) + perhapsone=false; + } +#ifndef NO_STDEXCEPT + if (allow_recursion && perhapsone){ + gen num1=undef; + try { + num1=_irem(makesequence(num,2*den),contextptr); + } catch (std::runtime_error & err){ + num1=undef; + } + if (!is_undef(num1) && num1!=num) return minus1pow(symb_prod(num1,symb_inv(den)),contextptr,false); + } +#endif + if (even && perhapsone) + return 1; + if (num.type==_INT_ && den.type==_INT_ && den.val<=MAX_ALG_EXT_ORDER_SIZE){ + return exp(cst_i*exponent*cst_pi,contextptr); + } + } + } + return new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(-1,exponent),_SEQ__VECT))); + } + + static gen pow_iterative(const gen & base,const gen & exponent,GIAC_CONTEXT){ + if (is_positive(-exponent,contextptr)) + return pow_iterative(inv(base,contextptr),-exponent,contextptr); + gen res=1,expo=exponent; + gen basepow=base; + while (!is_zero(expo)){ + gen q,r=irem(expo,2,q); + if (!is_zero(r)) + res = res*basepow; + expo=q; + if ( !is_zero(expo) ) + basepow=basepow*basepow; + } + return res; + } + + gen pow(const gen & base,const gen & exponent,GIAC_CONTEXT){ + // if (!( (++control_c_counter) & control_c_counter_mask)) +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) { + interrupted = true; ctrl_c=false; + return gensizeerr(gettext("Stopped by user interruption.")); + } + if (exponent.type==_INT_){ + if (exponent.val==1) return base; + if (exponent.val==2 && base.type<=_CPLX){ + if (base.type==_CPLX && base.subtype==3){ + double a=base._CPLXptr->_DOUBLE_val,b=(base._CPLXptr+1)->_DOUBLE_val; + return gen(a*a-b*b,2.0*a*b); + } + return operator_times(base,base,contextptr); + } + } + if (is_undef(base)) + return base; + if (is_undef(exponent)) + return exponent; + { + gen a,b; + if (is_algebraic_program(base,a,b)) + return symbolic(at_program,gen(makevecteur(a,0,pow(b,exponent,contextptr)),_SEQ__VECT)); + if (is_algebraic_program(exponent,a,b)) + return symbolic(at_program,gen(makevecteur(a,0,pow(base,b,contextptr)),_SEQ__VECT)); + } + if (base.type==_VECT && base.subtype!=_POLY1__VECT && !is_squarematrix(base)){ + *logptr(contextptr) << gettext("Warning, ^ is ambiguous on non square matrices. Use .^ to apply ^ element by element.") << '\n'; + if (exponent.type==_VECT) + return apply(base,exponent,contextptr,giac_pow); + if (base.subtype!=_LIST__VECT && (exponent.type==_INT_ && exponent.val %2==0) ) + return pow(dotvecteur(*base._VECTptr,*base._VECTptr,contextptr),exponent.val/2,contextptr); + return apply1st(base,exponent,contextptr,&giac_pow); + } + if (exponent.type==_VECT) + return apply2nd(base,exponent,contextptr,&giac_pow); + if (exponent.type==_FRAC){ + if (base.type<_POLY || base.type==_FLOAT_){ + if (exponent==plus_one_half) + return sqrt(base,contextptr); + if (exponent==minus_one_half) + return inv(sqrt(base,contextptr),contextptr); + } + if (exponent._FRACptr->num==1 && exponent._FRACptr->den==2 && base.type==_SYMB){ + vecteur v=lvar(base); + if (v.size()==1 && v.front().is_symb_of_sommet(at_pow) && v.front()._SYMBptr->feuille[1]==plus_one_half && is_integer(v.front()._SYMBptr->feuille[0])){ + gen a,b,c=v.front()._SYMBptr->feuille[0]; + if (is_linear_wrt(base,v.front(),b,a,contextptr) && (is_integer(a) ||a.type==_FRAC) && (is_integer(b) || b.type==_FRAC)){ + gen d=a*a-b*b*c; + if (is_positive(d,contextptr)){ + d=sqrt(d,contextptr); + if (is_integer(d) || d.type==_FRAC){ + return sqrt((a+d)/2,contextptr)+sign(b,contextptr)*sqrt((a-d)/2,contextptr); + } + } + } + } + } + return pow(base,new_ref_symbolic(symbolic(at_prod,makesequence(exponent._FRACptr->num,symb_inv(exponent._FRACptr->den)))),contextptr); + } + if (is_inf(base)){ + if (is_zero(exponent,contextptr)) + return undef; + if (exponent==plus_inf){ + if (base==plus_inf) + return base; + return unsigned_inf; + } + if (exponent==minus_inf) + return 0; + gen d; + bool b=has_evalf(exponent,d,1,contextptr); + if (b && is_strictly_positive(-exponent,contextptr) ) + return 0; + if (b && base==plus_inf &&is_strictly_positive(exponent,contextptr)) + return plus_inf; + if ( (exponent.type==_INT_) ){ + if (exponent.val % 2) + return base; + else + return plus_inf; // for unsigned_inf in _DOUBLE_ mode only!! + } + if (b && is_strictly_positive(exponent,contextptr)) + return unsigned_inf; + return undef; + } + if (base.type==_SYMB){ + unary_function_ptr & u =base._SYMBptr->sommet; + if (u==at_unit){ + vecteur & v=*base._SYMBptr->feuille._VECTptr; + gen v1=v[1]; + vecteur w; + if (v1.is_symb_of_sommet(at_prod)) + w=gen2vecteur(v1._SYMBptr->feuille); + else + w.push_back(v1); + for (unsigned i=0;ifeuille[0],v1._SYMBptr->feuille[1]*exponent,contextptr); + else + v1=pow(v1,exponent,contextptr); + } + if (w.size()==1) v1=w.front(); else v1=symbolic(at_prod,gen(w,_SEQ__VECT)); + return new_ref_symbolic(symbolic(at_unit,makenewvecteur(pow(v[0],exponent,contextptr),v1))); + } + if (u==at_abs && exponent.type==_INT_ && !complex_mode(contextptr) && !has_i(base)){ + int n=exponent.val,m; + if (n<0 && n%2) + m=n-1; + else + m=(n/2)*2; // or m=n%2?n-1:n; + gen basep=pow(base._SYMBptr->feuille,m); + if (n%2) + return base*basep; + else + return basep; + } + if (u==at_pnt && exponent.type==_INT_ && exponent.val%2==0){ + return pow(abs_norm2(remove_at_pnt(base),contextptr),exponent.val/2,contextptr); + } + if (u==at_sign && exponent.type==_INT_ && !complex_mode(contextptr) && !has_i(base)){ + int n=exponent.val; + if (n%2) + return base; + else + return 1; + } + if (u==at_exp){ + // (e^a)^b=e^(a*b) + // but we keep (e^a)^b if b is integer and e^(a*b) is not simplified + // for rational dependance + gen res=exp(base._SYMBptr->feuille*exponent,contextptr); + if (exponent.type!=_INT_ || !res.is_symb_of_sommet(at_exp)) + return res; + } + if (u==at_inv && base._SYMBptr->feuille.type==_SYMB && (base._SYMBptr->feuille._SYMBptr->sommet==at_exp ||base._SYMBptr->feuille._SYMBptr->sommet==at_pow)) + return inv(pow(base._SYMBptr->feuille,exponent,contextptr),contextptr); + if (u==at_pow && !has_i(base)){ + vecteur & v=*base._SYMBptr->feuille._VECTptr; + gen & v1=v[1]; + gen new_exp=v1*exponent; + if (new_exp.type>_IDNT) + new_exp=normal(new_exp,contextptr); + if ( v1.type==_INT_ && v1.val%2==0 + && (new_exp.type!=_INT_ || new_exp.val%2 ) + && !complex_mode(contextptr) ) + return pow(abs(v[0],contextptr),new_exp,contextptr); + else + return pow(v[0],new_exp,contextptr); + } + if (u==at_equal || u==at_equal2){ + vecteur & vb=*base._SYMBptr->feuille._VECTptr; + return new_ref_symbolic(symbolic(base._SYMBptr->sommet,makesequence(pow(vb.front(),exponent,contextptr),pow(vb.back(),exponent,contextptr)))); + } + if (exponent.type==_INT_){ + if (exponent.val==0) + return 1; + if (exponent.val==1) + return base; + return new_ref_symbolic(symbolic(at_pow,gen(makevecteur(base,exponent),_SEQ__VECT))); + } + } + if (abs_calc_mode(contextptr)==38 && !complex_mode(contextptr) && is_exactly_zero(base) && is_exactly_zero(exponent)) // was is_zero(,.contextptr) changed so that MINREAL^0 is not undef but 1 + return undef; + switch ( (base.type<< _DECALAGE) | exponent.type ) { + case _INT___INT_: case _ZINT__INT_: case _REAL__INT_: case _CPLX__INT_: case _IDNT__INT_: + return pow(base,exponent.val); + case _DOUBLE___DOUBLE_: + if (exponent._DOUBLE_val==int(std::floor(exponent._DOUBLE_val+.25))) + return pow(base,int(std::floor(exponent._DOUBLE_val+.25))); + if (base._DOUBLE_val>=0) +#ifdef _SOFTMATH_H + return std::giac_gnuwince_pow(base._DOUBLE_val,exponent._DOUBLE_val); +#else + return std::pow(base._DOUBLE_val,exponent._DOUBLE_val); +#endif + else + return exp(exponent*log(base,contextptr),contextptr); + case _FRAC__DOUBLE_: + return exp(exponent*log(base,contextptr),contextptr); + case _FLOAT___FLOAT_: + if (exponent._FLOAT_val==get_int(exponent._FLOAT_val)) + return pow(base,get_int(exponent._FLOAT_val)); + if (is_strictly_positive(-base,contextptr)) + return exp(exponent*ln(base,contextptr),contextptr); + return fpow(base._FLOAT_val,exponent._FLOAT_val); + case _INT___FLOAT_: + if (exponent._FLOAT_val==get_int(exponent._FLOAT_val)) + return pow(base,get_int(exponent._FLOAT_val)); + if (is_strictly_positive(-base,contextptr)) + return exp(exponent*ln(base,contextptr),contextptr); + return fpow(giac_float(base.val),exponent._FLOAT_val); + case _FLOAT___INT_: + return fpow(base._FLOAT_val,giac_float(exponent.val)); + case _DOUBLE___INT_: + if (base._DOUBLE_val>=0) +#ifdef _SOFTMATH_H + return std::giac_gnuwince_pow(base._DOUBLE_val,exponent.val); +#else + return std::pow(base._DOUBLE_val,exponent.val); +#endif + else + return (exponent.val%2?-1:1)*std::pow(-base._DOUBLE_val,exponent.val);//exp(exponent*log(-base,contextptr),contextptr); + case _INT___DOUBLE_: +#ifdef _SOFTMATH_H + return std::giac_gnuwince_pow(base.val,exponent._DOUBLE_val); +#else + return std::pow(double(base.val),exponent._DOUBLE_val); +#endif + case _ZINT__DOUBLE_: +#ifdef _SOFTMATH_H + return std::giac_gnuwince_pow(mpz_get_d(*base._ZINTptr),exponent._DOUBLE_val); +#else + return std::pow(mpz_get_d(*base._ZINTptr),exponent._DOUBLE_val); +#endif + case _DOUBLE___ZINT: + if (base._DOUBLE_val>=0) +#ifdef _SOFTMATH_H + return std::giac_gnuwince_pow(base._DOUBLE_val,mpz_get_d(*exponent._ZINTptr)); +#else + return std::pow(base._DOUBLE_val,mpz_get_d(*exponent._ZINTptr)); +#endif + else + return exp(exponent*log(base,contextptr),contextptr); + case _POLY__INT_: + if (exponent.val<0) + return fraction(1,pow(*base._POLYptr,-exponent.val)); + else + return pow(*base._POLYptr,exponent.val); + case _MAP__INT_: + if (exponent.val>=0) + return pow(base,exponent.val); + case _FRAC__INT_: + return pow(*base._FRACptr,exponent.val); + case _EXT__INT_: case _MOD__INT_: case _VECT__INT_: case _USER__INT_: + return pow(base,exponent.val); + case _MOD__ZINT: + return makemod(powmod(*base._MODptr,exponent,*(base._MODptr+1)),*(base._MODptr+1)); + default: + if (is_undef(base)) + return base; + if (is_undef(exponent)) + return exponent; + if (base.type==_STRNG || exponent.type==_STRNG) + return gensizeerr(contextptr); + if (is_one(base) && !is_inf(exponent)) + return base; + if (exponent.is_symb_of_sommet(at_prod) && exponent._SYMBptr->feuille.type==_VECT && exponent._SYMBptr->feuille._VECTptr->size()==2){ + gen e1=exponent._SYMBptr->feuille._VECTptr->front(); + gen e2=exponent._SYMBptr->feuille._VECTptr->back(); + if (e1.is_symb_of_sommet(at_ln) && e2.is_symb_of_sommet(at_inv) && e2._SYMBptr->feuille.is_symb_of_sommet(at_ln) && base==e2._SYMBptr->feuille._SYMBptr->feuille) + return e1._SYMBptr->feuille; + } + if (is_squarematrix(base)){ + if ((exponent.type==_REAL || exponent.type==_DOUBLE_ || exponent.type==_FLOAT_)) + return matpow(*base._VECTptr,exponent,contextptr); + if (exponent.type>=_IDNT) + *logptr(contextptr) << gettext("Use matpow to force computation of a power of matrix via jordanisation") << '\n'; + } + if (base.type==_REAL || base.type==_DOUBLE_ || + (base.type==_CPLX + // && base.subtype==3 + ) + || base.type==_FLOAT_ || ( (base.type<_POLY || base.type==_FLOAT_) && (exponent.type==_REAL || exponent.type==_DOUBLE_ || exponent.type==_FLOAT_))) + return exp(exponent*log(base,contextptr),contextptr); + /* + if (base.is_symb_of_sommet(at_neg)) + return minus1pow(exponent)*pow(base._SYMBptr->feuille,exponent); + */ + if ((base.type==_INT_) && (base.val<0)){ + if (exponent==plus_one_half) + return cst_i*sqrt(-base.val,contextptr); + // if (exponent==-one_half) + // return rdiv(cst_i,sqrt(-base.val)); + } + if (is_exactly_zero(base)){ + gen d; +#if 1 + // 0^k should return 0 if k is assumed to be positive + d=sign(exponent,contextptr); + if (is_one(d)) + return base; + if (is_minus_one(d)) + return unsigned_inf; +#else + bool b=has_evalf(exponent,d,1,contextptr); + if (b && is_positive(exponent,contextptr)) + return base; + if (b && is_positive(-exponent,contextptr)) + return unsigned_inf; +#endif + return undef; + } + if (base.type==_SPOL1) + return sppow(*base._SPOL1ptr,exponent,contextptr); + if (is_integer(base) && is_positive(-base,contextptr)){ +#if 0 + if (abs_calc_mode(contextptr)==38 && !complex_mode(contextptr)) + return gensizeerr(gettext("Negative to a fractional power")); +#endif + return minus1pow(exponent,contextptr)*pow(-base,exponent,contextptr); + } + if (is_inf(exponent)){ + if (base.type==_VECT) + return gensizeerr(contextptr); + return exp(exponent*ln(base,contextptr),contextptr); + } + // extract integral powers in a product exponent + if ((exponent.type==_SYMB) && (exponent._SYMBptr->sommet==at_prod)){ + gen subexponent_num(1),subexponent_deno(1); + gen superexponent(1); + const_iterateur it=exponent._SYMBptr->feuille._VECTptr->begin(),itend=exponent._SYMBptr->feuille._VECTptr->end(); + for (;it!=itend;++it){ + if (it->type==_INT_){ + superexponent = superexponent * (*it); + continue; + } + if ( (it->type==_SYMB) && (it->_SYMBptr->sommet==at_inv)) + subexponent_deno = subexponent_deno * (it->_SYMBptr->feuille); + else + subexponent_num = subexponent_num * (*it); + } + if (superexponent.type!=_INT_ + || (!lidnt(exponent).empty() && absint(superexponent.val)>MAX_COMMON_ALG_EXT_ORDER_SIZE) + ) + return new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(base,exponent),_SEQ__VECT))); + if (subexponent_deno.type!=_INT_ || (absint(subexponent_deno.val)>MAX_ALG_EXT_ORDER_SIZE && !lidnt(base).empty())){ + if (is_one(superexponent)) + return new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(base,_FRAC2_SYMB(subexponent_num,subexponent_deno)),_SEQ__VECT))); + return new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(base,_FRAC2_SYMB(subexponent_num,subexponent_deno)),_SEQ__VECT))),superexponent),_SEQ__VECT))); + } + int q=superexponent.val / subexponent_deno.val; + int r=superexponent.val % subexponent_deno.val; + gen res(1); + if (r){ + if (complex_mode(contextptr) && fastsign(base,contextptr)==-1){ // is_strictly_positive(-base,contextptr)){ + gen base1=-base; + res=exp((cst_i*cst_pi*subexponent_num)/subexponent_deno,contextptr); + res=new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(pow(base1,subexponent_num,contextptr),inv(subexponent_deno,contextptr)),_SEQ__VECT)))*res; + } + else + res=new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(pow(base,subexponent_num,contextptr),inv(subexponent_deno,contextptr)),_SEQ__VECT))); + if (r!=1) + res=new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(res,r),_SEQ__VECT))); + } + if (!q) + return res; + if (q==1){ + if (is_one(subexponent_num)) + return res*base; + return res*new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(base,subexponent_num),_SEQ__VECT))); + } + if (q==-1) + return res*inv(pow(base,subexponent_num,contextptr),contextptr); + return res*new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(pow(base,subexponent_num,contextptr),q),_SEQ__VECT))); + } + gen var1,var2,res1,res2; + if (is_algebraic_program(base,var1,res1) && is_algebraic_program(exponent,var2,res2)){ + if (var1!=var2 && is_constant_wrt(res2,var1,contextptr)){ + res2=subst(res2,var2,var1,false,contextptr); + var2=var1; + } + if (var1==var2) + return symbolic(at_program,gen(makevecteur(var1,0,pow(res1,res2,contextptr)),_SEQ__VECT)); + } + if (exponent.type==_ZINT){ + if (base.type==_USER) + return pow_iterative(base,exponent,contextptr); + return exp(exponent*log(base,contextptr),contextptr); + } + return new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(base,exponent),_SEQ__VECT))); + } + } + + gen sym_mult(const gen & a,const gen & b,GIAC_CONTEXT){ +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) { + interrupted = true; ctrl_c=false; + return gensizeerr(gettext("Stopped by user interruption.")); + } + if (is_undef(a)) + return a; + if (is_undef(b)) + return b; + if (is_inequality(a) && !is_equal(a)){ + int bs=fastsign(b,contextptr); + if (bs==-1) + return new_ref_symbolic(symbolic(a._SYMBptr->sommet,makesequence(a._SYMBptr->feuille._VECTptr->back()*b,a._SYMBptr->feuille._VECTptr->front()*b))); + if (bs==1) + return new_ref_symbolic(symbolic(a._SYMBptr->sommet,makesequence(a._SYMBptr->feuille._VECTptr->front()*b,a._SYMBptr->feuille._VECTptr->back()*b))); + } + if (is_inequality(b) && !is_equal(b)){ + int bs=fastsign(a,contextptr); + if (bs==-1) + return new_ref_symbolic(symbolic(b._SYMBptr->sommet,makesequence(a*b._SYMBptr->feuille._VECTptr->back(),a*b._SYMBptr->feuille._VECTptr->front()))); + if (bs==1) + return new_ref_symbolic(symbolic(b._SYMBptr->sommet,makesequence(a*b._SYMBptr->feuille._VECTptr->front(),a*b._SYMBptr->feuille._VECTptr->back()))); + } + if (a.is_symb_of_sommet(at_unit)){ + if (equalposcomp(lidnt(b),cst_pi)!=0) + return sym_mult(a,evalf(b,1,contextptr),contextptr); + vecteur & va=*a._SYMBptr->feuille._VECTptr; + if (b.is_symb_of_sommet(at_unit)){ + vecteur & v=*b._SYMBptr->feuille._VECTptr; + gen res=va[1]*v[1]; + res=ratnormal(res,contextptr); + if (is_one(res)) + return va[0]*v[0]; + return new_ref_symbolic(symbolic(at_unit,makenewvecteur(operator_times(va[0],v[0],contextptr),res))); + } + else { + if (lidnt(b).empty()) + return new_ref_symbolic(symbolic(at_unit,makenewvecteur(operator_times(va[0],b,contextptr),va[1]))); + } + } + if (b.is_symb_of_sommet(at_unit)){ + if (equalposcomp(lidnt(a),cst_pi)!=0) + return sym_mult(evalf(a,1,contextptr),b,contextptr); + if (lidnt(a).empty()){ + vecteur & v=*b._SYMBptr->feuille._VECTptr; + return new_ref_symbolic(symbolic(at_unit,makenewvecteur(operator_times(a,v[0],contextptr),v[1]))); + } + } + gen var1,var2,res1,res2; + if (is_algebraic_program(a,var1,res1)){ + if (is_algebraic_program(b,var2,res2)){ + if (var1!=var2 && is_constant_wrt(res2,var1,contextptr)){ + res2=subst(res2,var2,var1,false,contextptr); + var2=var1; + } + if (var1==var2) + return symbolic(at_program,gen(makevecteur(var1,0,operator_times(res1,res2,contextptr)),_SEQ__VECT)); + } + if (!is_constant_wrt(b,var1,contextptr)) + *logptr(contextptr) << "Warning function*constant with constant dependent of mute variable" << '\n'; + return symbolic(at_program,gen(makevecteur(var1,0,operator_times(res1,b,contextptr)),_SEQ__VECT)); + } + if (is_algebraic_program(b,var2,res2)){ + if (!is_constant_wrt(a,var2,contextptr)) + *logptr(contextptr) << "Warning constant*function with constant dependent of mute variable" << '\n'; + return symbolic(at_program,gen(makevecteur(var2,0,operator_times(a,res2,contextptr)),_SEQ__VECT)); + } + if (is_inf(a)){ + if (is_exactly_zero(normal(b,contextptr))) + return undef; + int s=fastsign(a,contextptr)*fastsign(b,contextptr); + if (s==1) + return plus_inf; + if (s) + return minus_inf; + return unsigned_inf; + } + if (is_inf(b)){ + if (is_exactly_zero(normal(a,contextptr))) + return undef; + int s=fastsign(a,contextptr)*fastsign(b,contextptr); + if (s==1) + return plus_inf; + if (s) + return minus_inf; + return unsigned_inf; + } + if (a.type==_INT_ && a.val==0 ) + return a; + if (a.type==_DOUBLE_ && a._DOUBLE_val==0 ) + return a; + if (a.type==_FLOAT_ && is_zero(a._FLOAT_val) ) + return a; + if (b.type==_INT_ && b.val==0) + return b; + if (b.type==_DOUBLE_ && b._DOUBLE_val==0 ) + return b; + if (b.type==_FLOAT_ && is_zero(b._FLOAT_val) ) + return b; + if ( a.is_approx()){ + gen b1; + if (has_evalf(b,b1,1,contextptr)&& (b.type!=b1.type || b!=b1)){ +#ifdef HAVE_LIBMPFR + if (a.type==_REAL){ + gen b2; +#if defined HAVE_LIBMPFI && !defined NO_RTTI + if (real_interval * ptr=dynamic_cast(a._REALptr)) + b2=convert_interval(b,mpfi_get_prec(ptr->infsup),contextptr); + else +#endif + b2=accurate_evalf(b,mpfr_get_prec(a._REALptr->inf)); + if (b2.is_approx()) + return (*a._REALptr)*b2; + } + if (a.type==_CPLX && a._CPLXptr->type==_REAL){ + gen b2; +#if defined HAVE_LIBMPFI && !defined NO_RTTI + if (real_interval * ptr=dynamic_cast(a._CPLXptr->_REALptr)) + b2=convert_interval(b,mpfi_get_prec(ptr->infsup),contextptr); + else +#endif + b2=accurate_evalf(b,mpfr_get_prec(a._CPLXptr->_REALptr->inf)); + if (b2.is_approx()) + return a*b2; + } +#endif + return a*b1; + } + } + if ( b.is_approx()){ + gen a1; + if (has_evalf(a,a1,1,contextptr) && (a.type!=a1.type || a!=a1)){ +#ifdef HAVE_LIBMPFR + if (b.type==_REAL){ + gen a2; +#if defined HAVE_LIBMPFI && !defined NO_RTTI + if (real_interval * ptr=dynamic_cast(b._REALptr)) + a2=convert_interval(a,mpfi_get_prec(ptr->infsup),contextptr); + else +#endif + a2=accurate_evalf(a,mpfr_get_prec(b._REALptr->inf)); + if (a2.is_approx()) + return a2*b; + } + if (b.type==_CPLX && b._CPLXptr->type==_REAL){ + gen a2; +#if defined HAVE_LIBMPFI && !defined NO_RTTI + if (real_interval * ptr=dynamic_cast(b._CPLXptr->_REALptr)) + a2=convert_interval(a,mpfi_get_prec(ptr->infsup),contextptr); + else +#endif + a2=accurate_evalf(a,mpfr_get_prec(b._CPLXptr->_REALptr->inf)); + if (a2.is_approx()) + return a2*b; + } +#endif + return a1*b; + } + } + if (is_one(a) && ((a.type!=_MOD) || (b.type==_MOD) )) + return b; + if (is_one(b) && ((b.type!=_MOD) || (a.type==_MOD) )) + return a; + if ((a.type==_SYMB) && equalposcomp(plot_sommets,a._SYMBptr->sommet)){ + gen tmp=remove_at_pnt(a); + if (tmp.type==_VECT && tmp.subtype==_VECTOR__VECT){ + if (b.type==_SYMB && equalposcomp(plot_sommets,b._SYMBptr->sommet)){ + gen tmpb=remove_at_pnt(b); + return dotvecteur(vector2vecteur(*tmp._VECTptr),vector2vecteur(*tmpb._VECTptr)); + } + return _vector(vector2vecteur(*tmp._VECTptr)*b,contextptr); + } + if ((b.type==_SYMB) && equalposcomp(plot_sommets,b._SYMBptr->sommet)){ + gen tmpb=complex2vecteur(remove_at_pnt(b),contextptr); + tmp=complex2vecteur(tmp,contextptr); + if (tmpb._VECTptr->size()==tmp._VECTptr->size()) + return dotvecteur(*tmp._VECTptr,*tmpb._VECTptr,contextptr); + return gensizeerr(gettext("Unable to multiply two graphic objects")); + } + return symbolic_plot_makevecteur(a._SYMBptr->sommet,a._SYMBptr->feuille*b,false,contextptr); + } + if ((b.type==_SYMB) && equalposcomp(plot_sommets,b._SYMBptr->sommet)){ + gen tmp=remove_at_pnt(b); + if (tmp.type==_VECT && tmp.subtype==_VECTOR__VECT) + return _vector(a*vector2vecteur(*tmp._VECTptr),contextptr); + gen b_(b); + if (b_.is_symb_of_sommet(at_curve) && b_._SYMBptr->feuille.type==_VECT && b_._SYMBptr->feuille._VECTptr->size()==2 && b_._SYMBptr->feuille._VECTptr->front().type==_VECT){ + // adjust param and cartesian eq + vecteur v=*b_._SYMBptr->feuille._VECTptr->front()._VECTptr; + if (v.size()==7) + v[6] =v[6]*a; + if (v.size()>=6){ + gen ax,ay; + reim(inv(a,contextptr),ax,ay,contextptr); + v[5]=subst(v[5],makevecteur(x__IDNT_e,y__IDNT_e),makevecteur(ax*x__IDNT_e-ay*y__IDNT_e,ax*y__IDNT_e+ay*x__IDNT_e),false,contextptr); + b_=symbolic(at_curve,gen(makevecteur(gen(v,b_._SYMBptr->feuille._VECTptr->front().subtype),b_._SYMBptr->feuille._VECTptr->back()),b_._SYMBptr->feuille.subtype)); + } + } + return symbolic_plot_makevecteur(b_._SYMBptr->sommet,b_._SYMBptr->feuille*a,false,contextptr); + } + if (a.is_symb_of_sommet(at_neg)){ + if (b.is_symb_of_sommet(at_neg)) + return operator_times(a._SYMBptr->feuille,b._SYMBptr->feuille,contextptr); + return -operator_times(a._SYMBptr->feuille,b,contextptr); + } + if (b.is_symb_of_sommet(at_neg)) + return -operator_times(a,b._SYMBptr->feuille,contextptr); + if (a.type==_POLY && b.is_symb_of_sommet(at_inv) && b._SYMBptr->feuille.type==_POLY){ + polynome & A=*a._POLYptr; + polynome & B=*b._SYMBptr->feuille._POLYptr; + polynome Q ,R; + if (A.TDivRem(B,Q,R) && R.coord.empty()) + return Q; + } + if (b.type==_POLY && a.is_symb_of_sommet(at_inv) && a._SYMBptr->feuille.type==_POLY){ + polynome & A=*b._POLYptr; + polynome & B=*a._SYMBptr->feuille._POLYptr; + polynome Q ,R; + if (A.TDivRem(B,Q,R) && R.coord.empty()) + return Q; + } + if (a.type==_FRAC){ + if (b.is_symb_of_sommet(at_inv) && is_cinteger(b._SYMBptr->feuille)) + return (*a._FRACptr)*fraction(1,b._SYMBptr->feuille); + if ( (b.type!=_SYMB) && (b.type!=_IDNT) ) { + if (b.type==_EXT) + return fraction(a._FRACptr->num*b,a._FRACptr->den).normal(); + return (*a._FRACptr)*b; + } + return sym_mult(_FRAC2_SYMB(a),b,contextptr); + } + if (b.type==_FRAC){ + if (a.is_symb_of_sommet(at_inv) && is_cinteger(a._SYMBptr->feuille)) + return fraction(1,a._SYMBptr->feuille)*(*b._FRACptr); + if ( (a.type!=_SYMB) && (a.type!=_IDNT) ){ + if (a.type==_EXT) + return fraction(a*b._FRACptr->num,b._FRACptr->den).normal(); + return a*(*b._FRACptr); + } + return sym_mult(a,_FRAC2_SYMB(b),contextptr); + } + if (is_cinteger(a) && b.is_symb_of_sommet(at_inv) && is_cinteger(b._SYMBptr->feuille)) + return a/b._SYMBptr->feuille; + if (is_cinteger(b) && a.is_symb_of_sommet(at_inv) && is_cinteger(a._SYMBptr->feuille)) + return b/a._SYMBptr->feuille; + if (a.type<=_CPLX && b.is_symb_of_sommet(at_inv)&& b._SYMBptr->feuille.type<=_CPLX) + return fraction(a,b._SYMBptr->feuille).normal(); + if (b.type<=_CPLX && a.is_symb_of_sommet(at_inv)&& a._SYMBptr->feuille.type<=_CPLX) + return fraction(b,a._SYMBptr->feuille).normal(); + if ((a.type<=_REAL || a.type==_FLOAT_) && is_strictly_positive(-a,contextptr)) + return -sym_mult(-a,b,contextptr); + if ((b.type<=_REAL || b.type==_FLOAT_) && is_strictly_positive(-b,contextptr)) + return -sym_mult(a,-b,contextptr); + if (a.type==_EXT){ + if (a.is_constant() && (b.type==_POLY)) + return a*(*b._POLYptr); + else + return algebraic_EXTension(b*(*a._EXTptr),*(a._EXTptr+1)); + } + if (b.type==_EXT){ + if (b.is_constant() && (a.type==_POLY)) + return (*a._POLYptr)*b; + else + return algebraic_EXTension(a*(*b._EXTptr),*(b._EXTptr+1)); + } + if ( (a.type==_INT_) && (a.val<0) && (a.val!=1<<31)){ + if (b.is_symb_of_sommet(at_inv) && (b._SYMBptr->feuille.type<_POLY || b._SYMBptr->feuille.is_symb_of_sommet(at_neg))) + return sym_mult(-a,inv(-b._SYMBptr->feuille,contextptr),contextptr); + else + return -sym_mult(-a,b,contextptr); + } + if ( (b.type==_INT_) && (b.val<0) && (b.val!=1<<31)){ + if (a.is_symb_of_sommet(at_inv)) + return sym_mult(-b,inv(-a._SYMBptr->feuille,contextptr),contextptr); + else + return -sym_mult(-b,a,contextptr); + } + if (is_equal(a)){ + vecteur & va=*a._SYMBptr->feuille._VECTptr; + if (is_equal(b)){ + vecteur & vb=*b._SYMBptr->feuille._VECTptr; + return new_ref_symbolic(symbolic(a._SYMBptr->sommet,gen(makenewvecteur(va.front()*vb.front(),va.back()*vb.back()),_SEQ__VECT))); + } + else + return new_ref_symbolic(symbolic(a._SYMBptr->sommet,gen(makenewvecteur(va.front()*b,va.back()*b),_SEQ__VECT))); + } + if (is_equal(b)){ + vecteur & vb=*b._SYMBptr->feuille._VECTptr; + return new_ref_symbolic(symbolic(b._SYMBptr->sommet,gen(makenewvecteur(a*vb.front(),a*vb.back()),_SEQ__VECT))); + } + if ((a.type==_SYMB)&& (b.type==_SYMB)){ + if ((a._SYMBptr->sommet==at_prod) && (b._SYMBptr->sommet==at_prod)) + return new_ref_symbolic(symbolic(at_prod,gen(mergevecteur(*(a._SYMBptr->feuille._VECTptr),*(b._SYMBptr->feuille._VECTptr)),_SEQ__VECT))); + else { + if (a._SYMBptr->sommet==at_prod) + return new_ref_symbolic(symbolic(*a._SYMBptr,b)); + else { + if (b._SYMBptr->sommet==at_prod) + return new_ref_symbolic(symbolic(a,b._SYMBptr->sommet,b._SYMBptr->feuille)); + else + return new_ref_symbolic(symbolic(at_prod,gen(makenewvecteur(a,b),_SEQ__VECT))); + } + } + } + if (b.type==_SYMB){ + if (b._SYMBptr->sommet==at_prod) + return new_ref_symbolic(symbolic(a,b._SYMBptr->sommet,b._SYMBptr->feuille)); + else + return new_ref_symbolic(symbolic(at_prod,gen(makenewvecteur(a,b),_SEQ__VECT))); + } + if (a.type==_SYMB){ + if (a._SYMBptr->sommet==at_prod) + return new_ref_symbolic(symbolic(*a._SYMBptr,b)); + else + return new_ref_symbolic(symbolic(at_prod,gen(b.type==_INT_?makenewvecteur(b,a):makenewvecteur(a,b),_SEQ__VECT))); + } + if ((a.type==_IDNT) || (b.type==_IDNT)) + return new_ref_symbolic(symbolic(at_prod,gen(makenewvecteur(a,b),_SEQ__VECT))); + if (a.type==_MOD) + return a*makemod(b,*(a._MODptr+1)); + if (b.type==_MOD) + return b*makemod(a,*(b._MODptr+1)); + return new_ref_symbolic(symbolic(at_prod,gen(makenewvecteur(a,b),_SEQ__VECT))); + // settypeerr(gettext("sym_mult")); + } + + static vecteur inv__VECT(const vecteur & v,GIAC_CONTEXT){ + vecteur w; + if (is_squarematrix(v)) + w=minv(v,contextptr); + else { + vecteur::const_iterator it=v.begin(),itend=v.end(); + for (;it!=itend;++it) + w.push_back(inv(*it,contextptr)); + } + return w; + } + + static vecteur invfirst(const vecteur & v){ + vecteur w(v); + if (!w.empty()) + w.front()=inv(w.front(),context0); + return w; + } + + static gen invdistrib(const gen & g,GIAC_CONTEXT){ + if (g.type!=_SYMB) + return inv(g,contextptr); + gen & f=g._SYMBptr->feuille; + if (g._SYMBptr->sommet==at_inv) + return f; + if (g._SYMBptr->sommet==at_pow) + return symbolic(at_pow,gen(makevecteur(f[0],-f[1]),_SEQ__VECT)); + if (g._SYMBptr->sommet==at_prod && f.type==_VECT){ + vecteur v = *f._VECTptr; + iterateur it=v.begin(),itend=v.end(); + for (;it!=itend;++it) + *it=invdistrib(*it,contextptr); + return symbolic(at_prod,gen(v,_SEQ__VECT)); + } + return inv(g,contextptr); + } + + gen inv_distrib(const gen & b,GIAC_CONTEXT){ + if (b.is_symb_of_sommet(at_prod)){ + gen f=b._SYMBptr->feuille; + return symbolic(at_prod,inv_distrib(f,contextptr)); + } + if (b.is_symb_of_sommet(at_pow)) + return pow(b._SYMBptr->feuille[0],-b._SYMBptr->feuille[1],contextptr); + if (b.is_symb_of_sommet(at_inv)) + return b._SYMBptr->feuille; + if (b.type==_VECT){ + vecteur v(*b._VECTptr); + for (unsigned i=0;iinv(); + case _DOUBLE_: + return 1/a._DOUBLE_val; + case _FLOAT_: + return finv(a._FLOAT_val); + case _CPLX: + if (is_exactly_zero(*a._CPLXptr)){ + if (is_one(abs(*(a._CPLXptr+1),contextptr))) + return -a; + } + if ( a._CPLXptr->type==_DOUBLE_ || a._CPLXptr->type==_FLOAT_ ||a._CPLXptr->type==_REAL || (a._CPLXptr+1)->type==_DOUBLE_ || (a._CPLXptr+1)->type==_FLOAT_ || (a._CPLXptr+1)->type==_REAL ){ + gen a2=no_context_evalf(a.squarenorm(contextptr)); + if (is_inf(a2)){ + gen theta=arg(a,contextptr); + theta=cos(theta,contextptr)-cst_i*sin(theta,contextptr); + a2=re(a*theta,contextptr); + return inv(a2,contextptr)*theta; + } + return gen(rdiv(no_context_evalf(a.re(contextptr)),a2,contextptr),rdiv(no_context_evalf(-a.im(contextptr)),a2,contextptr)); + } + return fraction(1,a); + case _IDNT: + if (a==undef) + return undef; + if (a==unsigned_inf) + return 0; + return new_ref_symbolic(symbolic(at_inv,a)); + case _SYMB: + if ((a==plus_inf) || (a==minus_inf)) + return 0; + { + vecteur v=alg_lvar(a); // change for limit(1/(1+sqrt(2)*cos(x))*sin(x-3*pi/4),x=3*pi/4); maybe we should only do evalf test and return undef + if (v.size()==1 && v.front().type==_VECT && v.front()._VECTptr->empty() && is_zero(evalf(a,1,contextptr)) && is_exactly_zero(recursive_normal(a,contextptr))) + return unsigned_inf; + } + if (a.is_symb_of_sommet(at_unit)){ + if (equalposcomp(lidnt(a),cst_pi)!=0) + return inv(evalf(a,1,contextptr),contextptr); + return new_ref_symbolic(symbolic(at_unit,makenewvecteur(inv(a._SYMBptr->feuille._VECTptr->front(),contextptr),inv_distrib(a._SYMBptr->feuille._VECTptr->back(),contextptr)))); + } + if (equalposcomp(plot_sommets,a._SYMBptr->sommet)) + return symbolic_plot_makevecteur( a._SYMBptr->sommet,inv(a._SYMBptr->feuille,contextptr),false,contextptr); + if (a._SYMBptr->sommet==at_inv) + return a._SYMBptr->feuille; + if (a._SYMBptr->sommet==at_NTHROOT && a._SYMBptr->feuille.type==_VECT && a._SYMBptr->feuille._VECTptr->size()==2){ + return symbolic(at_NTHROOT,makesequence(-a._SYMBptr->feuille._VECTptr->front(),a._SYMBptr->feuille._VECTptr->back())); + } + if (a._SYMBptr->sommet==at_neg) + return -inv(a._SYMBptr->feuille,contextptr); + else { + if (a._SYMBptr->sommet==at_prod) + return new_ref_symbolic(symbolic(at_prod,gen(inv__VECT(*(a._SYMBptr->feuille._VECTptr),contextptr),a._SYMBptr->feuille.subtype))); + else + return new_ref_symbolic(symbolic(at_inv,a)); + } + case _VECT: + if (a.subtype==_PNT__VECT) + return gen(invfirst(*a._VECTptr),a.subtype); + if (a.subtype==_POLY1__VECT) + return fraction(gen(vecteur(1,plus_one),_POLY1__VECT),a); + if (a.subtype==_MATRIX__VECT && !is_squarematrix(a)) + return gensizeerr(gettext("Inv of non-square matrix")); + return gen(inv__VECT(*a._VECTptr,contextptr),a.subtype); + case _EXT: + return inv_EXT(a); + case _SPOL1: + return spdiv(gen2spol1(1),*a._SPOL1ptr,contextptr); + case _USER: + return a._USERptr->inv(); + case _MOD: + return modinv(a); + case _FRAC: + if (a._FRACptr->num.type==_CPLX) + return fraction(a._FRACptr->den,a._FRACptr->num).normal(); + if (is_positive(a._FRACptr->num,contextptr)) + return fraction(a._FRACptr->den,a._FRACptr->num); + else + return fraction(-a._FRACptr->den,-a._FRACptr->num); + default: + if (is_undef(a)) + return a; + return new_ref_symbolic(symbolic(at_inv,a)); + // settypeerr(gettext("Inv")); + } + + } + + /* + gen inv(const gen & a,GIAC_CONTEXT){ + return inv(a,context0); + } + */ + + gen gen::inverse(GIAC_CONTEXT) const { return inv(*this,contextptr); } + + static void inpow(const gen & base,unsigned long int exponent,gen & res){ +#if 0 + res=1; + gen basepow=base; + while (exponent){ + if (exponent%2) + res = res*basepow; + if ( (exponent /=2) ) + basepow=basepow*basepow; + } +#else + if (exponent==1) + res=base; + else { + inpow(base,exponent/2,res); + res=res*res; + if (exponent %2) + res=res*base; + } +#endif + } + + gen pow(const gen & base, unsigned long int exponent){ + // if (!( (++control_c_counter) & control_c_counter_mask)) +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) { + interrupted = true; ctrl_c=false; + return gensizeerr(gettext("Stopped by user interruption.")); + } + ref_mpz_t * e; + gen res; + switch (base.type ) { + case _INT_: + if (base.val<0 && (exponent % 2)) + return(-pow(-base.val,exponent)); + else + return(pow(absint(base.val),exponent)); + case _DOUBLE_: +#ifdef _SOFTMATH_H + return std::giac_gnuwince_pow(base._DOUBLE_val,double(exponent)); +#else + return std::pow(base._DOUBLE_val,double(exponent)); +#endif + case _FLOAT_: + return fpow(base._FLOAT_val,giac_float(double(exponent))); + case _ZINT: + e=new ref_mpz_t; + mpz_pow_ui(e->z,*base._ZINTptr,exponent); + return e; + case _VECT: + if (base.subtype==_POLY1__VECT && base._VECTptr->size()<5){ + vecteur res; + if (miller_pow(*base._VECTptr,exponent,res)) + return gen(res,_POLY1__VECT); + } + /* no break, _VECT handled by next case */ + case _CPLX: case _REAL: case _EXT: case _MOD: case _USER: + // gauss integer power + if (!exponent){ + if (ckmatrix(base)) + return midn(int(base._VECTptr->size())); + if (base.type==_USER) + return base*inv(base,context0); + return 1; + } + inpow(base,exponent,res); + return(res); + case _IDNT: + if (is_undef(base)) + return base; + if (!exponent) + return 1; + if (exponent==1) + return base; + return new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(base,(longlong)exponent),_SEQ__VECT))); + case _SYMB: + if (!exponent) + return 1; + if (exponent==1) + return base; + if (base._SYMBptr->sommet==at_pow){ + res= (*((base._SYMBptr->feuille)._VECTptr))[1]; + return pow( (base._SYMBptr->feuille)._VECTptr->front(),gen((longlong) (exponent)) * res,context0) ; + } + if ((exponent % 2==0) && base._SYMBptr->sommet==at_abs) + return new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(base._SYMBptr->feuille,(longlong) exponent),_SEQ__VECT))); + return new_ref_symbolic(symbolic(at_pow,gen(makenewvecteur(base,(longlong) exponent),_SEQ__VECT))); + case _POLY: + return pow(*base._POLYptr,(int) exponent); + case _FRAC: + return pow(*base._FRACptr,(int) exponent); + case _MAP:{ + gen res; + inpow(base,exponent,res); + return res; + } + default: + if (is_undef(base)) + return base; + return gentypeerr(gettext("Pow")) ; + } + return 0; + } + + gen pow(const gen & base, int exponent){ + if (base==zero){ + if (exponent>0) + return base; + if (!exponent) + return undef; + if (exponent %2) + return unsigned_inf; + return plus_inf; + } + if (exponent<0){ + if (-exponent<0) + return gensizeerr("pow: int exponent underflow"); + return inv(pow(base,-exponent),context0); + } + if (is_one(base)) + return base; + if (is_minus_one(base)) + return exponent%2?base:base*base; + unsigned long int expo=exponent; + gen b; + if (base.type<=_ZINT && has_evalf(base,b,0,context0) && !is_inf(b) && + is_greater(abs(exponent*log(abs(b,context0),context0),context0),powlog2float,context0)){ + return gensizeerr("Exponent overflow"); + *logptr(context0) << "Exponent overflow" << '\n'; + if (is_strictly_greater(1,abs(b,context0),context0)) + return 0; + return (exponent%2==0 || is_greater(b,0,context0))?plus_inf:minus_inf; // overflow + // return pow(b,expo); + } + return(pow(base,expo)); + } + + gen pow(unsigned long int base, unsigned long int exponent){ + ref_mpz_t *e=new ref_mpz_t; +#if defined(EMCC) || defined(EMCC2) + mpz_set_si(e->z,base); + mpz_pow_ui(e->z,e->z,exponent); + return e; + if (base==int(base)){ // too slow! + mpz_set_si(e->z,1); + for (unsigned long int i=0;iz,e->z,int(base)); + } + return e; + } +#endif + mpz_ui_pow_ui(e->z,base,exponent); + return e; + } + + static void _ZINTdiv (const gen & a,const gen & b,ref_mpz_t * & quo){ + // at least one is not an int, uncoerce remaining int + ref_mpz_t *aptr,*bptr; + if (a.type!=_INT_) +#ifdef SMARTPTR64 + aptr= (ref_mpz_t *) (* ((ulonglong * ) &a) >> 16); +#else + aptr=a.__ZINTptr; +#endif + else { + aptr=new ref_mpz_t; + mpz_set_si(aptr->z,a.val); + } + if (b.type!=_INT_) +#ifdef SMARTPTR64 + bptr= (ref_mpz_t *) (* ((ulonglong * ) &b) >> 16); +#else + bptr=b.__ZINTptr; +#endif + else { + bptr=new ref_mpz_t; + mpz_set_si(bptr->z,b.val); + } + quo=new ref_mpz_t; + mpz_tdiv_q(quo->z,aptr->z,bptr->z); + if (a.type==_INT_){ + delete aptr; + } + if (b.type==_INT_){ + delete bptr; + } + } + + // a and b must be integers or Gaussian integers + static gen iquobest(const gen & a,const gen & b){ + if (is_strictly_positive(-a,0)) + return -iquobest(-a,b); + return iquo(a+iquo(b,2),b); + } + + // a and b must be integers or Gaussian integers + static gen iquocmplx(const gen & a,const gen & b){ + gen b2=b.squarenorm(0); + gen ab=a*b.conj(0); + gen res(iquobest(re(ab,context0),b2),iquobest(im(ab,context0),b2)); // ok + return res; + } + + static polynome iquopoly(const polynome & a,const gen & b){ + polynome res(a); + vector< monomial >::iterator it=res.coord.begin(),itend=res.coord.end(); + for (;it!=itend;++it) + it->value=iquo(it->value,b); + return res; + } + + // integer quotient, use rdiv for symbolic division + gen iquo(const gen & a,const gen & b){ + if ((b.type==_INT_)){ + switch (b.val){ + case 1: + return a; + case -1: + return -a; + case 0: + return gensizeerr(gettext("Division by 0")); + } + } + if (a.type==_POLY) // may be called by resulant interpolation + return iquopoly(*a._POLYptr,b); + ref_mpz_t * quo; + switch ( (a.type<< _DECALAGE) | b.type ) { + case _INT___INT_: + return(a.val/b.val); + case _ZINT__ZINT: case _INT___ZINT: case _ZINT__INT_: + _ZINTdiv(a,b,quo); + return quo; + case _CPLX__INT_: case _CPLX__ZINT: + return gen(iquo(*a._CPLXptr,b),iquo(*(a._CPLXptr+1),b)); + case _INT___CPLX: case _ZINT__CPLX: + return iquocmplx(a,b); + case _CPLX__CPLX: + return adjust_complex_display(iquocmplx(a,b),a,b); + case _EXT__INT_: case _EXT__ZINT: + return rdiv(a,b); + default: + return gentypeerr(gettext("iquo")); + } + return 0; + } + + // a and b must be integer or Gaussian integers + static gen rdivsimp(const gen & a,const gen & b){ + if (is_positive(-b,context0)) // ok + return rdivsimp(-a,-b); + gen c(gcd(a,b,context0)); + if (c.type==_CPLX) + c=gcd(c.re(context0),c.im(context0),context0); // ok + return fraction(iquo(a,c),iquo(b,c)); + } + + static gen divpoly(const polynome & p, const gen & e){ + if (p.coord.empty()) + return zero; + gen coefft; int pt=coefftype(p,coefft); + if (pt==_MOD || pt==_USER){ + polynome res(p); + mulpoly(res,coefft/(e*coefft),res); + return res; + } + gen d=gcd(Tcontent(p),e,context0); + if (d.type==_EXT) + d=_gcd(*d._EXTptr,context0); + if (is_one(d)){ + if (e==cst_i || e==minus_one || e==-cst_i) + return p/e; + return fraction(p,e); + } + gen den(rdiv(e,d,context0)); + gen iden(inv(den,context0)); + if ( (iden.type!=_SYMB) && (iden.type!=_FRAC)) + return (p/d)*iden; + else + return fraction(p/d,den); + } + + static gen divpoly(const gen & e,const polynome & p){ + if (is_exactly_zero(e)) + return e; + if (Tis_constant(p)&& p.coord.front().value.type<_POLY) + return rdiv(e,p.coord.front().value,context0); + gen d=gcd(Tcontent(p),e,context0); + gen tmp=polynome(rdiv(e,d,context0),p.dim); + return fraction(tmp,p/d); + } + + static gen divpolypoly(const gen & a,const gen &b){ + polynome ap(*a._POLYptr),bp(*b._POLYptr); + polynome q(ap.dim),r(ap.dim); + if (divrem1(ap,bp,q,r) && r.coord.empty()) + return q; + return normal(fraction(a,b),context0); // ok + } + + bool is_exactly_zero_normal(const gen &b,GIAC_CONTEXT){ + if (b.type!=_SYMB) + return is_exactly_zero(b); + const unary_function_ptr & u=b._SYMBptr->sommet; + if (u==at_neg) return is_exactly_zero_normal(b._SYMBptr->feuille,contextptr); + if (u==at_prod){ + gen f=b._SYMBptr->feuille; + if (f.type==_VECT){ + vecteur &v=*f._VECTptr; + for (int i=0;itype==_DOUBLE_ || a._CPLXptr->type==_FLOAT_) || ((a._CPLXptr+1)->type==_DOUBLE_ || (a._CPLXptr+1)->type==_FLOAT_) ) + return rdiv(no_context_evalf(a),no_context_evalf(b),contextptr); + if (a._CPLXptr->type==_REAL){ + if ((a._CPLXptr+1)->type==_REAL) + return rdiv(*a._CPLXptr,b,contextptr)+cst_i*rdiv(*(a._CPLXptr+1),b,contextptr); +#ifdef HAVE_LIBMPFR + return rdiv(*a._CPLXptr,b,contextptr)+cst_i*rdiv(real_object(*(a._CPLXptr+1),mpfr_get_prec(a._CPLXptr->_REALptr->inf)),b,contextptr); +#else + return rdiv(*a._CPLXptr,b,contextptr)+cst_i*rdiv(real_object(*(a._CPLXptr+1)),b,contextptr); +#endif + } + if ((a._CPLXptr+1)->type==_REAL){ +#ifdef HAVE_LIBMPFR + return rdiv(real_object(*a._CPLXptr,mpfr_get_prec((a._CPLXptr+1)->_REALptr->inf)),b,contextptr)+cst_i*rdiv(*(a._CPLXptr+1),b,contextptr); +#else + return rdiv(real_object(*a._CPLXptr),b)+cst_i*rdiv(*(a._CPLXptr+1),b,contextptr); +#endif + } + if (is_exactly_zero(b)) + return unsigned_inf; + if (is_exactly_zero(a%b)) + return iquo(a,b); + else + return rdivsimp(a,b); + case _CPLX__CPLX: + if (a.subtype==3 || b.subtype==3) + return a*inv(b,contextptr); + return adjust_complex_display(rdiv(a*conj(b,contextptr),b.squarenorm(contextptr),contextptr),a,b); + case _DOUBLE___CPLX: case _FLOAT___CPLX: case _INT___CPLX: case _ZINT__CPLX: case _REAL__CPLX: + if (is_one(a)) + return inv(b,contextptr); + return rdiv(a*conj(b,contextptr),b.squarenorm(contextptr),contextptr); + case _DOUBLE___DOUBLE_: + return a._DOUBLE_val/b._DOUBLE_val; + case _DOUBLE___INT_: + return a._DOUBLE_val/b.val; + case _INT___DOUBLE_: + return a.val/b._DOUBLE_val; + case _FLOAT___FLOAT_: + return a._FLOAT_val/b._FLOAT_val; + case _FLOAT___INT_: + return a._FLOAT_val/giac_float(b.val); + case _INT___FLOAT_: + return giac_float(a.val)/b._FLOAT_val; +#ifdef BCD + case _FLOAT___ZINT: + return a._FLOAT_val/giac_float(b._ZINTptr); + case _ZINT__FLOAT_: + return giac_float(a._ZINTptr)/b._FLOAT_val; +#endif + case _FLOAT___DOUBLE_: + return a._FLOAT_val/giac_float(b._DOUBLE_val); + case _DOUBLE___FLOAT_: + return giac_float(a._DOUBLE_val)/b._FLOAT_val; + case _ZINT__DOUBLE_: + return mpz_get_d(*a._ZINTptr)/b._DOUBLE_val; + case _CPLX__DOUBLE_: case _CPLX__REAL: + return gen(rdiv(*a._CPLXptr,b,contextptr),rdiv(*(a._CPLXptr+1),b,contextptr)); + case _DOUBLE___ZINT: + return a._DOUBLE_val/mpz_get_d(*b._ZINTptr); + // _CPLX__DOUBLE_, _DOUBLE___CPLX, _CPLX__CPLX, _ZINT__CPLX, _INT___CPLX + case _VECT__INT_: case _VECT__ZINT: case _VECT__DOUBLE_: case _VECT__FLOAT_: case _VECT__CPLX: case _VECT__FRAC: + case _VECT__SYMB: case _VECT__IDNT: case _VECT__POLY: case _VECT__EXT: + if (a.subtype==_VECTOR__VECT) + return a*inv(b,contextptr); + return gen(divvecteur(*a._VECTptr,b),a.subtype); + case _MAP__INT_: case _MAP__ZINT: case _MAP__DOUBLE_: case _MAP__FLOAT_: case _MAP__CPLX: + case _MAP__SYMB: case _MAP__IDNT: case _MAP__POLY: case _MAP__EXT: { + gen_map m; + gen g(m); + *g._MAPptr=*a._MAPptr; + sparse_div(*g._MAPptr,b); + return g; + } + case _VECT__VECT: + if (a.subtype==_POLY1__VECT || b.subtype==_POLY1__VECT) + return fraction(a,b).normal(); + if (is_squarematrix(b)){ + if (abs_calc_mode(contextptr)==38){ + *logptr(contextptr) << gettext("Warning: A/B with B a square matrix is a misleading notation interpreted as inv(B)*A") << '\n'; + return inv(b,contextptr)*a; + } + *logptr(contextptr) << gettext("Warning, pointwise division of a by b. For matrix division, please use inv(b)*a or a*inv(b)") << '\n'; + } + if (b._VECTptr->size()==1) + return rdiv(a,b._VECTptr->front(),contextptr); + return apply(a,b,contextptr,rdiv); + case _POLY__POLY: + return divpolypoly(a,b); + case _FRAC__FRAC: + if (a._FRACptr->num.type==_CPLX || a._FRACptr->den.type==_CPLX || + b._FRACptr->num.type==_CPLX || b._FRACptr->den.type==_CPLX){ + gen d=gcd(a._FRACptr->den,b._FRACptr->den,contextptr); + return (a._FRACptr->num*(b._FRACptr->den/d))/((a._FRACptr->den/d)*b._FRACptr->num); + } + return (*a._FRACptr)/(*b._FRACptr); + case _SPOL1__SPOL1: + return spdiv(*a._SPOL1ptr,*b._SPOL1ptr,contextptr); + case _POLY__DOUBLE_: case _POLY__FLOAT_: case _POLY__REAL: + return (*a._POLYptr)/b; + case _POLY__INT_: + if (b.val==1) return a; + case _POLY__ZINT: case _POLY__CPLX: + return divpoly(*a._POLYptr,b); + case _INT___POLY: case _ZINT__POLY: case _CPLX__POLY: + return divpoly(a,*b._POLYptr); + case _INT___FRAC: case _ZINT__FRAC: + if (is_positive(-b._FRACptr->num,contextptr)){ + // if (is_one(a)) return fraction(-b._FRACptr->den,-b._FRACptr->num); + return (-b._FRACptr->den*a)/(-b._FRACptr->num); + } + // if (is_one(a)) return fraction(b._FRACptr->den,b._FRACptr->num); + return (b._FRACptr->den*a)/b._FRACptr->num; + case _INT___VECT: case _ZINT__VECT: case _CPLX__VECT: case _DOUBLE___VECT: case _FLOAT___VECT: case _SYMB__VECT: + if (b.subtype==_LIST__VECT) + return apply2nd(a,b,contextptr,rdiv); + if (ckmatrix(b)) + return a*inv(b,contextptr); + if (calc_mode(contextptr)==1 && b.subtype!=_POLY1__VECT) + return apply2nd(a,b,contextptr,rdiv); + return fraction(a,b); + default: +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) { + interrupted = true; ctrl_c=false; + return gensizeerr(gettext("Stopped by user interruption.")); + } + if (is_undef(a)) + return a; + if (is_undef(b)) + return b; + if (a.type==_STRNG || b.type==_STRNG) + return gensizeerr("string /"); + { + gen var1,var2,res1,res2; + if (is_algebraic_program(a,var1,res1)){ + if (is_algebraic_program(b,var2,res2)){ + if (var1!=var2 && is_constant_wrt(res2,var1,contextptr)){ + res2=subst(res2,var2,var1,false,contextptr); + var2=var1; + } + if (var1==var2) + return symbolic(at_program,gen(makevecteur(var1,0,rdiv(res1,res2,contextptr)),_SEQ__VECT)); + } + if (!is_constant_wrt(b,var1,contextptr)) + *logptr(contextptr) << "Warning function/constant with constant dependent of mute variable" << '\n'; + return symbolic(at_program,gen(makevecteur(var1,0,rdiv(res1,b,contextptr)),_SEQ__VECT)); + } + if (is_algebraic_program(b,var2,res2)){ + if (!is_constant_wrt(a,var2,contextptr)) + *logptr(contextptr) << "Warning constant/function with constant dependent of mute variable" << '\n'; + return symbolic(at_program,gen(makevecteur(var2,0,rdiv(a,res2,contextptr)),_SEQ__VECT)); + } + } + if (a.type==_FLOAT_) + return rdiv(evalf_double(a,1,contextptr),b,contextptr); + if (b.type==_FLOAT_) + return rdiv(a,evalf_double(b,1,contextptr),contextptr); + if (a.is_symb_of_sommet(at_unit) || b.is_symb_of_sommet(at_unit)) + return operator_times(a,inv(b,contextptr),contextptr); + if (is_one(b)) + return chkmod(a,b); + if (is_minus_one(b)) + return chkmod(-a,b); + if (is_exactly_zero(a)){ + if (!is_exactly_zero_normal(b,contextptr)) + return a; + else + return undef; + } + if (is_exactly_zero(b)) + return unsigned_inf; + if (is_inf(a)){ + if (is_inf(b)) + return undef; + if (is_zero(b)) + return unsigned_inf; + return a*b; + } + if (is_inf(b)){ + if (is_inf(a)) + return undef; + else + return zero; + } + if (a==b && a.type!=_REAL && b.type!=_REAL) + return chkmod(plus_one,a); + if (a.is_approx()){ + gen b1; + if (has_evalf(b,b1,1,contextptr) && (b.type!=b1.type || b!=b1)){ +#ifdef HAVE_LIBMPFR + if (a.type==_REAL){ + gen b2=accurate_evalf(b,mpfr_get_prec(a._REALptr->inf)); + if (b2.is_approx()) + return rdiv(a,b2,contextptr); + } + if (a.type==_CPLX && a._CPLXptr->type==_REAL){ + gen b2=accurate_evalf(b,mpfr_get_prec(a._CPLXptr->_REALptr->inf)); + if (b2.is_approx()) + return rdiv(a,b2,contextptr); + } +#endif + return rdiv(a,b1,contextptr); + } + } + if (b.is_approx()){ + gen a1; + if (has_evalf(a,a1,1,contextptr) && (a.type!=a1.type || a!=a1)){ +#ifdef HAVE_LIBMPFR + if (b.type==_REAL){ + gen a2=accurate_evalf(a,mpfr_get_prec(b._REALptr->inf)); + if (a2.is_approx()) + return rdiv(a2,b,contextptr); + } + if (b.type==_CPLX && b._CPLXptr->type==_REAL){ + gen a2=accurate_evalf(a,mpfr_get_prec(b._CPLXptr->_REALptr->inf)); + if (a2.is_approx()) + return rdiv(a2,b,contextptr); + } +#endif + return rdiv(a1,b,contextptr); + } + } + if (a.type==_REAL) + return (*a._REALptr)*inv(b,contextptr); + if (b.type==_REAL) + return a*b._REALptr->inv(); + if (a.type==_SPOL1) + return spdiv(*a._SPOL1ptr,gen2spol1(b),contextptr); + if (b.type==_SPOL1) + return spdiv(gen2spol1(a),*b._SPOL1ptr,contextptr); + if (a.type==_USER && b.type!=_USER) + return (*a._USERptr)/b; + if (a.type==_USER || b.type==_USER) + return a*inv(b,contextptr); + if (a.type==_FRAC){ + if ( (b.type!=_SYMB) && (b.type!=_IDNT) ) + return (*a._FRACptr)/b; + return rdiv(_FRAC2_SYMB(a),b,contextptr); + } + if (b.type==_FRAC){ + if ( a.type!=_SYMB && a.type!=_IDNT && !(a.type==_VECT && a.subtype==_POLY1__VECT) ) // POLY1__VECT check added feb 2017 for poly hermite normal form + return a/(*b._FRACptr); + //return rdiv(a,_FRAC2_SYMB(b),contextptr); + // return symbolic(at_prod,makesequence(a,b._FRACptr->den,symbolic(at_inv,b._FRACptr->num))); + return (b._FRACptr->den*a)/b._FRACptr->num; + } + if (is_equal(a)){ + vecteur & va=*a._SYMBptr->feuille._VECTptr; + if (is_equal(b)){ + vecteur & vb=*b._SYMBptr->feuille._VECTptr; + return new_ref_symbolic(symbolic(a._SYMBptr->sommet,makesequence(rdiv(va.front(),vb.front(),contextptr),rdiv(va.back(),vb.back(),contextptr)))); + } + else + return new_ref_symbolic(symbolic(a._SYMBptr->sommet,makesequence(rdiv(va.front(),b,contextptr),rdiv(va.back(),b,contextptr)))); + } + if (is_equal(b)){ + vecteur & vb=*b._SYMBptr->feuille._VECTptr; + return new_ref_symbolic(symbolic(b._SYMBptr->sommet,makesequence(rdiv(a,vb.front(),contextptr),rdiv(a,vb.back(),contextptr)))); + } + /* commented since * is not always commutative + if (a.is_symb_of_sommet(at_prod) && a._SYMBptr->feuille.type==_VECT){ + int i=equalposcomp(*a._SYMBptr->feuille._VECTptr,b); + if (i){ + vecteur v(*a._SYMBptr->feuille._VECTptr); + v.erase(v.begin()+i-1); + if (v.size()==1) + return v.front(); + else + return new_ref_symbolic(symbolic(at_prod,v)); + } + } + */ + if (b.is_symb_of_sommet(at_neg)) + return -rdiv(a,b._SYMBptr->feuille,contextptr); + if ((b.type<=_REAL || b.type==_FLOAT_) && is_strictly_positive(-b,context0)) + return -rdiv(a,-b,contextptr); + if ( (a.type==_SYMB) || (a.type==_IDNT) || (a.type==_FUNC) || (b.type==_SYMB) || (b.type==_IDNT) || (b.type==_FUNC) ){ + if (is_one(a)) return symb_inv(b); + if (is_minus_one(a)) return -symb_inv(b); + if (a.is_symb_of_sommet(at_prod) && a._SYMBptr->feuille.type==_VECT){ + ref_vecteur * vptr = new_ref_vecteur(0); + vptr->v.reserve(a._SYMBptr->feuille._VECTptr->size()+1); + vptr->v=*a._SYMBptr->feuille._VECTptr; + vptr->v.push_back(symb_inv(b)); + return symbolic(at_prod,gen(vptr,_SEQ__VECT)); + } + return operator_times(a,symb_inv(b),contextptr); + } + if (a.type==_STRNG || b.type==_STRNG) + return gentypeerr(gettext("rdiv")); + return fraction(a,b).normal(); + } + } + + /* Tests */ + // 0 if unknown, 1 if >0, -1 if <0 + // no test for symbolics if context_ptr=0 + int fastsign(const gen & a,GIAC_CONTEXT){ + if (is_zero(a,contextptr) || is_undef(a)) + return 0; + if (is_inf(a)){ + if (a==plus_inf) + return 1; + if (a==minus_inf) + return -1; + return 0; + } + switch (a.type) { + case _INT_: + if (a.val>0) + return 1; + else + return -1; + case _ZINT: + return signint(mpz_cmp_si(*a._ZINTptr,0)); + case _FRAC: + return fastsign(a._FRACptr->num,contextptr)*fastsign(a._FRACptr->den,contextptr); + case _CPLX: + return 0; + case _DOUBLE_: + if (a._DOUBLE_val>0) + return 1; + else + return -1; + case _FLOAT_: + return fsign(a._FLOAT_val); + case _REAL: + if (a._REALptr->maybe_zero()) + return 0; + return a._REALptr->is_positive(); // this is the sign + case _SYMB: + if (a._SYMBptr->sommet==at_neg) + return -fastsign(a._SYMBptr->feuille,contextptr); + if (a._SYMBptr->sommet==at_inv) + return fastsign(a._SYMBptr->feuille,contextptr); + if (a._SYMBptr->sommet==at_abs || (a._SYMBptr->sommet==at_exp && is_real(a._SYMBptr->feuille,contextptr))) + return 1; + } + if (a.type==_SYMB){ + bool aplus=a.is_symb_of_sommet(at_plus); + if (aplus || a.is_symb_of_sommet(at_prod)){ + gen f=a._SYMBptr->feuille; + if (f.type==_VECT){ + vecteur & v=*f._VECTptr; + int i=0,fs=v.size(),curs=0; + for (;ifeuille; + if (f.type==_VECT && f._VECTptr->size()==2){ + gen & ex = f._VECTptr->back(); + if (ex.type==_INT_){ + if (ex.val%2==0) + return 1; + return fastsign(f._VECTptr->front(),contextptr); + } + if (ex.type==_FRAC && ex._FRACptr->den.type==_INT_ && ex._FRACptr->den.val % 2 ==0 ) + return 1; + } + } + } + if (is_inf(a)){ + if (a==plus_inf) + return 1; + if (a==minus_inf) + return -1; + return 0; + } + if (a.type==_IDNT){ + vecteur v; + if (find_range(a,v,contextptr) && v.size()==1 && v.front().type==_VECT && v.front()._VECTptr->size()==2){ + if (is_positive(v.front()._VECTptr->front(),contextptr)) + return 1; + if (is_positive(-v.front()._VECTptr->back(),contextptr)) + return -1; + } + } + gen approx; + if (has_evalf(a,approx,1,contextptr) && (a.type!=approx.type ||a!=approx)) + return fastsign(approx,contextptr); + // FIXME GIAC_CONTEXT?? + /* + if (contextptr){ + gen test=superieur_strict(a,0,contextptr); + if (test.type==_INT_){ + if (test.val) + return test.val; + test=inferieur_strict(a,0,contextptr); + if (test.type==_INT_) + return -test.val; + } + } + */ + return 0; + } + + bool is_greater(const gen & a,const gen &b,GIAC_CONTEXT){ + gen test=superieur_egal(a,b,contextptr); + if ((test.type==_INT_) && (test.val==1)) + return true; + else + return false; + } + + bool is_strictly_greater(const gen & a,const gen &b,GIAC_CONTEXT){ + gen test=superieur_strict(a,b,contextptr); + if ((test.type==_INT_) && (test.val==1)) + return true; + else + return false; + } + + bool is_positive(const gen & a,GIAC_CONTEXT){ + switch (a.type){ + case _INT_: + return a.val>=0; + case _CPLX: + return is_zero(*(a._CPLXptr+1)) && is_positive(*a._CPLXptr,contextptr); + case _REAL: + return (a._REALptr->is_positive()>0) || a._REALptr->is_zero(); + case _ZINT: + if (mpz_sgn(*a._ZINTptr)==-1) + return false; + else + return true; + case _POLY: + return is_positive(a._POLYptr->coord.front()); + case _FRAC: + return (is_positive(a._FRACptr->num,contextptr) && is_positive(a._FRACptr->den,contextptr)) || (is_positive(-a._FRACptr->num,contextptr) && is_positive(-a._FRACptr->den,contextptr)); + case _EXT: + return false; + case _SYMB: + if (a==plus_inf) + return true; + if (a==minus_inf) + return false; + if (a._SYMBptr->sommet==at_exp) + return true; + if (a._SYMBptr->sommet==at_ln) + return is_positive(a._SYMBptr->feuille-1,contextptr); + if (a._SYMBptr->sommet==at_program) + return true; + return is_greater(a,0,contextptr); + case _FUNC: + return true; + default: + return is_greater(a,0,contextptr); + } + } + + bool is_strictly_positive(const gen & a,GIAC_CONTEXT){ + if (a.type==_REAL){ + if (a._REALptr->maybe_zero()) + return false; + } else { + if (is_exactly_zero(a)) + return false; + } + return is_positive(a,contextptr); + } + + bool ck_is_greater(const gen & a,const gen &b,GIAC_CONTEXT){ + if (a==b) + return true; + gen test=superieur_strict(a,b,contextptr); + if (test.type!=_INT_) + cksignerr(test); + if (test.val==1) + return true; + else + return false; + } + + bool ck_is_strictly_greater(const gen & a,const gen &b,GIAC_CONTEXT){ + gen test=superieur_strict(a,b,contextptr); + if (test.type!=_INT_) + cksignerr(test); + if (test.val==1) + return true; + else + return false; + } + + bool ck_is_positive(const gen & a,GIAC_CONTEXT){ + switch (a.type){ + case _INT_: + return a.val>=0; + case _ZINT: + if (mpz_sgn(*a._ZINTptr)==-1) + return false; + else + return true; + case _SYMB: + if (a==plus_inf) + return true; + if (a==minus_inf) + return false; + if (a._SYMBptr->sommet==at_exp) + return true; + if (a._SYMBptr->sommet==at_ln) + return ck_is_positive(a._SYMBptr->feuille-1,contextptr); + return ck_is_greater(a,0,contextptr); + default: + return ck_is_greater(a,0,contextptr); + } + } + + bool ck_is_strictly_positive(const gen & a,GIAC_CONTEXT){ + if (is_zero(a,contextptr)) + return false; + return ck_is_positive(a,contextptr); + } + + gen min(const gen & a, const gen & b,GIAC_CONTEXT){ + if (a.type==_DOUBLE_ && b.type==_DOUBLE_) + return a._DOUBLE_valfeuille; + if (f.type==_VECT && f._VECTptr->size()==2){ + return symbolic(ae?at_superieur_strict:at_superieur_egal,makesequence(f._VECTptr->back(),f._VECTptr->front())); + } + } + if (a.is_symb_of_sommet(at_and)){ + gen f=_not(a._SYMBptr->feuille,context0); + return symbolic(at_ou,f); + } + if (a.is_symb_of_sommet(at_ou)){ + gen f=_not(a._SYMBptr->feuille,context0); + return symbolic(at_and,f); + } + return symb_not(a); + } + } + + struct islesscomplexthanf_compare { + islesscomplexthanf_compare() {} + bool operator ()(const gen & a,const gen &b){ return islesscomplexthanf(a,b); } + }; + + void islesscomplexthanf_sort(iterateur it,iterateur itend){ + islesscomplexthanf_compare m; + sort(it,itend,m); + } + + struct f_compare { + bool (*f)(const gen &a,const gen &b); + f_compare():f(islesscomplexthanf){} + f_compare(bool (*f_)(const gen &a,const gen &b)):f(f_){} + inline bool operator () (const gen & a,const gen &b){ return f(a,b); } + }; + + void gen_sort_f(iterateur it,iterateur itend,bool (*f)(const gen &a,const gen &b)){ + f_compare m(f); + sort(it,itend,m); + } + + + // equality of vecteurs representing geometrical lines + static bool geo_equal(const vecteur &v,const vecteur & w,int subtype,GIAC_CONTEXT){ + int vs=int(v.size()),ws=int(w.size()); + if (vs!=ws) + return false; + if (v==w) + return true; + if ( (subtype==_LINE__VECT) && (vs==2)){ + if (v[1]==v[0]) + return v==w; + // v[1]!=v[0] + if (!is_zero(im(rdiv(w[0]-v[0],v[1]-v[0],contextptr),contextptr),contextptr)) + return false; + if (!is_zero(im(rdiv(w[1]-v[0],v[1]-v[0],contextptr),contextptr),contextptr)) + return false; + return true; + } + if (subtype==_SET__VECT){ + vecteur w1(w),v1(v); +#if 1 + islesscomplexthanf_sort(w1.begin(),w1.end()); + islesscomplexthanf_sort(v1.begin(),v1.end()); +#else + sort(w1.begin(),w1.end(),islesscomplexthanf); + sort(v1.begin(),v1.end(),islesscomplexthanf); +#endif + return w1==v1; + } + return false; + } + + bool operator_equal(const gen & a,const gen & b,GIAC_CONTEXT){ + switch ( (a.type<< _DECALAGE) | b.type ) { + case _INT___INT_: + return (a.val==b.val); + case _INT___MOD: case _ZINT__MOD: + return a==*b._MODptr; + case _MOD__INT_: case _MOD__ZINT: + return b==*a._MODptr; + case _INT___ZINT: + return (mpz_cmp_si(*b._ZINTptr,a.val)==0); + case _INT___DOUBLE_: + return double(a.val)==b._DOUBLE_val; + case _DOUBLE___INT_: + return a._DOUBLE_val==double(b.val); + case _REAL__INT_: case _INT___REAL: case _REAL__ZINT: case _ZINT__REAL: case _REAL__FRAC: case _FRAC__REAL: case _DOUBLE___FRAC: case _FRAC__DOUBLE_: case _FRAC__FLOAT_: case _FLOAT___FRAC: + return is_exactly_zero(a-b); + case _INT___FLOAT_: + return giac_float(a.val)==b._FLOAT_val; + case _FLOAT___INT_: + return a._FLOAT_val==giac_float(b.val); + case _ZINT__INT_: + return (mpz_cmp_si(*a._ZINTptr,b.val)==0); + case _ZINT__ZINT: + return (mpz_cmp(*a._ZINTptr,*b._ZINTptr)==0); + case _INT___CPLX: case _ZINT__CPLX: + return ( operator_equal(a,re(b,contextptr),contextptr) && is_zero(im(b,contextptr),contextptr)); + case _CPLX__ZINT: case _CPLX__INT_: + return ( operator_equal(re(a,contextptr),b,contextptr) && is_zero(im(a,contextptr),contextptr)) ; + case _CPLX__CPLX: + return( operator_equal(*a._CPLXptr,*b._CPLXptr,contextptr) && operator_equal(*(a._CPLXptr+1),*(b._CPLXptr+1),contextptr) ); + case _DOUBLE___DOUBLE_: + if (a._DOUBLE_val==b._DOUBLE_val) + return true; + if (my_isnan(a._DOUBLE_val) && my_isnan(b._DOUBLE_val)) + return true; // avoid infinite loop in evalf + return absdouble(a._DOUBLE_val-b._DOUBLE_val)name==b._IDNTptr->name || *a._IDNTptr->name==*b._IDNTptr->name); + return a._IDNTptr->id_name==b._IDNTptr->id_name || strcmp(a._IDNTptr->id_name,b._IDNTptr->id_name)==0; + case _SYMB__SYMB: + if (a._SYMBptr==b._SYMBptr) + return true; + if (a._SYMBptr->sommet!=b._SYMBptr->sommet) + return false; + return (a._SYMBptr->feuille==b._SYMBptr->feuille); + case _VECT__VECT: + if (a._VECTptr==b._VECTptr) + return true; + if (a.subtype!=b.subtype){ + if ( (a.subtype==_MATRIX__VECT && b.subtype==0) || + (b.subtype==_MATRIX__VECT && a.subtype==0) ) + ; // don't consider them different + else + return false; + } + if (a.subtype) + return geo_equal(*a._VECTptr,*b._VECTptr,a.subtype,contextptr); + return *a._VECTptr==*b._VECTptr; + case _POLY__POLY: + if (a._POLYptr==b._POLYptr) + return true; + return (a._POLYptr->dim==b._POLYptr->dim) && (a._POLYptr->coord==b._POLYptr->coord); + case _FRAC__FRAC: + return (a._FRACptr->num==b._FRACptr->num) && (a._FRACptr->den==b._FRACptr->den); + case _STRNG__STRNG: + if (is_undef(a)) return false; + if (is_undef(b)) return false; + return (a._STRNGptr==b._STRNGptr) || (*a._STRNGptr==*b._STRNGptr); + case _FUNC__FUNC: + return (a._FUNCptr==b._FUNCptr) || (*a._FUNCptr==*b._FUNCptr); + case _MOD__MOD: + return ( (*a._MODptr==*b._MODptr) && (*(a._MODptr+1)==*(b._MODptr+1)) ); + case _EXT__EXT: + return ( change_subtype(*a._EXTptr,_POLY1__VECT)==change_subtype(*b._EXTptr,_POLY1__VECT) && (*(a._EXTptr+1)==*(b._EXTptr+1)) ); + case _SPOL1__SPOL1: + return *a._SPOL1ptr==*b._SPOL1ptr; + default: // Check pointers, type subtype + if ((a.type==b.type) && (a.subtype==b.subtype) && (a.val==b.val) && a._ZINTptr==b._ZINTptr) + return true; + if (a.type<=_REAL && b.type<=_REAL) + return is_zero(a-b,contextptr); + if ( (a.type==_FLOAT_ || a.type==_DOUBLE_ || a.type==_REAL) && (b.type<=_REAL || b.type==_FRAC || b.type==_FLOAT_)) + return is_zero(a-evalf(b,1,contextptr)); + if ( (b.type==_FLOAT_ || b.type==_DOUBLE_ || b.type==_REAL) && (a.type<=_REAL || a.type==_FRAC || a.type==_FLOAT_)) + return is_zero(evalf(a,1,contextptr)-b); + if (a.type==_USER) + return *a._USERptr==b; + if (b.type==_USER) + return *b._USERptr==a; + if (a.type==_INT_ && a.subtype==_INT_TYPE && b.type==_FUNC){ + if (a==_STRNG && b==at_string) return true; + if (a==_VECT && b==at_vector) return true; + if (a==_FLOAT_ && b==at_float) return true; + if (a==_DOUBLE_ && b==at_real) return true; + if (a==_CPLX && b==at_complex) return true; + if ( (a==_INT_||a==_ZINT) && b==at_int) return true; + } + if (b.type==_INT_ && b.subtype==_INT_TYPE && a.type==_FUNC) + return operator_equal(b,a,contextptr); + return false; + } + } + + bool identificateur::operator ==(const identificateur & i){ + return id_name==i.id_name || !strcmp(id_name,i.id_name); + } + + bool operator ==(const gen & a,const identificateur & i){ + return a.type==_IDNT && (a._IDNTptr->id_name==i.id_name || !strcmp(a._IDNTptr->id_name,i.id_name)); + } + + bool identificateur::operator ==(const gen & i){ + return i.type==_IDNT && (id_name==i._IDNTptr->id_name || !strcmp(id_name,i._IDNTptr->id_name)); + } + + bool operator ==(const gen & a,const gen & b){ + return operator_equal(a,b,context0); + } + + bool operator !=(const gen & a,const gen & b){ + return !(a==b); + } + + gen equal(const gen & a,const gen &b,GIAC_CONTEXT){ + if (a.type==_VECT && b.type==_VECT && !b._VECTptr->empty()){ + if (calc_mode(contextptr)==1 && a.subtype==_GGBVECT && b.subtype==_GGBVECT){ + return symbolic(at_equal,makesequence(a,b)); + } + else { + if (a._VECTptr->size()==b._VECTptr->size()) + return apply(a,b,contextptr,equal); + return apply2nd(a,b,contextptr,equal); + } + } + if (is_equal(a)) // so that equal(a=0 ,1) returns a=1, used for fsolve + return equal(a._SYMBptr->feuille[0],b,contextptr); + // only in ggb mode, because we want to be able to do subst(x[1],x=[1,2]) + if (calc_mode(contextptr)==1 && a.type==_IDNT && b.type==_VECT && b.subtype!=_SEQ__VECT && b.subtype!=_GGB__VECT){ + vecteur v=*b._VECTptr; + for (unsigned i=0;ifeuille[0],b,contextptr); + // only in ggb mode, because we want to be able to do subst(x[1],x=[1,2]) + if (calc_mode(contextptr)==1 && a.type==_IDNT && b.type==_VECT){ + vecteur v=*b._VECTptr; + for (unsigned i=0;ifeuille[1]; + if (f.type==_FRAC && f._FRACptr->den.type==_INT_ && f._FRACptr->den.val %2==0) + return 1; + } + } + if (a.is_symb_of_sommet(at_neg) && !is_inf(a)) + return -sign(a._SYMBptr->feuille,contextptr); + if (a.is_symb_of_sommet(at_inv)) + return sign(a._SYMBptr->feuille,contextptr); + if (a.is_symb_of_sommet(at_prod)){ + vecteur v=gen2vecteur(a._SYMBptr->feuille); + gen res=1; + for (int i=0;i1e-6) + *logptr(contextptr) << gettext("Warning, sign might return 0 incorrectly because the value of eps is too large ") << eps << '\n'; + switch (a.type){ + case _INT_: case _ZINT: + if (is_positive(a,contextptr)) + return 1; + else + return -1; + case _DOUBLE_: + if (a._DOUBLE_val>eps) + return 1.0; + if (a._DOUBLE_val<-eps) + return -1.0; + return 0.0; + case _FLOAT_: // NOTE: does not follow eps rule + if (a._FLOAT_val>0) + return giac_float(1.0); + if (a._FLOAT_val<0) + return giac_float(-1.0); + return giac_float(0.0); + case _REAL: + { + if (a._REALptr->is_zero()) + return 0; + if (a._REALptr->maybe_zero()) + return undef; + int res=a._REALptr->is_positive(); + if (res) + return res; + return undef; + } + return -1; + case _CPLX: + return a/abs(a,contextptr); + case _FRAC: + return sign(a._FRACptr->num,contextptr)*sign(a._FRACptr->den,contextptr); + } + int fs=fastsign(a,contextptr); + if (fs) + return fs; + gen b=evalf_double(a,1,contextptr); + if (b.type==_DOUBLE_){ + if (b._DOUBLE_val>eps) + return plus_one; + if (b._DOUBLE_val<-eps) + return minus_one; +#ifdef HAVE_LIBMPFR // FIXME try to avoid rounding errors + b=accurate_evalf(eval(a,1,contextptr),1000); + if (is_greater(b,1e-250,contextptr)) + return plus_one; + if (is_greater(-1e-250,b,contextptr)) + return minus_one; +#endif + // return zero; // returning 0 is wrong, sign(a) is much better! + } + if (b.type==_FLOAT_){ + if (b._FLOAT_val>eps) + return plus_one; + if (b._FLOAT_val<-eps) + return minus_one; + return zero; + } + if (is_zero(im(a,contextptr),contextptr)){ + int s=sturmsign(a,true,contextptr); + if (s && s!=-2) + return s; + } + return new_ref_symbolic(symbolic(at_sign,a)); + } + + static gen sym_is_greater(const gen & a,const gen & b,GIAC_CONTEXT){ + if (is_undef(a)) + return a; + if (is_undef(b)) + return b; + if (a==unsigned_inf || b==unsigned_inf || a.type==_VECT || b.type==_VECT) + return undef; + if (a==b) + return false; + if ( (b==plus_inf) || (a==minus_inf) ) + return false; + if ( (b==minus_inf) || (a==plus_inf) ) + return true; + if (is_equal(a) && is_equal(b) ){ + gen & af=a._SYMBptr->feuille; + gen & bf=b._SYMBptr->feuille; + if (af.type==_VECT && bf.type==_VECT && af._VECTptr->size()==2 && bf._VECTptr->size()==2 && af._VECTptr->front()==bf._VECTptr->front()) + return sym_is_greater(af._VECTptr->back(),bf._VECTptr->back(),contextptr); + } + if (a.type==_STRNG && b.type==_STRNG) + return *a._STRNGptr>=*b._STRNGptr; + if (a.type==_USER) + return (*a._USERptr>b); + if (b.type==_USER) + return (*b._USERptr<=a); + if (a.is_symb_of_sommet(at_superieur_strict) || a.is_symb_of_sommet(at_superieur_egal) || a.is_symb_of_sommet(at_inferieur_strict) || a.is_symb_of_sommet(at_inferieur_egal) ) + return false; + if (b.is_symb_of_sommet(at_superieur_strict) || b.is_symb_of_sommet(at_superieur_egal) || b.is_symb_of_sommet(at_inferieur_strict) || b.is_symb_of_sommet(at_inferieur_egal) ) + return false; + if (a.type==_CPLX || b.type==_CPLX) + return symb_superieur_strict(a,b); + gen approx; + if (has_evalf(a,approx,1,contextptr) && approx.type==_CPLX && !is_zero(im(approx,contextptr)/re(approx,contextptr),contextptr)) + return symb_superieur_strict(a,b); + if (has_evalf(a-b,approx,1,contextptr)){ + if (approx.type==_CPLX && is_zero(im(approx,contextptr)/re(approx,contextptr),contextptr)) + approx=re(approx,contextptr); + if (approx.type==_DOUBLE_ ){ +#ifdef HAVE_LIBMPFR + // FIXME?? try to avoid rounding error with more digits + if (fabs(approx._DOUBLE_val)<1e-5 && (a-b).type!=_FRAC){ + gen tmp=accurate_evalf(eval(a-b,1,contextptr),1100); // 1100 bits exceeds double precision, if a and b are equal up to double precision, this will be rounded to 0.0 + tmp=evalf_double(tmp,1,contextptr); + if (tmp.type==_DOUBLE_) + approx=tmp; + } +#endif + return (approx._DOUBLE_val>0); + } + if (approx.type==_REAL) + return is_strictly_positive(approx,contextptr); + if (approx.type==_FLOAT_ ) + return (approx._FLOAT_val>0); + } + gen g=sign(a-b,contextptr); + if (is_one(g)) + return plus_one; + if (is_minus_one(g)) + return false; + return symb_superieur_strict(a,b); + } + + gen superieur_strict(const gen & a,const gen & b,GIAC_CONTEXT){ + switch ( (a.type<< _DECALAGE) | b.type ) { + case _INT___INT_: + return (a.val>b.val); + case _INT___ZINT: + return (mpz_cmp_si(*b._ZINTptr,a.val)<0); + case _ZINT__INT_: + return (mpz_cmp_si(*a._ZINTptr,b.val)>0); + case _ZINT__ZINT: + return (mpz_cmp(*a._ZINTptr,*b._ZINTptr)>0); + case _DOUBLE___DOUBLE_: + return a._DOUBLE_val>b._DOUBLE_val; + case _FRAC__FRAC: + if (is_positive(a._FRACptr->den,contextptr) && is_positive(b._FRACptr->den,contextptr)) + return superieur_strict(a._FRACptr->num*b._FRACptr->den,a._FRACptr->den*b._FRACptr->num,contextptr); + break; + case _FRAC__INT_: case _FRAC_ZINT: + if (is_positive(a._FRACptr->den,contextptr)) + return superieur_strict(a._FRACptr->num,a._FRACptr->den*b,contextptr); + break; + case _INT___FRAC: case _ZINT__FRAC: + if (is_positive(b._FRACptr->den,contextptr)) + return superieur_strict(b._FRACptr->den*a,b._FRACptr->num,contextptr); + break; + case _DOUBLE___INT_: + return a._DOUBLE_val>b.val; + case _INT___DOUBLE_: + return a.val>b._DOUBLE_val; + case _FLOAT___FLOAT_: + return a._FLOAT_val>b._FLOAT_val; + case _FLOAT___INT_: + return a._FLOAT_val>b.val; + case _INT___FLOAT_: + return a.val>b._FLOAT_val; + case _DOUBLE___ZINT: + return a._DOUBLE_val>mpz_get_d(*b._ZINTptr); + case _ZINT__DOUBLE_: + return mpz_get_d(*a._ZINTptr)>b._DOUBLE_val; + } + if (a.type<=_REAL && b.type<=_REAL) + return is_strictly_positive(a-b,contextptr); + return sym_is_greater(a,b,contextptr); + } + + gen inferieur_strict(const gen & a,const gen & b,GIAC_CONTEXT){ + return superieur_strict(b,a,contextptr); + } + + gen superieur_egal(const gen & a,const gen & b,GIAC_CONTEXT){ + if ( (a.type==_REAL && b.type<=_REAL) || + (b.type==_REAL && a.type<=_REAL) ){ + if (is_positive(a-b,contextptr)) + return 1; + return 0; + } + gen g=!superieur_strict(b,a,contextptr); + if (is_undef(g)) return g; + if (g.type==_INT_) + return g; + return symb_superieur_egal(a,b); + } + + gen inferieur_egal(const gen & a,const gen & b,GIAC_CONTEXT){ + return superieur_egal(b,a,contextptr); + } + + bool has_inf_or_undef(const gen & g){ + if (g.type!=_VECT) + return is_inf(g) || is_undef(g); + const_iterateur it=g._VECTptr->begin(),itend=g._VECTptr->end(); + for (;it!=itend;++it){ + if (has_inf_or_undef(*it)) + return true; + } + return false; + } + + bool is_inf(const gen & e){ + switch (e.type){ + case _IDNT: + return !strcmp(e._IDNTptr->id_name,string_infinity); + case _SYMB: + return is_inf(e._SYMBptr->feuille); + case _DOUBLE_: + return my_isinf(e._DOUBLE_val); + case _FLOAT_: + return fis_inf(e._FLOAT_val); + default: + return false; + } + } + bool is_undef(const vecteur & v){ + return !v.empty() && is_undef(v.front()); + } + bool is_undef(const polynome & p){ + return !p.coord.empty() && is_undef(p.coord.front()); + } + // we are using exponent as undef marker because coeff=undef is used + // for Landau notation O(x^exponent) + bool is_undef(const sparse_poly1 & s){ + return !s.empty() && is_undef(s.front().exponent); + } + bool is_undef(const gen & e){ + switch (e.type){ + case _IDNT: + return !strcmp(e._IDNTptr->id_name,string_undef); + case _STRNG: + return e.subtype==-1; + case _VECT: + return !e._VECTptr->empty() && is_undef(e._VECTptr->front()); + case _POLY: + return !e._POLYptr->coord.empty() && is_undef(e._POLYptr->coord.front().value); + case _SPOL1: + return !e._SPOL1ptr->empty() && is_undef(e._SPOL1ptr->front().exponent); + case _FLOAT_: + return fis_nan(e._FLOAT_val); + case _DOUBLE_: + return my_isnan(e._DOUBLE_val); + case _CPLX: + return is_undef(*e._CPLXptr) || is_undef(*(e._CPLXptr+1)); + case _FRAC: + return is_undef(e._FRACptr->num); + default: + return false; + } + } + + bool is_zero__VECT(const vecteur & v,GIAC_CONTEXT){ + vecteur::const_iterator it=v.begin(),itend=v.end(); + for (;it!=itend;++it){ + if (!is_zero(*it,contextptr)) + return false; + } + return true; + } + + bool is_zero(const gen & a,GIAC_CONTEXT){ + switch (a.type ) { + case _INT_: + return !a.val; + case _ZINT: + return (!mpz_sgn(*a._ZINTptr)); + case _REAL: + return fabs(evalf_double(a,1,contextptr)._DOUBLE_val)<=epsilon(contextptr);// return a._REALptr->is_zero(); + case _CPLX: + return (is_zero(*a._CPLXptr,contextptr) && is_zero(*(a._CPLXptr+1),contextptr)); + case _DOUBLE_: + return (fabs(a._DOUBLE_val)<=epsilon(contextptr)); + case _FLOAT_: + return is_exactly_zero(a._FLOAT_val); + case _VECT: + return is_zero__VECT(*a._VECTptr,contextptr); + case _POLY: + return a._POLYptr->coord.empty(); + case _FRAC: + return is_zero(a._FRACptr->num,contextptr); + case _MOD: + return is_zero(*a._MODptr,contextptr); + case _USER: + return a._USERptr->is_zero(); + case _SYMB: + if (a._SYMBptr->sommet==at_unit) + return is_zero(a._SYMBptr->feuille[0]); + default: + return false; + } + } + + bool is_exactly_zero(const gen & a){ + switch (a.type ) { + case _INT_: + return !a.val; + case _ZINT: + return (!mpz_sgn(*a._ZINTptr)); + case _REAL: + return a._REALptr->is_zero(); + case _CPLX: + return (is_exactly_zero(*a._CPLXptr) && is_exactly_zero(*(a._CPLXptr+1))); + case _DOUBLE_: + return a._DOUBLE_val==0; + case _FLOAT_: + return fis_exactly_zero(a._FLOAT_val); + case _POLY: + return a._POLYptr->coord.empty(); + case _FRAC: + return is_exactly_zero(a._FRACptr->num); + case _MOD: + return is_exactly_zero(*a._MODptr); + case _USER: + return a._USERptr->is_zero(); + default: + return false; + } + } + + bool is_one(const gen & a){ + switch (a.type ) { + case _INT_: + return a.val==1; + case _ZINT: + return mpz_cmp_si(*a._ZINTptr,1)==0; + case _CPLX: + return is_one(*a._CPLXptr) && is_zero(*(a._CPLXptr+1)); + case _DOUBLE_: + return a._DOUBLE_val==1; + case _FLOAT_: + return a._FLOAT_val==giac_float(1); + case _REAL: + return is_exactly_zero(a-1); + case _VECT: + return a._VECTptr->size()==1 && is_one(a._VECTptr->front()); + case _POLY: + return Tis_constant(*a._POLYptr) && (is_one(a._POLYptr->coord.front().value)); + case _FRAC: + return a._FRACptr->num == a._FRACptr->den; + case _MOD: + return is_one(*a._MODptr); + case _USER: + return a._USERptr->is_one(); + default: + return false; + } + } + + bool is_minus_one(const gen & a){ + switch (a.type ) { + case _INT_: + return a.val==-1; + case _ZINT: + return mpz_cmp_si(*a._ZINTptr,-1)==0; + case _CPLX: + return (is_minus_one(*a._CPLXptr) && is_zero(*(a._CPLXptr+1),context0)); + case _DOUBLE_: + return a._DOUBLE_val==-1; + case _FLOAT_: + return a._FLOAT_val==giac_float(-1); + case _REAL: + return is_exactly_zero(a+1); + case _VECT: + return a._VECTptr->size()==1 && is_minus_one(a._VECTptr->front()); + case _POLY: + return Tis_constant(*a._POLYptr) && (is_minus_one(a._POLYptr->coord.front().value)); + case _FRAC: + return a._FRACptr->num == -a._FRACptr->den; + case _MOD: + if (*(a._MODptr+1)==plus_two) + return is_one(*a._MODptr); + else + return is_minus_one(*a._MODptr); + case _SYMB: + return a._SYMBptr->sommet==at_neg && is_one(a._SYMBptr->feuille); + case _USER: + return a._USERptr->is_minus_one(); + default: + return false; + } + } + + bool is_sq_minus_one(const gen & a){ + switch (a.type ) { + case _CPLX: case _MOD: case _USER: + return is_minus_one(a*a); + case _VECT: + return a._VECTptr->size()==1 && is_sq_minus_one(a._VECTptr->front()); + case _POLY: + return Tis_constant(*a._POLYptr) && (is_sq_minus_one(a._POLYptr->coord.front().value)); + default: + return false; + } + } + + gen gen::operator [] (int i) const{ + return operator_at(i,context0); + } + + gen gen::operator_at(int i,GIAC_CONTEXT) const{ + if (type==_SYMB){ + if (!i) + return _SYMBptr->sommet; + if (_SYMBptr->feuille.type!=_VECT){ + if (i==1) + return _SYMBptr->feuille; + else + return gendimerr(contextptr); + } + if (unsigned(i)>_SYMBptr->feuille._VECTptr->size()) + return gendimerr(contextptr); + return (*(_SYMBptr->feuille._VECTptr))[i-1]; + } + if (type==_MOD){ + if (!i) + return _MOD; + if (i==1) + return *_MODptr; + if (i==2) + return *(_MODptr+1); + return gendimerr(contextptr); + } + if (type==_IDNT) + return symb_at(makesequence(*this,i)); + if (type==_FUNC){ + if (*this==at_ln){ + i=i+array_start(contextptr); // (xcas_mode(contextptr)!=0); + return inv(ln(i,contextptr),contextptr)*(*this); + } + if (*this==at_maple_root){ + identificateur tmp(" x"); + gen g=symb_program(tmp,zero,new_ref_symbolic(symbolic(at_makesuite,i,tmp)),contextptr); + g=makesequence(at_maple_root,g); + return symb_compose(g); + } + } + if (this->type!=_VECT){ + if (calc_mode(contextptr)==1) + return *this; + return gentypeerr(gettext("Gen [int]")); + } + if (i<0) i+=_VECTptr->size(); + if (unsigned(i)>=_VECTptr->size()){ + if (array_start(contextptr))//(xcas_mode(contextptr)!=0 || abs_calc_mode(contextptr)==38) + ++i; + return gendimerr(gettext("Index outside range : ")+ print_INT_(i)+", vector size is "+print_INT_(int(_VECTptr->size())) +#ifndef GIAC_HAS_STO_38 + +", syntax compatibility mode "+print_program_syntax(xcas_mode(contextptr)) +#endif + +"\n"); + } + return (*(this->_VECTptr))[i]; + } + + gen gen::operator [] (const gen & i) const { + return operator_at(i,context0); + } + + gen gen::operator_at(const gen & i,GIAC_CONTEXT) const { + if (type==_STRNG && subtype==-1) return *this; + if (i.type==_DOUBLE_){ + double id=i._DOUBLE_val; + if (int(id)==id) + return (*this)[int(id)]; + } + if (i.type==_FLOAT_){ + giac_float id=i._FLOAT_val; + if (giac_float(get_int(id))==id) + return (*this)[get_int(id)]; + } + if (i.type==_REAL){ + double id=i.evalf_double(1,contextptr)._DOUBLE_val; + if (int(id)==id) + return (*this)[int(id)]; + } + if ((type==_STRNG) && (i.type==_INT_)){ + int s=int(_STRNGptr->size()),I=i.val; + if (I<0) I+=s; + if ( (I=0)) + return string2gen(string()+'"'+(*_STRNGptr)[I]+'"'); + } + if (type==_IDNT) + return new_ref_symbolic(symbolic(at_at,gen(makenewvecteur(*this,i),_SEQ__VECT))); + if (type==_USER) + return (*_USERptr)[i]; + if (type==_MAP){ + gen_map::const_iterator it=_MAPptr->find(i),itend=_MAPptr->end(); + if (it!=itend) + return it->second; + if (subtype==_SPARSE_MATRIX) + return 0; + } + if (type==_SPOL1){ + sparse_poly1::const_iterator it=_SPOL1ptr->begin(),itend=_SPOL1ptr->end(); + for (;it!=itend;++it){ + if (it->exponent==i) + return it->coeff; + } + return 0; + } + if (is_symb_of_sommet(at_at)){ // add i at the end of the index + if (_SYMBptr->feuille.type==_VECT && _SYMBptr->feuille._VECTptr->size()==2){ + gen operand=_SYMBptr->feuille._VECTptr->front(); + vecteur indice=makevecteur(_SYMBptr->feuille._VECTptr->back()); + indice.push_back(i); + return symb_at(makenewvecteur(operand,gen(indice,_SEQ__VECT))); + } + } + if (i.type==_DOUBLE_) + return (*this)[(int) i._DOUBLE_val]; + if (i.type==_FLOAT_) + return (*this)[ get_int(i._FLOAT_val) ]; + if (i.type==_SYMB){ + bool ideuxpoints=i._SYMBptr->sommet==at_deuxpoints; + if (i._SYMBptr->sommet==at_interval || ideuxpoints) { + gen i1=_ceil(i._SYMBptr->feuille._VECTptr->front(),contextptr); + gen iback=i._SYMBptr->feuille._VECTptr->back(); + int step=1; + if (ideuxpoints && iback.is_symb_of_sommet(at_deuxpoints)){ + gen istep=iback._SYMBptr->feuille; + iback=istep[0]; + istep=istep[1]+array_start(contextptr); + if (!is_integral(istep) || istep.type!=_INT_ || istep.val==0) + return gendimerr(contextptr); + step=istep.val; + if (step<0 && is_zero(i1)) + i1=minus_one; + if (0 && step<0 && is_zero(iback)){ // detected during translation + *logptr(contextptr) << gettext("Warning, using :0:-step, use :-1:-step for ::") << '\n'; + } + } + gen i2=_floor(iback,contextptr); + if (is_integral(i1) && is_integral(i2)){ + int debut=i1.val,fin=i2.val+(ideuxpoints?(step<0?1:-1):0); + int S=1; + if (type==_STRNG) S=int(_STRNGptr->size()); + if (type==_VECT) S=int(_VECTptr->size()); + if (debut>=S) + return (type==_STRNG)?string2gen("",false):gen(vecteur(0),subtype); + if (debut<0) debut+=S; + if (fin<0) fin+=S; + fin=giacmin(fin,S-1); + debut=giacmin(debut,S-1); + if (debut<0 || step*double(fin-debut)<0 ) + return (type==_STRNG)?string2gen("",false):gen(vecteur(0),subtype); // swap(debut,fin); + if (step==1){ + if (type==_STRNG) + return string2gen('"'+_STRNGptr->substr(debut,fin-debut+1)+'"'); + if (type==_VECT) + return gen(vecteur(_VECTptr->begin()+debut,_VECTptr->begin()+fin+1),subtype); + } + if (type==_STRNG){ + const string & s=*_STRNGptr; + string res; + if (step<0){ + for (;debut>=fin;debut+=step) + res += s[debut]; + } + else { + for (;debut<=fin;debut+=step) + res += s[debut]; + } + return string2gen(res,false); + } + if (type==_VECT){ + const vecteur & v=*_VECTptr; + vecteur res; + res.reserve(absint(fin-debut)/step+1); + if (step<0){ + for (;debut>=fin;debut+=step) + res.push_back(v[debut]); + } + else { + for (;debut<=fin;debut+=step) + res.push_back(v[debut]); + } + return gen(res,subtype); + } + } + } + } + if (i.type==_VECT){ + const_iterateur it=i._VECTptr->begin(),itend=i._VECTptr->end(); + gen res (*this); + for (;it!=itend;++it){ + if (it->type==_VECT){ + vecteur tmp; + const_iterateur jt=it->_VECTptr->begin(),jtend=it->_VECTptr->end(); + for (;jt!=jtend;++jt){ + tmp.push_back(res[*jt]); + } + return gen(tmp,it->subtype); + } + bool itdeuxpoints=it->type==_SYMB && it->_SYMBptr->sommet==at_deuxpoints; + if ( (it->type==_SYMB) && (it->_SYMBptr->sommet==at_interval || itdeuxpoints) && (it+1!=itend) ){ + // submatrix extraction + gen i1=it->_SYMBptr->feuille._VECTptr->front(),iback=it->_SYMBptr->feuille._VECTptr->back(); + int step=1; + if (itdeuxpoints && iback.is_symb_of_sommet(at_deuxpoints)){ + gen istep=iback._SYMBptr->feuille; + iback=istep[0]; + istep=istep[1]+array_start(contextptr); + if (!is_integral(istep) || istep.type!=_INT_ || istep==0) + return gendimerr(contextptr); + step=istep.val; + if (step<0 && is_zero(i1)) + i1=minus_one; + if (step<0 && is_zero(iback)){ + *logptr(contextptr) << gettext("Warning, using :0:-step, use :-1:-step for ::") << '\n'; + } + } + if (i1.type==_INT_ && iback.type==_INT_){ + int debut=i1.val,fin=iback.val+(itdeuxpoints?(step<0?1:-1):0); + if (res.type==_VECT){ + int S=int(res._VECTptr->size()); + if (debut<0) debut +=S; + if (fin<0) fin +=S; + fin=giacmin(fin,S-1); + debut=giacmin(debut,S-1); + if (debut<0 || step*double(fin-debut)<0 ) + return gendimerr(contextptr); + iterateur jt=res._VECTptr->begin()+debut,jtend=_VECTptr->begin()+fin; + gen fin_it(vecteur(it+1,itend),_SEQ__VECT); + vecteur v; + v.reserve(absint(jtend-jt)/step+1); + if (step<0){ + for (;jt>=jtend;jt+=step) + v.push_back((*jt)[fin_it]); + } + else { + for (;jt<=jtend;jt+=step) + v.push_back((*jt)[fin_it]); + } + if (res.subtype==_MATRIX__VECT && !ckmatrix(v)) + return v; + return gen(v,res.subtype); + } + } + } + res = res[*it]; + } + return res; + } + if (i.type!=_INT_) + return symb_at(makesequence(*this,i)); + return this->operator_at(i.val,contextptr); + } + + /* + gen & gen::operator [](int i){ + if (this->type!=_VECT) + return gentypeerr(gettext("Gen [int]")); + if (i>=_VECTptr->size()) + return gendimerr(contextptr); + return (*(this->_VECTptr))[i]; + } + + gen & gen::operator [] (const gen & i) { + if (i.type==_DOUBLE_) + return (*this)[(int) i._DOUBLE_val]; + if (i.type!=_INT_) + return gentypeerr(gettext("Gen [gen]")); + if (this->type!=_VECT) + return gentypeerr(gettext("Gen [gen]")); + if (i.val>=_VECTptr->size()) + return gendimerr(gettext("Gen [_VECT]")); + return (*(this->_VECTptr))[i.val]; + } + */ + + gen gen::operator () (const gen & i,const context * contextptr) const{ + return (*this)(i,undef,contextptr); + } + + gen gen::operator () (const gen & i,const gen & progname,const context * contextptr) const{ + bool isprog=type==_FUNC || this->is_symb_of_sommet(at_program) || this->is_symb_of_sommet(*at_program); + if (!isprog){ + if (i.is_symb_of_sommet(at_equal)) + return _subst(makesequence(*this,i),contextptr); + if (i.type==_VECT){ + vecteur & v = *i._VECTptr; + vecteur vin,vout; + for (unsigned j=0;jfeuille[0]); + vout.push_back(v[j]._SYMBptr->feuille[1]); + } + if (vin.size()==v.size()) + return subst(*this,vin,vout,false,contextptr); + } + } + if (type==_SYMB){ + // Functional case for sommet + if (_SYMBptr->sommet==at_program) { + gen tmp=_SYMBptr->feuille; + if (tmp.type!=_VECT) + return gensizeerr(contextptr); + vecteur tmpv=*tmp._VECTptr; tmpv[1]=i; + return _program(gen(tmpv,tmp.subtype),progname,contextptr); + } +#ifndef RTOS_THREADX + if (_SYMBptr->sommet==at_rpn_prog){ + vecteur pile; + if (rpn_mode(contextptr)) + pile=history_out(contextptr); + if ( (i.type!=_VECT) || (i.subtype!=_SEQ__VECT)) + pile.push_back(i); + else + pile=mergevecteur(pile,*i._VECTptr); + vecteur prog; + if (_SYMBptr->feuille.type==_VECT) + prog=*_SYMBptr->feuille._VECTptr; + else + prog=vecteur(1,_SYMBptr->feuille); + return gen(rpn_eval(prog,pile,contextptr),_RPN_STACK__VECT); + } +#endif + if (_SYMBptr->sommet==at_compose){ + gen tmp=_SYMBptr->feuille; + if (tmp.type!=_VECT) + return tmp(i,contextptr); + gen res=i; + const_iterateur it=tmp._VECTptr->begin(),itend=tmp._VECTptr->end(); + for (;itend!=it;){ + --itend; + res=(*itend)(res,contextptr); + } + return res; + } + if (_SYMBptr->sommet==at_composepow){ + gen tmp=_SYMBptr->feuille; + if (tmp.type!=_VECT || tmp._VECTptr->size()!=2 || tmp._VECTptr->back().type!=_INT_) + return symb_of(tmp,i); + gen res=i; + int n=tmp._VECTptr->back().val; + if (n<0){ + // try to invert the function + gen x(identificateur("xinvert")),y(identificateur("yinvert")); + gen f=tmp._VECTptr->front(); + gen s=_solve(makesequence(symb_equal(f(x,contextptr),y),x),contextptr); + if (s.type!=_VECT || s._VECTptr->size()<1 || is_undef(s._VECTptr->front())) + return gensizeerr("Unable to invert function"); + if (s._VECTptr->size()>1) + *logptr(contextptr) << "Choosing first solution in "<front(),contextptr); + n=-n; + tmp=makesequence(f,n); + } + if (!n) + return i; + int ratnormal_test=MAX_RECURSION_LEVEL/2; + // otherwise f(x):=-3x+2; g:=(f@@300)(x):; simplifier(g); might segfault + tmp=tmp._VECTptr->front(); + for (int j=0;jsommet==at_derive || _SYMBptr->sommet==at_function_diff || _SYMBptr->sommet==at_of || _SYMBptr->sommet==at_at) + return new_ref_symbolic(symbolic(at_of,makesequence(*this,i))); + gen & f=_SYMBptr->feuille; + // distributions laws: add arguments and reeval + if (is_distribution(_SYMBptr->sommet)){ + vecteur args(gen2vecteur(f)); + if (i.type==_VECT && i.subtype==_SEQ__VECT) + args=mergevecteur(args,*i._VECTptr); + else + args.push_back(i); + return _SYMBptr->sommet(gen(args,_SEQ__VECT),contextptr); + } + if (string(_SYMBptr->sommet.ptr()->s)=="pari"){ + vecteur argv(gen2vecteur(f)); + if (i.type==_VECT && i.subtype!=_SEQ__VECT) + argv=mergevecteur(argv,vecteur(1,i)); + else + argv=mergevecteur(argv,gen2vecteur(i)); + return _SYMBptr->sommet(gen(argv,_SEQ__VECT),contextptr); + } + if (f==makenewvecteur(zero)){ + return _SYMBptr->sommet(i,contextptr); + } + // other case, apply feuille to i then apply sommet + if (f.type!=_VECT) + return _SYMBptr->sommet(f(i,contextptr),contextptr); + vecteur lid(lidnt(*this)); + if (lid.size()==1 && !has_algebraic_program(*this)){ + if (lid.front()==vx_var) + // suspect something like P:=x^3+1 then P(2) + *logptr(contextptr) << "Warning, evaluating univariate expression of x(value) like if expression was a function.\nYou should write subst(" << *this << "," << lid.front() << "," << i << ")" << '\n'; + else + return gensizeerr("Expression used like a function "+this->print(contextptr)+"\nYou should write subst("+this->print(contextptr)+","+lid.front().print(contextptr)+","+i.print(contextptr)+")"); + return subst(*this,lid.front(),i,false,contextptr); + } + vecteur res(*f._VECTptr); + iterateur it=res.begin(),itend=res.end(); + bool warn=false; + for (;it!=itend;++it){ + if (it->type==_IDNT) + warn=true; + *it=(*it)(i,contextptr); + } + if (warn) + *logptr(contextptr) << gettext("Warning, evaluating (") << *this << ")(" << i << ") as a function not as a product" << '\n'; + return _SYMBptr->sommet(res,contextptr); + } + if (type==_FUNC){ + if ( (i.type==_VECT) && (i.subtype==_SEQ__VECT) && (i._VECTptr->size()==1)) + return (*_FUNCptr)(i._VECTptr->front(),contextptr); + else + return (*_FUNCptr)(i,contextptr); + } + if (i.type==_DOUBLE_ && giac_floor(i._DOUBLE_val)==i._DOUBLE_val ) + return (*this)((int) i._DOUBLE_val,contextptr); + if (i.type==_FLOAT_ && ffloor(i._FLOAT_val)==i._FLOAT_val ) + return (*this)(get_int(i._FLOAT_val),contextptr); + if (type==_INT_ && subtype==_INT_TYPE && i.type==_VECT){ + return gen(*i._VECTptr,type); + } + if (type<_IDNT ) + return *this; + if (type==_USER) + return (*_USERptr)(i,contextptr); + if (type==_STRNG){ + gen ii(i); + if (!is_integral(ii)) + return gensizeerr(gettext("Bad index")); + if (ii.val<1 || ii.val>int(_STRNGptr->size())) + return gendimerr(gettext("Index out of range")); + return string2gen(string(1,(*_STRNGptr)[ii.val-1]),false); + } + if (type==_VECT){ + if (of_pointer_38 && _VECTptr->size()==2 && _VECTptr->front().type==_POINTER_ && _VECTptr->front().subtype==_APPLET_POINTER && _VECTptr->back().type==_POINTER_ && _VECTptr->back().subtype==_VARFUNCDEF_POINTER ) + return of_pointer_38(_VECTptr->front()._POINTER_val,_VECTptr->back()._POINTER_val,i); + if (1 || + abs_calc_mode(contextptr)==38){ + if (i.type==_VECT){ + gen res=*this; + int is=int(i._VECTptr->size()); + for (int k=0;kfeuille; + if (ife.type==_VECT && ife._VECTptr->size()==2){ + const gen & if1=ife._VECTptr->front(); + const gen & if2=ife._VECTptr->back(); + if (if1.type==_INT_ && if2.type==_INT_ && if1.val>=1 && if2.val>=1 && if1.val<=if2.val && if1.val<=int(_VECTptr->size()) && if2.val<=int(_VECTptr->size())) + return gen(vecteur(_VECTptr->begin()+if1.val-1,_VECTptr->begin()+if2.val),subtype); + } + } + gen tmp=_floor(i,contextptr); + if (tmp.type!=_INT_) + return gendimerr(contextptr); + if (tmp.val<1 || tmp.val>int(_VECTptr->size()) ) + return gendimerr(contextptr); + return (*_VECTptr)[tmp.val-1]; + } + // Old code for _VECT type was just return (*this)[i]; + vecteur w(*_VECTptr); + iterateur it=w.begin(),itend=w.end(); + for (;it!=itend;++it) + *it=(*it)(i,contextptr); + return gen(w,subtype); + } + else { + if (has_inf_or_undef(i)) + return undef; + return symb_of(*this,i); + } + } + + static bool compare_VECT(const vecteur & v,const vecteur & w){ + int s1=int(v.size()),s2=int(w.size()); + if (s1!=s2) + return s1islesscomplexthan(*jt); + } + } + // setsizeerr(); should not happen... commented because it happens! + return false; + } + + // return true if *this is "strictly less complex" than other + bool gen::islesscomplexthan (const gen & other ) const { + // FIXME it is not the natural order, but used for pivot selection + if (type<_IDNT && is_zero(*this,context0)){ + // if (type==_INT_ && other.type==_INT_) return valid_name,other._IDNTptr->id_name)<0; + case _POLY: + if (_POLYptr->coord.size()!=other._POLYptr->coord.size()) + return _POLYptr->coord.size()coord.size(); + return _POLYptr->coord.front().value.islesscomplexthan(other._POLYptr->coord.front().value); + case _MOD: + if (*(_MODptr+1)!=*(other._MODptr+1)){ +#ifndef NO_STDEXCEPT + setsizeerr(gettext("islesscomplexthan mod")); +#endif + } + return _MODptr->islesscomplexthan(*other._MODptr); + case _SYMB: + if (_SYMBptr->sommet !=other._SYMBptr->sommet ){ +#ifdef GIAC_HAS_STO_38 // otherwise 1 test of chk_xavier fails, needs to check + int c=strcmp(_SYMBptr->sommet.ptr()->s,other._SYMBptr->sommet.ptr()->s); + if (c) return c<0; +#endif + return (alias_type) _SYMBptr->sommet.ptr() <(alias_type) other._SYMBptr->sommet.ptr(); + } + return _SYMBptr->feuille.islesscomplexthan(other._SYMBptr->feuille); + // return false; + case _VECT: + return compare_VECT(*_VECTptr,*other._VECTptr); + case _EXT: + if (*(_EXTptr+1)!=*(other._EXTptr+1)) + return (_EXTptr+1)->islesscomplexthan(*(other._EXTptr+1)); + return _EXTptr->islesscomplexthan(*(other._EXTptr)); + case _STRNG: + return *_STRNGptr<*other._STRNGptr; + default: + return this->print(context0)< other.print(context0); + } + } + + bool islesscomplexthanf(const gen & a,const gen & b){ + return a.islesscomplexthan(b); + } + + static gen monomial_degree(const gen & a){ + if (a.type<_IDNT) + return 0; + if (a.type==_IDNT){ + // detect constants of integration + if (strlen(a._IDNTptr->id_name)>=3 && a._IDNTptr->id_name[0]=='c' && a._IDNTptr->id_name[1]=='_') + return 0; + return 1; + } + if (a.type!=_SYMB) + return 0; + if (a._SYMBptr->sommet==at_neg) + return monomial_degree(a._SYMBptr->feuille); + if (a._SYMBptr->sommet==at_inv) + return -monomial_degree(a._SYMBptr->feuille); + if (a._SYMBptr->sommet==at_pow && a._SYMBptr->feuille.type==_VECT && a._SYMBptr->feuille._VECTptr->size()==2) + return (*a._SYMBptr->feuille._VECTptr)[1]; + if (a._SYMBptr->sommet==at_plus){ + gen af=a._SYMBptr->feuille; + if (af.type!=_VECT) + return monomial_degree(af); + gen res(0); + for (unsigned i=0;isize();++i){ + res = max(res,monomial_degree((*af._VECTptr)[i]),context0); + } + return res; + } + if (a._SYMBptr->sommet!=at_prod) + return 0; + gen af=a._SYMBptr->feuille; + if (af.type!=_VECT) + return monomial_degree(af); + gen res(0); + for (unsigned i=0;isize();++i){ + res += monomial_degree((*af._VECTptr)[i]); + } + return res; + } + + static bool is_monomial(const gen & a){ + if (a.type<=_IDNT) + return true; + if (a.type!=_SYMB) + return false; + if (a._SYMBptr->sommet==at_pow) + return true; + if (a._SYMBptr->sommet!=at_prod && a._SYMBptr->sommet!=at_plus && a._SYMBptr->sommet!=at_neg && a._SYMBptr->sommet!=at_inv) + return false; + gen af=a._SYMBptr->feuille; + if (af.type!=_VECT) + return is_monomial(af); + for (unsigned i=0;isize();++i){ + if (!is_monomial((*af._VECTptr)[i])) + return false; + } + return true; + } + + static bool islesscomplexthanf2(const gen & a,const gen & b,GIAC_CONTEXT){ + if (a==b) + return false; + if (a.type==_VECT && b.type==_VECT && a._VECTptr->size()==2 && b._VECTptr->size()==2){ + gen & a2=a._VECTptr->back(); + gen & b2=b._VECTptr->back(); + if (a2!=b2) + return islesscomplexthanf2(a2,b2,contextptr); + } + if (is_monomial(a) && is_monomial(b)){ + gen da=monomial_degree(a); + gen db=monomial_degree(b); + if (da!=db) + return increasing_power(contextptr)?is_greater(db,da,contextptr):is_greater(da,db,contextptr); + bool apow=a.is_symb_of_sommet(at_pow); + bool bpow=b.is_symb_of_sommet(at_pow); + if (apow && !bpow) + return true; + if (bpow && !apow) + return false; + } + if (a.type==b.type) + return a.islesscomplexthan(b); + if (a.type==_FRAC && b.type>=_POLY) + return false; + if (a.type>=_POLY && b.type==_FRAC) + return true; + return !a.islesscomplexthan(b); + } + + struct f_compare_context { + bool (*f)(const gen &a,const gen &b,GIAC_CONTEXT); + const context * ptr; + f_compare_context():f(islesscomplexthanf2),ptr(context0){} + f_compare_context(bool (*f_)(const gen &a,const gen &b,GIAC_CONTEXT),GIAC_CONTEXT):f(f_),ptr(contextptr){} + inline bool operator () (const gen & a,const gen &b){ return f(a,b,ptr); } + }; + + void gen_sort_f_context(iterateur it,iterateur itend,bool (*f)(const gen &a,const gen &b,GIAC_CONTEXT),GIAC_CONTEXT){ + f_compare_context m(f,contextptr); + sort(it,itend,m); + } + + int gen::symb_size () const { + if (type==_SYMB) + return _SYMBptr->size(); + else + return 1; + } + + bool symb_size_less(const gen & a,const gen & b){ + return a.symb_size() < b.symb_size(); + } + + bool gen::is_symb_of_sommet(const unary_function_ptr & u) const { + return type==_SYMB && _SYMBptr->sommet==u; + } + + bool gen::is_symb_of_sommet(const unary_function_ptr * u) const { + return type==_SYMB && _SYMBptr->sommet==u; + } + + gen operator && (const gen & a,const gen & b){ + if (is_zero(a,context0)){ + if (b.type==_DOUBLE_) + return 0.0; + if (b.type==_FLOAT_) + return giac_float(0); + return change_subtype(!is_zero(a),_INT_BOOLEAN); + } + if (is_zero(b,context0)){ + if (a.type==_DOUBLE_ ) + return 0.0; + if (a.type==_FLOAT_) + return giac_float(0); + return change_subtype(!is_zero(b),_INT_BOOLEAN); + } + if (a.type<=_CPLX || a.type==_FLOAT_ || a.type==_FRAC){ + if (b.type<=_CPLX || b.type==_FLOAT_ || b.type==_FRAC) + return change_subtype(!is_zero(b),_INT_BOOLEAN); + return b; + } + if (b.type<=_CPLX || b.type==_FLOAT_ || b.type==_FRAC){ + if (a.type<=_CPLX || a.type==_FLOAT_ || a.type==_FRAC) + return change_subtype(!is_zero(a),_INT_BOOLEAN); + return a; + } + if (a.is_symb_of_sommet(at_and)){ + if (b.is_symb_of_sommet(at_and)) + return new_ref_symbolic(symbolic(at_and,gen(mergevecteur(*a._SYMBptr->feuille._VECTptr,*b._SYMBptr->feuille._VECTptr),_SEQ__VECT))); + vecteur v=*a._SYMBptr->feuille._VECTptr; + v.push_back(b); + return new_ref_symbolic(symbolic(at_and,v)); + } + if (b.is_symb_of_sommet(at_and)){ + vecteur v=*b._SYMBptr->feuille._VECTptr; + v.push_back(a); + return new_ref_symbolic(symbolic(at_and,v)); + } + if ( ((a.type==_IDNT) || (a.type==_SYMB)) || ((b.type==_IDNT) || (b.type==_SYMB)) ) + return symb_and(a,b); + if ( (a.type==_DOUBLE_) || (b.type==_DOUBLE_) ) + return 1.0; + if ( (a.type==_FLOAT_) || (b.type==_FLOAT_) ) + return giac_float(1); + return change_subtype(plus_one,_INT_BOOLEAN); + } + + gen operator || (const gen & a,const gen & b){ + if (is_zero(a,context0)) + return change_subtype(!is_zero(b),_INT_BOOLEAN); + if (is_zero(b,context0)) + return change_subtype(!is_zero(a),_INT_BOOLEAN); + if (a.is_symb_of_sommet(at_ou)){ + if (b.is_symb_of_sommet(at_ou)) + return new_ref_symbolic(symbolic(at_ou,gen(mergevecteur(*a._SYMBptr->feuille._VECTptr,*b._SYMBptr->feuille._VECTptr),_SEQ__VECT))); + vecteur v=*a._SYMBptr->feuille._VECTptr; + v.push_back(b); + return new_ref_symbolic(symbolic(at_ou,v)); + } + if (b.is_symb_of_sommet(at_ou)){ + vecteur v=*b._SYMBptr->feuille._VECTptr; + v.push_back(a); + return new_ref_symbolic(symbolic(at_ou,v)); + } + if ( ((a.type==_IDNT) || (a.type==_SYMB)) || ((b.type==_IDNT) || (b.type==_SYMB)) ) + return symb_ou(a,b); + if ( (a.type==_DOUBLE_) || (b.type==_DOUBLE_) ) + return 1.0; + if ( (a.type==_FLOAT_) || (b.type==_FLOAT_) ) + return giac_float(1); + return change_subtype(plus_one,_INT_BOOLEAN); + } + + gen collect(const gen & g,GIAC_CONTEXT){ + if (g.type==_VECT) + return apply(g,collect,contextptr); + if (is_inf(g)) + return g; + return liste2symbolique(symbolique2liste(g,contextptr)); + } + + static bool modified_islesscomplexthanf(const gen& a,const gen& b){ + if (a.type!=b.type && (a.type<=_CPLX || b.type<=_CPLX)) + return a.typefeuille,b._SYMBptr->feuille); + return modified_islesscomplexthanf(a._SYMBptr->feuille,b); + } + if (b.is_symb_of_sommet(at_neg)) + return modified_islesscomplexthanf(a,b._SYMBptr->feuille); + if (a.is_symb_of_sommet(at_inv)){ + if (b.is_symb_of_sommet(at_inv)) + return modified_islesscomplexthanf(a._SYMBptr->feuille,b._SYMBptr->feuille); + if (a._SYMBptr->feuille.type<_IDNT) + return modified_islesscomplexthanf(a._SYMBptr->feuille,b); + return false; + } + if (b.is_symb_of_sommet(at_inv)){ + if (b._SYMBptr->feuille.type<_IDNT) + return modified_islesscomplexthanf(a,b._SYMBptr->feuille); + return true; + } + if (a.is_symb_of_sommet(at_pow)){ + if (b.is_symb_of_sommet(at_pow)) + return modified_islesscomplexthanf(a._SYMBptr->feuille[0],b._SYMBptr->feuille[0]); + return modified_islesscomplexthanf(a._SYMBptr->feuille[0],b); + } + if (b.is_symb_of_sommet(at_pow)) + return modified_islesscomplexthanf(a,b._SYMBptr->feuille[0]); + if (a.type!=b.type){ + if (a.type==_FRAC && b.type>=_POLY) + return true; + if (b.type==_FRAC && a.type>=_POLY) + return false; + } + return islesscomplexthanf(a,b); + } + + class modified_compare { + public: + modified_compare(){} + bool operator ()(const gen &a,const gen &b){ return modified_islesscomplexthanf(a,b);} + }; + + // return true if a is -basis^exp + static bool power_basis_exp(const gen& a,gen & basis,gen & expa){ + if (a.is_symb_of_sommet(at_neg)) + return !power_basis_exp(a._SYMBptr->feuille,basis,expa); + if (a.is_symb_of_sommet(at_inv)){ + gen & tmp=a._SYMBptr->feuille; + bool b=power_basis_exp(tmp,basis,expa); + expa=-expa; + return b; + } // de-commented 2/2/2013 so that regrouper(x^2/x) works + if (a.is_symb_of_sommet(at_pow)){ + gen & tmp=a._SYMBptr->feuille; + if (tmp.type!=_VECT || tmp._VECTptr->size()!=2){ +#ifndef NO_STDEXCEPT + setsizeerr(gettext("power_basis_exp")); +#endif + return false; + } + expa=tmp._VECTptr->back(); + basis=tmp._VECTptr->front(); + } + else { + basis=a; + expa=plus_one; + } + return false; + } + + static gen regroup_inv(const vecteur & vtmp){ + vecteur vtmp1,vtmp2; + gen tt(1); + for (unsigned i=0;ifeuille); + else + vtmp1.push_back(vtmp[i]); + } + if (!vtmp1.empty()){ + if (vtmp1.size()==1) + tt=vtmp1.front(); + else + tt=new_ref_symbolic(symbolic(at_prod,gen(vtmp1,_SORTED__VECT))); + } + if (!vtmp2.empty()){ + if (vtmp2.size()==1) + tt=tt/vtmp2.front(); + else + tt=tt/new_ref_symbolic(symbolic(at_prod,gen(vtmp2,_SORTED__VECT))); + } + return tt; + } + + // Helpers for symbolic addition + // from a product returns a list with the numeric coeff and the monomial + static vecteur terme2unitaire(const gen & x,bool sorted,GIAC_CONTEXT){ + if (x.type<_POLY) + return makevecteur(x,plus_one); + gen tmp; + if (x.type!=_SYMB || x._SYMBptr->sommet==at_program || x._SYMBptr->sommet==at_when) + return makevecteur(1,x); + if (x._SYMBptr->sommet==at_neg){ + vecteur v=terme2unitaire(x._SYMBptr->feuille,sorted,contextptr); + v[0]=-v[0]; + return v; + } + if (x._SYMBptr->sommet==at_binary_minus){ + vecteur v=terme2unitaire(x._SYMBptr->feuille,sorted,contextptr); + v[1]=-v[1]; + return v; + } + if (x._SYMBptr->sommet==at_prod && (tmp=x._SYMBptr->feuille).type==_VECT && !tmp._VECTptr->empty() ){ + vecteur & v = *tmp._VECTptr; + int s=int(v.size()); + if (s==2 && (sorted || tmp.subtype==_SORTED__VECT)) + return makevecteur(v[0],v[1]); + vecteur vtmp(v.begin(),v.end()); + for (unsigned i=0;ifeuille.is_symb_of_sommet(at_pow)){ + gen f= vtmp[i]._SYMBptr->feuille._SYMBptr->feuille; + if (f.type==_VECT && f._VECTptr->size()==2) + vtmp[i]=symbolic(at_pow,makesequence(f._VECTptr->front(),-f._VECTptr->back())); + } + } + if (equalposcomp(vtmp,undef)) + return makevecteur(1,undef); + if (equalposcomp(vtmp,0)){ + if (equalposcomp(vtmp,unsigned_inf)) + return makevecteur(1,undef); + return makevecteur(0,plus_one); + } +#if 1 // def NSPIRE + // COUT << "modified " << (int) modified_islesscomplexthanf << '\n'; wait_key_pressed() ; + modified_compare m; + sort(vtmp.begin(),vtmp.end(),m); + // COUT << "after modified " << '\n'; wait_key_pressed() ; +#else + sort(vtmp.begin(),vtmp.end(),modified_islesscomplexthanf); +#endif + // collect term with the same power + const_iterateur it=vtmp.begin(),itend=vtmp.end(); + vecteur vsorted; + vsorted.reserve(itend-it); + gen precbasis,precexpo,basis,expo,constcoeff(plus_one); + for (;it!=itend;++it){ + if (it->type<=_CPLX) + constcoeff=constcoeff*(*it); + else { + if (it->is_symb_of_sommet(at_inv) && it->_SYMBptr->feuille.type<=_CPLX) + constcoeff=constcoeff/it->_SYMBptr->feuille; + else + break; + } + } + if (!is_one(constcoeff)) + vsorted.push_back(constcoeff); + bool isneg(false),hasneg(false); + if (it!=itend){ + power_basis_exp(*it,precbasis,precexpo); + precexpo=zero; + for (;it!=itend;++it){ + if (power_basis_exp(*it,basis,expo)){ + isneg=!isneg; + hasneg=true; + } + if (!vsorted.empty() && basis==vsorted.back()){ + vsorted.pop_back(); + expo+=1; + } + if (basis==precbasis) + precexpo=precexpo+expo; + else { + if (!is_zero(precexpo,contextptr)){ + if (is_strictly_positive(-precexpo,contextptr)) + vsorted.push_back(inv(pow(precbasis,-precexpo,contextptr),contextptr)); + else + vsorted.push_back(pow(precbasis,precexpo,contextptr)); + } + // vsorted.push_back(pow(precbasis,precexpo,contextptr)); + precbasis=basis; + precexpo=expo; + } + } + if (!is_zero(precexpo,contextptr)){ + if (is_strictly_positive(-precexpo,contextptr)){ + gen tmp=pow(precbasis,-precexpo,contextptr); + if (tmp.is_symb_of_sommet(at_prod)) + tmp=symbolic(at_inv,tmp); + else + tmp=inv(tmp,contextptr); + vsorted.push_back(tmp); + } + else + vsorted.push_back(pow(precbasis,precexpo,contextptr)); + } + } + vecteur res; + if (hasneg){ + res=terme2unitaire(_prod(vsorted,contextptr),sorted,contextptr); + if (isneg) + res[0]=-res[0]; + return res; + } + if (vsorted.empty()) + vsorted.push_back(1); + if (vsorted.front().type<_POLY || vsorted.front().type==_FRAC){ + vtmp=vecteur(vsorted.begin()+1,vsorted.end()); + gen tt(1); + if (!vtmp.empty()){ + if (vtmp.size()==1) + tt=vtmp.front(); + else + tt=regroup_inv(vtmp); + } + res=makevecteur(vsorted.front(),tt); + } + else + res=makevecteur(plus_one,regroup_inv(vsorted)); + return res; + } + // recurse + if (x._SYMBptr->sommet==at_pow) + return makevecteur(plus_one,x._SYMBptr->sommet(collect(x._SYMBptr->feuille,contextptr),contextptr)); + tmp=collect(x._SYMBptr->feuille,contextptr); + if (x._SYMBptr->sommet==at_inv){ + if (is_zero(tmp)) + return makevecteur(1,unsigned_inf); + } + return makevecteur(plus_one,new_ref_symbolic(symbolic(x._SYMBptr->sommet,tmp))); + } + + // assumes v is a sorted list, shrink it + // should be written to a gen of type _VECT and subtype _SORTED__VECT + static vecteur fusionliste(const vecteur & v){ + const_iterateur it=v.begin(),itend=v.end(); + if (itend-it<2) + return v; + vecteur res; + gen current=(*it)[1]; + gen current_coeff=(*it)[0]; + ++it; + for (;it!=itend;++it){ + if ((*it)[1].type!=current.type || (current.type==_DOUBLE_ && current._DOUBLE_val!=(*it)[1]._DOUBLE_val) || (*it)[1]!=current ){ + res.push_back(makenewvecteur(current_coeff,current)); + current_coeff=(*it)[0]; + current=(*it)[1]; + } + else + current_coeff=current_coeff+(*it)[0]; + } + res.push_back(makenewvecteur(current_coeff,current)); + return res; + } + + struct tri_context { + const context * contextptr; + bool operator()(const gen & a,const gen &b){ return islesscomplexthanf2(a,b,contextptr); } + tri_context(const context * ptr):contextptr(ptr){}; + tri_context():contextptr(0){}; + }; + + // from a sum in x returns a list of [coeff monomial] + // e.g. 5+2x+3*x*y -> [ [5 1] [2 x] [ 3 x*y] ] + vecteur symbolique2liste(const gen & x,GIAC_CONTEXT){ + if (!x.is_symb_of_sommet(at_plus)) + return vecteur(1,terme2unitaire(x,false,contextptr)); + bool sorted=x._SYMBptr->feuille.subtype==_SORTED__VECT; + gen number; + vecteur varg=gen2vecteur(x._SYMBptr->feuille); + vecteur vres; + const_iterateur it=varg.begin(),itend=varg.end(); + for (;it!=itend;++it){ + if (it->type<_POLY || it->type==_FRAC) + number=number+(*it); + else + vres.push_back(terme2unitaire(*it,sorted,contextptr)); + } + if (!is_exactly_zero(number)) + vres.push_back(makenewvecteur(1,number)); + if (x._SYMBptr->feuille.subtype==_SORTED__VECT) + return vres; + sort(vres.begin(),vres.end(),tri_context(contextptr)); + return fusionliste(vres); + } + + /* + // assumes v1, v2 are sorted and shrinked, merge them -> sorted and shrinked + static vecteur fusion2liste(const vecteur & v1,const vecteur & v2){ + const_iterateur it=v1.begin(),itend=v1.end(),jt=v2.begin(),jtend=v2.end(); + vecteur res; + gen tmp; + for (;it!=itend;){ + if (jt==jtend){ + for (;it!=itend;++it) + res.push_back(*it); + return res; + } + // both iterator are valid + vecteur & vi=*it->_VECTptr; + vecteur & vj=*jt->_VECTptr; + if (vi[1]==vj[1]){ + tmp=vi[0]+vj[0]; + if (!is_exactly_zero(tmp)) + res.push_back(makenewvecteur(tmp,vi[1])); + ++it; + ++jt; + } + else { + if (vi[1].islesscomplexthan(vj[1])){ + res.push_back(*it); + ++it; + } + else { + res.push_back(*jt); + ++jt; + } + } // end tests + } // end for loop + // finish jt + for (;jt!=jtend;++jt) + res.push_back(*jt); + return res; + } + */ + + // v should be sorted and shrinked + gen liste2symbolique(const vecteur & v){ + vecteur res; + const_iterateur it=v.begin(),itend=v.end(); + res.reserve(itend-it); + for (;it!=itend;++it){ + vecteur & vtmp(*it->_VECTptr); + gen & tmp = vtmp.back(); + gen coeff=eval(vtmp.front(),1,context0); + if (is_exactly_zero(coeff)) + continue; + if (tmp.is_symb_of_sommet(at_prod) && tmp._SYMBptr->feuille.type==_VECT && tmp._SYMBptr->feuille._VECTptr->size()==1){ + res.push_back(coeff*tmp._SYMBptr->feuille._VECTptr->front()); + continue; + } + if (coeff.is_symb_of_sommet(at_neg)){ + res.push_back(-(coeff._SYMBptr->feuille*tmp)); + continue; + } + if ( (coeff.type==_FRAC || is_integer(coeff)) && is_positive(-coeff,context0)) + res.push_back(-((-coeff)*tmp)); + else + res.push_back(coeff*tmp); + } + int s=int(res.size()); + if (!s) + return zero; + if (s==1) + return res.front(); + return new_ref_symbolic(symbolic(at_plus,gen(res,_SORTED__VECT))); + } + + /* Euclidean-like Arithmetic */ + static void swap(int & a,int & b){ + int t=a; + a=b; + b=t; + } + + int absint(int a){ + if (a<0) + return -a; + else + return a; + } + + double absdouble(double a){ + if (a<0) + return -a; + else + return a; + } + + int giacmin(int a, int b){ + if (a0){ + if (n%2) + c=(c*b)%m; + n /= 2; + b=(b*b)%m; + } + } + else { + while (n>0){ + if (n%2) + c=(c*longlong(b))%m; + n /= 2; + b=(b*longlong(b))%m; + } + } + return c; + } + + int smod(int r,int m){ + if (m<=0){ + if (!m) + return r; + m=-m; + } + r = r % m; +#if 1 + r += (unsigned(r)>>31)*m; // make positive + return r-(unsigned((m>>1)-r)>>31)*m; +#else + longlong tmp= longlong(r)+r; + if (tmp>m) + return r-m; + if (tmp<=-m) + return r+m; + return r; +#endif + } + + int smod(longlong r,int m){ + int R=r%m; + R += (unsigned(R)>>31)*m; // make positive + int res2=R-(unsigned((m>>1)-R)>>31)*m; + return res2; + int res1=(R>m/2)?R-m:R; + if (res1!=res2) + CERR << "smod longlong " << r << " " << m << '\n'; + return res1; + //return smod(R,m); + } + + longlong smodll(longlong a,longlong b){ + longlong r=a%b; + if (r>b/2) + r -= b; + else { + if (r<=-b/2) + r += b; + } + return r; + } + + int gcd(int a,int b){ + if (a!=b){ + int r; + while (b){ + r=a%b; + a=b; + b=r; + } + } + return absint(a); + } + +#if defined(EMCC) || defined(EMCC2) + void my_mpz_gcd(mpz_t &z,const mpz_t & A,const mpz_t & B){ + mpz_t a,b; + mpz_init_set(a,A); + mpz_init_set(b,B); + while (mpz_cmp_si(b,0)){ + mpz_tdiv_r(z,a,b); + mpz_swap(a,b); + mpz_swap(b,z); + } + mpz_set(z,a); + mpz_abs(z,z); + mpz_clear(a); + mpz_clear(b); + } + void my_mpz_gcdext(mpz_t & d,mpz_t & u,mpz_t &v,const mpz_t & a,const mpz_t & b){ + mpz_t q,r1,r2,u1,u2,v1,v2; + // mpz_t r3,u3,v3; + mpz_init_set(r1,a); mpz_init_set(r2,b); + mpz_init_set_ui(u1,1); mpz_init_set_ui(u2,0); + mpz_init_set_ui(v1,0); mpz_init_set_ui(v2,1); + mpz_init(q); + // mpz_init(r3); mpz_init(u3); mpz_init(v3); + while (mpz_cmp_si(r2,0)){ + // CERR << "iegcd " << gen(r1) << " " << gen(r2) << '\n'; + mpz_tdiv_qr(q,r1,r1,r2); + mpz_swap(r1,r2); + mpz_submul(u1,q,u2); + mpz_swap(u1,u2); + mpz_submul(v1,q,v2); + mpz_swap(v1,v2); + } + if (mpz_cmp_si(r1,0)<0){ + mpz_neg(r1,r1); mpz_neg(u1,u1); mpz_neg(v1,v1); + } + mpz_swap(d,r1); mpz_swap(u,u1); mpz_swap(v,v1); +#if 0 // debugging + CERR << gen(d) << " " << gen(u) << " " << gen(v) << '\n'; + mpz_gcdext(d,u,v,a,b); + CERR << gen(d) << " " << gen(u) << " " << gen(v) << '\n'; +#endif + mpz_clear(q); mpz_clear(r1); mpz_clear(r2); + mpz_clear(u1); mpz_clear(u2); + mpz_clear(v1); mpz_clear(v2); + // mpz_clear(u3); mpz_clear(v3); mpz_clear(r3); + } + bool my_mpz_invert(mpz_t & ainv,const mpz_t & a,const mpz_t & m){ + mpz_t d,v; + mpz_init(d); mpz_init(v); + my_mpz_gcdext(d,ainv,v,a,m); + mpz_clear(v); + bool ok=mpz_cmp_si(d,1)==0; + mpz_clear(d); + return ok; + } +#else + void my_mpz_gcd(mpz_t &z,const mpz_t & a,const mpz_t & b){ + mpz_gcd(z,a,b); + } + void my_mpz_gcdext(mpz_t & d,mpz_t & u,mpz_t &v,const mpz_t & a,const mpz_t & b){ + mpz_gcdext(d,u,v,a,b); + } + bool my_mpz_invert(mpz_t & ainv,const mpz_t & a,const mpz_t & m){ + return mpz_invert(ainv,a,m)!=0; + } +#endif + + int simplify(int & a,int & b){ + int d=gcd(a,b); + a=a/d; + b=b/d; + return d; + } + + static gen _CPLXgcd(const gen & a,const gen & b){ // a & b must be gen + if (!is_cinteger(a) || !is_cinteger(b) ) + return plus_one; + gen acopy(a),bcopy(b),r; + for (;;){ + if (is_exactly_zero(bcopy)){ + complex c=gen2complex_d(acopy); + double d=arg(c); + int quadrant=int(std::floor((2*d)/M_PI)); + switch (quadrant){ + case 0: + return acopy; + case 1: + return acopy*(-cst_i); + case -1: + return acopy*cst_i; + case 2: case -2: + return -acopy; + default: + return acopy; + } + } + r=acopy%bcopy; + acopy=bcopy; + bcopy=r; + } + } + + static gen polygcd(const polynome & a,const polynome & b){ + ref_polynome * resptr=new ref_polynome(a.dim); + gcd(a,b,resptr->t); + return resptr; + } + + // gcd(undef,x)=x to be used inside series + static gen symgcd(const gen & a,const gen& b,GIAC_CONTEXT){ + if (is_exactly_zero(a) || is_undef(a) || (is_one(b))) + return b; + if (is_one(a) || is_undef(b) || (is_exactly_zero(b))) + return a; + if (a==b) + return a; + if ( (a.type==_MOD) && (b.type==_MOD) && (a._MODptr->type<=_CPLX) && (b._MODptr->type<= _CPLX) ) + return chkmod(plus_one,a); + if (a.type==_MOD || b.type==_MOD || a.type==_DOUBLE_ || a.type==_FLOAT_ || a.type==_REAL || b.type==_DOUBLE_ || b.type==_FLOAT_ || b.type==_REAL ) + return plus_one; + if ( (a.type==_POLY) && (b.type==_POLY) ) + return polygcd(*a._POLYptr,*b._POLYptr); + if ( (a.type==_EXT) && (b.type ==_EXT) ){ + if ( (*(a._EXTptr+1)!=*(b._EXTptr+1)) || (a._EXTptr->type!=_VECT) || (b._EXTptr->type!=_VECT) ) + return plus_one; + environment *env=new environment; + vecteur g=gcd(*a._EXTptr->_VECTptr,*b._EXTptr->_VECTptr,env); + delete env; + return ext_reduce(g,*(a._EXTptr+1)); + } + if ( (a.type==_FRAC) || (b.type==_FRAC)) + return plus_one; + if (a.type==_EXT){ + if (a._EXTptr->type!=_VECT) + return gentypeerr(gettext("symgcd")); + if ( (a._EXTptr+1)->type!=_VECT) + return symgcd(ext_reduce(a),b,contextptr); + gen aa(lgcd(*a._EXTptr->_VECTptr)); + gen res=gcd(aa,b,contextptr),b2(rdiv(b,res,contextptr)); + if (is_one(b2) || is_minus_one(b2))// || b2.type==_POLY) + return res; + vecteur ua,u,v,dd; + divvecteur(*(a._EXTptr->_VECTptr),aa,ua); + const vecteur & uv=*((a._EXTptr+1)->_VECTptr); + egcd(ua,uv,0,u,v,dd); + // u and v are not used but we can't use gcd here because we want to + // "factor" dd=extension(ua,uv)*extension(u,uv) + gen dd0(dd.front()); + simplify(b2,dd0); + if (is_one(dd0)) + return res*algebraic_EXTension(ua,*(a._EXTptr+1)); + return res; + } + if (b.type==_EXT) + return symgcd(b,a,contextptr); + if (a.type==_POLY) + return gcd(*a._POLYptr,polynome(b,a._POLYptr->dim)); + if (b.type==_POLY) + return gcd(*b._POLYptr,polynome(a,b._POLYptr->dim)); + if ( a.type!=_DOUBLE_ && a.type!=_FLOAT_ && a.type!=_VECT && b.type!=_DOUBLE_ && b.type!=_FLOAT_ && b.type!=_VECT ) + return rationalgcd(a,b,contextptr); + return plus_one; // return gentypeerr(gettext("symgcd")); + } + + gen simplify(gen & n, gen & d){ + if ( (d.type==_DOUBLE_ || d.type==_FLOAT_) || + ( (d.type==_CPLX) && + ((d._CPLXptr->type==_DOUBLE_ || d._CPLXptr->type==_FLOAT_) || + ((d._CPLXptr+1)->type==_DOUBLE_ || (d._CPLXptr+1)->type==_FLOAT_)) ) + ){ + gen dd=no_context_evalf(d); + gen nn=no_context_evalf(n); + // if (d==dd && n==nn) return 1; // avoid infinite recursion? + n=rdiv(nn,dd,context0); + d=plus_one; + return dd; + } + if ( (n.type==_DOUBLE_ || n.type==_FLOAT_) || + ( (n.type==_CPLX) && + ((n._CPLXptr->type==_DOUBLE_ || n._CPLXptr->type==_FLOAT_) || + ((n._CPLXptr+1)->type==_DOUBLE_ || (n._CPLXptr+1)->type==_FLOAT_)) ) + ){ + gen nn=no_context_evalf(n); + n=plus_one; + d=rdiv(no_context_evalf(d),nn,context0); + return nn*simplify(n,d); + } + if (n.type==_FRAC || d.type==_FRAC) + return plus_one; + if (is_one(d)) + return d; + if (is_zero(d)){ + n=undef; + d=1; + return n; + } + if (is_zero(n)){ + gen tmp=d; + d=1; + return tmp; + } + if ( (n.type==_MOD) && (d.type!=_MOD) ) + d=makemod(d,*(n._MODptr+1)); + if (d.type==_MOD){ + if (d._MODptr->is_cinteger()){ + gen dd(d); + n=n*inv(dd,context0); + d=makemodquoted(plus_one,*(d._MODptr+1)); + return dd; + } + } + if (is_one(n)) + return n; + if ((n.type==_POLY) && (d.type==_POLY)){ + polynome np(*n._POLYptr),dp(*d._POLYptr); + if (np.dim && dp.dim && np.dim!=dp.dim) + return gensizeerr(gettext("simplify: Polynomials do not have the same dimension")); + polynome g(np.dim); + g=simplify(np,dp); + n=np; + d=dp; + return g; + } + if (n.type==_VECT){ + if (d.type==_VECT){ + environment * env=new environment; + vecteur g=gcd(*n._VECTptr,*d._VECTptr,env); + delete env; + n=gen(*n._VECTptr/g,_POLY1__VECT); + d=gen(*d._VECTptr/g,_POLY1__VECT); + return gen(g,_POLY1__VECT); + } + gen gg=lgcd(*n._VECTptr,d); + if (!is_one(gg)){ + n=divvecteur(*n._VECTptr,gg); + d=d/gg; + } + return gg; + // old code + gen nd=_gcd(n,context0); + gen g=simplify(nd,d); + if (!is_one(g)) n=divvecteur(*n._VECTptr,g); + return g; + } + if (d.type==_VECT){ + gen dd=_gcd(d,context0); + gen g=simplify(n,dd); + d=divvecteur(*d._VECTptr,g); + return g; + } + if (d.type==_EXT){ + if ( (d._EXTptr->type==_INT_) || (d._EXTptr->type==_ZINT) ){ + n=n*inv(d,context0); + gen d_copy=d; + d=1; + return d_copy; + } + if ( (d._EXTptr+1)->type==_EXT || (d._EXTptr+1)->type==_FRAC){ + d=ext_reduce(d); + return simplify(n,d); + } + if (d._EXTptr->type==_VECT){ + vecteur u,v,dd; + if ( (d._EXTptr+1)->type!=_VECT) + return gensizeerr(gettext("gen.cc:simplify")); + egcd(*(d._EXTptr->_VECTptr),*((d._EXTptr+1)->_VECTptr),0,u,v,dd); + gen tmp=algebraic_EXTension(u,*((d._EXTptr+1)->_VECTptr)); + if (tmp.type!=_EXT){ + return gensizeerr(gettext("gen.cc:simplify/tmp.type!=_EXT")); + // return 1; + } + n=n*tmp; + d=d*tmp; + return simplify(n,d)*inv_EXT(tmp); + } + return gentypeerr(gettext("simplify")); + } + if (n.type==_EXT){ + gen n_EXT=*n._EXTptr; + gen g=simplify(n_EXT,d); + n=algebraic_EXTension(n_EXT,*(n._EXTptr+1)); + return g; + } + if (n.type==_POLY) { + return simplify3(n,d); // changed made 18 dec 2016 for speed + polynome np(*n._POLYptr),dp(d,n._POLYptr->dim); + polynome g(np.dim); + g=simplify(np,dp); + n=np; + d=dp; + return g; + } + if (d.type==_POLY){ + polynome np(n,d._POLYptr->dim),dp(*d._POLYptr); + polynome g(np.dim); + g=simplify(np,dp); + n=np; + d=dp; + return g; + } + vecteur l(lvar(n)); + lvar(d,l); + gen num=e2r(n,l,context0),den=e2r(d,l,context0),g=gcd(num,den,context0); // ok + den=rdiv(den,g,context0); + if (is_exactly_zero(re(den,context0))){ //ok + den=cst_i*den; + g=-cst_i*g; + } + if (is_positive(-den,context0)){ // ok + den=-den; + g=-g; + } + n=r2sym(rdiv(num,g,context0),l,context0); // ok + d=r2sym(den,l,context0); // ok + return r2sym(g,l,context0); // ok + } + + gen gcd(const gen & a,const gen & b){ + return gcd(a,b,context0); + } + gen gcd(const gen & a,const gen & b,GIAC_CONTEXT){ + ref_mpz_t * res; + switch ( (a.type<< _DECALAGE) | b.type ) { + case _INT___INT_: + return(gcd(a.val,b.val)); + case _INT___ZINT: + if (a.val) + return(int(mpz_gcd_ui(NULL,*b._ZINTptr,absint(a.val)))); + else + return is_positive(b,contextptr)?b:-b; + case _ZINT__INT_: + if (b.val) + return(int(mpz_gcd_ui(NULL,*a._ZINTptr,absint(b.val)))); + else + return is_positive(a,contextptr)?a:-a; + case _ZINT__ZINT: +#if !defined USE_GMP_REPLACEMENTS && !defined BF2GMP_H + { + int test=mpz_cmp(*a._ZINTptr,*b._ZINTptr); + if (test==0 || (test>0 && mpz_divisible_p(*a._ZINTptr,*b._ZINTptr))) + return abs(b,contextptr); + if (test<0 && mpz_divisible_p(*b._ZINTptr,*a._ZINTptr)) + return abs(a,contextptr); + } +#endif + res = new ref_mpz_t; + my_mpz_gcd(res->z,*a._ZINTptr,*b._ZINTptr); + return(res); + case _INT___CPLX: case _ZINT__CPLX: + case _CPLX__INT_: case _CPLX__ZINT: + case _CPLX__CPLX: + return _CPLXgcd(a,b); + case _POLY__POLY: + return polygcd(*a._POLYptr,*b._POLYptr); + case _VECT__VECT: + return gen(gcd(*a._VECTptr,*b._VECTptr,0,ntl_on(contextptr) && a._VECTptr->size()>=NTL_MODGCD && b._VECTptr->size()>=NTL_MODGCD),_POLY1__VECT); + case _FRAC__FRAC: + return fraction(gcd(a._FRACptr->num,b._FRACptr->num,contextptr),lcm(a._FRACptr->den,b._FRACptr->den)); + default: + if (a.type==_FRAC) + return fraction(gcd(a._FRACptr->num,b,contextptr),a._FRACptr->den); + if (b.type==_FRAC) + return fraction(gcd(b._FRACptr->num,a,contextptr),b._FRACptr->den); + if (a.type==_USER) + return a._USERptr->gcd(b); + if (b.type==_USER) + return b._USERptr->gcd(a); + { + gen aa(a),bb(b); + if (is_integral(aa) && is_integral(bb)) + return gcd(aa,bb,contextptr); + } + return symgcd(a,b,contextptr); + } + } + + gen lcm(const gen & a,const gen & b){ + return normal(rdiv(a,gcd(a,b,context0),context0),context0)*b; // ok + } + + static void ciegcd(const gen &a_orig,const gen &b_orig, gen & u,gen &v,gen &d ){ + gen a(a_orig),b(b_orig),au(plus_one),bu(zero),q,r,ru; + while (!is_exactly_zero(b)){ + q=iquo(a,b); + r=a-b*q; + a=b; + b=r; + ru=au-bu*q; + au=bu; + bu=ru; + } + u=au; + d=a; + v=iquo(d-a_orig*u,b_orig); + } + + int iegcd(int a_,int b_,int &u,int & v){ + int a(a_),b(b_),au(1),bu(0),r,ru; + longlong q; + while (b){ + q=a/b; + r=a-b*q; + a=b; + b=r; + ru=au-bu*q; + au=bu; + bu=ru; + } + u=au; + v=(a-longlong(a_)*u)/b_; + return a; + } + + void egcd(const gen &ac,const gen &bc, gen & u,gen &v,gen &d ){ + gen a(ac),b(bc); + switch ( (a.type<< _DECALAGE) | b.type ) { + case _INT___INT_: case _INT___ZINT: case _ZINT__INT_: case _ZINT__ZINT: + if (a.type==_INT_) + a.uncoerce(); + if (b.type==_INT_) + b.uncoerce(); + if (!u.type) + u.uncoerce(); + if (!v.type) + v.uncoerce(); + if (!d.type) + d.uncoerce(); + my_mpz_gcdext(*d._ZINTptr,*u._ZINTptr,*v._ZINTptr,*a._ZINTptr,*b._ZINTptr); + if (mpz_sizeinbase(*u._ZINTptr,2)<32) + u=mpz_get_si(*u._ZINTptr); + if (mpz_sizeinbase(*v._ZINTptr,2)<32) + v=mpz_get_si(*v._ZINTptr); + if (mpz_sizeinbase(*d._ZINTptr,2)<32) + d=mpz_get_si(*d._ZINTptr); + break; + default: + ciegcd(a,b,u,v,d); + break; + } + } + + static void _ZINTmod (const gen & a,const gen & b,ref_mpz_t * & rem){ + if (is_strictly_positive(-b,context0)) + return _ZINTmod(a,-b,rem); + // at least one is not an int, uncoerce remaining int + ref_mpz_t *aptr,*bptr; + if (a.type!=_INT_) +#ifdef SMARTPTR64 + aptr= (ref_mpz_t *) (* ((ulonglong * ) &a) >> 16); +#else + aptr=a.__ZINTptr; +#endif + else { + aptr=new ref_mpz_t; + mpz_set_si(aptr->z,a.val); + } + if (b.type!=_INT_) +#ifdef SMARTPTR64 + bptr= (ref_mpz_t *) (* ((ulonglong * ) &b) >> 16); +#else + bptr=b.__ZINTptr; +#endif + else { + bptr=new ref_mpz_t; + mpz_set_si(bptr->z,b.val); + } + rem=new ref_mpz_t; + mpz_tdiv_r(rem->z,aptr->z,bptr->z); + if (a.type==_INT_) + delete aptr; + if (b.type==_INT_) + delete bptr; + } + + gen operator %(const gen & a,const gen & b){ + ref_mpz_t * rem; + switch ( (a.type<< _DECALAGE) | b.type ) { + case _INT___INT_: + if (b.val) + return(a.val % b.val); + else + return a.val; + case _ZINT__ZINT: case _INT___ZINT: case _ZINT__INT_: + _ZINTmod(a,b,rem); + return(rem); + case _CPLX__INT_: case _CPLX__ZINT: + return gen(smod((*a._CPLXptr), b), smod(*(a._CPLXptr+1), b) ); + case _INT___CPLX: case _ZINT__CPLX: case _CPLX__CPLX: + return(a-b*iquo(a,b)); + case _VECT__VECT: + return (*a._VECTptr)%(*b._VECTptr); + default: + return gentypeerr(gettext("%")); + } + return 0; + } + + bool is_multiple(const gen & a,const gen &b){ + if (a.type==_INT_){ + if (b.type!=_INT_) + return false; + return a.val%b.val==0; + } + if (a.type!=_ZINT) + return false; + if (b.type==_INT_) + return modulo(*a._ZINTptr,b.val)==0; + return a%b==0; + } + + static void _ZINTrem(const gen & a,const gen &b,gen & q,ref_mpz_t * & rem){ + // COUT << a << " irem " << b << '\n'; + ref_mpz_t *aptr,*bptr; + if (a.type!=_INT_) +#ifdef SMARTPTR64 + aptr= (ref_mpz_t *) (* ((ulonglong * ) &a) >> 16); +#else + aptr=a.__ZINTptr; +#endif + else { + aptr = new ref_mpz_t; + mpz_set_si(aptr->z,a.val); + } + if (b.type!=_INT_) +#ifdef SMARTPTR64 + bptr= (ref_mpz_t *) (* ((ulonglong * ) &b) >> 16); +#else + bptr=b.__ZINTptr; +#endif + else { + bptr = new ref_mpz_t; + mpz_set_si(bptr->z,b.val); + } + rem=new ref_mpz_t; + q.uncoerce(); + mpz_tdiv_qr(*q._ZINTptr,rem->z,aptr->z,bptr->z); + if (a.type==_INT_) + delete aptr; + if (b.type==_INT_) + delete bptr; + } + + gen irem(const gen & a,const gen & b,gen & q){ + ref_mpz_t * rem; + register int r; + switch ( (a.type<< _DECALAGE) | b.type ) { + case _INT___INT_: + if (!b.val) + return a; + r=a.val % b.val; + /* + if (r<0){ + if (b.val>0){ + q=gen(a.val/b.val-1); + r += b.val; + } + else { + q=gen(a.val/b.val+1); + r -= b.val; + } + } + else + */ + q=gen(a.val/b.val); + return r; + case _ZINT__ZINT: case _INT___ZINT: case _ZINT__INT_: + _ZINTrem(a,b,q,rem); + return(rem); + case _INT___CPLX: case _ZINT__CPLX: case _CPLX__CPLX: case _CPLX__INT_: case _CPLX__ZINT: + q=iquo(a,b); + return(a-b*q); + default: + return gentypeerr(gettext("irem")); + } + return 0; + } + + static void _ZINTsmod(const gen & a, const gen & b, ref_mpz_t * & rem){ + // at least one is not an int, uncoerce remaining int + ref_mpz_t *aptr,*bptr; + if (a.type!=_INT_) +#ifdef SMARTPTR64 + aptr= (ref_mpz_t *) (* ((ulonglong * ) &a) >> 16); +#else + aptr=a.__ZINTptr; +#endif + else { + aptr = new ref_mpz_t; + mpz_set_si(aptr->z,a.val); + } + if (b.type!=_INT_) +#ifdef SMARTPTR64 + bptr= (ref_mpz_t *) (* ((ulonglong * ) &b) >> 16); +#else + bptr=b.__ZINTptr; +#endif + else { + bptr = new ref_mpz_t; + mpz_set_si(bptr->z,b.val); + } + rem = new ref_mpz_t; + mpz_t rem1,rem2,rem3; + mpz_init(rem1); mpz_init(rem2); mpz_init(rem3); + mpz_mod(rem1,aptr->z,bptr->z); // rem1 positive remainder + if (mpz_sgn(bptr->z)>0) + mpz_sub(rem2,rem1,bptr->z); // negative remainder + else + mpz_add(rem2,rem1,bptr->z); + // choose smallest one in abs value + mpz_neg(rem3,rem2); + if (mpz_cmp(rem1,rem3)>0) + mpz_set(rem->z,rem2); + else + mpz_set(rem->z,rem1); + if (a.type==_INT_) + delete aptr; + if (b.type==_INT_) + delete bptr; + mpz_clear(rem1); mpz_clear(rem2); mpz_clear(rem3); + } + + void smod(const vecteur & v,const gen & g,vecteur & w){ + const_iterateur it=v.begin(),itend=v.end(); + w.resize(itend-it); + iterateur jt=w.begin(); + for (;it!=itend;++jt,++it) + *jt=smod(*it,g); + } + + vecteur smod(const vecteur & v,const gen & g){ + vecteur w(v); + smod(w,g,w); + return w; + } + + static gen smodSYMB(const gen & a,const gen & b){ + vecteur lv(lvar(a)); + gen n,d,f; + f=e2r(a,lv,context0); // ok + fxnd(f,n,d); + n=smod(n,b); + d=smod(d,b); + f=n/d; + return r2e(f,lv,context0); // ok + } + + static gen fixfracmod(const gen & res, int modulo){ + gen n=res._FRACptr->num,d=res._FRACptr->den; + if (n.type!=_POLY) + return res; + if (d.type==_INT_) + return invmod(d.val,modulo)*n; + if (d.type!=_POLY) + return res; + polynome np=*n._POLYptr,dp=*d._POLYptr,tmp,quo,rem; + np=smod(np,modulo); + tmp=gcdmod(np,dp,modulo); + divremmod(np,tmp,modulo,quo,rem); + np=quo; + divremmod(dp,tmp,modulo,quo,rem); + dp=quo; + if (is_one(dp)) + return np; + return fraction(np,dp); + } + + gen smod(const gen & a,const gen & b){ + if (b.type==_INT_ && b.val==0) + return a; + ref_mpz_t * rem; + switch ( (a.type<< _DECALAGE) | b.type ) { + case _INT___INT_: + return smod(a.val,b.val); + case _ZINT__INT_: + return smod(modulo(*a._ZINTptr,absint(b.val)),b.val); + case _INT___ZINT: case _ZINT__ZINT: + _ZINTsmod(a,b,rem); + return(rem); + case _CPLX__INT_: case _CPLX__ZINT: + return gen(smod(*a._CPLXptr,b),smod(*(a._CPLXptr+1),b)); + case _POLY__INT_: case _POLY__ZINT: + return smod(*a._POLYptr,b); + case _VECT__INT_: case _VECT__ZINT: + if (a.ref_count()==1){ + smod(*a._VECTptr,b,*a._VECTptr); + if (a.subtype==_POLY1__VECT) + *a._VECTptr=trim(*a._VECTptr,0); + return a; + } + { + gen res(new_ref_vecteur(*a._VECTptr),a.subtype); + smod(*res._VECTptr,b,*res._VECTptr); + if (a.subtype==_POLY1__VECT) + *res._VECTptr=trim(*res._VECTptr,0); + return res; + } + default: + if (a.type==_SYMB) + return smodSYMB(a,b); + if (a.type==_FRAC && is_integer(b) && is_integer(a._FRACptr->den)) + return smod(a._FRACptr->num*invmod(a._FRACptr->den,b),b); + if (a.type==_FRAC && b.type==_INT_) + return fixfracmod(a,b.val); + if ( (b.type==_INT_) || (b.type==_ZINT) ) + return a; + // error, b must be _DOUBLE_ +#ifndef NO_STDEXCEPT + throw(std::runtime_error("smod 2nd argument must be _DOUBLE_")); +#endif + return undef; + } + } + + static bool _ZINTinvmod(const gen & a,const gen & modulo, ref_mpz_t * & res){ + ref_mpz_t *aptr,*bptr; + if (a.type!=_INT_) +#ifdef SMARTPTR64 + aptr= (ref_mpz_t *) (* ((ulonglong * ) &a) >> 16); +#else + aptr = a.__ZINTptr; +#endif + else { + aptr = new ref_mpz_t; + mpz_set_si(aptr->z,a.val); + } + if (modulo.type) +#ifdef SMARTPTR64 + bptr= (ref_mpz_t *) (* ((ulonglong * ) &modulo) >> 16); +#else + bptr = modulo.__ZINTptr; +#endif + else { + bptr = new ref_mpz_t; + mpz_set_si(bptr->z,modulo.val); + } + res = new ref_mpz_t; + bool ok=my_mpz_invert(res->z,aptr->z,bptr->z)!=0; + if (a.type==_INT_) + delete aptr; + if (!modulo.type) + delete bptr; + if (!ok){ +#ifndef NO_STDEXCEPT + setsizeerr(gettext("Not invertible ")+a.print(context0)+" mod "+modulo.print(context0)); +#endif + delete res; + res=0; + return false; + } + return true; + } + + gen invmod(const gen & a,const gen & modulo){ + if (a.type==_USER) + return a._USERptr->inv(); + if (a.type==_MOD){ + if (*(a._MODptr+1)!=modulo) + return gensizeerr("Incompatible modulo "+a.print(context0)+","+modulo.print(context0)); + return inv(a,context0); + } + if (a.type==_CPLX){ + gen r=re(a,context0),i=im(a,context0); // ok + gen n=invmod(r*r+i*i,modulo); + return smod(r*n,modulo)-cst_i*smod(i*n,modulo); + } + if (a.type==_POLY) + return fraction(1,a); + ref_mpz_t * res; + switch ( (a.type<< _DECALAGE) | modulo.type) { + case _INT___INT_: + return(invmod(a.val,modulo.val)); + case _INT___ZINT: case _ZINT__INT_: case _ZINT__ZINT: + if (!_ZINTinvmod(a,modulo,res)) + return gentypeerr(gettext("invmod")); + return gen(res); + default: + return gentypeerr(gettext("invmod")); + } + return 0; + } + + bool in_fracmod(const gen &m,const gen & a,mpz_t & d,mpz_t & d1,mpz_t & absd1,mpz_t &u,mpz_t & u1,mpz_t & ur,mpz_t & q,mpz_t & r,mpz_t &sqrtm,mpz_t & tmp,gen & num,gen & den){ + mpz_set(d,*m._ZINTptr); + mpz_set(d1,*a._ZINTptr); + mpz_set_si(u,0); + mpz_set_si(u1,1); + mpz_tdiv_q_2exp(q,*m._ZINTptr,1); + mpz_sqrt(sqrtm,q); + // int signe; + for (;;){ + mpz_abs(absd1,d1); + if (mpz_cmp(absd1,sqrtm)<=0) + break; + mpz_fdiv_qr(q,r,d,d1); + // u-q*u1->ur, v-q*v1->vr + mpz_mul(tmp,q,u1); + mpz_sub(ur,u,tmp); + // u1 -> u, ur -> u1 ; v1 -> v, vr -> v1, d1 -> d, r -> d1 +#ifdef USE_GMP_REPLACEMENTS + mpz_set(u,u1); + mpz_set(u1,ur); + mpz_set(d,d1); + mpz_set(d1,r); +#else + mpz_swap(u,u1); + mpz_swap(u1,ur); + mpz_swap(d,d1); + mpz_swap(d1,r); +#endif + } + // u1*a+v1*m=d1 -> a=d1/u1 modulo m + if (mpz_sizeinbase(d1,2)<=30) + num=int(mpz_get_si(d1)); + else + num=d1; + if (mpz_sizeinbase(u1,2)<=30) + den=int(mpz_get_si(u1)); + else + den=u1; + mpz_set(q,*m._ZINTptr); + my_mpz_gcd(r,q,u1); + bool ok=mpz_cmp_ui(r,1)==0; + if (!ok){ + CERR << "Bad reconstruction a=" << a << " mod " << m << " u1=" << gen(u1) << " u1*a+v1*m= " << num << " gcd(u1,m)=" << gen(r) << '\n'; + simplify3(num,den); + return false; + } + return true; + } + + bool alloc_fracmod(const gen & a_orig,const gen & modulo,gen & res,mpz_t & d,mpz_t & d1,mpz_t & absd1,mpz_t &u,mpz_t & u1,mpz_t & ur,mpz_t & q,mpz_t & r,mpz_t &sqrtm,mpz_t & tmp){ + // write a as p/q with |p| and |q|begin(),itend=a_orig._VECTptr->end(); + vecteur v; + v.reserve(itend-it); + for (;it!=itend;++it){ + if (!alloc_fracmod(*it,modulo,res,d,d1,absd1,u,u1,ur,q,r,sqrtm,tmp)) + return false; + v.push_back(res); + } + res=gen(v,a_orig.subtype); + return true; + } + if (a_orig.type==_POLY){ + vector< monomial >::const_iterator it=a_orig._POLYptr->coord.begin(),itend=a_orig._POLYptr->coord.end(); + polynome v(a_orig._POLYptr->dim); + v.coord.reserve(itend-it); + for (;it!=itend;++it){ + if (!alloc_fracmod(it->value,modulo,res,d,d1,absd1,u,u1,ur,q,r,sqrtm,tmp)) + return false; + v.coord.push_back(monomial(res,it->index)); + } + res=gen(v); + return true; + } + if (a_orig.type==_CPLX){ + gen reres,imres; + if ( !alloc_fracmod(*a_orig._CPLXptr,modulo,reres,d,d1,absd1,u,u1,ur,q,r,sqrtm,tmp) || !alloc_fracmod(*(a_orig._CPLXptr+1),modulo,imres,d,d1,absd1,u,u1,ur,q,r,sqrtm,tmp) ) + return false; + res=reres+cst_i*imres; + return true; + } + gen a(a_orig),m(modulo),num,den; + if (a.type==_INT_) + a.uncoerce(); + if (m.type==_INT_) + m.uncoerce(); + if ( (a.type!=_ZINT) || (m.type!=_ZINT) ) + return false; + bool ok=in_fracmod(m,a,d,d1,absd1,u,u1,ur,q,r,sqrtm,tmp,num,den); + if (num.type==_ZINT && mpz_sizeinbase(*num._ZINTptr,2)<=30) + num=int(mpz_get_si(*num._ZINTptr)); + if (den.type==_ZINT && mpz_sizeinbase(*den._ZINTptr,2)<=30) + den=int(mpz_get_si(*den._ZINTptr)); + if (is_positive(den,context0)) // ok + res=fraction(num,den); + else + res=fraction(-num,-den); + return ok; + } + + bool fracmod(const gen & a_orig,const gen & modulo,gen & res){ + unsigned prealloc=a_orig.type==_ZINT?mpz_sizeinbase(*a_orig._ZINTptr,2):0; + mpz_t u,d,u1,d1,absd1,sqrtm,q,ur,r,tmp; + mpz_init2(u,prealloc); + mpz_init2(d,prealloc); + mpz_init2(u1,prealloc); + mpz_init(d1); + mpz_init(absd1); + mpz_init(sqrtm); + mpz_init(q); + mpz_init2(ur,prealloc); + mpz_init2(r,prealloc); + mpz_init2(tmp,prealloc); + bool b=alloc_fracmod(a_orig,modulo,res,d,d1,absd1,u,u1,ur,q,r,sqrtm,tmp); + mpz_clear(d); + mpz_clear(u); + mpz_clear(u1); + mpz_clear(d1); + mpz_clear(absd1); + mpz_clear(sqrtm); + mpz_clear(q); + mpz_clear(ur); + mpz_clear(r); + mpz_clear(tmp); + return b; + } + + gen fracmod(const gen & a_orig,const gen & modulo){ + if (a_orig==0) + return a_orig; + gen res; + if (!fracmod(a_orig,modulo,res)) + return gensizeerr(gettext("Reconstructed denominator is not prime with modulo")); + return res; + } + + static void _ZINTpowmod(const gen & base,const gen & expo,const gen & modulo, ref_mpz_t * & res){ + ref_mpz_t *aptr,*bptr; + if (base.type) +#ifdef SMARTPTR64 + aptr= (ref_mpz_t *) (* ((ulonglong * ) &base) >> 16); +#else + aptr=base.__ZINTptr; +#endif + else { + aptr = new ref_mpz_t; + mpz_set_si(aptr->z,base.val); + } + if (modulo.type) +#ifdef SMARTPTR64 + bptr= (ref_mpz_t *) (* ((ulonglong * ) &modulo) >> 16); +#else + bptr=modulo.__ZINTptr; +#endif + else { + bptr = new ref_mpz_t; + mpz_set_si(bptr->z,modulo.val); + } + res = new ref_mpz_t; + if (!expo.type) + mpz_powm_ui(res->z,aptr->z,expo.val,*modulo._ZINTptr); + else + mpz_powm (res->z,aptr->z,*expo._ZINTptr,bptr->z); + if (!base.type) + delete aptr; + if (!modulo.type) + delete bptr; + } + + gen powmod(const gen &base,const gen & expo,const gen & modulo){ + if (is_exactly_zero(modulo)) + return pow(base,expo,context0); + if (base.type==_VECT){ + const_iterateur it=base._VECTptr->begin(),itend=base._VECTptr->end(); + vecteur res; + for (;it!=itend;++it) + res.push_back(powmod(*it,expo,modulo)); + return gen(res,base.subtype); + } + if ((expo.type!=_INT_) && (expo.type!=_ZINT)) + return gensizeerr(gettext("powmod")); // exponent must be a _DOUBLE_ integer + if (!is_positive(expo,context0)) // ok + return(powmod(invmod(base,modulo),-expo,modulo)); + if (modulo.type==_INT_){ + // try converting base to int and expo to a long + gen mybase(base % modulo); + if ( (expo.type==_INT_) && (mybase.type==_INT_) ){ + unsigned long tmp=expo.val; + return powmod(mybase.val,tmp,modulo.val); + } + } + ref_mpz_t * res; + switch ( (base.type<< _DECALAGE) | modulo.type) { + case _INT___INT_: case _INT___ZINT: case _ZINT__INT_: case _ZINT__ZINT: + _ZINTpowmod(base,expo,modulo,res); + return(res); + default: + return gentypeerr(gettext("powmod")); + } + return 0; + } + + // assuming amod and bmod are prime together, find c such that + // c = a mod amod and c = b mod bmod + // hence a + A*amod = b + B*bmod + // or A*amod -B*bmod = b - a + gen ichinrem(const gen & a,const gen &b,const gen & amod, const gen & bmod){ + if (a.type==_INT_ && b.type==_INT_ && amod.type==_INT_ && bmod.type==_INT_ && gcd(amod.val,bmod.val)==1){ + int amodinv=invmod(amod.val,bmod.val); + longlong res=a.val+((longlong(amodinv)*(b.val-longlong(a.val)))%bmod.val)*amod.val; + return res; + } + gen A,B,d,q; + egcd(amod,bmod,A,B,d); + if (is_one(d)) + q=b-a; + else + if (!is_exactly_zero(irem(b-a,d,q))) + return gensizeerr(gettext("No Integer Solution")); + A=A*q; + return smod(A*amod+a,amod*bmod); + } + + gen isqrt(const gen & a){ + if ( (a.type!=_INT_) && (a.type!=_ZINT)) + return gentypeerr(gettext("isqrt")); + ref_mpz_t *aptr; + if (a.type!=_INT_) +#ifdef SMARTPTR64 + aptr= (ref_mpz_t *) (* ((ulonglong * ) &a) >> 16); +#else + aptr=a.__ZINTptr; +#endif + else { + aptr = new ref_mpz_t; + mpz_set_si(aptr->z,a.val); + } + ref_mpz_t *res = new ref_mpz_t; + mpz_sqrt(res->z,aptr->z); + if (a.type==_INT_) + delete aptr; + return res; + } + + int is_perfect_square(const gen & a){ + if ( (a.type!=_INT_) && (a.type!=_ZINT)) + return false; + ref_mpz_t *aptr; + if (a.type!=_INT_) +#ifdef SMARTPTR64 + aptr= (ref_mpz_t *) (* ((ulonglong * ) &a) >> 16); +#else + aptr=a.__ZINTptr; +#endif + else { + aptr = new ref_mpz_t; + mpz_set_si(aptr->z,a.val); + } + int res= mpz_perfect_square_p(aptr->z); + if (a.type==_INT_) + delete aptr; + return res; + } + + bool miller_rabin(const gen & a,const gen & p){ + gen p1=p-1,q,s(p1),r; + int t=0; + // p-1=2^t*s + for (;;++t){ + gen Q; + r=irem(s,2,Q); + if (r!=0) + break; + s=Q; + } + gen A(powmod(a,s,p)); + if (A==1 || A==p1) return true; + for (int i=0;ia.val) + return 2; + if (a.val%p==0) + return 0; + } + } +#ifdef BF2GMP_H + for (int i=0;i> 16); +#else + aptr=a.__ZINTptr; +#endif + else { + aptr = new ref_mpz_t; + mpz_set_si(aptr->z,a.val); + } + int res= mpz_probab_prime_p(aptr->z,TEST_PROBAB_PRIME); + if (a.type==_INT_) + delete aptr; + return res; +#endif // BF2GMP + } + + gen nextprime(const gen & a){ + if ( (a.type!=_INT_) && (a.type!=_ZINT)) + return gentypeerr(gettext("nextprime")); + gen res(a); + if (is_exactly_zero(smod(res,plus_two))) + res=res+1; + for ( ; ; res=res+2){ +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) + return gensizeerr(gettext("Interrupted")); + if (is_probab_prime_p(res)) + return(res); + } + } + + gen prevprime(const gen & a){ + if ( (a.type!=_INT_) && (a.type!=_ZINT)) + return gentypeerr(gettext("prevprime")); + if (a==2) + return a; + if (is_greater(2,a,context0)) + return gensizeerr(context0); + gen res(a); + if (is_exactly_zero(smod(res,plus_two))) + res=res-1; + for ( ; res.type==_ZINT || (res.type==_INT_ && res.val>1); res=res-2){ +#ifdef TIMEOUT + control_c(); +#endif + if (ctrl_c || interrupted) + return gensizeerr(gettext("Interrupted")); + if (is_probab_prime_p(res)) + return(res); + } + return zero; + } + + int jacobi(const gen & a, const gen &b){ + if ( (a.type!=_INT_ && a.type!=_ZINT) || (b.type!=_INT_ && b.type!=_ZINT)){ +#ifndef NO_STDEXCEPT + settypeerr(gettext("jacobi")); +#endif + return -RAND_MAX; + } + ref_mpz_t *aptr,*bptr; + if (a.type!=_INT_) +#ifdef SMARTPTR64 + aptr= (ref_mpz_t *) (* ((ulonglong * ) &a) >> 16); +#else + aptr = a.__ZINTptr; +#endif + else { + aptr = new ref_mpz_t; + mpz_set_si(aptr->z,a.val); + } + if (b.type!=_INT_) +#ifdef SMARTPTR64 + bptr= (ref_mpz_t *) (* ((ulonglong * ) &b) >> 16); +#else + bptr=b.__ZINTptr; +#endif + else { + bptr = new ref_mpz_t; + mpz_set_si(bptr->z,b.val); + } + int res= mpz_jacobi(aptr->z,bptr->z); + if (a.type==_INT_) + delete aptr; + if (b.type==_INT_) + delete bptr; + return res; + } + + int legendre(const gen & a, const gen & b){ + if ( (a.type!=_INT_ && a.type!=_ZINT) || (b.type!=_INT_ && b.type!=_ZINT)){ +#ifndef NO_STDEXCEPT + settypeerr(gettext("legendre")); +#endif + return -RAND_MAX; + } + ref_mpz_t *aptr,*bptr; + if (a.type!=_INT_) +#ifdef SMARTPTR64 + aptr= (ref_mpz_t *) (* ((ulonglong * ) &a) >> 16); +#else + aptr=a.__ZINTptr; +#endif + else { + aptr= new ref_mpz_t; + mpz_set_si(aptr->z,a.val); + } + if (b.type!=_INT_) +#ifdef SMARTPTR64 + bptr= (ref_mpz_t *) (* ((ulonglong * ) &b) >> 16); +#else + bptr=b.__ZINTptr; +#endif + else { + bptr= new ref_mpz_t; + mpz_set_si(bptr->z,b.val); + } + int res=mpz_legendre(aptr->z,bptr->z); + if (a.type==_INT_) + delete aptr; + if (b.type==_INT_) + delete bptr; + return res; + } + + bool has_denominator(const gen & n){ + switch (n.type ) { + case _INT_: case _ZINT: case _CPLX: case _DOUBLE_: case _FLOAT_: case _IDNT: case _EXT: case _POLY: case _MOD: case _USER: case _REAL: case _VECT: + return false; + case _SYMB: case _FRAC: + return true; + default: +#ifndef NO_STDEXCEPT + settypeerr(gettext("has_denominator")); +#endif + return false; + } + return 0; + } + + + gen factorial(unsigned long int i){ + if (i>(unsigned long int)FACTORIAL_SIZE_LIMIT){ +#ifndef NO_STDEXCEPT + setstabilityerr(); +#endif + return plus_inf; + } + ref_mpz_t * e = new ref_mpz_t; + mpz_fac_ui(e->z,i); + return e; + } + + gen comb(unsigned long int i,unsigned long j){ + if (i>(unsigned long int)FACTORIAL_SIZE_LIMIT){ + double d=std::min(j,i-j)*std::log10(double(i)); + if (d>2*FACTORIAL_SIZE_LIMIT){ +#ifndef NO_STDEXCEPT + setstabilityerr(); +#endif + return undef; + } + } + ref_mpz_t * e = new ref_mpz_t; + if (iz,i,j); +#else + mpz_set_ui(e->z,1); + for (unsigned long int k=i;k>i-j;--k) + mpz_mul_ui(e->z,e->z,k); + mpz_t tmp,tmp1; + mpz_init(tmp); mpz_init(tmp1); + mpz_fac_ui(tmp,j); + mpz_fdiv_q(tmp1,e->z,tmp); + mpz_set(e->z,tmp1); + mpz_clear(tmp); mpz_clear(tmp1); +#endif + return e; + } + + gen perm(unsigned long int i,unsigned long j){ + if (i>(unsigned long int)FACTORIAL_SIZE_LIMIT){ + double d=j*std::log10(double(i)); + if (d>2*FACTORIAL_SIZE_LIMIT){ +#ifndef NO_STDEXCEPT + setstabilityerr(); +#endif + return undef; + } + } + ref_mpz_t * e = new ref_mpz_t; + if (iz,1); + for (unsigned long int k=i;k>i-j;--k) + mpz_mul_ui(e->z,e->z,k); + return e; + } + + /* I/O: Input routines */ + + gen chartab2gen(char * s,GIAC_CONTEXT){ + gen res; + // subtype=0; + // initialize as a null _INT_ + // type = _INT_; + // val = 0; + if (!*s) + return res; +#if defined(EMCC) || defined(EMCC2) + int base=10; +#else + int base=(abs_calc_mode(contextptr)==38 || calc_mode(contextptr)==1)?10:0; +#endif + if (s[0]=='#' || s[0]=='0') { + if (s[1]=='x' || s[1]=='X'){ + s[0]='0'; + s[1]='0'; + base=16; + } + if (s[1]=='o' || s[1]=='O'){ + s[0]='0'; + s[1]='0'; + base=8; + } + } + if (s[1]=='b' || s[1]=='B'){ + s[0]='0'; + s[1]='0'; + base=2; + } +#ifdef _LIB_CE_ERRNO_H +#ifndef BESTA_OS + __set_errno(0); +#endif +#else + errno = 0; +#endif + char * endchar; +#ifdef VISUALC + longlong ll=strtol(s,&endchar,base); +#else + longlong ll=strtoll(s,&endchar,base); +#endif + int l =int(strlen(s)); + if (l>0 && s[l-1]=='.'){ + // make a copy of s, call chartab2gen recursivly, + // because some implementations of strtod do not like a . at the end +#if 1 // def FREERTOS + ALLOCA(char, scopy, l+2); +#else + char * scopy=(char *)alloca(l+2); +#endif + strcpy(scopy,s); + scopy[l]='0'; + scopy[l+1]=0; + return chartab2gen(scopy,contextptr); + } + if (*endchar) {// non integer + int digits=decimal_digits(contextptr); + // count numeric char + int delta=0; + if (l && s[0]=='0') + ++delta; + for (int k=0;k'9') + ++delta; + } + if (l>digits+delta) + digits=l-delta; +#if !defined __MINGW_H && defined HAVE_LIBMPFR // #ifndef GIAC_HAS_STO_38 + if (digits>14){ +#if 1 // def HAVE_LIBMPFR + int nbits=digits2bits(digits); +#ifdef HAVE_LIBPTHREAD + int locked=pthread_mutex_trylock(&mpfr_mutex); + if (!locked) + mpfr_set_default_prec(nbits); + // mpf_set_default_prec (decimal_digits); + real_object r; + int res=mpfr_set_str(r.inf,s,10,MPFR_RNDN); + if (!locked) + pthread_mutex_unlock(&mpfr_mutex); +#else + real_object r; + mpfr_set_default_prec(nbits); + int res=mpfr_set_str(r.inf,s,10,MPFR_RNDN); +#endif // HAVE_LIBPTHREAD +#else // LIBMPFR + real_object r; + int res=mpf_set_str(r.inf,s,10); +#endif // LIBMPFR + gen rg(r); + // rg.dbgprint(); + if (!res) + return rg; + } // end if (digits>14) +#endif // LIBMPFR was GIAC_HAS_STO_38 + double d; +#if defined __MINGW_H || defined NSPIRE || defined FXCG +#ifdef NSPIRE + d=Strtod(s,&endchar); +#else + d=strtod(s,&endchar); +#endif // NSPIRE +#else // NSPIRE || FXCG +#if !defined __MINGW_H && defined HAVE_LIBPTHREAD + int locked=pthread_mutex_trylock(&locale_mutex); + if (!locked){ + char * lc=setlocale(LC_NUMERIC,(char *)NULL); + setlocale(LC_NUMERIC,"POSIX"); + d=strtod(s,&endchar); + setlocale(LC_NUMERIC,lc); + pthread_mutex_unlock(&locale_mutex); + } + else + d=strtod(s,&endchar); +#else + char * lc=setlocale(LC_NUMERIC,(char const *)NULL); + setlocale(LC_NUMERIC,"POSIX"); + d=strtod(s,&endchar); + setlocale(LC_NUMERIC,lc); +#endif // PTHREAD +#endif // NSPIRE + if (*endchar){ +#ifdef BCD + giac_float gf; + gf=strtobcd(s,(const char **)&endchar); + if (!*endchar) + return gf; + for (int i=0;i'9')) + base=16; + } + } + int maxsize = 5 + (s[0]=='-'); + if (base==10 && lz,s,base); + res= gen(ptr); + return res; + } + } + + gen string2gen(const string & ss,bool remove_ss_quotes){ + gen res; +#ifdef SMARTPTR64 + * ((ulonglong * ) &res) = ulonglong(new ref_string(remove_ss_quotes?ss.substr(1,ss.size()-2):ss)) << 16; +#else + res.__STRNGptr = new ref_string(remove_ss_quotes?ss.substr(1,ss.size()-2):ss); +#endif + res.type=_STRNG; + return res; + } + + int giac_yyparse(void * scanner); + + static int try_parse(const string & s_orig,GIAC_CONTEXT){ + string s=s_orig; + if (1 || abs_calc_mode(contextptr)!=38){ + // remove leading spaces + for (int i=0;i10 && (s.substr(0,5)=="\"def " || s.substr(0,10)=="\"function ")){ + string news=""; + int ss=s.size()-1; + for (;ss>5;--ss){ + if (s[ss]=='"') + break; + } + for (int i=1;istackaddr && thread_param_ptr(contextptr)->stacksize/2){ + gen er; + short int err=s.size(); + if (debug_infolevel>10000) + CERR << (size_t) &err << " " << ((size_t) thread_param_ptr(contextptr)->stackaddr)+4*65536 << '\n'; + if ( ((size_t) &err) < ((size_t) thread_param_ptr(contextptr)->stackaddr)+4*65536){ + gensizeerr(gettext("Too many recursion levels"),er); + parsed_gen(er,contextptr); + return 1; + } + } +#endif // pthread + int res; + int isqrt=i_sqrt_minus1(contextptr); +#ifndef NO_STDEXCEPT + try { +#endif + void * scanner; + YY_BUFFER_STATE state=set_lexer_string(s,scanner,contextptr); + if (xcas_mode(contextptr)==0 && try_parse_i(contextptr)) + i_sqrt_minus1(0,contextptr); + res=giac_yyparse(scanner); + delete_lexer_string(state,scanner); + // if xcas_mode(contextptr)<=0 scan for i:=something, if not present replace i by sqrt(-1) + if (xcas_mode(contextptr)==0 && try_parse_i(contextptr)){ + const gen& p = parsed_gen(contextptr); + if (1) { // p.type==_SYMB || p.type==_VECT){ + vecteur v(rlvarx(p,i__IDNT_e)); + if (!v.empty()){ + vecteur w=lop(v,at_program); + int i,vs=int(w.size()); + for (i=0;ifeuille; + if (args.type!=_VECT || args._VECTptr->empty()) + continue; + if (contains(args._VECTptr->front(),i__IDNT_e)){ + *logptr(contextptr) << gettext("Warning, i is usually sqrt(-1), I'm using a symbolic variable instead but you should check your input") << '\n'; + return res; + } + } + w=lop(v,at_local); + vs=int(w.size()); + for (i=0;ifeuille; + if (args.type!=_VECT || args._VECTptr->empty()) + continue; + if (contains(args._VECTptr->front(),i__IDNT_e)){ + *logptr(contextptr) << gettext("Warning, i is usually sqrt(-1), I'm using a symbolic variable instead but you should check your input") << '\n'; + return res; + } + } + v=lop(v,at_sto); + vs=int(v.size()); + for (i=0;ifeuille[1]==i__IDNT_e){ + *logptr(contextptr) << gettext("Warning, i is usually sqrt(-1), I'm using a symbolic variable instead but you should check your input") << '\n'; + break; + } + } + if (i==vs){ +#ifndef NSPIRE + my_ostream * log = logptr(contextptr); + logptr(0,contextptr); +#endif + i_sqrt_minus1(1,contextptr); + void * scanner2; + YY_BUFFER_STATE state2=set_lexer_string(s,scanner2,contextptr); + res=giac_yyparse(scanner2); +#ifndef NSPIRE + logptr(log,contextptr); +#endif + delete_lexer_string(state2,scanner2); + } + } + } + } // end if (xcas_mode(contextptr)==0 ... +#ifndef NO_STDEXCEPT + } + catch (std::runtime_error & error){ + i_sqrt_minus1(isqrt,contextptr); + if (!first_error_line(contextptr)) + first_error_line(lexer_line_number(contextptr),contextptr); + parser_error(error.what(),contextptr); +#ifdef HAVE_SIGNAL_H_OLD + messages_to_print += string(error.what()) + '\n'; +#endif + return 1; + } +#endif + i_sqrt_minus1(isqrt,contextptr); + return res; + } + + static gen aplatir_plus(const gen & g){ + // Quick check for embedded + at the left coming from parser + if (g.is_symb_of_sommet(at_plus) && g._SYMBptr->feuille.type==_VECT){ + iterateur it=g._SYMBptr->feuille._VECTptr->begin(),itend=g._SYMBptr->feuille._VECTptr->end(); + if (it==itend) + return 0; + vecteur v; + v.reserve(itend-it+1); + gen f; + for (;it!=itend;){ + for (--itend;itend!=it;--itend) + v.push_back(aplatir_fois_plus(*itend)); + if (!it->is_symb_of_sommet(at_plus)){ + v.push_back(aplatir_fois_plus(*it)); + break; + } + f=it->_SYMBptr->feuille; + if (f.type!=_VECT){ + v.push_back(*it); + break; + } + it=f._VECTptr->begin(); + itend=f._VECTptr->end(); + } + reverse(v.begin(),v.end()); + return new_ref_symbolic(symbolic(at_plus,gen(v,_SEQ__VECT))); + } + return g; + } + + gen aplatir_fois_plus(const gen & g){ + if (g.type==_VECT){ + vecteur v(*g._VECTptr); + iterateur it=v.begin(),itend=v.end(); + for (;it!=itend;++it) + *it=aplatir_fois_plus(*it); + return gen(v,g.subtype); + } + if (g.type!=_SYMB) + return g; + if (g._SYMBptr->sommet==at_pow && g._SYMBptr->feuille.type==_VECT && g._SYMBptr->feuille.subtype!=_SEQ__VECT) + return symbolic(at_pow,change_subtype(g._SYMBptr->feuille,_SEQ__VECT)); + if (g._SYMBptr->sommet==at_plus) + return aplatir_plus(g); + gen & f=g._SYMBptr->feuille; + if (g._SYMBptr->sommet==at_prod && f.type==_VECT && f._VECTptr->size()==2) + return sym_mult(aplatir_fois_plus(f._VECTptr->front()),aplatir_fois_plus(f._VECTptr->back()),context0); + return new_ref_symbolic(symbolic(g._SYMBptr->sommet,aplatir_fois_plus(f))); + } + + static gen aplatir_plus_only(const gen & g){ + if (g.type==_VECT){ + const vecteur & v=*g._VECTptr; + vecteur w(v); + const_iterateur it=v.begin(),itend=v.end(); + iterateur jt=w.begin(); + for (;it!=itend;++jt,++it) + *jt=aplatir_plus_only(*it); + return gen(w,g.subtype); + } + if (g.type!=_SYMB) + return g; + // Quick check for embedded + at the left coming from parser + if (g.is_symb_of_sommet(at_plus) && g._SYMBptr->feuille.type==_VECT){ + const_iterateur it=g._SYMBptr->feuille._VECTptr->begin(),itend=g._SYMBptr->feuille._VECTptr->end(); + if (it==itend) + return 0; + vecteur v; + v.reserve(itend-it+1); + register const gen * f; + for (;it!=itend;){ + for (--itend;itend!=it;--itend) + v.push_back(*itend); + // Check first element of the vector g, if it's not a + add it to v and end + if (it->type!=_SYMB || it->_SYMBptr->sommet!=at_plus || (f=&it->_SYMBptr->feuille,f->type!=_VECT) ){ + v.push_back(*it); + break; + } + // first element was a plus, restart with all it's arguments + itend=f->_VECTptr->end(); + it=f->_VECTptr->begin(); + } + reverse(v.begin(),v.end()); + return gen(new_ref_symbolic(symbolic(at_plus,gen(v,_SEQ__VECT)))).change_subtype(g.subtype); + } + return gen(new_ref_symbolic(symbolic(g._SYMBptr->sommet,aplatir_plus_only(g._SYMBptr->feuille)))).change_subtype(g.subtype); + } + + static int protected_giac_yyparse(const string & chaine,gen & parse_result,GIAC_CONTEXT){ + int s; + s=int(chaine.size()); + if (!s) + return 1; +#ifdef HAVE_LIBPTHREAD + static pthread_mutex_t parse_mutex = PTHREAD_MUTEX_INITIALIZER; + int locked = pthread_mutex_lock(&parse_mutex); +#else // HAVE_LIBPTHREAD + int locked = 0; +#endif + int res = 1; +#ifndef NO_STDEXCEPT + try { +#endif + res=try_parse(chaine,contextptr); + gen g=parsed_gen(contextptr); + if (g.type<=_FLOAT_){ + parse_result=aplatir_plus_only(g); + // parse_result=aplatir_fois_plus(g); + if (g.type==_SYMB && parse_result.type==_SYMB) + parse_result.subtype=g.subtype; +#ifdef HAVE_LIBPTHREAD + if (!locked) + pthread_mutex_unlock(&parse_mutex); +#endif + return res; + } + parsed_gen(0,contextptr); + parse_result.type=0; + parse_result=0; + CERR << "Incomplete parse" << '\n'; +#ifdef HAVE_LIBPTHREAD + if (!locked) + pthread_mutex_unlock(&parse_mutex); +#endif +#ifndef NO_STDEXCEPT + } catch (std::runtime_error &e) { +#ifdef HAVE_LIBPTHREAD + if (!locked) + pthread_mutex_unlock(&parse_mutex); +#endif + } +#endif // exception + return res; + } + + gen::gen(const string & s,GIAC_CONTEXT){ + subtype=0; + string ss(s); + /* + string::iterator it=ss.begin(),itend=ss.end(); + for (;it!=itend;++it) + if (*it=='\\') + *it=' '; + */ + type=_INT_; + if (s==string(s.size(),' ')){ + *this=undef; + return; + } + if (protected_giac_yyparse(s,*this,contextptr)){ + if (ss.empty()) + ss=""""""; + if (ss[0]!='"') + ss = '"'+ss; + if ((ss.size()==1) || (ss[ss.size()-1]!='"')) + ss += '"'; +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_string(ss.substr(1,ss.size()-2))) << 16; + subtype=0; +#else + __STRNGptr = new ref_string(ss.substr(1,ss.size()-2)); +#endif + type=_STRNG; + } + } + + gen genfromstring(const string & s){ + return gen(s,context0); + } + + /* + gen::gen(const string & s,const vecteur & l,GIAC_CONTEXT){ + type=_INT_; + if (protected_giac_yyparse(s,*this,contextptr)){ + string ss(s); + if (ss.empty()) + ss=""""""; + if (ss[0]!='"') + ss = '"'+ss; + if ((ss.size()==1) || (ss[ss.size()-1]!='"')) + ss += '"'; +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_string(ss.substr(1,ss.size()-2))) << 16; +#else + __STRNGptr = new ref_string(ss.substr(1,ss.size()-2)); +#endif + type=_STRNG; + } + subtype=0; + } + */ + + gen::gen(const wchar_t * ws,GIAC_CONTEXT){ + size_t l=0; + const wchar_t * ptr=ws; + for (;*ptr;++ptr){ ++l; } + char * line=new char[4*l+1]; + unicode2utf8(ws,line,int(l)); + string ss(line); + delete [] line; + subtype=0; + type=_INT_; + if (ss==string(ss.size(),' ')){ + *this=undef; + return; + } +#ifdef HAVE_SSTREAM + ostringstream warnstream; +#endif // HAVE_SSTREAM +#ifndef NSPIRE + my_ostream * oldptr = logptr(contextptr); +#ifdef WITH_MYOSTREAM + my_ostream newptr(&warnstream); + logptr(&newptr,contextptr); +#else +#if !defined HAVE_SSTREAM || defined NSPIRE + logptr(&COUT,contextptr); +#else +#ifndef KHICAS + logptr(&warnstream,contextptr); +#endif +#endif // HAVE_SSTREAM +#endif // WITH_MYIOSTREAM +#endif // NSPIRE + if (protected_giac_yyparse(ss,*this,contextptr)){ + if (ss.empty()) + ss=""""""; + if (ss[0]!='"') + ss = '"'+ss; + if ((ss.size()==1) || (ss[ss.size()-1]!='"')) + ss += '"'; +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_string(ss.substr(1,ss.size()-2))) << 16; + subtype=0; +#else + __STRNGptr = new ref_string(ss.substr(1,ss.size()-2)); +#endif + type=_STRNG; + } +#ifndef NSPIRE + logptr(oldptr,contextptr); +#endif +#if !defined HAVE_SSTREAM || defined NSPIRE +#else + if (!warnstream.str().empty()) + parser_error(warnstream.str(),contextptr); +#endif + } + + /* I/O: Print routines */ +int sprint_int(char * s,int r){ + char * ptr=s; + if (r<0){ + *ptr='-'; + ++ptr; + r=-r; + } + int i; + if (r==0){ + *ptr='0'; + *(ptr+1)=0; + return 1; + } + *(ptr+10)=0; + for (i=9;r;--i){ + *(ptr+i)='0'+r%10; + r/=10; + } + ++i; + if (i>0){ // shift left i char + char * buf; + for (buf=ptr+i;buf<=ptr+9;++buf){ + *(buf-i)=*buf; + } + *(buf-i)=0; + ptr=buf-i; + } + else + ptr += 10; + return ptr-s; +} + +void sprint_double(char * s,double d){ + char * buf=s; + if (d==0){ + strcpy(buf,"0.0"); + return; + } + if (d<0){ + *buf='-'; + ++buf; + d=-d; + } + int i=d; + if (i==d && d<1e9){ + sprint_int(buf,i); + return; + } + for (i=0;i<280 && d>=1.0;i+=14){ + d=d*1e-14; + } + for (;i>-280 && d<1.0;i-=14){ + d=d*1e14; + } + for (;i<310 && d>=1.0;++i){ + d=d*.1; + } + if (i==310){ + strcpy(buf,"inf"); + return; + } + for (;i>-310 && d<1.0;--i){ + d=d*10; + } + if (i==-310){ + strcpy(buf,"0.0"); + return; + } + // 1.0<=d<10, d*10^i + d=d/10; ++i; // 0.1<=d<1, d*10^i + *buf='.'; + char * ptr=buf; + ++buf; + int r=(int)(d*1e9+.5); + if (r>=1e9){ + r=r/10; + ++i; + } + buf += sprint_int(buf,r); + if (i>0 && i<7){ + // move . i positions to the right + for (int j=0;j3 || forme[1]<'0' || forme[1]>'9' || (forme.size()==3 && forme[2]<'0' && forme[2]>'9')) + return "invalid format"; + if (my_isnan(d)) + return "undef"; + if (my_isinf(d)) + return "infinity"; + char s[256]; + string f2=string("%.")+forme.substr(1,forme.size()-1)+ch; + sprintfdouble(s,f2.c_str(),d); + return s; + } + if (xcas_mode(contextptr)==3 && double(int(d))==d) + return print_INT_(int(d)); + char s[256]; +#ifdef SOFTMATH + sprintfdouble(s,"%.14g",d); + return s; +#else + string form("%."+print_INT_(giacmin(decimal_digits(contextptr),14))); + int sf=scientific_format(contextptr); + switch (sf){ + case 0: case 2: + if (abs_calc_mode(contextptr)==38) + form += 'G'; + else + form += "g"; + break; + case 1: + form += "e"; // or "f" ?? + break; + case 3: + form += "a"; + } + if (calc_mode(contextptr)==1) + form[form.size()-1]=toupper(form[form.size()-1]); + if (sf==2){ + // engineering format + int ndigits=int(giac_floor(std::log10(d)+0.5)); + ndigits = 3*(ndigits /3); + sprintfdouble(s,form.c_str(),d/std::pow(10.0,ndigits)); + return s+("e"+print_INT_(ndigits)); + } + sprintfdouble(s,form.c_str(),d); + // 1073741824=2^30, fixme always try with a .0 for large numbers if longfloat not available? + if (sf +#if 1 // def HAVE_LIBMPFR + || d>=1073741824 || d<=-1073741824 +#endif + ) + return s; + for (int i=0;s[i];++i){ + if (s[i]=='.' || s[i]==',' || s[i]=='e' || s[i]=='E') + return s; + } + return string(s)+".0"; +#endif + } + + gen maptoarray(const gen_map & m,GIAC_CONTEXT){ + vecteur res; + gen_map::const_iterator it=m.begin(),itend=m.end(); + if (it==itend) + return gendimerr(gettext("Empty array")); + gen_map::const_reverse_iterator lastit=m.rbegin(); + // find index ranges + gen premidx=it->first,lastidx=lastit->first; + if (premidx.type!=_VECT || lastidx.type!=_VECT) + return gentypeerr(gettext("Bad array indexes")); + vecteur & pv=*premidx._VECTptr; + vecteur & lv=*lastidx._VECTptr; + unsigned ps=unsigned(pv.size()); + vector indexes(ps); + if (ps==0) + return res; + if (lv.size()!=ps ) + return gendimerr(contextptr); + for (unsigned i=0;isecond); + } + res.push_back(tmp); + } + else { + vecteur tmp(indexes[ps-1]); + for (int i=ps-2;i>=0;--i){ + vecteur newtmp; + for (int j=0;jtype!=_VECT) + return gendimerr(contextptr); + for (unsigned i=0;ifirst[i]-pv[i]).val; + if (pos<0 || unsigned(pos)>=tmpptr->_VECTptr->size()) + return gendimerr(contextptr); + tmpptr=&((*tmpptr->_VECTptr)[pos]); + } + *tmpptr = it->second; + } + res.push_back(tmp); + } + return new_ref_symbolic(symbolic(at_array,res)); + } + + static string printmap(const gen_map & m,GIAC_CONTEXT){ + string s("table(\n"); + gen_map::const_iterator it=m.begin(),itend=m.end(); + for (;it!=itend;){ + gen bb=it->first; + if (bb.type!=_STRNG && array_start(contextptr)){ + if (bb.type==_VECT) + bb=bb+vecteur(bb._VECTptr->size(),plus_one); + else + bb=bb+plus_one; + } + if (bb.type==_VECT && bb.subtype==_SEQ__VECT) + s+='('; + s += bb.print(contextptr); + if (bb.type==_VECT && bb.subtype==_SEQ__VECT) + s+=')'; + s += " = " + it->second.print(contextptr); + ++it; + if (it!=itend) + s += ','; + s += '\n'; + } + return s+")"; + } + + std::string printmpf_t(const mpf_t & inf,GIAC_CONTEXT){ +#if !defined USE_GMP_REPLACEMENTS && !defined BF2GMP_H +#ifdef VISUALC + char * ptr=new char[decimal_digits(contextptr)+30]; +#else + char ptr[decimal_digits(contextptr)+30]; +#endif + bool negatif=mpf_sgn(inf)<0; + mp_exp_t expo; + if (negatif){ + mpf_t inf2; + mpf_init(inf2); + mpf_neg(inf2,inf); + mpf_get_str(ptr,&expo,10,decimal_digits(contextptr),inf2); + mpf_clear(inf2); + } + else + mpf_get_str(ptr,&expo,10,decimal_digits(contextptr),inf); + std::string res(ptr),reste(res.substr(1,res.size()-1)); +#ifdef VISUALC + delete [] ptr; +#endif + res=res[0]+("."+reste); + if (expo!=1) + res += "e"+print_INT_(expo-1); + if (negatif) + return "-"+res; + else + return res; +#else // USE_GMP_REPLACEMENTS +#if defined NSPIRE || defined FXCG || defined KHICAS + return "mpf_t not implemented"; +#else + std::ostringstream out; +#ifdef LONGFLOAT_DOUBLE + out << std::setprecision(decimal_digits(contextptr)) << inf; +#else + out << std::setprecision(decimal_digits(contextptr)) << *inf; +#endif + return out.str(); +#endif // NSPIRE +#endif // USE_GMP_REPLACEMENTS + } + + + string print_ZINT(const mpz_t & a){ + /* + char * s =mpz_get_str (NULL, 10,a) ; + string res(s); + free(s); + return res; + */ + size_t l=mpz_sizeinbase (a, 10) + 2; + if (l>unsigned(MAX_PRINTABLE_ZINT)) + return "Integer_too_large_for_display"; +#if defined( VISUALC ) || defined( BESTA_OS ) + ALLOCA(char, s, l); //s = ( char * )alloca( l ); +#else + char s[l]; +#endif + mpz_get_str (s, 10,a) ; + string tmp(s); + + return tmp; + } + + string hexa_print_ZINT(const mpz_t & a){ + size_t l=mpz_sizeinbase (a, 16) + 2; + if (l>unsigned(MAX_PRINTABLE_ZINT)) + return "Integer_too_large"; +#if defined( VISUALC ) || defined( BESTA_OS ) + ALLOCA(char, s, l);//char * s = ( char * )alloca( l ); +#else + char s[l]; +#endif + string res("0x"); +#ifdef USE_GMP_REPLACEMENTS + if (mpz_sgn(a) == -1){ + mpz_t tmpint; + mpz_init(tmpint); + mpz_neg(tmpint, a); + mpz_get_str(s,16,tmpint); + mpz_clear(tmpint); + + res = "-" + res + s; + } + else { + mpz_get_str(s,16,a); + res += s; + } +#else + mpz_get_str (s,16,a) ; + res += s; +#endif // USE_GMP_REPLACEMENTS + + return res; + } + + string octal_print_ZINT(const mpz_t & a){ + size_t l=mpz_sizeinbase (a, 8) + 2; + if (l>unsigned(MAX_PRINTABLE_ZINT)) + return "Integer_too_large"; +#if defined( VISUALC ) || defined( BESTA_OS ) + ALLOCA(char, s, l);//char * s = ( char * )alloca( l ); +#else + char s[l]; +#endif + string res("0"); +#ifdef USE_GMP_REPLACEMENTS + if (mpz_sgn(a) == -1){ + mpz_t tmpint; + mpz_init(tmpint); + mpz_neg(tmpint, a); + mpz_get_str(s,8,tmpint); + mpz_clear(tmpint); + res = "-" + res + s; + } + else { + mpz_get_str(s,8,a); + res += s; + } +#else + mpz_get_str (s,8,a) ; + res += s; +#endif // USE_GMP_REPLACEMENTS + + return res; + } + + string binary_print_ZINT(const mpz_t & a){ + size_t l=mpz_sizeinbase (a, 2) + 2; + if (l>unsigned(MAX_PRINTABLE_ZINT)) + return "Integer_too_large"; +#if defined( VISUALC ) || defined( BESTA_OS ) + ALLOCA(char, s, l);//char * s = ( char * )alloca( l ); +#else + char s[l]; +#endif + string res("0b"); +#ifdef USE_GMP_REPLACEMENTS + if (mpz_sgn(a) == -1){ + mpz_t tmpint; + mpz_init(tmpint); + mpz_neg(tmpint, a); + mpz_get_str(s,2,tmpint); + mpz_clear(tmpint); + res = "-" + res + s; + } + else { + mpz_get_str(s,2,a); + res += s; + } +#else + mpz_get_str (s,2,a) ; + res += s; +#endif // USE_GMP_REPLACEMENTS + + return res; + } + + string printinner_VECT(const vecteur & v, int subtype,GIAC_CONTEXT){ + string s; + return add_printinner_VECT(s,v,subtype,contextptr); + } + + string & add_printinner_VECT(string & s,const vecteur &v,int subtype,GIAC_CONTEXT){ + vecteur::const_iterator it=v.begin(), itend=v.end(); + if (it==itend) + return s; + for(;;){ + if ( (subtype==_RPN_FUNC__VECT) && (it->type==_SYMB) && (it->_SYMBptr->sommet==at_quote)) + s += "'"+it->_SYMBptr->feuille.print(contextptr)+"'"; + else { + if ( (it->type==_SYMB && it->_SYMBptr->sommet==at_sto) + // || (it->type==_VECT && it->subtype==_SEQ__VECT && it->_VECTptr->size()>=2) + ) + s += "("+it->print(contextptr)+")"; + else + add_print(s,*it,contextptr); // s += it->print(contextptr); + } + ++it; + if (it==itend){ + return s; + } + if ( (subtype!=_RPN_FUNC__VECT) && + // (subtype || (!rpn_mode(contextptr)) ) && + ( ((it-1)->type!=_SYMB) || ((it-1)->_SYMBptr->sommet!=at_comment) ) + ) + s += ','; + else + s += ' '; + } + } + + string begin_VECT_string(int subtype,bool tex,GIAC_CONTEXT){ + string s; + switch (subtype){ + case _SEQ__VECT: + break; + case _SET__VECT: + if (xcas_mode(contextptr)>0 || calc_mode(contextptr)==1){ + if (tex) + s+="\\{"; + else + s="{"; + } + else + s="set["; + break; + case _RPN_STACK__VECT: + s="stack("; + break; + case _RPN_FUNC__VECT: + s="<< "; + break; + case _GROUP__VECT: + s="group["; + break; +#ifdef HAVE_LIBMPFI + case _INTERVAL__VECT: + s="i["; + break; +#endif + case _LINE__VECT: + s="line["; + break; + case _VECTOR__VECT: + s="vector["; + break; + case _GGBVECT: + s=(calc_mode(contextptr)==1?"ggbvect(":"ggbvect["); + break; +#if !defined(EMCC) && !defined(EMCC2) + case _LOGO__VECT: + s="logo["; + break; +#endif + case _PNT__VECT: + s="pnt["; + break; + case _POINT__VECT: + s="point["; + break; + case _TUPLE__VECT: + s="tuple["; + break; + case _MATRIX__VECT: + if (calc_mode(contextptr)==1) + s="{"; + else { + int pyc=python_compat(contextptr); + // s="matrix["; + if (!os_shell || pyc<0) + s="["; + else + s=abs_calc_mode(contextptr)==38?"[":"matrix["; + } + break; + case _POLY1__VECT: + if (!os_shell) + s="["; + else + s="poly1["; + break; + case _ASSUME__VECT: + s = "assume["; + break; + case _FOLDER__VECT: + s = "folder["; + break; + case _POLYEDRE__VECT: + s= "polyedre["; + break; + case _RGBA__VECT: + s= "rgba["; + break; + case _LIST__VECT: + if (!os_shell) + s="["; + else { + if (tex) + s="\\{"; + else + s=abs_calc_mode(contextptr)==38?"{":"list["; + } + break; + case _GGB__VECT: + if (calc_mode(contextptr)==1) + s="("; // warning: can not be reparsed from giac + else + s="ggbpnt["; + break; + case _TABLE__VECT: + s="{/"; + break; + default: + s=calc_mode(contextptr)==1?"{":"["; + } + return s; + } + + string end_VECT_string(int subtype,bool tex,GIAC_CONTEXT){ + string s; + switch (subtype){ + case _SEQ__VECT: + return s; + case _SET__VECT: + if (xcas_mode(contextptr)>0 || calc_mode(contextptr)==1){ + if (tex) + return "\\}"; + else + return "}"; + } + else + return "]"; + case _RPN_STACK__VECT: + return ")"; + case _RPN_FUNC__VECT: + return " >>"; + case _LIST__VECT: + if (tex) + return "\\}"; + else + return abs_calc_mode(contextptr)==38?"}":"]"; + case _GGB__VECT: + if (calc_mode(contextptr)==1) + return ")"; + else + return "]"; + case _POINT__VECT: case _VECTOR__VECT: case _POLY1__VECT: case _PNT__VECT: + return "]"; + case _GGBVECT: + return calc_mode(contextptr)==1?")":"]"; + case 0: case _MATRIX__VECT: + return calc_mode(contextptr)==1?"}":"]"; + case _TABLE__VECT: + return "/}"; + default: + return calc_mode(contextptr)==1?"}":"]"; + } + } + + const char * svg2doutput(const gen & g,string & S,GIAC_CONTEXT){ +#if defined(EMCC) || defined(EMCC2) + bool fullview=true; + vector vx,vy,vz; + double window_xmin,window_xmax,window_ymin,window_ymax,window_zmin,window_zmax; + bool ortho=autoscaleg(g,vx,vy,vz,contextptr); + autoscaleminmax(vx,window_xmin,window_xmax,fullview); + autoscaleminmax(vy,window_ymin,window_ymax,fullview); + double xscale=window_xmax-window_xmin,yscale=window_ymax-window_ymin; + double ratio=yscale/xscale; + double gratio=0.6,gwidth=9; +#ifndef GIAC_GGB + gwidth=EM_ASM_DOUBLE_V({ + var hw=window.innerWidth; + if (typeof(svgwidth)!="undefined") + return svgwidth*1.0; + if (hw>=1000) + return 9.0*hw/1000.0; + else + return hw/60.0; + }); +#endif // GIAC_GGB + //CERR << gwidth << '\n'; + int maxgratio=ortho?10:3; + if (ratiomaxgratio*gratio) ortho=false; else ortho=true; + if (ortho){ + if (ratio>gratio){ // yscale>gratio*xscale, use yscale for x + double xc=(window_xmax+window_xmin)/2; + window_xmin=xc-yscale/(2*gratio); + window_xmax=xc+yscale/(2*gratio); + } + else { // xscale>yscale/gratio + double yc=(window_ymax+window_ymin)/2; + window_ymin=yc-gratio*xscale/2; + window_ymax=yc+gratio*xscale/2; + } + ratio=gratio; + ortho=false; + } + bool axes=overwrite_viewbox(g,window_xmin,window_xmax,window_ymin,window_ymax,window_zmin,window_zmax); + xscale=window_xmax-window_xmin;yscale=window_ymax-window_ymin; + ratio=yscale/xscale; + //COUT << window_xmin << " " << window_xmax << " " << window_ymin << " " << window_ymax << '\n'; + //g=_symetrie(makesequence(_droite(makesequence(0,1),contextptr),g),contextptr); + //S='"'+svg_preamble(7,7,gnuplot_xmin,gnuplot_xmax,gnuplot_ymin,gnuplot_ymax,ortho,false,default_color(contextptr))+gen2svg(g,contextptr)+svg_grid(gnuplot_xmin,gnuplot_xmax,gnuplot_ymin,gnuplot_ymax,default_color(contextptr))+"\""; + S='"'+svg_preamble_pixel(g,gwidth,gwidth*gratio,window_xmin,window_xmax,window_ymin,window_ymax,ortho,false,default_color(contextptr)); + plot_attr P; + title_legende(g,P); + S= S+(gen2svg(g,window_xmin,window_xmax,window_ymin,window_ymax,ratio/gratio,contextptr,false)+(axes?svg_grid(window_xmin,window_xmax,window_ymin,window_ymax,P,default_color(contextptr))+"\"":"")); +#endif + return S.c_str(); + } + + string print_VECT(const vecteur & v,int subtype,GIAC_CONTEXT){ + if (v.empty()){ + switch (subtype){ + case _SEQ__VECT: + return xcas_mode(contextptr)==1?"NULL":"seq[]"; + case _SET__VECT: + if (xcas_mode(contextptr)>0 || calc_mode(contextptr)==1) + return "{ }"; + else + return "set[ ]"; + case _RPN_FUNC__VECT: + return "<< >>"; + case _RPN_STACK__VECT: + return "stack()"; + } + } +#if 1 // for debugging/profiling pixon_print + if (!v.empty() && is_pnt_or_pixon(v.back())){ + gen f=v.back(); + if (f.is_symb_of_sommet(at_pnt)){ + f=f._SYMBptr->feuille; + if (f.type==_VECT) + f=f._VECTptr->front(); + } + if (f.is_symb_of_sommet(at_pixon)){ + string S; + pixon_print(v,S,contextptr); + return S; + } + } +#endif + string s; + if (subtype==_SPREAD__VECT && !v.empty() && v.front().type==_VECT){ +#if defined(EMCC) || defined(EMCC2) + bool add_quotes=true; + s = "["; +#else + bool add_quotes=false; + s = "spreadsheet["; +#endif + int nr=int(v.size()); + int nc=int(v.front()._VECTptr->size()); + for (int i=0;;){ + int save_r,save_c; + vecteur & w=*v[i]._VECTptr; + s +='['; + for (int j=0;;){ + save_r=printcell_current_row(contextptr); + save_c=printcell_current_col(contextptr); + printcell_current_row(contextptr)=i; + printcell_current_col(contextptr)=j; + if (add_quotes){ + gen tmp=w[j]; + if (tmp.type==_VECT && tmp._VECTptr->size()>=2){ + vecteur & w=*tmp._VECTptr; + s += "['"+w[0].print(contextptr)+"',"; + s += "'"+w[1].print(contextptr)+"',"; + // COUT << i << " " << j << " " << w[1] << '\n'; + if (w[1].type==_STRNG && *w[1]._STRNGptr=="") + s += "'      ']"; + else { + string ms; + if (w[1].is_symb_of_sommet(at_pnt)){ + svg2doutput(w[1],ms,contextptr); // remove quotes + if (ms[0]=='"' && ms[ms.size()-1]=='"') + ms=ms.substr(1,ms.size()-2); + } +#ifndef GIAC_HAS_STO_38 + else + ms=*_mathml(makesequence(w[1],1),contextptr)._STRNGptr; +#endif + string res; + int l=ms.size(); + res.reserve(l); + const char * ch=ms.c_str(); + for (int i=0;i1; + if (paren) s+='('; + for(;;){ + s += it->print(contextptr); + ++it; + if (it==itend){ + if (paren) + return s+')'; + return s; + } + s += '+'; + } + } + + string print_the_type(int val,GIAC_CONTEXT){ + if (xcas_mode(contextptr)==1){ + switch(val){ + case _INT_: + return "integer"; + case _DOUBLE_: + return "double"; + case _FLOAT_: + return "float"; + case _ZINT: + return "integer"; + case _CPLX: + return "complex"; + case _VECT: + return "vector"; + case _IDNT: + return "symbol"; + case _SYMB: + return "algebraic"; + case _FRAC: + return "rational"; + case _MAPLE_LIST: + return "list"; + } + } + if (abs_calc_mode(contextptr)!=38){ + switch(val){ + case _DOUBLE_: + return "real"; + case _ZINT: + return "integer"; + case _CPLX: + return "complex"; + case _VECT: + return "vector"; + case _IDNT: + return "identifier"; + case _SYMB: + return "expression"; + case _FRAC: + return "rational"; + case _STRNG: + return "string"; + case _FUNC: + return "func"; + } + } + switch(val){ + case _INT_: + return "DOM_int"; + case _DOUBLE_: + return "DOM_FLOAT"; + case _FLOAT_: + return "DOM_SPECIALFLOAT"; + case _ZINT: + return "DOM_INT"; + case _CPLX: + return "DOM_COMPLEX"; + case _VECT: + return "DOM_LIST"; + case _IDNT: + return "DOM_IDENT"; + case _SYMB: + return "DOM_SYMBOLIC"; + case _FRAC: + return "DOM_RAT"; + case _STRNG: + return "DOM_STRING"; + case _FUNC: + return "DOM_FUNC"; + case _REAL: + return "DOM_LONGFLOAT"; + case _MAP: + return "DOM_MAP"; + case _SPOL1: + return "DOM_SERIES"; + } + return print_INT_(val); + } + + string print_STRNG(const string & s){ + string res("\""); + int l=int(s.size()); + for (int i=0;i0 || python_compat(contextptr)<0) + return "I"; + else + return "i"; + } + + static string print_EQW(const eqwdata & e){ + string s; + s += "eqwdata(position"+print_INT_(e.x)+","+print_INT_(e.y)+",dxdy,"+print_INT_(e.dx)+","+print_INT_(e.dy); + s += ",font,"+print_INT_(e.eqw_attributs.fontsize); + s += ",background," +print_INT_(e.eqw_attributs.background); + s += ",text_color," +print_INT_(e.eqw_attributs.text_color)+","; + if (e.selected) + s +="selected,"; + if (e.active) + s +="active,"; + s += e.g.print(context0)+")"; + return s; + } + + string gen::print() const{ + return print(context0); + } + + // FIXME!!! + int gen::sprint(std::string * sptr,GIAC_CONTEXT) const{ + return 0; + } + + string gen::print_universal(GIAC_CONTEXT) const{ + int lang=language(contextptr); + language(-1,contextptr); + string res; +#ifdef NO_STDEXCEPT + res=print(contextptr); +#else + try { + res=print(contextptr); + } + catch (...){ } +#endif + language(lang,contextptr); + return res; + } + + wchar_t * gen::wprint(GIAC_CONTEXT) const { + string s=print(contextptr); + unsigned int ss=unsigned(s.size()); + wchar_t * ptr = (wchar_t *) malloc(sizeof(wchar_t)*(ss+1)); + /* + unsigned int l=utf82unicode(s.c_str(),ptr,ss); + if (l0){ + if (val) + return "True"; + else + return "False"; + } + if (xcas_mode(contextptr)==2){ + if (val) + return "TRUE"; + else + return "FALSE"; + } + else { + if (val) + return "true"; + else + return "false"; + } + } + if (subtype==_INT_COLOR){ + switch (language(contextptr)){ + case 1: + switch (val){ + case _BLACK: + return "noir"; + case _RED: + return "rouge"; + case _GREEN: + return "vert"; + case _YELLOW: + return "jaune"; + case _BLUE: + return "bleu"; + case _MAGENTA: + return "magenta"; + case _CYAN: + return "cyan"; + case _WHITE: + return "blanc"; + case _FILL_POLYGON: + return "rempli"; + case _QUADRANT2: + return "quadrant2"; + case _QUADRANT3: + return "quadrant3"; + case _QUADRANT4: + return "quadrant4"; + case _POINT_LOSANGE: + return "point_losange"; + case _POINT_CARRE: + return "point_carre"; + case _POINT_PLUS: + return "point_plus"; + case _POINT_TRIANGLE: + return "point_triangle"; + case _POINT_ETOILE: + return "point_etoile"; + case _POINT_POINT: + return "point_point"; + case _POINT_INVISIBLE: + return "point_invisible"; + case 49: + return "gomme"; + case _LINE_WIDTH_2: + return "epaisseur_ligne_2"; + case _LINE_WIDTH_3: + return "epaisseur_ligne_3"; + case _LINE_WIDTH_4: + return "epaisseur_ligne_4"; + case _LINE_WIDTH_5: + return "epaisseur_ligne_5"; + case _LINE_WIDTH_6: + return "epaisseur_ligne_6"; + case _LINE_WIDTH_7: + return "epaisseur_ligne_7"; + case _LINE_WIDTH_8: + return "epaisseur_ligne_8"; + case _POINT_WIDTH_2: + return "epaisseur_point_2"; + case _POINT_WIDTH_3: + return "epaisseur_point_3"; + case _POINT_WIDTH_4: + return "epaisseur_point_4"; + case _POINT_WIDTH_5: + return "epaisseur_point_5"; + case _POINT_WIDTH_6: + return "epaisseur_point_6"; + case _POINT_WIDTH_7: + return "epaisseur_point_7"; + case _POINT_WIDTH_8: + return "epaisseur_point_8"; + case _HIDDEN_NAME: + return "nom_cache"; + case _DASH_LINE: + return "ligne_tiret"; + case _DOT_LINE: + return "ligne_point"; + case _DASHDOT_LINE: + return "ligne_tiret_point"; + case _DASHDOTDOT_LINE: + return "ligne_tiret_pointpoint"; + case _CAP_FLAT_LINE: + return "ligne_chapeau_plat"; + case _CAP_ROUND_LINE: + return "ligne_chapeau_rond"; + case _CAP_SQUARE_LINE: + return "ligne_chapeau_carre"; + } + break; + case 4: + switch (val){ + case _BLACK: + return "black"; + case _RED: + return "red"; + case _GREEN: + return "green"; + case _YELLOW: + return "yellow"; + case _BLUE: + return "blue"; + case _MAGENTA: + return "magenta"; + case _CYAN: + return "cyan"; + case _WHITE: + return "white"; + case _FILL_POLYGON: + return "filled"; + case _QUADRANT2: + return "quadrant2"; + case _QUADRANT3: + return "quadrant3"; + case _QUADRANT4: + return "quadrant4"; + case _POINT_LOSANGE: + return "ρομβοειδές_σημείο"; + case _POINT_CARRE: + return "τετραγωνικό_σημείο"; + case _POINT_PLUS: + return "σταυροειδές_σημείο"; + case _POINT_TRIANGLE: + return "τριγωνικό_σημείο"; + case _POINT_ETOILE: + return "αστροειδές_σημείο"; + case _POINT_POINT: + return "point_point"; + case _POINT_INVISIBLE: + return "αόρατο_σημείο"; + case 49: + return "gomme"; + case _LINE_WIDTH_2: + return "εύρος_γραμμής_2"; + case _LINE_WIDTH_3: + return "εύρος_γραμμής_3"; + case _LINE_WIDTH_4: + return "εύρος_γραμμής_4"; + case _LINE_WIDTH_5: + return "εύρος_γραμμής_5"; + case _LINE_WIDTH_6: + return "εύρος_γραμμής_6"; + case _LINE_WIDTH_7: + return "εύρος_γραμμής_7"; + case _LINE_WIDTH_8: + return "εύρος_γραμμής_8"; + case _POINT_WIDTH_2: + return "εύρος_σημείου_2"; + case _POINT_WIDTH_3: + return "εύρος_σημείου_3"; + case _POINT_WIDTH_4: + return "εύρος_σημείου_4"; + case _POINT_WIDTH_5: + return "εύρος_σημείου_5"; + case _POINT_WIDTH_6: + return "εύρος_σημείου_6"; + case _POINT_WIDTH_7: + return "εύρος_σημείου_7"; + case _POINT_WIDTH_8: + return "εύρος_σημείου_8"; + case _HIDDEN_NAME: + return "hidden_name"; + case _DASH_LINE: + return "γραμμή_διακεκομμένη"; + case _DOT_LINE: + return "παύλα_τελεία"; + case _DASHDOT_LINE: + return "γραμμή_παύλα_τελεία"; + case _DASHDOTDOT_LINE: + return "γραμμή_παύλα_τελείατελεία"; + case _CAP_FLAT_LINE: + return "γραμμή_επίπεδο_καβούκι"; + case _CAP_ROUND_LINE: + return "γραμμή_στρογγυλό_καβούκι"; + case _CAP_SQUARE_LINE: + return "γραμμή_τετράγωνο_καβούκι"; + } + default: + switch (val){ + case _BLACK: + return "black"; + case _RED: + return "red"; + case _GREEN: + return "green"; + case _YELLOW: + return "yellow"; + case _BLUE: + return "blue"; + case _MAGENTA: + return "magenta"; + case _CYAN: + return "cyan"; + case _WHITE: + return "white"; + case _FILL_POLYGON: + return "filled"; + case _QUADRANT2: + return "quadrant2"; + case _QUADRANT3: + return "quadrant3"; + case _QUADRANT4: + return "quadrant4"; + case _POINT_LOSANGE: + return "rhombus_point"; + case _POINT_CARRE: + return "square_point"; + case _POINT_PLUS: + return "plus_point"; + case _POINT_TRIANGLE: + return "triangle_point"; + case _POINT_ETOILE: + return "star_point"; + case _POINT_POINT: + return "point_point"; + case _POINT_INVISIBLE: + return "invisible_point"; + case 49: + return "gomme"; + case _LINE_WIDTH_2: + return "line_width_2"; + case _LINE_WIDTH_3: + return "line_width_3"; + case _LINE_WIDTH_4: + return "line_width_4"; + case _LINE_WIDTH_5: + return "line_width_5"; + case _LINE_WIDTH_6: + return "line_width_6"; + case _LINE_WIDTH_7: + return "line_width_7"; + case _LINE_WIDTH_8: + return "line_width_8"; + case _POINT_WIDTH_2: + return "point_width_2"; + case _POINT_WIDTH_3: + return "point_width_3"; + case _POINT_WIDTH_4: + return "point_width_4"; + case _POINT_WIDTH_5: + return "point_width_5"; + case _POINT_WIDTH_6: + return "point_width_6"; + case _POINT_WIDTH_7: + return "point_width_7"; + case _POINT_WIDTH_8: + return "point_width_8"; + case _HIDDEN_NAME: + return "hidden_name"; + case _DASH_LINE: + return "dash_line"; + case _DOT_LINE: + return "dot_line"; + case _DASHDOT_LINE: + return "dashdot_line"; + case _DASHDOTDOT_LINE: + return "dashdotdot_line"; + case _CAP_FLAT_LINE: + return "cap_flat_line"; + case _CAP_ROUND_LINE: + return "cap_round_line"; + case _CAP_SQUARE_LINE: + return "cap_square_line"; + } + } + // switch (val){ } + } + if (subtype==_INT_PLOT){ + switch(val){ + case _ADAPTIVE: + return "adaptive"; + case _AXES: + return "axes"; + case _COLOR: + return "color"; + case _FILLED: + return "filled"; + case _FONT: + return "font"; + case _LABELS: + return "labels"; + case _LEGEND: + return "legend"; + case _LINESTYLE: + return "linestyle"; + case _RESOLUTION: + return "resolution"; + case _SAMPLE: + return "sample"; + case _SCALING: + return "scaling"; + case _STYLE: + return "style"; + case _SYMBOL: + return "symbol"; + case _SYMBOLSIZE: + return "symbolsize"; + case _THICKNESS: + return "thickness"; + case _TITLE: + return "title"; + case _TITLEFONT: + return "titlefont"; + case _VIEW: + return "view"; + case _AXESFONT: + return "axesfont"; + case _COORDS: + return "coords"; + case _LABELFONT: + return "labelfont"; + case _LABELDIRECTIONS: + return "labeldirections"; + case _NUMPOINTS: + return "numpoints"; + case _TICKMARKS: + return "tickmarks"; + case _XTICKMARKS: + return "xtickmarks"; + case _NSTEP: + return "nstep"; + case _XSTEP: + return "xstep"; + case _YSTEP: + return "ystep"; + case _ZSTEP: + return "zstep"; + case _TSTEP: + return "tstep"; + case _USTEP: + return "ustep"; + case _VSTEP: + return "vstep"; + case _FRAMES: + return "frames"; + case _GL_TEXTURE: + return "gl_texture"; + case _GL_LIGHT0: + return "gl_light0"; + case _GL_LIGHT1: + return "gl_light1"; + case _GL_LIGHT2: + return "gl_light2"; + case _GL_LIGHT3: + return "gl_light3"; + case _GL_LIGHT4: + return "gl_light4"; + case _GL_LIGHT5: + return "gl_light5"; + case _GL_LIGHT6: + return "gl_light6"; + case _GL_LIGHT7: + return "gl_light7"; + case _GL_AMBIENT: + return "gl_ambient"; + case _GL_SPECULAR: + return "gl_specular"; + case _GL_DIFFUSE: + return "gl_diffuse"; + case _GL_POSITION: + return "gl_position"; + case _GL_SPOT_DIRECTION: + return "gl_spot_direction"; + case _GL_SPOT_EXPONENT: + return "gl_spot_exponent"; + case _GL_SPOT_CUTOFF: + return "gl_spot_cutoff"; + case _GL_CONSTANT_ATTENUATION: + return "gl_constant_attenuation"; + case _GL_LINEAR_ATTENUATION: + return "gl_linear_attenuation"; + case _GL_QUADRATIC_ATTENUATION: + return "gl_quadratic_attenuation"; + case _GL_OPTION: + return "gl_option"; + case _GL_SMOOTH: + return "gl_smooth"; + case _GL_FLAT: + return "gl_flat"; + case _GL_SHININESS: + return "gl_shininess"; + case _GL_FRONT: + return "gl_front"; + case _GL_BACK: + return "gl_back"; + case _GL_FRONT_AND_BACK: + return "gl_front_and_back"; + case _GL_AMBIENT_AND_DIFFUSE: + return "gl_ambient_and_diffuse"; + case _GL_EMISSION: + return "gl_emission"; + case _GL_LIGHT_MODEL_AMBIENT: + return "gl_light_model_ambient"; + case _GL_LIGHT_MODEL_LOCAL_VIEWER: + return "gl_light_model_local_viewer"; + case _GL_LIGHT_MODEL_TWO_SIDE: + return "gl_light_model_two_side"; + case _GL_LIGHT_MODEL_COLOR_CONTROL: + return "gl_light_model_color_control"; + case _GL_BLEND: + return "gl_blend"; + case _GL_SRC_ALPHA: + return "gl_src_alpha"; + case _GL_ONE_MINUS_SRC_ALPHA: + return "gl_one_minus_src_alpha"; + case _GL_SEPARATE_SPECULAR_COLOR: + return "gl_separate_specular_color"; + case _GL_SINGLE_COLOR: + return "gl_single_color"; + case _GL_MATERIAL: + return "gl_material"; + case _GL_COLOR_INDEXES: + return "gl_color_indexes"; + case _GL_LIGHT: + return "gl_light"; + case _GL_PERSPECTIVE: + return "gl_perspective"; + case _GL_ORTHO: + return "gl_ortho"; + case _GL_QUATERNION: + return "gl_quaternion"; + case _GL_ROTATION_AXIS: + return "gl_rotation_axis"; + case _GL_X: + return "gl_x"; + case _GL_Y: + return "gl_y"; + case _GL_Z: + return "gl_z"; + case _GL_XTICK: + return "gl_xtick"; + case _GL_YTICK: + return "gl_ytick"; + case _GL_ZTICK: + return "gl_ztick"; + case _GL_ANIMATE: + return "gl_animate"; + case _GL_SHOWAXES: + return "gl_showaxes"; + case _GL_SHOWNAMES: + return "gl_shownames"; + case _GL_X_AXIS_NAME: + return "gl_x_axis_name"; + case _GL_Y_AXIS_NAME: + return "gl_y_axis_name"; + case _GL_Z_AXIS_NAME: + return "gl_z_axis_name"; + case _GL_X_AXIS_UNIT: + return "gl_x_axis_unit"; + case _GL_Y_AXIS_UNIT: + return "gl_y_axis_unit"; + case _GL_Z_AXIS_UNIT: + return "gl_z_axis_unit"; + case _GL_LOGX: + return "gl_logx"; + case _GL_LOGY: + return "gl_logy"; + case _GL_LOGZ: + return "gl_logz"; + } + } + if (subtype==_INT_MAPLELIB){ + switch (val){ + case _LINALG: + return "linalg"; + case _NUMTHEORY: + return "numtheory"; + case _GROEBNER: + return "groebner"; + } + } + if (subtype==_INT_MAPLECONVERSION){ + switch (val){ + case _MAPLE_LIST: + return "list"; + case _SET__VECT: + return "set"; + case _MATRIX__VECT: + return "matrix"; + case _POLY1__VECT: + return "polynom"; + case _TRIG: + return "trig"; + case _EXPLN: + return "expln"; + case _PARFRAC: + return "parfrac"; + case _FULLPARFRAC: + return "fullparfrac"; + case _CONFRAC: + return "confrac"; + case _BASE: + return "base"; + case _POSINT: + return "posint"; + case _NEGINT: + return "negint"; + case _NONPOSINT: + return "nonposint"; + case _NONNEGINT: + return "nonnegint"; + case _LP_BINARY: + return "lp_binary"; + case _LP_BINARYVARIABLES: + return "lp_binaryvariables"; + case _LP_DEPTHLIMIT: + return "lp_depthlimit"; + case _LP_INTEGER: + return "lp_integer"; + case _LP_INTEGERVARIABLES: + return "lp_integervariables"; + case _LP_MAXIMIZE: + return "lp_maximize"; + case _LP_NONNEGATIVE: + return "lp_nonnegative"; + case _LP_NONNEGINT: + return "lp_nonnegint"; + case _LP_ASSUME: + return "lp_assume"; + case _LP_NODE_LIMIT: + return "lp_nodelimit"; + case _LP_METHOD: + return "lp_method"; + case _LP_SIMPLEX: + return "lp_simplex"; + case _LP_INTERIOR_POINT: + return "lp_interiorpoint"; + case _LP_MAX_CUTS: + return "lp_maxcuts"; + case _LP_GAP_TOLERANCE: + return "lp_gaptolerance"; + case _LP_NODESELECT: + return "lp_nodeselect"; + case _LP_VARSELECT: + return "lp_varselect"; + case _LP_FIRSTFRACTIONAL: + return "lp_firstfractional"; + case _LP_LASTFRACTIONAL: + return "lp_lastfractional"; + case _LP_MOSTFRACTIONAL: + return "lp_mostfractional"; + case _LP_PSEUDOCOST: + return "lp_pseudocost"; + case _LP_DEPTHFIRST: + return "lp_depthfirst"; + case _LP_BREADTHFIRST: + return "lp_breadthfirst"; + case _LP_BEST_LOCAL_BOUND: + return "lp_bestlocalbound"; + case _LP_BEST_PROJECTION: + return "lp_bestprojection"; + case _LP_HYBRID: + return "lp_hybrid"; + case _LP_ITERATION_LIMIT: + return "lp_iterationlimit"; + case _LP_TIME_LIMIT: + return "lp_timelimit"; + case _LP_VERBOSE: + return "lp_verbose"; + case _LP_HEURISTIC: + return "lp_heuristic"; + case _NLP_PRESOLVE: + return "nlp_presolve"; + case _NLP_METHOD: + return "nlp_method"; + case _NLP_SAMPLES: + return "nlp_samples"; + case _NLP_INTEGER: + return "nlp_integer"; + case _NLP_INTEGERVARIABLES: + return "nlp_integervariables"; + case _NLP_BINARY: + return "nlp_binary"; + case _NLP_BINARYVARIABLES: + return "nlp_binaryvariables"; + case _NLP_NONNEGINT: + return "nlp_nonnegint"; + case _NLP_TOLERANCE: + return "nlp_tolerance"; + case _NLP_VERBOSE: + return "nlp_verbose"; + case _NLP_FEAS_TOL: + return "nlp_feasibilitytolerance"; + case _NLP_INT_TOL: + return "nlp_integertolerance"; + case _LP_PRESOLVE: + return "lp_presolve"; + case _NLP_INITIALPOINT: + return "nlp_initialpoint"; + case _NLP_ITERATIONLIMIT: + return "nlp_iterationlimit"; + case _NLP_NONNEGATIVE: + return "nlp_nonnegative"; + case _NLP_PRECISION: + return "nlp_precision"; + case _NLP_MAXIMIZE: + return "nlp_maximize"; + case _GT_CONNECTED: + return "connected"; + case _GT_SPRING: + return "spring"; + case _GT_TREE: + return "tree"; + case _GT_PLANAR: + return "planar"; + case _GT_DIRECTED: + return "directed"; + case _GT_WEIGHTED: + return "weighted"; + case _GT_WEIGHTS: + return "weights"; + case _GT_BIPARTITE: + return "bipartite"; + case _GT_ACYCLIC: + return "acyclic"; + case _KDE_BANDWIDTH: + return "bandwidth"; + case _KDE_BINS: + return "bins"; + case _ANN_LEARNING_RATE: + return "learning_rate"; + case _ANN_WEIGHT_DECAY: + return "weight_decay"; + case _ANN_RELU: + return "ReLU"; + case _ANN_HALF_MSE: + return "MSE"; + case _ANN_CROSS_ENTROPY: + return "cross_entropy"; + case _ANN_LOG_LOSS: + return "log_loss"; + case _ANN_BLOCK_SIZE: + return "block_size"; + case _ANN_MOMENTUM: + return "momentum"; + case _ANN_TOPOLOGY: + return "topology"; + } + } + if (subtype==_INT_MUPADOPERATOR){ + switch (val){ + case _DELETE_OPERATOR: + return "Delete"; + case _PREFIX_OPERATOR: + return "Prefix"; + case _POSTFIX_OPERATOR: + return "Postfix"; + case _BINARY_OPERATOR: + return "Binary"; + case _NARY_OPERATOR: + return "Nary"; + } + } + if (subtype==_INT_GROEBNER){ + switch (val){ + case _REVLEX_ORDER: + return "revlex"; + case _PLEX_ORDER: + return "plex"; + case _TDEG_ORDER: + return "tdeg"; + case _WITH_COCOA: + return "with_cocoa"; + case _WITH_F5: + return "with_f5"; + case _MODULAR_CHECK: + return "modular_check"; + case _RUR_REVLEX: + return "rur"; + } + } + return print_INT_(val); + } + + static void print_float(const float & f,char * ch){ + sprintfdouble(ch,"%.14g",f); + } + + string print_FLOAT_(const giac_float & f,GIAC_CONTEXT){ + char ch[64]; +#ifdef BCD +#ifndef CAS38_DISABLED + int i=get_int(f); + if (is_zero(f-i)) + return print_INT_(i)+'.'; +#endif + print_float(f,ch); +#else + print_float(f,ch); +#endif + return ch; + } + + static string print_FRAC(const gen & f,GIAC_CONTEXT){ + if (f._FRACptr->num.type==_INT_ && f._FRACptr->den.type==_INT_){ + string s(f._FRACptr->num.print(contextptr)); + s += "/"; + add_print(s,f._FRACptr->den,contextptr); + return s; + } + if (calc_mode(contextptr)==1 && f._FRACptr->den.type==_CPLX){ + gen n=f._FRACptr->num,d=f._FRACptr->den,dr,di; + reim(d,dr,di,contextptr); + n=n*gen(dr,-di); + d=dr*dr+di*di; + gen nd=fraction(n,d); + if (nd.type==_FRAC) + return print_FRAC(nd,contextptr); + else + return nd.print(contextptr); + } + return _FRAC2_SYMB(f).print(contextptr); + } + + string gen::print(GIAC_CONTEXT) const{ + switch (type ) { + case _INT_: + if (val<0 && val != (1<<31) && calc_mode(contextptr)==38) + return "−"+(-*this).print(contextptr); + if (subtype) + return localize(printint32(val,subtype,contextptr),language(contextptr)); + switch (integer_format(contextptr)){ + case 16: + return hexa_print_INT_(val); + case 8: + return octal_print_INT_(val); + case 2: + return binary_print_INT_(val); + default: + return print_INT_(val); + } + case _DOUBLE_: + return print_DOUBLE_(_DOUBLE_val,contextptr); + case _FLOAT_: + if (abs_calc_mode(contextptr)==38 && is_strictly_positive(-*this,contextptr)) return "−"+print_FLOAT_(-_FLOAT_val,contextptr); + return print_FLOAT_(_FLOAT_val,contextptr); + case _ZINT: + if (abs_calc_mode(contextptr)==38 && is_strictly_positive(-*this,contextptr)) + return "−"+(-*this).print(contextptr); + switch (integer_format(contextptr)){ + case 16: + return hexa_print_ZINT(*_ZINTptr); + case 8: + return octal_print_ZINT(*_ZINTptr); + default: + return print_ZINT(*_ZINTptr); + } + case _REAL: + return _REALptr->print(contextptr); + case _CPLX: + // if (abs_calc_mode(contextptr)==38) return "("+_CPLXptr->print(contextptr)+","+(_CPLXptr+1)->print(contextptr)+")"; + if (is_exactly_zero(*(_CPLXptr+1))) + return _CPLXptr->print(contextptr); +#ifndef GIAC_GGB + if (*complex_display_ptr(*this) &1){ +#ifdef BCD + if (_CPLXptr->type==_FLOAT_ && (_CPLXptr+1)->type==_FLOAT_) +#ifdef GIAC_HAS_STO_38 + //grad + return abs(*this,contextptr).print(contextptr)+"\xe2\x88\xa1"+print_FLOAT_(atan2f(_CPLXptr->_FLOAT_val,(_CPLXptr+1)->_FLOAT_val,angle_radian(contextptr)?AMRad:(angle_degree(contextptr)?AMDeg:AMGrad)),contextptr); +#else + return abs(*this,contextptr).print(contextptr)+"\xe2\x88\xa1"+print_FLOAT_(atan2f(_CPLXptr->_FLOAT_val,(_CPLXptr+1)->_FLOAT_val,angle_radian(contextptr)),contextptr); +#endif +#endif + // return abs(*this,contextptr).print(contextptr)+"\xe2\x88\xa1"+(angle_radian(contextptr)?arg(*this,contextptr):arg(*this,contextptr)*rad2deg_g).print(contextptr); + return abs(*this,contextptr).print(contextptr)+"\xe2\x88\xa1"+arg(*this,contextptr).print(contextptr); + } +#endif // GIAC_GGB + if (is_exactly_zero(*_CPLXptr)){ + if (is_one(*(_CPLXptr+1))) + return printi(contextptr); + if (is_minus_one(*(_CPLXptr+1))) + return (abs_calc_mode(contextptr)==38?string("−"):string("-"))+printi(contextptr); + return ((_CPLXptr+1)->print(contextptr) + string("*"))+printi(contextptr); + } + if (is_one(*(_CPLXptr+1))) + return (_CPLXptr->print(contextptr) + string("+"))+printi(contextptr); + if (is_minus_one(*(_CPLXptr+1))) + return (_CPLXptr->print(contextptr) + string("-"))+printi(contextptr); + if (is_positive(-(*(_CPLXptr+1)),contextptr)) + return (_CPLXptr->print(contextptr) + string("-") + (-(*(_CPLXptr+1))).print(contextptr) + "*")+printi(contextptr); + return (_CPLXptr->print(contextptr) + string("+") + (_CPLXptr+1)->print(contextptr) + "*")+printi(contextptr); + case _IDNT: + if (calc_mode(contextptr)==1 && (is_inf(*this) || is_undef(*this))) + return "?"; + return _IDNTptr->print(contextptr); + case _SYMB: + { + int d=depth(*this,0,print_max_depth); + if (d>=print_max_depth) + return "Too many embeddings"; + } + if (is_inf(_SYMBptr->feuille)){ + if (_SYMBptr->sommet==at_plus){ +#ifdef KHICAS + return "oo"; +#else + if ( + // calc_mode(contextptr)!=1 + abs_calc_mode(contextptr)==38 + ) + return "∞"; + else + return "+infinity"; +#endif + } + if (_SYMBptr->sommet==at_neg){ +#ifdef KHICAS + return "-oo"; +#else + if ( + // calc_mode(contextptr)!=1 + abs_calc_mode(contextptr)==38 + ) + return "-∞"; + else + return "-infinity"; +#endif + } + } + if (subtype==_SPREAD__SYMB){ + if (_SYMBptr->sommet==at_sto) + return "=("+_SYMBptr->print(contextptr)+")"; + return "="+_SYMBptr->print(contextptr); + } + else + return _SYMBptr->print(contextptr); + case _VECT: + if (subtype==_GRAPH__VECT){ + string s; + if (is_graphe(*this,s,contextptr)) + return '"'+s+'"'; + } + return print_VECT(*_VECTptr,subtype,contextptr); + case _POLY: + return _POLYptr->print() ; + case _SPOL1: + return print_SPOL1(*_SPOL1ptr,contextptr); + case _EXT: { + string s("%%{"); + s += _EXTptr->print(contextptr); + s += ':'; + s += (*(_EXTptr+1)).print(contextptr); + s += "%%}"; + return s; + } + case _USER: + return _USERptr->print(contextptr); + case _MOD: +#ifdef GIAC_HAS_STO_38 + if ( (_MODptr->type==_SYMB && _MODptr->_SYMBptr->sommet!=at_pow) || (_MODptr->type==_VECT && _MODptr->subtype==_SEQ__VECT) ) + return "("+_MODptr->print(contextptr)+") %% "+(*(_MODptr+1)).print(contextptr); + return _MODptr->print(contextptr)+" %% "+(*(_MODptr+1)).print(contextptr); +#else + if ( (_MODptr->type==_SYMB && _MODptr->_SYMBptr->sommet!=at_pow) || (_MODptr->type==_VECT && _MODptr->subtype==_SEQ__VECT) ) + return "("+_MODptr->print(contextptr)+")"+(python_compat(contextptr)?" mod ":" % ")+(*(_MODptr+1)).print(contextptr); + return _MODptr->print(contextptr)+(python_compat(contextptr)?" mod ":" % ")+(*(_MODptr+1)).print(contextptr); +#endif + case _FRAC: + return print_FRAC(*this,contextptr); + case _STRNG: +#ifdef GIAC_HAS_STO_38 + // if (subtype==-1) + // return AspenPrintErrorString(*_STRNGptr); +#endif + return print_STRNG(*_STRNGptr); + case _FUNC: + if (*this==at_return){ + if (xcas_mode(contextptr)==3) + return "Return"; + else + return "return ;"; + } + if (rpn_mode(contextptr) || _FUNCptr->ptr()->printsommet==&printastifunction || subtype==0) + return _FUNCptr->ptr()->print(contextptr); + else + return string("'")+_FUNCptr->ptr()->print(contextptr)+"'"; + case _MAP: + if (subtype==1) + return maptoarray(*_MAPptr,contextptr).print(contextptr); + else + return printmap(*_MAPptr,contextptr); + case _EQW: + return print_EQW(*_EQWptr); + case _POINTER_: { + // handle 64 bits pointers + unsigned long long u=(unsigned long long)_POINTER_val; + if (u<(1U<<31)) + return "pointer("+hexa_print_INT_(int((alias_type)_POINTER_val))+","+print_INT_(subtype)+")"; + gen z=longlong(u); + return "pointer("+hexa_print_ZINT(*z._ZINTptr)+","+print_INT_(subtype)+")"; + } + default: +#ifndef NO_STDEXCEPT + settypeerr(gettext("print")); +#endif + return "print error"; + } + return "print error"; + } + +#ifdef ConnectivityKit + const char * gen::dbgprint() const { return "Done";} +#else +#if defined(VISUALC) && !defined(MS_SMART) +#include + const char * gen::dbgprint() const { ATLTRACE2("%s\r\n", this->print(0).c_str()); return "Done";} +#else + const char * gen::dbgprint() const{ + if (this->type==_POLY) + return _POLYptr->dbgprint(); + static string *sptr=0; + if (!sptr) sptr=new string; + *sptr=this->print(context0); +#if 0 // ndef NSPIRE + COUT << *sptr; +#endif + return sptr->c_str(); + } +#endif +#endif + +#ifdef KHICAS + stdostream & operator << (stdostream & os,const gen & a){ + return os << a.print(context0); + } +#endif +#ifndef NSPIRE + ostream & operator << (ostream & os,const gen & a) { return os << a.print(context0); } +#endif + + string monome::print(GIAC_CONTEXT) const { + // if (abs_calc_mode(contextptr)==38 ) + return "%%%{" + coeff.print(contextptr) + ',' + exponent.print(contextptr) + "%%%}" ; + //return "<<" + coeff.print(contextptr) + ',' + exponent.print(contextptr) + ">>" ; + } + + const char * monome::dbgprint() const { + static string *sptr=0; + if (!sptr) sptr=new string; + *sptr=this->print(context0); +#if 0 // ndef NSPIRE + COUT << *sptr; +#endif + return sptr->c_str(); + } + +#ifndef NSPIRE + ostream & operator << (ostream & os,const monome & m){ + return os << m.print(context0) ; + } +#endif + + /* + gen string2_ZINT(string s,int l,int & pos){ + char ss[l+1]; + int neg=1; + if (s[pos]=='-'){ + pos++; + neg=-1; + } + int i=0; + for (;(pos='0') && (s[pos]<='9');pos++,i++) + ss[i]=s[pos]; + if ((!i) && (s[pos]=='i') || (s[pos]=='I')){ + return(neg); + } + assert(i); + ss[i]=char(0); + mpz_t *mpzin = new mpz_t[1]; + mpz_init(*mpzin); + mpz_set_str (*mpzin, ss, 10); + if (neg>0) + return(gen(mpzin)); + else + return(-gen(mpzin)); + } + + istream & operator >> (istream & is,gen & a){ + string s; + is >> s; + int l=s.size(); + int pos=0; + a=gen(0); + while (pos nio::ios_base & operator>>(nio::ios_base & is,gen & a){ + string s; + is >> s; + a = gen(s,context0); + return is; + } +#else + istream & operator >> (istream & is,gen & a){ + string s; + is >> s; + a = gen(s,context0); + return is; + } +#endif + + /* Some string utilities not use anymore */ + // Note that this function should be optimized for large input + string cut_string(const string & chaine,int nchar,vector & ligne_end) { + // CERR << CLOCK() << '\n'; + int pos; + if (ligne_end.empty()) + pos=0; + else + pos=ligne_end.back()+1; + int l=int(chaine.size()); + string res; + for (int i=0;i=l-1)) ){ + ligne_end.push_back(pos+l); + // CERR << CLOCK() << '\n'; + return res+chaine.substr(i,l-i); + } + if ((k>=i) && (k & endlines,vector & positions){ + string res; + endlines.clear(); + positions.clear(); + int s_in=int(history_in.size()),s_out=int(history_out.size()); + int s=giacmax(s_in,s_out); + for (int i=0;i=0) && (pospos1;){ + --i; + char ch = s[i]; + if (ch=='(') + ++counter1; + if (ch==')') + --counter1; + if (ch=='[') + ++counter2; + if (ch==']') + --counter2; + } + } + for (;pos1>=0;--pos1){ + char ch=s[pos1]; + if ( (!counter1) && (!counter2) && ( (ch=='(') || (ch=='[') || (ch=='+') || (ch=='-') || (ch==',') )){ + if ( (pos1=0;--pos1) + if (!isalphan(s[pos1])) + break; + ++pos1; + } + break; + } + } + if (ch==')') + --counter1; + if (ch=='['){ + ++counter2; + if ( (!counter1) && (!counter2) ){ + if (s[pos2-1]==']') + break; + if ( pos1 && isalphan(s[pos1-1])){ + --pos1; + for (;pos1>=0;--pos1) + if (!isalphan(s[pos1])) + break; + ++pos1; + } + break; + } + } + if (ch==']') + --counter2; + } + } + + static void find_right(const string & s,int & pos1,int & pos2){ + int l=int(s.size()); + pos1=giacmin(giacmax(pos1,0),l); + pos2=giacmax(giacmin(pos2,l),0); + int pos2orig=pos2; + int counter1=0,counter2=0; + for (int i=pos1;(ipos2orig)){ + --pos2; + break; + } + if (ch=='(') + ++counter1; + if (ch==')'){ + --counter1; + if ( (!counter1) && (!counter2) ){ + if ( (pos1>0) && (s[pos1]=='(') && isalphan(s[pos1-1])){ + --pos1; + for (;pos1>=0;--pos1) + if (!isalphan(s[pos1])) + break; + ++pos1; + } + break; + } + } + if (ch=='[') + ++counter2; + if (ch==']'){ + --counter2; + if ( (!counter1) && (!counter2) ){ + if ( (pos1>0) && (s[pos1]=='[') && isalphan(s[pos1-1])){ + --pos1; + for (;pos1>=0;--pos1) + if (!isalphan(s[pos1])) + break; + ++pos1; + } + break; + } + } + } + if (pos2==l+1) + find_left(s,pos1,pos2); + } + + void increase_selection(const string & s,int & pos1,int& pos2){ + int l=int(s.size()); + int pos1_orig(pos1),pos2_orig(pos2); + // adjust selection (does not change anything on a valid selection) + find_left(s,pos1,pos2); + find_right(s,pos1,pos2); + if ( (pos1!=pos1_orig) || (pos2!=pos2_orig) ) + return; + if (pos1 && (pos21){ + char op=s[pos1-1]; + --pos1; + for (;pos1;--pos1){ + if (s[pos1]==',') + op=0; + if (!is_operator_char(s[pos1],op)) + break; + } + if (s[pos1]=='(' && pos1){ + --pos1; + for (;pos1;--pos1){ + if (!isalphan(s[pos1])) + break; + } + ++pos1; + } + find_left(s,pos1,pos2); + find_right(s,pos1,pos2); + return; + } + pos1=0; + ++pos2; + find_right(s,pos1,pos2); + } + + void decrease_selection(const string & s,int & pos1,int& pos2){ + int l=int(s.size()); + int pos2_orig(pos2); + // adjust selection (does not change anything on a valid selection) + find_left(s,pos1,pos2); + if (pos2!=l) + --pos2; + if (!pos2) + return; + int counter1=0,counter2=0; + char op=' '; + if (pos2pos1;--pos2){ + char ch=s[pos2]; + if (ch=='('){ + ++counter1; + if ( (!counter1) && (!counter2) && pos2_orig && (s[pos2_orig-1]==')') ){ + pos1=pos2+1; + pos2=pos2_orig-1; + return; + } + } + if (ch==')') + --counter1; + if (ch=='[') + ++counter2; + if (ch==']') + --counter2; + if (ch==',') + op=0; + if ( (!counter1) && (!counter2) && ( is_operator_char(ch,op) || (ch==',')) ) + return; + } + for (;pos10;--pos2){ + if (s[pos2-1]==',') + op=0; + if (!is_operator_char(s[pos2-1],op) && (s[pos2-1]!='(') && (s[pos2-1]!='[') ) + break; + } + if (pos2<=0){ + pos1=0; + pos2=0; + return; + } + pos1=pos2-1; + find_left(s,pos1,pos2); + find_right(s,pos1,pos2); + } + + string remove_extension(const string & chaine){ + int s=int(chaine.size()); + if (s>4 && chaine.substr(s-4,4)==".tns") + return remove_extension(chaine.substr(0,s-4)); + int l=int(chaine.find_last_of('.',s)); + int ll=int(chaine.find_last_of('/',s)); + if (l>0 && l=s || l>ll) + return chaine.substr(0,l); + } + return chaine; + } + + //environment * env=new environment; + + // Real object and real interval functions + + real_object & real_object::operator = (const real_object & g) { +#ifdef HAVE_LIBMPFR + mpfr_clear(inf); + mpfr_init2(inf,mpfr_get_prec(g.inf)); + mpfr_set(inf,g.inf,MPFR_RNDN); +#else + mpf_clear(inf); + mpf_init_set(inf,g.inf); +#endif + return *this; + } + +#ifdef HAVE_LIBMPFI + real_interval::real_interval(const mpfi_t & interv) { + int nbits=mpfi_get_prec(interv); + mpfr_set_prec(inf,nbits); + mpfi_get_fr(inf,interv); + mpfi_init2(infsup,nbits); + mpfi_set(infsup,interv); + } +#endif + + real_object & real_interval::operator = (const real_interval & g) { +#ifdef HAVE_LIBMPFR + mpfr_clear(inf); +#else + mpf_clear(inf); +#endif +#ifdef HAVE_LIBMPFI + mpfi_clear(infsup); +#else +#ifdef HAVE_LIBMPFR + mpfr_clear(sup); +#else + mpf_clear(sup); +#endif +#endif +#ifdef HAVE_LIBMPFR + mpfr_init2(inf,mpfr_get_prec(g.inf)); + mpfr_set(inf,g.inf,MPFR_RNDN); +#else + mpf_init_set(inf,g.inf); +#endif +#ifdef HAVE_LIBMPFI + mpfi_init2(infsup,mpfi_get_prec(g.infsup)); + mpfi_set(infsup,g.infsup); +#else +#ifdef HAVE_LIBMPFR + mpfr_init2(sup,mpfr_get_prec(g.sup)); + mpfr_set(sup,g.sup,MPFR_RNDN); +#else + mpf_init_set(sup,g.sup); +#endif +#endif + return *this; + } + + real_object & real_interval::operator = (const real_object & g) { +#ifdef NO_RTTI + const real_interval * ptr=0; +#else + const real_interval * ptr=dynamic_cast (&g); +#endif + if (ptr) + return *this=*ptr; +#ifdef HAVE_LIBMPFR + mpfr_clear(inf); +#ifdef HAVE_LIBMPFI + mpfi_clear(infsup); +#else + mpfr_clear(sup); +#endif + mpfr_init2(inf,mpfr_get_prec(g.inf)); + mpfr_set(inf,g.inf,MPFR_RNDN); +#ifdef HAVE_LIBMPFI + mpfi_init2(infsup,mpfr_get_prec(g.inf)); + mpfi_set_fr(infsup,g.inf); +#else + mpfr_init2(sup,mpfr_get_prec(g.inf)); + mpfr_set(sup,g.inf,MPFR_RNDN); +#endif +#else // HAVE_LIBMPFR + mpf_clear(inf); +#ifdef HAVE_LIBMPFI + mpfi_clear(infsup); +#else + mpf_clear(sup); +#endif + mpf_init_set(inf,g.inf); +#ifdef HAVE_LIBMPFI + mpfi_init_set_fr(infsup,g.inf); +#else + mpf_init_set(sup,g.inf); +#endif +#endif // HAVE_LIBMPFR + return *this; + } + + real_object::real_object() { +#ifdef HAVE_LIBMPFR + mpfr_init(inf); +#else + mpf_init(inf); +#endif + } + + real_object::real_object(const real_object & g){ +#ifdef HAVE_LIBMPFR + mpfr_init2(inf,mpfr_get_prec(g.inf)); + mpfr_set(inf,g.inf,MPFR_RNDN); +#else + mpf_init_set(inf,g.inf); +#endif + } + + real_object::real_object(double d) { +#ifdef HAVE_LIBMPFR + mpfr_init_set_d(inf,d,MPFR_RNDN); +#else + mpf_init_set_d(inf,d); +#endif + } + +#ifdef HAVE_LIBMPFR + real_object::real_object(const mpfr_t & d) { + mpfr_init2(inf,mpfr_get_prec(d)); + mpfr_set(inf,d,MPFR_RNDN); + } +#endif + + real_object::real_object(const mpf_t & d) { +#ifdef HAVE_LIBMPFR + mpfr_init(inf); + mpfr_set_f(inf,d,MPFR_RNDN); +#else + mpf_init_set(inf,d); +#endif + } + + real_object::real_object(const gen & g){ + switch (g.type){ + case _INT_: +#ifdef HAVE_LIBMPFR + mpfr_init_set_si(inf,g.val,MPFR_RNDN); +#else + mpf_init_set_si(inf,g.val); +#endif + return; + case _DOUBLE_: +#ifdef HAVE_LIBMPFR + mpfr_init_set_d(inf,g._DOUBLE_val,MPFR_RNDN); +#else + mpf_init_set_d(inf,g._DOUBLE_val); +#endif + return; + case _ZINT: +#ifdef HAVE_LIBMPFR + mpfr_init(inf); + mpfr_set_z(inf,*g._ZINTptr,MPFR_RNDN); +#else + mpf_init(inf); + mpf_set_z(inf,*g._ZINTptr); +#endif + return; + case _REAL: +#ifdef HAVE_LIBMPFR + mpfr_init2(inf,mpfr_get_prec(g._REALptr->inf)); + mpfr_set(inf,g._REALptr->inf,MPFR_RNDN); +#else + mpf_init_set(inf,g._REALptr->inf); +#endif + return; + } + if (g.type==_FRAC){ + gen tmp=real_object(g._FRACptr->num)/real_object(g._FRACptr->den); + if (tmp.type==_REAL){ +#ifdef HAVE_LIBMPFR + mpfr_init2(inf,mpfr_get_prec(tmp._REALptr->inf)); + mpfr_set(inf,tmp._REALptr->inf,MPFR_RNDN); +#else + mpf_init_set(inf,tmp._REALptr->inf); +#endif + return; + } + } +#ifndef NO_STDEXCEPT + setsizeerr(gettext("Unable to convert to real ")+g.print(context0)); +#endif + return; + } + + real_object::real_object(const gen & g,unsigned int precision){ + switch (g.type){ + case _INT_: +#ifdef HAVE_LIBMPFR + mpfr_init2(inf,precision); + mpfr_set_si(inf,g.val,MPFR_RNDN); +#else + mpf_init_set_si(inf,g.val); +#endif + return; + case _DOUBLE_: +#ifdef HAVE_LIBMPFR + mpfr_init2(inf,precision); + mpfr_set_d(inf,g._DOUBLE_val,MPFR_RNDN); +#else + mpf_init_set_d(inf,g._DOUBLE_val); +#endif + return; + case _ZINT: +#ifdef HAVE_LIBMPFR + mpfr_init2(inf,precision); + mpfr_set_z(inf,*g._ZINTptr,MPFR_RNDN); +#else + mpf_init(inf); + mpf_set_z(inf,*g._ZINTptr); +#endif + return; + case _REAL: +#ifdef HAVE_LIBMPFR + mpfr_init2(inf,precision); + mpfr_set(inf,g._REALptr->inf,MPFR_RNDN); +#else + mpf_init_set(inf,g._REALptr->inf); +#endif + return; + } + if (g.type==_FRAC){ + gen tmp=real_object(g._FRACptr->num,precision)/real_object(g._FRACptr->den,precision); + if (tmp.type==_REAL){ +#ifdef HAVE_LIBMPFR + mpfr_init2(inf,mpfr_get_prec(tmp._REALptr->inf)); + mpfr_set(inf,tmp._REALptr->inf,MPFR_RNDN); +#else + mpf_init_set(inf,tmp._REALptr->inf); +#endif + return; + } + } + int save_decimal_digits=decimal_digits(context0); + set_decimal_digits(giacmax(20,std::ceil(precision* + 0.30102999566398119 + //M_LN2/M_LN10 + )),context0); + gen tmp=re(evalf(g,1,context0),context0); + set_decimal_digits(save_decimal_digits,context0); + if (tmp.type!=_REAL){ +#ifndef NO_STDEXCEPT + setsizeerr(gettext("Unable to convert to real ")+g.print(context0)); +#endif + return; + } +#ifdef HAVE_LIBMPFR + mpfr_init2(inf,precision); + mpfr_set(inf,tmp._REALptr->inf,MPFR_RNDN); +#else + mpf_init_set(inf,tmp._REALptr->inf); +#endif + } + + gen::gen(const real_object & g){ +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_real_object) << 16; +#else + __REALptr = new ref_real_object; +#endif + type = _REAL; + subtype=0; +#ifdef HAVE_LIBMPFR + mpfr_set_prec(_REALptr->inf,mpfr_get_prec(g.inf)); + mpfr_set(_REALptr->inf,g.inf,MPFR_RNDN); +#else + mpf_set(_REALptr->inf,g.inf); +#endif +#ifdef KHICAS + if ((size_t) _REALptr > stackptr) + ctrl_c=interrupted=true; +#endif + } + + gen::gen(const real_interval & g){ +#ifdef SMARTPTR64 + * ((ulonglong * ) this) = ulonglong(new ref_real_interval) << 16; +#else + __REALptr = (ref_real_object *) new ref_real_interval; +#endif +#ifdef KHICAS + if ((size_t) _REALptr > stackptr) + ctrl_c=interrupted=true; +#endif + type = _REAL; + subtype=0; +#ifdef NO_RTTI + real_interval * ptr=0; +#else + real_interval * ptr=dynamic_cast(_REALptr); +#endif +#ifdef HAVE_LIBMPFR + mpfr_set_prec(ptr->inf,mpfr_get_prec(g.inf)); + mpfr_set(ptr->inf,g.inf,MPFR_RNDN); +#else + mpf_set(ptr->inf,g.inf); +#endif +#ifdef HAVE_LIBMPFI + int nbits=mpfi_get_prec(g.infsup); + mpfi_set_prec(ptr->infsup,nbits); + mpfi_set(ptr->infsup,g.infsup); +#else +#ifdef HAVE_LIBMPFR + mpfr_set(ptr->sup,g.sup,MPFR_RNDN); +#else + mpf_set(ptr->sup,g.sup); +#endif +#endif + } + + double real_object::evalf_double() const{ +#ifdef HAVE_LIBMPFR + return mpfr_get_d(inf,MPFR_RNDN); +#else + return mpf_get_d(inf); +#endif + } + + gen real_object::addition (const gen & g,GIAC_CONTEXT) const{ + switch (g.type){ + case _REAL: + return *this+*g._REALptr; + case _CPLX: + return gen(this->addition(*g._CPLXptr,contextptr),*(g._CPLXptr+1)); + case _FRAC: + if (!is_integer(g._FRACptr->num) || !is_integer(g._FRACptr->den)) + return sym_add(*this,g,contextptr); + case _INT_: case _DOUBLE_: case _ZINT: +#ifdef HAVE_LIBMPFR + return *this+real_object(g,mpfr_get_prec(inf)); +#else + return *this+real_object(g); +#endif + default: + return sym_add(*this,g,contextptr); + } + return gensizeerr(gettext("real_object + gen")+this->print(contextptr)+","+g.print(contextptr)); + } + + gen real_interval::addition (const gen & g,GIAC_CONTEXT) const{ + switch (g.type){ + case _REAL: + return *this+*g._REALptr; + case _CPLX: + return gen(this->addition(*g._CPLXptr,contextptr),*(g._CPLXptr+1)); + case _FRAC: + if (!is_integer(g._FRACptr->num) || !is_integer(g._FRACptr->den)) + return sym_add(*this,g,contextptr); + case _INT_: case _DOUBLE_: case _ZINT: +#ifdef HAVE_LIBMPFR + return *this+real_object(g,mpfr_get_prec(inf)); +#else + return *this+real_object(g); +#endif + default: + return sym_add(*this,g,contextptr); + } + return gensizeerr(gettext("real_object + gen")+this->print(contextptr)+","+g.print(contextptr)); + } + + gen real_object::operator + (const gen & g) const{ + return addition(g,context0); + } + + static real_interval add(const real_interval & i,const real_interval & g){ + real_interval res(i); +#ifdef HAVE_LIBMPFR + mpfr_add(res.inf,i.inf,g.inf,MPFR_RNDD); +#ifdef HAVE_LIBMPFI + mpfi_add(res.infsup,i.infsup,g.infsup); +#else + mpfr_add(res.sup,i.sup,g.sup,MPFR_RNDU); +#endif +#else // HAVE_LIBMPFR + mpf_add(res.inf,i.inf,g.inf); +#ifdef HAVE_LIBMPFI + mpfi_add(res.infsup,i.infsup,g.infsup); +#else + mpf_add(res.sup,i.sup,g.sup); +#endif +#endif // HAVE_LIBMPFR + return res; + } + + real_interval real_interval::operator + (const real_interval & g) const{ + return add(*this,g); + } + + static real_interval add(const real_interval & i,const real_object & g){ +#ifdef NO_RTTI + const real_interval * ptr=0; +#else + const real_interval * ptr=dynamic_cast(&g); +#endif + if (ptr) + return add(i,*ptr); + real_interval res(i); +#ifdef HAVE_LIBMPFR + mpfr_add(res.inf,i.inf,g.inf,MPFR_RNDD); +#ifdef HAVE_LIBMPFI + mpfi_add_fr(res.infsup,i.infsup,g.inf); +#else + mpfr_add(res.sup,i.sup,g.inf,MPFR_RNDU); +#endif +#else // HAVE_LIBMPFR + mpf_add(res.inf,i.inf,g.inf); +#ifdef HAVE_LIBMPFI + mpfi_add_fr(res.infsup,i.infsup,g.inf); +#else + mpf_add(res.sup,i.sup,g.inf); +#endif +#endif // HAVE_LIBMPFR + return res; + } + + gen real_interval::operator + (const real_object & g) const{ + return add(*this,g); + } + + gen real_object::operator + (const real_object & g) const{ +#ifdef NO_RTTI + const real_interval * ptr=0; +#else + const real_interval * ptr=dynamic_cast(&g); +#endif + if (ptr) + return add(*ptr,*this); +#ifdef HAVE_LIBMPFR + mpfr_t sum; + mpfr_init2(sum,giacmin(mpfr_get_prec(this->inf),mpfr_get_prec(g.inf))); + mpfr_add(sum,this->inf,g.inf,MPFR_RNDN); + real_object res(sum); + mpfr_clear(sum); +#else + mpf_t sum; + mpf_init(sum); + mpf_add(sum,this->inf,g.inf); +#ifdef LONGFLOAT_DOUBLE + real_object res; res.inf=sum; +#else + real_object res(sum); +#endif + mpf_clear(sum); +#endif + return res; + } + + gen real_object::subtract (const gen & g,GIAC_CONTEXT) const{ + return substract(g,contextptr); + } + gen real_object::substract (const gen & g,GIAC_CONTEXT) const{ + switch (g.type){ + case _REAL: + return *this-*g._REALptr; + case _FRAC: + if (!is_integer(g._FRACptr->num) || !is_integer(g._FRACptr->den)) + return sym_sub(*this,g,contextptr); + case _INT_: case _DOUBLE_: case _ZINT: +#ifdef HAVE_LIBMPFR + return *this - real_object(g,mpfr_get_prec(inf)); +#else + return *this - real_object(g); +#endif + default: + return sym_sub(*this,g,contextptr); + } + return gensizeerr(gettext("real_object + gen")+this->print(contextptr)+","+g.print(contextptr)); + } + gen real_interval::subtract (const gen & g,GIAC_CONTEXT) const{ + return substract(g,contextptr); + } + gen real_interval::substract (const gen & g,GIAC_CONTEXT) const{ + switch (g.type){ + case _REAL: + return *this-*g._REALptr; + case _FRAC: + if (!is_integer(g._FRACptr->num) || !is_integer(g._FRACptr->den)) + return sym_sub(*this,g,contextptr); + case _INT_: case _DOUBLE_: case _ZINT: +#ifdef HAVE_LIBMPFR + return *this - real_object(g,mpfr_get_prec(inf)); +#else + return *this - real_object(g); +#endif + default: + return sym_sub(*this,g,contextptr); + } + return gensizeerr(gettext("real_object + gen")+this->print(contextptr)+","+g.print(contextptr)); + } + + gen real_object::operator - (const gen & g) const{ + return substract(g,context0); + } + + static real_interval sub(const real_interval & i,const real_interval & g){ + real_interval res(i); +#ifdef HAVE_LIBMPFI + mpfi_sub(res.infsup,i.infsup,g.infsup); + mpfr_sub(res.inf,i.inf,g.inf,MPFR_RNDD); +#else +#ifdef HAVE_LIBMPFR + mpfr_sub(res.inf,i.sup,g.inf,MPFR_RNDD); + mpfr_sub(res.sup,i.inf,g.sup,MPFR_RNDU); +#else + mpf_sub(res.inf,i.sup,g.inf); + mpf_sub(res.sup,i.inf,g.sup); +#endif +#endif + return res; + } + + real_interval real_interval::operator - (const real_interval & g) const{ + return sub(*this,g); + } + + static real_interval sub(const real_interval & i,const real_object & g){ +#ifdef NO_RTTI + const real_interval * ptr=0; +#else + const real_interval * ptr=dynamic_cast(&g); +#endif + if (ptr) + return sub(i,*ptr); + real_interval res(i); +#ifdef HAVE_LIBMPFI + mpfi_sub_fr(res.infsup,i.infsup,g.inf); + mpfr_sub(res.inf,i.inf,g.inf,MPFR_RNDD); +#else +#ifdef HAVE_LIBMPFR + mpfr_sub(res.inf,i.sup,g.inf,MPFR_RNDD); + mpfr_sub(res.sup,i.inf,g.inf,MPFR_RNDU); +#else + mpf_sub(res.inf,i.sup,g.inf); + mpf_sub(res.sup,i.inf,g.inf); +#endif +#endif + return res; + } + + gen real_interval::operator - (const real_object & g) const{ + return sub(*this,g); + } + + gen real_object::operator - (const real_object & g) const{ +#ifdef NO_RTTI + const real_interval * ptr=0; +#else + const real_interval * ptr=dynamic_cast(&g); +#endif + if (ptr) + return -(*ptr)+(*this); +#ifdef HAVE_LIBMPFR + mpfr_t sum; + mpfr_init2(sum,giacmin(mpfr_get_prec(this->inf),mpfr_get_prec(g.inf))); + mpfr_sub(sum,this->inf,g.inf,MPFR_RNDN); + real_object res(sum); + mpfr_clear(sum); +#else + mpf_t sum; + mpf_init(sum); + mpf_sub(sum,this->inf,g.inf); +#ifdef LONGFLOAT_DOUBLE + real_object res; res.inf=sum; +#else + real_object res(sum); +#endif + mpf_clear(sum); +#endif + return res; + } + + gen real_object::operator -() const { +#ifdef NO_RTTI + const real_interval * ptr=0; +#else + const real_interval * ptr=dynamic_cast(this); +#endif + if (ptr) + return -*ptr; + real_object res(*this); +#ifdef HAVE_LIBMPFR + mpfr_neg(res.inf,res.inf,MPFR_RNDN); +#else + mpf_neg(res.inf,res.inf); +#endif + return res; + } + + gen real_object::inv() const { + real_object res(*this); +#ifdef HAVE_LIBMPFR + mpfr_ui_div(res.inf,1,res.inf,MPFR_RNDN); +#else + mpf_ui_div(res.inf,1,res.inf); +#endif + return res; + } + + gen real_object::sqrt() const { +#if defined LONGFLOAT_DOUBLE && !defined HAVE_LIBMPFR + real_object res; res.inf=std::sqrt(inf); return res; +#else + real_object res(*this); +#ifdef HAVE_LIBMPFR + mpfr_sqrt(res.inf,res.inf,MPFR_RNDN); +#else + mpf_sqrt(res.inf,res.inf); +#endif + return res; +#endif + } + + gen real_object::abs() const { +#ifdef HAVE_LIBMPFR + if (mpfr_sgn(inf)>=0) +#else + if (mpf_sgn(inf)>=0) +#endif + return *this; + return -(*this); + } + + static void compile_with_mpfr(){ + setsizeerr(gettext("Compile with MPFR or USE_GMP_REPLACEMENTS if you want transcendental long float support")); + } + + gen real_object::exp() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf=std::exp(res.inf); +#else + *res.inf = ::exp(*res.inf); +#endif +#else +#ifdef HAVE_LIBMPFR + mpfr_exp(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif // USE_GMP_REPLACEMENTS + return res; + } + + gen real_object::log() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf=std::log(res.inf); +#else + *res.inf = ::log(*res.inf); +#endif +#else +#ifdef HAVE_LIBMPFR + mpfr_log(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif + return res; + } + + gen real_object::sin() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf=std::sin(res.inf); +#else + *res.inf = ::sin(*res.inf); +#endif +#else +#ifdef HAVE_LIBMPFR + mpfr_sin(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif + return res; + } + + gen real_object::cos() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf=std::cos(res.inf); +#else + *res.inf = ::cos(*res.inf); +#endif +#else +#ifdef HAVE_LIBMPFR + mpfr_cos(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif + return res; + } + + gen real_object::tan() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf=std::tan(res.inf); +#else + *res.inf = ::tan(*res.inf); +#endif +#else +#ifdef HAVE_LIBMPFR + mpfr_tan(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif + return res; + } + + gen real_object::sinh() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf=std::sinh(res.inf); +#else + *res.inf = ::sinh(*res.inf); +#endif +#else +#ifdef HAVE_LIBMPFR + mpfr_sinh(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif + return res; + } + + gen real_object::cosh() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf=std::cosh(res.inf); +#else + *res.inf = ::cosh(*res.inf); +#endif +#else +#ifdef HAVE_LIBMPFR + mpfr_cosh(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif + return res; + } + + gen real_object::tanh() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf=std::tanh(res.inf); +#else + *res.inf = ::tanh(*res.inf); +#endif +#else +#ifdef HAVE_LIBMPFR + mpfr_tanh(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif + return res; + } + + gen real_object::asin() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf=std::asin(res.inf); +#else + *res.inf = ::asin(*res.inf); +#endif +#else +#ifdef HAVE_LIBMPFR + mpfr_asin(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif + return res; + } + + gen real_object::acos() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf=std::acos(res.inf); +#else + *res.inf = ::acos(*res.inf); +#endif +#else +#ifdef HAVE_LIBMPFR + mpfr_acos(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif + return res; + } + + gen real_object::atan() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf=std::atan(res.inf); +#else + *res.inf = ::atan(*res.inf); +#endif +#else +#ifdef HAVE_LIBMPFR + mpfr_atan(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif + return res; + } + + gen real_object::asinh() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf= std::log(res.inf+std::sqrt(res.inf*res.inf+1)); +#else + *res.inf = ::asinh(*res.inf); +#endif +#else +#if defined HAVE_LIBMPFR && !defined BF2GMP_H + mpfr_asinh(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif + return res; + } + + gen real_object::acosh() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf=std::log(res.inf+std::sqrt(res.inf+1)*std::sqrt(res.inf-1)); +#else + *res.inf = ::acosh(*res.inf); +#endif +#else +#if defined HAVE_LIBMPFR && !defined BF2GMP_H + mpfr_acosh(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif + return res; + } + + gen real_object::atanh() const { + real_object res(*this); +#ifdef USE_GMP_REPLACEMENTS +#ifdef LONGFLOAT_DOUBLE + res.inf=std::log((1+res.inf)/(1-res.inf))/2; +#else + *res.inf = ::atanh(*res.inf); +#endif +#else +#if defined HAVE_LIBMPFR && !defined BF2GMP_H + mpfr_atanh(res.inf,res.inf,MPFR_RNDN); +#else + compile_with_mpfr(); +#endif +#endif + return res; + } + + gen real_interval::operator -() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFR + mpfr_neg(res.inf,res.inf,MPFR_RNDU); +#ifdef HAVE_LIBMPFI + mpfi_neg(res.infsup,res.infsup); +#else + mpfr_neg(res.sup,res.sup,MPFR_RNDD); + mpfr_swap(res.inf,res.sup); +#endif +#else // MPFR + mpf_neg(res.inf,res.inf); +#ifdef HAVE_LIBMPFI + mpfi_neg(res.infsup,res.infsup); +#else + mpf_neg(res.sup,res.sup); +#ifdef mpf_swap + mpf_swap(res.inf,res.sup); +#endif +#endif +#endif // MPFR + return res; + } + + gen real_interval::inv() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_ui_div(res.infsup,1,res.infsup); + mpfr_ui_div(res.inf,1,res.inf,MPFR_RNDD); +#else + // FIXME check sign +#ifndef NO_STDEXCEPT + setsizeerr(gettext("real_interval inv")); +#endif + /* mpf_neg(res.inf,res.inf); + mpf_neg(res.sup,res.sup); + mpf_swap(res.inf,res.sup); */ +#endif + return res; + } + + gen real_interval::sqrt() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_sqrt(res.infsup,res.infsup); + mpfr_sqrt(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::abs() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_abs(res.infsup,res.infsup); + mpfr_abs(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval abs")); +#endif + } + + gen real_interval::exp() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_exp(res.infsup,res.infsup); + mpfr_exp(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::log() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_log(res.infsup,res.infsup); + mpfr_log(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::sin() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_sin(res.infsup,res.infsup); + mpfr_sin(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::cos() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_cos(res.infsup,res.infsup); + mpfr_cos(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::tan() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_tan(res.infsup,res.infsup); + mpfr_tan(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::sinh() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_sinh(res.infsup,res.infsup); + mpfr_sinh(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::cosh() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_cosh(res.infsup,res.infsup); + mpfr_cosh(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::tanh() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_tanh(res.infsup,res.infsup); + mpfr_tanh(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::asin() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_asin(res.infsup,res.infsup); + mpfr_asin(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::acos() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_acos(res.infsup,res.infsup); + mpfr_acos(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::atan() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_atan(res.infsup,res.infsup); + mpfr_atan(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::asinh() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_asinh(res.infsup,res.infsup); + mpfr_asinh(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::acosh() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_acosh(res.infsup,res.infsup); + mpfr_acosh(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_interval::atanh() const { + real_interval res(*this); +#ifdef HAVE_LIBMPFI + mpfi_atanh(res.infsup,res.infsup); + mpfr_atanh(res.inf,res.inf,MPFR_RNDD); + return res; +#else + return gensizeerr(gettext("real_interval sqrt")); +#endif + } + + gen real_object::multiply (const gen & g,GIAC_CONTEXT) const{ + switch (g.type){ + case _REAL: + return *this * *g._REALptr; + case _CPLX: + return gen(this->multiply(*g._CPLXptr,contextptr),this->multiply(*(g._CPLXptr+1),contextptr)); + case _FRAC: + if (!is_integer(g._FRACptr->num) || !is_integer(g._FRACptr->den)) + return sym_mult(*this,g,contextptr); + case _INT_: case _DOUBLE_: case _ZINT: +#ifdef HAVE_LIBMPFR + return *this * real_object(g,mpfr_get_prec(inf)); +#else + return *this * real_object(g); +#endif + default: + return sym_mult(*this,g,contextptr); + } + } + + gen real_interval::multiply (const gen & g,GIAC_CONTEXT) const{ + switch (g.type){ + case _REAL: + return *this * *g._REALptr; + case _CPLX: + return gen(this->multiply(*g._CPLXptr,contextptr),this->multiply(*(g._CPLXptr+1),contextptr)); + case _FRAC: + if (!is_integer(g._FRACptr->num) || !is_integer(g._FRACptr->den)) + return sym_mult(*this,g,contextptr); + case _INT_: case _DOUBLE_: case _ZINT: +#ifdef HAVE_LIBMPFR + return *this * real_object(g,mpfr_get_prec(inf)); +#else + return *this * real_object(g); +#endif + default: + return sym_mult(*this,g,contextptr); + } + } + + gen real_object::operator * (const gen & g) const{ + return multiply(g,context0); + } + + gen real_object::operator / (const gen & g) const{ + return *this * g.inverse(context0); + } + + gen real_object::divide (const gen & g,GIAC_CONTEXT) const{ + return multiply(g.inverse(contextptr),contextptr); + } + + gen real_interval::divide (const gen & g,GIAC_CONTEXT) const{ + return multiply(g.inverse(contextptr),contextptr); + } + + gen real_object::operator / (const real_object & g) const{ + return *this * g.inv(); + } + + static real_interval mul(const real_interval & i,const real_interval & g){ + real_interval res(i); +#ifdef HAVE_LIBMPFR + mpfr_mul(res.inf,i.inf,g.inf,MPFR_RNDN); +#else + mpf_mul(res.inf,i.inf,g.inf); +#endif +#ifdef HAVE_LIBMPFI + mpfi_mul(res.infsup,i.infsup,g.infsup); +#else + // FIXME: should check signs for interval arithmetic!! +#ifndef NO_STDEXCEPT + setsizeerr(gettext("real_interval mul")); +#endif + // mpf_mul(res.sup,i.sup,g.sup); +#endif + return res; + } + + real_interval real_interval::operator * (const real_interval & g) const{ + return mul(*this,g); + } + + static real_interval mul(const real_interval & i,const real_object & g){ +#ifdef NO_RTTI + const real_interval * ptr=0; +#else + const real_interval * ptr=dynamic_cast(&g); +#endif + if (ptr) + return mul(i,*ptr); + real_interval res(i); +#ifdef HAVE_LIBMPFR + mpfr_mul(res.inf,i.inf,g.inf,MPFR_RNDN); +#else + mpf_mul(res.inf,i.inf,g.inf); +#endif +#ifdef HAVE_LIBMPFI + mpfi_mul_fr(res.infsup,i.infsup,g.inf); +#else + // FIXME: should check signs for interval arithmetic!! +#ifndef NO_STDEXCEPT + setsizeerr(gettext("real_interval mul 2")); +#endif + // mpf_mul(res.sup,i.sup,g.inf); +#endif + return res; + } + + gen real_interval::operator * (const real_object & g) const{ + return mul(*this,g); + } + + gen real_object::operator * (const real_object & g) const{ +#ifdef NO_RTTI + const real_interval * ptr=0; +#else + const real_interval * ptr=dynamic_cast(&g); +#endif + if (ptr) + return mul(*ptr,*this); +#ifdef HAVE_LIBMPFR + mpfr_t sum; + mpfr_init2(sum,giacmin(mpfr_get_prec(this->inf),mpfr_get_prec(g.inf))); + mpfr_mul(sum,this->inf,g.inf,MPFR_RNDN); + real_object res(sum); + mpfr_clear(sum); +#else + mpf_t sum; + mpf_init(sum); + mpf_mul(sum,this->inf,g.inf); +#ifdef LONGFLOAT_DOUBLE + real_object res; res.inf=sum; +#else + real_object res(sum); +#endif + mpf_clear(sum); +#endif + return res; + } + + int real_object::is_positive() const{ +#ifdef HAVE_LIBMPFR + return mpfr_sgn(inf); +#else + return mpf_sgn(inf); +#endif + } + + int real_interval::is_positive() const{ +#ifdef HAVE_LIBMPFI + if (mpfi_is_zero(infsup)>0) + return 0; + if (mpfi_is_pos(infsup)) + return 1; + if (mpfi_is_nonpos(infsup)) + return -1; + return 0; +#else +#ifdef HAVE_LIBMPFR + return mpfr_sgn(inf); +#else + return mpf_sgn(inf); +#endif +#endif + } + + string print_binary(const real_object & r){ +#ifdef HAVE_LIBMPFR + mp_exp_t expo; + int dd=mpfr_get_prec(r.inf); +#ifdef VISUALC + char * ptr=new char[dd+2]; +#else + char ptr[dd+2]; +#endif + if (!mpfr_get_str(ptr,&expo,2,dd,r.inf,MPFR_RNDN) || !(*ptr)) + return "MPFR print binary error "+r.print(context0); + string res; + if (ptr[0]=='-') + res="-0000."+string(ptr+1); + else + res="0000."+string(ptr); +#ifdef VISUALC + delete [] ptr; +#endif // VISUALC + return res+"E"+print_INT_(expo); +#else // MPFR + return "Error no MPFR printing "+r.print(context0); +#endif + } + + gen read_binary(const string & s,unsigned int precision){ +#ifdef HAVE_LIBMPFR + real_object r; + mpfr_set_prec(r.inf,precision); +#ifndef HAVE_MPFR_SET_STR_RAW + // MPFR 2.2 + mpfr_strtofr (r.inf, (char *)s.c_str(), 0, 2, MPFR_RNDN); +#else + // FOR MPFR 2.0 use instead + mpfr_set_str_raw(r.inf,(char *)s.c_str()); +#endif // GNUWINCE + return r; + return gensizeerr(gettext("MPFR error reading binary ")+s); +#else // HAVE_LIBMPFR + return gensizeerr(gettext("Error no MPFR reading ")+s); +#endif // HAVE_LIBMPFR + return undef; + } + + std::string real_object::print(GIAC_CONTEXT) const{ +#if defined HAVE_LIBMPFI && !defined NO_RTTI + if (const real_interval * ptr=dynamic_cast(this)){ + mpfr_t l,u; + int nbits=mpfi_get_prec(ptr->infsup); + mpfr_init2(l,nbits); mpfr_init2(u,nbits); + mpfi_get_left(l,ptr->infsup); mpfi_get_right(u,ptr->infsup); + real_object L(l),U(u); + mpfr_clear(l); mpfr_clear(u); + string s("["); + s += L.print(contextptr); + s += ".."; + s += U.print(contextptr); + s += "]"; + return s; + } +#endif +#ifdef HAVE_LIBMPFR + if (mpfr_nan_p(inf)) + return "undef"; + bool negatif=mpfr_sgn(inf)<0; + if (mpfr_inf_p(inf)) + return negatif?"-infinity":"+infinity"; + mp_exp_t expo; + int dd=mpfr_get_prec(inf); +#if defined(EMCC) || defined(EMCC2) // workaround: mpfr_set_prec or get_prec has problems with emcc + if (dd==53) + dd=100; +#endif + dd=bits2digits(dd); + dd--; +#ifdef VISUALC + char * ptr=new char[dd+2]; +#else + char ptr[dd+2]; +#endif + if (negatif){ + mpfr_t inf2; + mpfr_init2(inf2,mpfr_get_prec(inf)); + mpfr_neg(inf2,inf,MPFR_RNDN); + mpfr_get_str(ptr,&expo,10,dd,inf2,MPFR_RNDN); + mpfr_clear(inf2); + } + else + mpfr_get_str(ptr,&expo,10,dd,inf,MPFR_RNDN); + std::string res(ptr); +#ifndef BF2GMP_H + if (expo){ + if (expo==1){ + string reste(res.substr(1,res.size()-1)); + res=res[0]+("."+reste); + } + else { + res = "0."+res; + res += calc_mode(contextptr)==1?'E':'e'; + res += print_INT_(expo); + } + } + else + res="0."+res; +#endif +#ifdef VISUALC + delete [] ptr; +#endif + if (negatif) + return "-"+res; + else + return res; +#else + return printmpf_t(inf,contextptr); +#endif + } + + bool real_object::is_zero() const{ +#ifdef HAVE_LIBMPFR + return !mpfr_sgn(inf); +#else + return mpf_sgn(inf)==0; +#endif + } + + bool real_object::maybe_zero() const{ +#ifdef HAVE_LIBMPFR + return !mpfr_sgn(inf); +#else + return mpf_sgn(inf)==0; +#endif + } + + bool real_interval::is_zero() const { +#ifdef HAVE_LIBMPFI + return mpfi_is_zero(infsup); +#else + return real_object::is_zero(); +#endif + } + + bool real_interval::maybe_zero() const{ +#ifdef HAVE_LIBMPFI + return mpfi_has_zero(infsup); +#else + return real_object::maybe_zero(); +#endif + } + + bool real_object::is_inf() const{ +#ifdef HAVE_LIBMPFR + return !mpfr_inf_p(inf); +#else +#ifndef NO_STDEXCEPT + setsizeerr(); +#endif + return false; +#endif + } + + bool real_interval::is_inf() const{ +#ifdef HAVE_LIBMPFI + return !mpfi_inf_p(infsup); +#else + return real_object::is_inf(); +#endif + } + + bool real_object::is_nan() const{ +#ifdef HAVE_LIBMPFR + return !mpfr_nan_p(inf); +#else +#ifndef NO_STDEXCEPT + setsizeerr(); +#endif + return false; +#endif + } + + bool real_interval::is_nan() const{ +#ifdef HAVE_LIBMPFI + return !mpfi_nan_p(infsup); +#else + return real_object::is_nan(); +#endif + } + + gen iprotecteval(const gen & g,int level,GIAC_CONTEXT){ +#ifdef KHICAS + enable_back_interrupt(); + gen res=protecteval(g,level,contextptr); + disable_back_interrupt(); + return res; +#else + return protecteval(g,level,contextptr); +#endif + } + +#if 0 // def KHICAS +#undef HAVE_LIBPTHREAD +#endif + +#ifdef HAVE_LIBPTHREAD + struct caseval_param{ + const char * s; + gen ans; + context * contextptr; + pthread_mutex_t mutex; + }; + void * thread_caseval(void * ptr_){ + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL); + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,NULL); + caseval_param * ptr=(caseval_param *)ptr_; + pthread_mutex_lock(&ptr->mutex); + gen g(ptr->s,ptr->contextptr); + g=equaltosto(g,ptr->contextptr); + ptr->ans=iprotecteval(g,1,ptr->contextptr); + pthread_mutex_unlock(&ptr->mutex); + return ptr; + } +#endif + + bool islogo(const gen & g){ + if (g.type!=_VECT || g._VECTptr->empty()) return false; + if (g.subtype==_LOGO__VECT) return true; + const vecteur & v=*g._VECTptr; + if (islogo(v.back())) + return true; + for (size_t i=0;isizeof(buf)) + S=S.substr(0,sizeof(buf)-1); + strcpy(buf,S.c_str()); + } + xcas::textedit(buf,sizeof(buf),true,contextptr,filename); + s=buf; + //S=buf; + //return S.c_str(); + } + if (!strcmp(s,"toolbox menu")){ + char buf[1024]=""; + showCatalog(buf,0,0,&C); + drawRectangle(0,0,320,222,_WHITE); + S=buf; + return S.c_str(); + } + if (!strcmp(s,"var menu")){ + gen g=select_var(contextptr); + drawRectangle(0,0,320,222,_WHITE); + S=g.type==_STRNG?*g._STRNGptr:g.print(contextptr); + if (!strcmp(S.c_str(),"undef")) + S=""; + return S.c_str(); + } + if (!strcmp(s,".")){ + xcas::displaylogo(); + S=turtle_state(contextptr).print(&C); + return S.c_str(); + } + if (!strcmp(s,"..")){ + _efface_logo(vecteur(0),contextptr); + return "turtle cleared"; + } +#endif + const char init[]="init geogebra"; + const char close[]="close geogebra"; + if (!strcmp(s,init)){ + init_geogebra(1,&C); + return "geogebra mode on"; + } + if (!strcmp(s,close)){ + init_geogebra(0,&C); + return "geogebra mode off"; + } +#ifdef TIMEOUT + if (strlen(s)>8){ + string args(s); + if (args.substr(0,8)=="timeout "){ + string t=args.substr(8,args.size()-8); + double f=atof(t.c_str()); + if (f>=0 && f<24*60){ + caseval_maxtime=f; + S="Max eval time set to "+gen(f).print(); + return S.c_str(); + } + } + if (args.substr(0,8)=="ckevery "){ + string t=args.substr(8,args.size()-8); + int f=atoi(t.c_str()); + if (f>0 && f<1e6){ + caseval_mod=f; + S="Check every "+gen(f).print(); + return S.c_str(); + } + } + } + ctrl_c=false; + interrupted=false; + caseval_begin=time(0); +#endif +#ifdef HAVE_LIBPTHREAD + gen g; + caseval_param cp={s,0,&C,PTHREAD_MUTEX_INITIALIZER}; + pthread_t pth; + pthread_attr_t attr; + pthread_attr_init(&attr); + int cres=pthread_create(&pth,&attr,thread_caseval,(void *)&cp); + if (cres){ + g=gen(s,&C); + g=equaltosto(g,&C); + g=iprotecteval(g,1,&C); + } + else { + // void * ptr; +#ifdef TIMEOUT + double d=caseval_maxtime; +#else + double d=3; +#endif + usleep(10000); + for (;d>0;--d){ + for (unsigned k=0;k<100;++k){ + if (ctrl_c || interrupted){ + d=0; + break; + } + int locked=pthread_mutex_trylock(&cp.mutex); + if (!locked){ + pthread_mutex_unlock(&cp.mutex); + void * ptr; + cres=pthread_join(pth,&ptr); + d=-1; + if (cres){ + g=string2gen("Thread join error",false); + g.subtype=-1; + } + else + g=cp.ans; + break; + } + usleep(10000); + } + } + if (d==0){ + ctrl_c=interrupted=true; + usleep(200000); + pthread_cancel(pth); + // cres=pthread_join(pth,NULL); // does not work + g=string2gen("Timeout",false); + g.subtype=-1; + } + pthread_attr_destroy(&attr); + } +#else + gen g(s,&C); + g=equaltosto(g,&C); + if (g.type==_VECT && !g._VECTptr->empty() && g._VECTptr->front().is_symb_of_sommet(at_set_language)){ + vecteur v=*g._VECTptr; + iprotecteval(v.front(),1,&C); + v.erase(v.begin()); + if (g.subtype==_SEQ__VECT && v.size()==1) + g=v.front(); + else + g=gen(v,g.subtype); + } + gen gp=g; + if (gp.is_symb_of_sommet(at_add_autosimplify)) + gp=gp._SYMBptr->feuille; +#ifdef KHICAS + bool push=false; +#else + bool push=!gp.is_symb_of_sommet(at_mathml) && !gp.is_symb_of_sommet(at_set_language); +#endif + //bool push=!g.is_symb_of_sommet(at_mathml); + if (push){ + history_in(&C).push_back(g); + // COUT << "hin " << g << '\n'; + } + g=iprotecteval(g,1,&C); + if (push){ + history_out(&C).push_back(g); + // COUT << "hout " << g << '\n'; + } +#endif +#if defined(EMCC) || defined(EMCC2) + // compile with -s LEGACY_GL_EMULATION=1 + gen last=g; + while (last.type==_VECT && last.subtype!=_LOGO__VECT && !last._VECTptr->empty()){ + gen tmp=last._VECTptr->back(); + if (tmp.is_symb_of_sommet(at_equal)) + last=vecteur(last._VECTptr->begin(),last._VECTptr->end()-1); + else + last=tmp; + } + if (last.type==_VECT && last.subtype==_LOGO__VECT){ + S="gr2d(logo("+last.print(&C)+"))"; + return S.c_str(); + } + if (calc_mode(&C)!=1 && (last.is_symb_of_sommet(at_pnt) || last.is_symb_of_sommet(at_pixon))){ +#if !defined(GIAC_GGB) && (defined(EMCC) || defined EMCC2) + if (is3d(last)){ + int worker=0; + worker=EM_ASM_INT_V({ + if (typeof(UI)!=="undefined" && typeof(UI.disable3d) !== 'undefined' && UI.disable3d) + return UI.disable3d; + if (Module.worker) return 1; else return 0; + }); + if (worker==-1) return "gl3d_not_supported"; + if (worker) return "gl3d_not_supported_if_workers_are_enabled"; + //giac_renderer(last.print(&C).c_str()); + int n=giac_gen_renderer(g,&C); + S="gl3d "+print_INT_(n); + return S.c_str(); + } +#endif // GIAC_GGB + last=remove_at_pnt(last); + if (last.is_symb_of_sommet(at_pixon)){ + S="gr2d(pixon("; + pixon_print(g,S,&C); + S+="))"; + return S.c_str(); + } + return svg2doutput(g,S,&C); + } +#endif // EMCC + if (calc_mode(&C)==1 && !lop(g,at_rootof).empty()) + g=evalf(g,1,&C); + if (has_undef_stringerr(g,S)){ + S="GIAC_ERROR: "+S; + } + else { + gen last=g; + while (last.type==_VECT && last.subtype!=_LOGO__VECT && !last._VECTptr->empty()){ + gen tmp=last._VECTptr->back(); + if (tmp.is_symb_of_sommet(at_equal)) + last=vecteur(last._VECTptr->begin(),last._VECTptr->end()-1); + else + last=tmp; + } +#ifdef KHICAS // replace ],[ by ][ + if (last.is_symb_of_sommet(at_pnt)){ + if (os_shell || nspirelua) + xcas::displaygraph(g,gp,&C); + S="Graphic_object"; + } + else { + if (os_shell){ + if (islogo(g)) + xcas::displaylogo(); + else { + if ( (g.type==_SYMB || (warn_symb_program_sto && g.type==_VECT && !g._VECTptr->empty() && g._VECTptr->front().type!=_STRNG)) && taille(g,256)<=256) + g=xcas::eqw(g,true,&C); + } + } + if (taille(g,100)>=100) + S="Large_object"; + else + S=g.print(&C); + } + if (!os_shell){ + string S_; + S_ += S[0]; + for (size_t i=1;i+11) + S_ +=S[S.size()-1]; + S=S_; + if (S.size()>=3 && S[0]=='[' && S[1]!='[' && S[S.size()-1]==']') + S='['+S+']'; // vector/list not allowed in Numworks calc app + } +#else + if (calc_mode(contextptr)!=1 && last.is_symb_of_sommet(at_pnt)) + S="Graphic_object"; + else if (islogo(g)) + S="Logo_turtle"; + else + S=g.print(&C); +#if !defined GIAC_GGB +#if defined EMCC || defined EMCC2 + double add_evalf=EM_ASM_DOUBLE_V({ + if (typeof(UI)!=="undefined" && typeof(UI.add_evalf)!="undefined") + return UI.add_evalf*1.0; + return 1.0; + }), + js_bigint=EM_ASM_DOUBLE_V({ + if (typeof(UI)!=="undefined" && typeof(UI.js_bigint)!="undefined") + return UI.js_bigint*1.0; + return 0.0; + }); +#else + double add_evalf=false,js_bigint=false; +#endif + if (g.type==_FRAC || g.type==_ZINT){ + if (add_evalf){ + S += "="; + S += evalf_double(g,1,&C).print(&C); + } + } + if (js_bigint && is_integer(g)) + S += "n"; + if (add_evalf && g.type==_SYMB){ + g=evalf_double(g,1,&C); + if (g.type<=_CPLX){ + S += "="; + S += g.print(&C); + } + } +#endif // !defined GIAC_GGB +#endif // NUWMORKS + } + return S.c_str(); + } + +#ifdef EMCC_BIND + EMSCRIPTEN_BINDINGS(cas){ + emscripten::function("caseval",&caseval,emscripten::allow_raw_pointers()); + } +#endif + +#ifndef NO_NAMESPACE_GIAC +} // namespace giac +#endif // ndef NO_NAMESPACE_GIAC + diff --git a/apps/KhiCAS/src/giac-1.6.0/src/gen.h b/apps/KhiCAS/src/giac-1.6.0/src/gen.h index b3345088b..95f7862ab 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/gen.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/gen.h @@ -1275,6 +1275,7 @@ namespace giac { return s.c_str(); } virtual std::string texprint (GIAC_CONTEXT) const { return "Nothing_to_print_tex"; } + virtual gen giac_constructor (GIAC_CONTEXT) const { return *this; } virtual gen eval(int level,const context * contextptr) const {return *this;}; virtual gen evalf(int level,const context * contextptr) const {return *this;}; virtual gen makegen(int i) const { return string2gen("makegen not redefined"); } ; diff --git a/apps/KhiCAS/src/giac-1.6.0/src/global.cc b/apps/KhiCAS/src/giac-1.6.0/src/global.cc index 03c88839e..42ed04ab1 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/global.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/global.cc @@ -52,7 +52,9 @@ using namespace std; #include #include #include -#include +#if !defined RTOS_THREADX +//#include +#endif #if !defined BESTA_OS && !defined FXCG #include #endif @@ -1577,7 +1579,7 @@ namespace giac { // 00 // type // record data - if (*ptr!=0xee0bddba) // ba dd 0b ee + if (*((unsigned *)ptr)!=0xee0bddba) // ba dd 0b ee return false; int pos=4; ptr+=4; for (;posparent=0; + if (ptr->history_in_ptr) + delete ptr->history_in_ptr; + if (ptr->history_out_ptr) + delete ptr->history_out_ptr; + if (ptr->history_plot_ptr) + delete ptr->history_plot_ptr; + if (ptr->quoted_global_vars) + delete ptr->quoted_global_vars; + if (ptr->rootofs) + delete ptr->rootofs; + if (ptr->globalptr) + delete ptr->globalptr; + if (ptr->tabptr) + delete ptr->tabptr; + ptr->tabptr=new sym_tab; + ptr->globalcontextptr=ptr; ptr->previous=0; ptr->globalptr=new global; + ptr->quoted_global_vars=new vecteur; + ptr->rootofs=new vecteur; + ptr->history_in_ptr=new vecteur; + ptr->history_out_ptr=new vecteur; + ptr->history_plot_ptr=new vecteur; + //init_context(ptr); + } + void init_context(context * ptr){ if (!ptr){ CERR << "init_context on null context" << '\n'; diff --git a/apps/KhiCAS/src/giac-1.6.0/src/global.h b/apps/KhiCAS/src/giac-1.6.0/src/global.h index fdb6596e9..f48f6ef6b 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/global.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/global.h @@ -18,6 +18,7 @@ */ #ifndef _GIAC_GLOBAL_H #define _GIAC_GLOBAL_H +//#define USE_OBJET_BIDON #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -369,6 +370,7 @@ Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); extern int GAMMA_LIMIT; extern int LIST_SIZE_LIMIT; extern int NEWTON_DEFAULT_ITERATION; + extern int NEWTON_MAX_RANDOM_RESTART; extern int DEFAULT_EVAL_LEVEL; extern int PARENTHESIS_NWAIT; extern int MAX_PROD_EXPAND_SIZE; @@ -814,6 +816,7 @@ throw(std::runtime_error("Stopped by user interruption.")); \ context * clone_context(const context *); void init_context(context * ptr); + void clear_context(context * ptr); extern const context * context0; std::vector & context_list(); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/help.cc b/apps/KhiCAS/src/giac-1.6.0/src/help.cc index 8e01e407c..4f3322fee 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/help.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/help.cc @@ -1030,11 +1030,16 @@ namespace giac { if (t>29 && ((stmp=s.substr(0,29))=="
  • " || stmp=="
  • ")){ s=s.substr(29,s.size()-29); t=int(s.size()); - if (!t || s[0]=='<') // skip index words with special color/font + if (!t) continue; + if (s[0]=='<'){ // skip index words with special color/font + if (t<30 || s.substr(0,36)!="") + continue; + s=s.substr(36,s.size()-1); + } int endcmd=int(s.find("<")); // position of end of commandname if (endcmd>2 && endcmd hrefs; for (;;){ diff --git a/apps/KhiCAS/src/giac-1.6.0/src/identificateur.cc b/apps/KhiCAS/src/giac-1.6.0/src/identificateur.cc index a43838559..bb9acf434 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/identificateur.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/identificateur.cc @@ -19,7 +19,7 @@ */ using namespace std; #include -#if !defined GIAC_HAS_STO_38 && !defined NSPIRE && !defined FXCG +#if !defined GIAC_HAS_STO_38 && !defined NSPIRE && !defined FXCG #include #endif #include @@ -128,8 +128,8 @@ namespace giac { #endif // GIAC_GENERIC_CONSTANTS -#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined KHICAS -#if 0 +#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined KHICAS || defined FXCG +#if 0 // 38 mode static const alias_identificateur alias_identificateur_a38={0,0,"A",0,0}; const identificateur & a__IDNT=* (const identificateur *) &alias_identificateur_a38; const alias_ref_identificateur ref_a38={-1,0,0,"A",0,0}; @@ -292,7 +292,7 @@ namespace giac { const define_alias_gen(alias_z38,_IDNT,0,&ref_z38); // const gen & z__IDNT_e = * (gen *) & alias_z38; -#else +#else // 38 mode static const alias_identificateur alias_identificateur_a38={0,0,"a",0,0}; const identificateur & a__IDNT=* (const identificateur *) &alias_identificateur_a38; const alias_ref_identificateur ref_a38={-1,0,0,"a",0,0}; @@ -454,7 +454,7 @@ namespace giac { const alias_ref_identificateur ref_z38={-1,0,0,"z",0,0}; const define_alias_gen(alias_z38,_IDNT,0,&ref_z38); // const gen & z__IDNT_e = * (gen *) & alias_z38; -#endif +#endif // else 38 static const alias_identificateur alias_identificateur_laplace_var={0,0," s",0,0}; const identificateur & laplace_var=* (const identificateur *) &alias_identificateur_laplace_var; @@ -480,15 +480,28 @@ namespace giac { const define_alias_gen(alias_at38,_IDNT,0,&ref_at38); const gen & at__IDNT_e = * (gen *) & alias_at38; +#ifndef FXCG #ifdef CAS38_DISABLED define_alias_gen(alias_vx38,_IDNT,0,&ref_x38); #else define_alias_gen(alias_vx38,_IDNT,0,&ref_xx38); #endif +#endif +#if defined NSPIRE || defined FXCG #ifdef NSPIRE // gen & vx_var = * (gen *) & alias_vx38; gen vx_var; +#else + gen & get_vx_var(){ + static gen * ptr=0; + if (!ptr){ + ptr=new gen(identificateur("x")); + } + //* ((char *)ptr->_IDNTptr->id_name)=xthetat?'t':'x'; + return * ptr; + } +#endif #else gen vx_var(identificateur("x")); #endif @@ -555,7 +568,11 @@ namespace giac { gen y__IDNT_e(y__IDNT); identificateur z__IDNT("z"); gen z__IDNT_e(z__IDNT); +#ifdef FXCG + identificateur laplace_var("S"); +#else identificateur laplace_var(" s"); +#endif gen laplace_var_e(laplace_var); identificateur theta__IDNT("θ"); gen theta__IDNT_e(theta__IDNT); @@ -999,7 +1016,9 @@ namespace giac { return orig; // If 38 is there, let it look at the current state and decide if it needs to evaluate the name or if it needs to let the CAS do it // This will depend on the order of priorities and the status of the requested variable (local/global...) +#ifndef FXCG if (storcl_38 && abs_calc_mode(contextptr)==38 && storcl_38(evaled,NULL,id_name,undef,false,contextptr,NULL,false)) return evaled; +#endif if (contextptr){ sym_tab::const_iterator it=contextptr->tabptr->find(id_name),itend=contextptr->tabptr->end(); if (it!=itend) @@ -1069,8 +1088,10 @@ namespace giac { // if (!ref_count) return false; // does not work for cst ref identificateur if (contextptr){ // Look for local variables... // If 38 is there, let it look at variable priorities, but ONLY looking at local for the moment! We do not want to look as globals as they might need to be quoted... +#ifndef FXCG if (storcl_38!=NULL && !No38Lookup && abs_calc_mode(contextptr)==38 && storcl_38(evaled,NULL,id_name,undef,false,contextptr, NULL, true)) return true; +#endif const context * cur=contextptr; int pythoncompat=python_compat(contextptr)?2:0; for (;cur->previous;cur=cur->previous){ @@ -1094,8 +1115,10 @@ namespace giac { if (cur->quoted_global_vars && !cur->quoted_global_vars->empty() && equalposcomp(*cur->quoted_global_vars,orig)) return false; // If 38 is there, look again, but now it is allowed to look at local and globals! +#ifndef FXCG if (storcl_38!=NULL && !No38Lookup && abs_calc_mode(contextptr)==38 && storcl_38(evaled,NULL,id_name,undef,false,contextptr, NULL, false)) return true; +#endif // printsymtab(cur->tabptr); sym_tab::const_iterator it=cur->tabptr->find(id_name); if (it==cur->tabptr->end()){ @@ -1120,10 +1143,12 @@ namespace giac { } if (quoted && *quoted & 1) return false; +#ifndef FXCG if (current_folder_name.type==_IDNT && current_folder_name._IDNTptr->value && current_folder_name._IDNTptr->value->type==_VECT){ evaled=find_in_folder(*current_folder_name._IDNTptr->value->_VECTptr,orig); return (evaled!=orig); } +#endif if (value){ evaled=value->eval(level,contextptr); return true; diff --git a/apps/KhiCAS/src/giac-1.6.0/src/ifactor.cc b/apps/KhiCAS/src/giac-1.6.0/src/ifactor.cc index 89c74f691..2db1a7cad 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/ifactor.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/ifactor.cc @@ -4163,7 +4163,7 @@ namespace giac { return g; return _matrix(makesequence(g._VECTptr->size()/2,2,g),contextptr); } -#ifndef EMCC +#if !defined EMCC && defined HAVE_LIBPARI if (b.type==_SYMB){ gen res; // b is assumed to be a minimal polynomial check if g is a norm @@ -4774,7 +4774,7 @@ namespace giac { else { // is q a power of a prime? double d=evalf_double(q,1,contextptr)._DOUBLE_val; - int maxpow=int(std::ceil(std::log(d)/std::log(3))); + int maxpow=int(std::ceil(std::log(d)/std::log(3.0))); for (int i=2;i<=maxpow;++i){ if ( (i>2 && i%2==0) || (i>3 && i%3==0) || diff --git a/apps/KhiCAS/src/giac-1.6.0/src/input_lexer.ll b/apps/KhiCAS/src/giac-1.6.0/src/input_lexer.ll index d71ff8289..d61f74c77 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/input_lexer.ll +++ b/apps/KhiCAS/src/giac-1.6.0/src/input_lexer.ll @@ -1039,11 +1039,18 @@ AN [0-9a-zA-Z_~ ?\200-\355\357-\376] } } bool instring=false; - // stupid match of bracket then parenthesis - int l=s.size(),nb=0,np=0; + // stupid match of bracket then parenthesis then quotes + int l=s.size(),nb=0,np=0,nq=0; int i=0; if (lexer_close_parenthesis(contextptr)){ for (;i2 && s[i-2]=='\'' && s[i-1]=='='){ + s.insert(s.begin()+i-1,' '); + ++l; + } + } if (!instring && i && s[i]=='/' && s[i-1]=='/'){ // skip comment until end of line for (;ifeuille,a,b; + if (is_linear_wrt(vf,gen_x,a,b,contextptr) && (a==1||a==-1)){ + if (b==0) break; // + gen e1=complex_subst(e,gen_x,a*(gen_x-b),contextptr); + gen E1=integrate_id_rem(e1,gen_x,remains_to_integrate,contextptr,intmode); + remains_to_integrate=complex_subst(remains_to_integrate,gen_x,a*gen_x+b,contextptr); + E1=complex_subst(E1,gen_x,a*gen_x+b,contextptr); + return a*E1/curgcd; + } + } + } if (!allsame && curgcd!=0 && curgcd!=1){ gen e1=complex_subst(e,gen_x,inv(curgcd,contextptr)*gen_x,contextptr); v=vecteur(1,gen_x); @@ -2790,7 +2808,7 @@ namespace giac { for (int i=1;ifeuille,contextptr); + gen vf=expand(ratnormal(v[i]._SYMBptr->feuille,contextptr),contextptr); vrep[i]=symbolic(v[i]._SYMBptr->sommet,vf); } if (v!=vrep) e1=complex_subst(e1,v,vrep,contextptr); @@ -4289,8 +4307,8 @@ namespace giac { primitive=integrate_chknum(v[0],x,rem,contextptr); primitive=eval(primitive,1,contextptr); restorepurge(xval,x,contextptr); - gen rs=limit(primitive,*x._IDNTptr,borne_sup,-1,contextptr); gen ri=limit(primitive,*x._IDNTptr,borne_inf,1,contextptr); + gen rs=limit(primitive,*x._IDNTptr,borne_sup,-1,contextptr); res=rs-ri; } else { @@ -5855,7 +5873,7 @@ namespace giac { gen af=evalf_double(v[2],1,contextptr),bf=evalf_double(v[3],1,contextptr); if (v[1].type==_IDNT && (is_inf(af) || af.type==_DOUBLE_) && (is_inf(bf) || bf.type==_DOUBLE_)){ vecteur w; -#ifndef NSPIRE +#if !defined FXCG && !defined NSPIRE my_ostream * ptr=logptr(contextptr); logptr(0,contextptr); #endif @@ -5878,7 +5896,7 @@ namespace giac { v0=v[0]; } #endif -#ifndef NSPIRE +#if !defined FXCG && !defined NSPIRE logptr(ptr,contextptr); #endif for (unsigned i=0;i=0 && h>=0) + os_fill_rect(x,y,w,h,c); } int os_get_pixel(int x,int y); /* returns new x position */ diff --git a/apps/KhiCAS/src/giac-1.6.0/src/k_defs.h b/apps/KhiCAS/src/giac-1.6.0/src/k_defs.h index ddc3f91f4..f52f36335 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/k_defs.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/k_defs.h @@ -1,4 +1,4 @@ -#define NSPIRE_FILEBUFFER 32768 +#define NSPIRE_FILEBUFFER 512*1024 // Character codes #define KEY_CHAR_0 0x30 #define KEY_CHAR_1 0x31 @@ -196,3 +196,4 @@ #define KEY_PRGM_ALPHA 77 #define KEY_PRGM_SHIFT 78 #define KEY_PRGM_MENU 48 +#define KEY_CTRL_SD 39990 diff --git a/apps/KhiCAS/src/giac-1.6.0/src/kadd.cc b/apps/KhiCAS/src/giac-1.6.0/src/kadd.cc index c98151ff9..99ef204db 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/kadd.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/kadd.cc @@ -154,6 +154,8 @@ void mastermind_disp(const vector & solution,const vector< vector > & //CERR << solution << " " << essai << " " << bien << " " << mal << endl; } } + os_draw_string(10,y0+20*4+2,COLOR_GREEN,_WHITE,"="); + os_draw_string(10,y0+20*5+2,COLOR_MAGENTA,_WHITE,"~"); int y=170; int x=os_draw_string_small_(x0,y,"0"); draw_filled_circle(x+10,y+10,10,COLOR_BLUE); @@ -229,33 +231,228 @@ int mastermind(GIAC_CONTEXT){ return 0; } +// Newton iteration for polynomial +// with simult Horner evaluation of p and p' at x +complex horner_newton(const vector> & p,const std::complex &x){ + complex num,den; + vector>::const_iterator it=p.begin(),itend=p.end(); + int n=itend-it-1; + for (;n;--n,++it){ + num *= x; + den *= x; + num += *it; + den += double(n)*(*it); + } // end for + // last step + num *= x; + num += *it; + return x-num/den; +} + +complex horner_newton(const vector & p,const std::complex &x){ + vector::const_iterator it=p.begin(),itend=p.end(); + int n=itend-it-1; + complex num=*it*x+*(it+1),den=(double(n)*(*it))*x+double(n-1)*(*(it+1)); + for (it+=2,n-=2;n;--n,++it){ + num *= x; + den *= x; + num += *it; + den += double(n)*(*it); + } // end for + // last step + num *= x; + num += *it; + return x-num/den; +} + int fractale(GIAC_CONTEXT){ freeze=true; - int X=320,Y=222,Nmax=10; - double d=10; - if (inputdouble(lang?"Number of iterations? (default 10)":"Nombre d'iterations? (defaut 10)",d,contextptr) && d>=1 && d<=20) - Nmax=d; - double w=2.7/X; - double h=-1.87/Y; - for (int y=0;y<=Y/2;++y){ - complex c(-2.1,h*y+0.935); - for (int x=0;x z(0); - int j; - for (j=0;j2) - break; + int X=320,Y=222,Nmax=16,Nmaxmin=5,Nmaxmax=50; + bool mandel=do_confirm("EXE: Mandelbrot, Back: bassins racines"); + vecteur P; vector> p,Z; + double np=0; complex na; + // if the polynomial is x^np+a=0 + // Newton iteration is x-(x^n+a)/(n*x^(n-1))=((n-1)*x-a)/(n*x^(n-1)) + vector pr; + bool real=true; + if (!mandel){ // Input Julia + string s; + inputline("Polynome (x^3-1)?","",s,false,65,contextptr); + if (s.empty()) s="x^3-1"; + gen g(s,contextptr); + g=_symb2poly(g,contextptr); + if (g.type!=_VECT || g._VECTptr->size()<3 || g._VECTptr->size()>9){ + do_confirm("Not a polynomial or degree<2 or degree>8"); + return 0; + } + P=*g._VECTptr; + if (!convert(P,p,true)){ + do_confirm("Unable to convert"); + return 0; + } + // detect x^n+a==0 + np=P.size()-1; + for (int i=1;i0; + int Ysym=2*ymax/(ymax-ymin)*Y-1; + for (int y=0;y c(xmin,h*y+ymax); + for (int x=0;x z(0); + for (j=0;j4) // this is more efficient than abs(z)>2 + break; + } + int color=126*j+2079; + os_set_pixel(x,y,color); + if (sym && ysym>0 && ysym c(xmin,h*y+ymax); + for (int x=0;x z(c),zp; + int nrac=Z.size(),j; + // Newton iterations + for (j=0;j1e20) + break; + zp=z; + if (np){ + z *=z ; + for (int i=3;i0 && ysymNmaxmin){ + --Nmax; continue; + } + if ( (k=='m' || k=='>' || k=='7' || k==KEY_CHAR_SQUARE) && Nmax=0){ char buf[2]={c,0}; @@ -497,7 +699,7 @@ int khicas_addins_menu(GIAC_CONTEXT){ } break; } - if (smallmenu.selection==6){ + if (smallmenu.selection==7){ // Exemple simple d'application tierce: la suite de Syracuse // on entre la valeur de u0 double d; int i; @@ -518,16 +720,16 @@ int khicas_addins_menu(GIAC_CONTEXT){ v.push_back(i); } // representation graphique de la liste en appelant la commande Xcas listplot - displaygraph(_listplot(v,contextptr),contextptr); + displaygraph(_listplot(v,contextptr),symbolic(at_listplot,v),contextptr); // copie vers presse-papier en l'affichant copy_clipboard(gen(v).print(contextptr),true); continue; // on entre la liste en ligne de commande et on quitte return Console_Input(gen(v).print(contextptr).c_str()); } - if (smallmenu.selection==7) // mastermind, on ne quitte pas + if (smallmenu.selection==8) // mastermind, on ne quitte pas mastermind(contextptr); - if (smallmenu.selection==8) + if (smallmenu.selection==9) fractale(contextptr); } // end sres==menu_selection Console_Disp(1,contextptr); @@ -1158,7 +1360,7 @@ void sheet_graph(tableur &t,GIAC_CONTEXT){ vecteur v; sheet_pnt(t.m,v); gen g(v); - check_do_graph(g,2,contextptr); + check_do_graph(g,0,2,contextptr); } int sheet_menu_menu(tableur & t,GIAC_CONTEXT){ @@ -1443,6 +1645,8 @@ giac::gen sheet(GIAC_CONTEXT){ if (!sheetptr) sheetptr=new_tableur(contextptr); tableur & t=*sheetptr; + sheet_eval(t,contextptr,true); + t.changed=false; bool status_freeze=false; t.keytooltip=false; for (;;){ @@ -1786,5 +1990,56 @@ giac::gen sheet(GIAC_CONTEXT){ } } - +int geoapp(GIAC_CONTEXT){ + int res=newgeo(contextptr); + if (res<0) return res; + // load a figure? + textArea * text=geoptr->hp; + vector fign,figs; + vecteur V(gen2vecteur(giac::_VARS(0,contextptr))); + for (int i=0;isize()==2 && val._VECTptr->front()==at_pnt){ + vecteur & v=*val._VECTptr; + if (v[1].type==_STRNG){ + fign.push_back(tmp.print(contextptr)); + figs.push_back(*v[1]._STRNGptr); + } + } + } + if (1 || !figs.empty()){ + if (0 && figs.size()==1){ + text->elements.clear(); + add(text,figs[0]); + text->filename=fign[0]; + } + else { + const char * tab[figs.size()+3]={0}; + for (int i=0;i=0 && selements.clear(); + if (sfilename=fign[s]+".py"; + geoparse(text,contextptr); + } + else { + geoptr->plot_instructions.clear(); + geoptr->symbolic_instructions.clear(); + geoptr->is3d=(s==figs.size()+1); + geoptr->update_rotation(); + geoptr->orthonormalize(); + text->filename="figure"+print_INT_(figs.size()+1)+".py"; + } + } + else return -3; + } + } + return geoloop(geoptr); +} #endif diff --git a/apps/KhiCAS/src/giac-1.6.0/src/kadd.cc~ b/apps/KhiCAS/src/giac-1.6.0/src/kadd.cc~ index 81c54e768..286f6fb14 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/kadd.cc~ +++ b/apps/KhiCAS/src/giac-1.6.0/src/kadd.cc~ @@ -154,6 +154,8 @@ void mastermind_disp(const vector & solution,const vector< vector > & //CERR << solution << " " << essai << " " << bien << " " << mal << endl; } } + os_draw_string(10,y0+20*4+2,COLOR_GREEN,_WHITE,"="); + os_draw_string(10,y0+20*5+2,COLOR_MAGENTA,_WHITE,"~"); int y=170; int x=os_draw_string_small_(x0,y,"0"); draw_filled_circle(x+10,y+10,10,COLOR_BLUE); @@ -229,33 +231,228 @@ int mastermind(GIAC_CONTEXT){ return 0; } +// Newton iteration for polynomial +// with simult Horner evaluation of p and p' at x +complex horner_newton(const vector> & p,const std::complex &x){ + complex num,den; + vector>::const_iterator it=p.begin(),itend=p.end(); + int n=itend-it-1; + for (;n;--n,++it){ + num *= x; + den *= x; + num += *it; + den += double(n)*(*it); + } // end for + // last step + num *= x; + num += *it; + return x-num/den; +} + +complex horner_newton(const vector & p,const std::complex &x){ + vector::const_iterator it=p.begin(),itend=p.end(); + int n=itend-it-1; + complex num=*it*x+*(it+1),den=(double(n)*(*it))*x+double(n-1)*(*(it+1)); + for (it+=2,n-=2;n;--n,++it){ + num *= x; + den *= x; + num += *it; + den += double(n)*(*it); + } // end for + // last step + num *= x; + num += *it; + return x-num/den; +} + int fractale(GIAC_CONTEXT){ freeze=true; - int X=320,Y=222,Nmax=10; - double d=10; - if (inputdouble(lang?"Number of iterations? (default 10)":"Nombre d'iterations? (defaut 10)",d,contextptr) && d>=1 && d<=20) - Nmax=d; - double w=2.7/X; - double h=-1.87/Y; - for (int y=0;y<=Y/2;++y){ - complex c(-2.1,h*y+0.935); - for (int x=0;x z(0); - int j; - for (j=0;j2) - break; + int X=320,Y=222,Nmax=16,Nmaxmin=5,Nmaxmax=50; + bool mandel=do_confirm("EXE: Mandelbrot, Back: bassins racines"); + vecteur P; vector> p,Z; + double np=0; complex na; + // if the polynomial is x^np+a=0 + // Newton iteration is x-(x^n+a)/(n*x^(n-1))=((n-1)*x-a)/(n*x^(n-1)) + vector pr; + bool real=true; + if (!mandel){ // Input Julia + string s; + inputline("Polynome (x^3-1)?","",s,false,65,contextptr); + if (s.empty()) s="x^3-1"; + gen g(s,contextptr); + g=_symb2poly(g,contextptr); + if (g.type!=_VECT || g._VECTptr->size()<3 || g._VECTptr->size()>9){ + do_confirm("Not a polynomial or degree<2 or degree>8"); + return 0; + } + P=*g._VECTptr; + if (!convert(P,p,true)){ + do_confirm("Unable to convert"); + return 0; + } + // detect x^n+a==0 + np=P.size()-1; + for (int i=1;i0; + int Ysym=2*ymax/(ymax-ymin)*Y-1; + for (int y=0;y c(xmin,h*y+ymax); + for (int x=0;x z(0); + for (j=0;j4) // this is more efficient than abs(z)>2 + break; + } + int color=126*j+2079; + os_set_pixel(x,y,color); + if (sym && ysym>0 && ysym c(xmin,h*y+ymax); + for (int x=0;x z(c),zp; + int nrac=Z.size(),j; + // Newton iterations + for (j=0;j1e20) + break; + zp=z; + if (np){ + z *=z ; + for (int i=3;i0 && ysymNmaxmin){ + --Nmax; continue; + } + if ( (k=='m' || k=='>' || k=='7' || k==KEY_CHAR_SQUARE) && Nmax & elem=text.elements; @@ -365,11 +562,15 @@ int finance(int mode,GIAC_CONTEXT){ // mode==-1 pret, 1 placement } solved=true; } - if (sres==KEY_CTRL_EXE || sres == MENU_RETURN_SELECTION || sres == KEY_CTRL_OK) { + int keynumber=-1; + if (sres>=KEY_CHAR_0 && sres<=KEY_CHAR_9) keynumber=sres-KEY_CHAR_0; + if (sres==KEY_CTRL_EXE || sres == MENU_RETURN_SELECTION || sres == KEY_CTRL_OK || keynumber>=0) { if (smallmenu.selection==7) // quit break; double d=*tabd[choix]; if (choix<2 && mode==1) d=-d; + if (keynumber>=0) + d=keynumber; if (!inputdouble(tab[choix],d,contextptr)) continue; if (choix<2 && mode==1) d=-d; @@ -392,12 +593,14 @@ int finance(int mode,GIAC_CONTEXT){ // mode==-1 pret, 1 placement return 0; } +int geoapp(GIAC_CONTEXT); + int khicas_addins_menu(GIAC_CONTEXT){ Menu smallmenu; #ifdef NUMWORKS - smallmenu.numitems=10; // INCREMENT IF YOU ADD AN APPLICATION + smallmenu.numitems=12; // INCREMENT IF YOU ADD AN APPLICATION #else - smallmenu.numitems=9; // INCREMENT IF YOU ADD AN APPLICATION + smallmenu.numitems=11; // INCREMENT IF YOU ADD AN APPLICATION #endif // and uncomment first smallmenuitems[app_number].text="Reserved" // replace by your application name @@ -407,18 +610,20 @@ int khicas_addins_menu(GIAC_CONTEXT){ smallmenu.height=12; smallmenu.scrollbar=1; smallmenu.scrollout=1; - smallmenuitems[0].text = (char*)((lang==1)?"Tableur":"Spreadsheet"); - smallmenuitems[1].text = (char*)((lang==1)?"Table periodique":"Periodic table"); - smallmenuitems[2].text = (char*)((lang==1)?"Pret":"Mortgage"); - smallmenuitems[3].text = (char*)((lang==1)?"Epargne":"TVM"); - smallmenuitems[4].text = (char*)((lang==1)?"Exemple simple: Syracuse":"Simple example; Syracuse"); - smallmenuitems[5].text = (char*)((lang==1)?"Exemple de jeu: Mastermind":"Game example: Mastermind"); - smallmenuitems[6].text = (char*)((lang==1)?"Fractale de Mandelbrot":"Mandelbrot fractal"); - // smallmenuitems[5].text = (char*)"Mon application"; // adjust numitem ! - // smallmenuitems[6].text = (char*)"Autre application"; - // smallmenuitems[7].text = (char*)"Encore une autre"; - // smallmenuitems[8].text = (char*)"Une avant-derniere"; - // smallmenuitems[9].text = (char*)"Une derniere"; + smallmenuitems[0].text = (char*)((lang==1)?"Geometrie":"Geometry"); + smallmenuitems[1].text = (char*)((lang==1)?"Tableur":"Spreadsheet"); + smallmenuitems[2].text = (char*)((lang==1)?"Table periodique":"Periodic table"); + smallmenuitems[3].text = (char*)((lang==1)?"Pret":"Mortgage"); + smallmenuitems[4].text = (char*)((lang==1)?"Epargne":"TVM"); + smallmenuitems[5].text = (char*)((lang==1)?"Table caracteres":"Char table"); + smallmenuitems[6].text = (char*)((lang==1)?"Exemple simple: Syracuse":"Simple example; Syracuse"); + smallmenuitems[7].text = (char*)((lang==1)?"Exemple de jeu: Mastermind":"Game example: Mastermind"); + smallmenuitems[8].text = (char*)((lang==1)?"Exemples de fractales":"Fractals examples"); + // smallmenuitems[8].text = (char*)"Mon application"; // adjust numitem ! + // smallmenuitems[9].text = (char*)"Autre application"; + // smallmenuitems[10].text = (char*)"Encore une autre"; + // smallmenuitems[11].text = (char*)"Une avant-derniere"; + // smallmenuitems[12].text = (char*)"Une derniere"; #ifdef NUMWORKS smallmenuitems[smallmenu.numitems-3].text = (char*)((lang==1)?"Personnaliser la flash":"Customize flash"); #endif @@ -435,9 +640,11 @@ int khicas_addins_menu(GIAC_CONTEXT){ handle_flash(contextptr); #endif // Attention les entrees sont decalees de 1 - if (smallmenu.selection==1) // tableur + if (smallmenu.selection==1) // geometry + geoapp(contextptr); + if (smallmenu.selection==2) // tableur sheet(contextptr); - if (smallmenu.selection==2){ // table periodique + if (smallmenu.selection==3){ // table periodique const char * name,*symbol; char protons[32],nucleons[32],mass[32],electroneg[32]; int res=periodic_table(name,symbol,protons,nucleons,mass,electroneg); @@ -473,17 +680,26 @@ int khicas_addins_menu(GIAC_CONTEXT){ ptr=strcpy(ptr,",")+strlen(ptr); ptr=strcpy(ptr,electroneg+4)+strlen(ptr); } - return Console_Input(console_buf); + copy_clipboard(console_buf,true); + // return Console_Input(console_buf); } - if (smallmenu.selection==3){ + if (smallmenu.selection==4){ finance(-1,contextptr); continue; } - if (smallmenu.selection==4){ + if (smallmenu.selection==5){ finance(1,contextptr); continue; } - if (smallmenu.selection==5){ + if (smallmenu.selection==6){ + int c=chartab(); + if (c>=0){ + char buf[2]={c,0}; + copy_clipboard(buf,true); + } + break; + } + if (smallmenu.selection==7){ // Exemple simple d'application tierce: la suite de Syracuse // on entre la valeur de u0 double d; int i; @@ -504,13 +720,16 @@ int khicas_addins_menu(GIAC_CONTEXT){ v.push_back(i); } // representation graphique de la liste en appelant la commande Xcas listplot - displaygraph(_listplot(v,contextptr),contextptr); + displaygraph(_listplot(v,contextptr),symbolic(at_listplot,v),contextptr); + // copie vers presse-papier en l'affichant + copy_clipboard(gen(v).print(contextptr),true); + continue; // on entre la liste en ligne de commande et on quitte return Console_Input(gen(v).print(contextptr).c_str()); } - if (smallmenu.selection==6) // mastermind, on ne quitte pas + if (smallmenu.selection==8) // mastermind, on ne quitte pas mastermind(contextptr); - if (smallmenu.selection==7) + if (smallmenu.selection==9) fractale(contextptr); } // end sres==menu_selection Console_Disp(1,contextptr); @@ -1141,7 +1360,7 @@ void sheet_graph(tableur &t,GIAC_CONTEXT){ vecteur v; sheet_pnt(t.m,v); gen g(v); - check_do_graph(g,2,contextptr); + check_do_graph(g,0,2,contextptr); } int sheet_menu_menu(tableur & t,GIAC_CONTEXT){ @@ -1352,8 +1571,11 @@ void sheet_cmdline(tableur &t,GIAC_CONTEXT){ if (g1.type==_VECT){ doit=false; matrice & m=*g1._VECTptr; - if (!ckmatrix(m) && t.movedown) - m=mtran(vecteur(1,m)); + if (!ckmatrix(m)){ + m=vecteur(1,m); + if (t.movedown) + m=mtran(m); + } matrice clip=t.clip; makespreadsheetmatrice(m,contextptr); t.clip=m; @@ -1423,6 +1645,8 @@ giac::gen sheet(GIAC_CONTEXT){ if (!sheetptr) sheetptr=new_tableur(contextptr); tableur & t=*sheetptr; + sheet_eval(t,contextptr,true); + t.changed=false; bool status_freeze=false; t.keytooltip=false; for (;;){ @@ -1664,7 +1888,7 @@ giac::gen sheet(GIAC_CONTEXT){ if ( (key >= KEY_CTRL_F1 && key <= KEY_CTRL_F6) || (key >= KEY_CTRL_F7 && key <= KEY_CTRL_F14) ){ - const char tmenu[]= "F1 stat1d\nsum(\nmean(\nstddev(\nmedian(\nhistogram(\nbarplot(\nboxwhisker(\nF2 stat2d\nlinear_regression_plot(\nlogarithmic_regression_plot(\nexponential_regression_plot(\npower_regression_plot(\npolynomial_regression_plot(\nsin_regression_plot(\nscatterplot(\npolygonscatterplot(\nF3 seq\nrange(\nseq(\ntableseq(\nplotseq(\ntablefunc(\nrandvector(\nrandmatrix(\nF4 edt\nedit_cell\nundo\ncopy_down\ncopy_right\ninsert_row\ninsert_col\nerase_row\nerase_col\nF6 graph\nreserved\nF= poly\nproot(\npcoeff(\nquo(\nrem(\ngcd(\negcd(\nresultant(\nGF(\nF: arit\n mod \nirem(\nifactor(\ngcd(\nisprime(\nnextprime(\npowmod(\niegcd(\nF8 list\nmakelist(\nrange(\nseq(\nlen(\nappend(\nranv(\nsort(\napply(\nF; plot\nplot(\nplotseq(\nplotlist(\nplotparam(\nplotpolar(\nplotfield(\nhistogram(\nbarplot(\nF7 real\nexact(\napprox(\nfloor(\nceil(\nround(\nsign(\nmax(\nmin(\nF< prog\n:\n&\n#\nhexprint(\nbinprint(\nf(x):=\ndebug(\npython(\nF> cplx\nabs(\narg(\nre(\nim(\nconj(\ncsolve(\ncfactor(\ncpartfrac(\nF= misc\n!\nrand(\nbinomial(\nnormald(\nexponentiald(\n\\\n % \n\n"; + const char tmenu[]= "F1 stat1d\nsum(\nmean(\nstddev(\nmedian(\nhistogram(\nbarplot(\nboxwhisker(\nF2 stat2d\nlinear_regression_plot(\nlogarithmic_regression_plot(\nexponential_regression_plot(\npower_regression_plot(\npolynomial_regression_plot(\nsin_regression_plot(\nscatterplot(\npolygonscatterplot(\nF3 seq\nrange(\nseq(\ntableseq(\nplotseq(\ntablefunc(\nrandvector(\nrandmatrix(\nF4 edt\n$\n:\nedit_cell\nundo\ncopy_down\ncopy_right\ninsert_row\ninsert_col\nF6 graph\nreserved\nF= poly\nproot(\npcoeff(\nquo(\nrem(\ngcd(\negcd(\nresultant(\nGF(\nF: arit\n mod \nirem(\nifactor(\ngcd(\nisprime(\nnextprime(\npowmod(\niegcd(\nF8 list\nmakelist(\nrange(\nseq(\nlen(\nappend(\nranv(\nsort(\napply(\nF; plot\nplot(\nplotseq(\nplotlist(\nplotparam(\nplotpolar(\nplotfield(\nhistogram(\nbarplot(\nF7 real\nexact(\napprox(\nfloor(\nceil(\nround(\nsign(\nmax(\nmin(\nF< prog\n:\n&\n#\nhexprint(\nbinprint(\nf(x):=\ndebug(\npython(\nF> cplx\nabs(\narg(\nre(\nim(\nconj(\ncsolve(\ncfactor(\ncpartfrac(\nF= misc\n!\nrand(\nbinomial(\nnormald(\nexponentiald(\n\\\n % \n\n"; const char * s=console_menu(key,(char *)tmenu,0); if (s && strlen(s)){ if (strcmp(s,"undo")==0){ @@ -1766,5 +1990,55 @@ giac::gen sheet(GIAC_CONTEXT){ } } - +int geoapp(GIAC_CONTEXT){ + int res=newgeo(contextptr); + if (res<0) return res; + // load a figure? + textArea * text=geoptr->hp; + vector fign,figs; + vecteur V(gen2vecteur(giac::_VARS(0,contextptr))); + for (int i=0;isize()==2 && val._VECTptr->front()==at_pnt){ + vecteur & v=*val._VECTptr; + if (v[1].type==_STRNG){ + fign.push_back(tmp.print(contextptr)); + figs.push_back(*v[1]._STRNGptr); + } + } + } + if (1 || !figs.empty()){ + if (0 && figs.size()==1){ + text->elements.clear(); + add(text,figs[0]); + text->filename=fign[0]; + } + else { + const char * tab[figs.size()+3]={0}; + for (int i=0;i=0 && selements.clear(); + if (sfilename=fign[s]+".py"; + geoparse(text,contextptr); + } + else { + geoptr->plot_instructions.clear(); + geoptr->symbolic_instructions.clear(); + geoptr->is3d=(s==figs.size()+1); + geoptr->orthonormalize(); + text->filename="figure"+print_INT_(figs.size()+1)+".py"; + } + } + else return -3; + } + } + return geoloop(geoptr); +} #endif diff --git a/apps/KhiCAS/src/giac-1.6.0/src/kdisplay.cc b/apps/KhiCAS/src/giac-1.6.0/src/kdisplay.cc index 17349dfa6..594027c91 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/kdisplay.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/kdisplay.cc @@ -32,8 +32,10 @@ #ifndef is_cx2 #define is_cx2 false #endif - - +int osok=1; +// pour le mode examen cx2, il y a 2 endroits ou is_cx2 est utilise dans smallmenu.selection==1 +// soit par extinction des leds (marche avec OS 5.2) +// soit comme sur la CX si l'ecriture en flash NAND marche un jour #ifdef KHICAS @@ -222,7 +224,7 @@ namespace giac { s += char(cur); s += " "; s += print_INT_(cur); - s += " 0x"; + s += " "; s += hexa_print_INT_(cur); os_draw_string(0,160,_BLACK,_WHITE,s.c_str()); os_draw_string(0,180,_BLACK,_WHITE,lang==1?"EXE: copier caractere":"EXE: copy char"); @@ -462,17 +464,15 @@ namespace giac { menuitem[0]='0'+cur; menuitem[1]=' '; menuitem[2]=0; - strcpy(menuitem+2,menu->items[curitem].text); } else { menuitem[0]=cur>=10?('0'+(cur/10)):' '; menuitem[1]='0'+(cur%10); menuitem[2]=' '; menuitem[3]=0; - strcpy(menuitem+3,menu->items[curitem].text); } } - //strncat(menuitem, menu->items[curitem].text, 68); + strncat(menuitem, menu->items[curitem].text, 250); if(menu->items[curitem].type != MENUITEM_SEPARATOR) { //make sure we have a string big enough to have background when item is selected: // MB_ElementCount is used instead of strlen because multibyte chars count as two with strlen, while graphically they are just one char, making fillerRequired become wrong @@ -983,6 +983,7 @@ namespace giac { {"csolve(equation,x)", 0, "Resolution exacte dans C d'une equation en x (ou d'un systeme polynomial).","x^2+x+1=0", 0, CAT_CATEGORY_SOLVE | (CAT_CATEGORY_COMPLEXNUM << 8) | XCAS_ONLY}, {"cube(A,B,C)", 0, "Cube d'arete AB avec une face dans le plan ABC", "[0,0,0],[1,0,0],[0,1,0]","[0,0,0],[0,2,sqrt(5)/2+3/2],[0,0,1]", CAT_CATEGORY_3D}, {"curl(u,vars)", 0, "Rotationnel du vecteur u.", "[2*x*y,x*z,y*z],[x,y,z]", 0, CAT_CATEGORY_LINALG | XCAS_ONLY}, + {"curvature([x(t),y(t)],t,t0)", 0, "Courbure de la courbe parametree [x(t),y(t)] en t0", "[t,t^2],t,1", "[t,t^2],t", CAT_CATEGORY_CALCULUS | (CAT_CATEGORY_2D << 8) | XCAS_ONLY}, {"cyan", "cyan", "Option d'affichage", "#display=cyan", 0, CAT_CATEGORY_PROGCMD}, {"cylinder(A,v,r,[h])", 0, "Cylindre d'axe A,v de rayon r et de hauteur optionnelle h", "[0,0,0],[0,1,0],2", "[0,0,0],[0,1,0],2,3", CAT_CATEGORY_3D}, {"debug(f(args))", 0, "Execute la fonction f en mode pas a pas.", 0, 0, CAT_CATEGORY_PROG | XCAS_ONLY}, @@ -1029,6 +1030,7 @@ namespace giac { {"float(x)", 0, "Convertit x en nombre approche (flottant).", "pi", 0, CAT_CATEGORY_REAL}, {"floor(x)", 0, "Partie entiere de x", "pi", 0, CAT_CATEGORY_REAL}, {"fonction f(x)", "fonction", "Definition de fonction (Xcas). Par exemple\nfonction f(x)\n local y;\ny:=x*x;\nreturn y;\nffonction", 0, 0, CAT_CATEGORY_PROG | XCAS_ONLY}, + {"frenet([x(t),y(t)],t,t0)", 0, "Courbure, centre de courbure et repere de Frenet de la courbe parametree [x(t),y(t)] en t0", "[t,t^2],t,1", "[t,t^2],t", CAT_CATEGORY_CALCULUS | (CAT_CATEGORY_2D << 8) | XCAS_ONLY}, {"from arit import *", "from arit import *", "Instruction pour utiliser les fonctions d'arithmetique entiere en Python", "#from arit import *", "#import arit", CAT_CATEGORY_ARIT}, {"from cas import *", "from cas import *", "Permet d'utiliser le calcul formel depuis Python", "#from cas import *", "#import cas", CAT_CATEGORY_ALGEBRA|(CAT_CATEGORY_CALCULUS<<8)}, {"from cmath import *", "from cmath import *", "Instruction pour utiliser les fonctions de maths sur les complexes (trigo, exponentielle, log, ...) en Python", "#from cmath import *;i=1j", "#import cmath", CAT_CATEGORY_COMPLEXNUM}, @@ -1072,6 +1074,11 @@ namespace giac { {"iquo(a,b)", 0, "Quotient euclidien de deux entiers.", "23,13", 0, CAT_CATEGORY_ARIT | XCAS_ONLY}, {"irem(a,b)", 0,"Reste euclidien de deux entiers", "23,13", 0, CAT_CATEGORY_ARIT | XCAS_ONLY}, {"isprime(n)", 0, "Renvoie 1 si n est premier, 0 sinon.", "11", "10", CAT_CATEGORY_ARIT}, + {"is_collinear(A,B,C)", 0, "Renvoie 1 ou 2 si A, B, C sont alignes, 0 sinon.", "1,i,-1", "i,0,-i", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_concyclic(A,B,C,D)", 0, "Renvoie 1 si A, B, C, D sont cocyliques, 0 sinon.", "1,i,-1,-i", "1,i,0,-i", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_element(A,G)", 0, "Renvoie 1 si A appartient a G, 0 sinon.", "point(0),circle(0,1)", "point(i),square(0,1)", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_parallel(D,E)", 0, "Renvoie 1 si D et E sont paralleles, 0 sinon.", "line(y=x),line(y=-x)", "line(y=x),line(y=x+1)", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_perpendicular(D,E)", 0, "Renvoie 1 si D et E sont perpendiculaires, 0 sinon.", "line(y=x),line(y=-x)", "line(y=x),line(y=x+1)", CAT_CATEGORY_2D | XCAS_ONLY }, {"jordan(A)", 0, "Forme normale de Jordan de la matrice A, renvoie P et D tels que P^-1*A*P=D", "[[1,2],[3,4]]", "[[1,1,-1,2,-1],[2,0,1,-4,-1],[0,1,1,1,1],[0,1,2,0,1],[0,0,-3,3,-1]]", CAT_CATEGORY_MATRIX | XCAS_ONLY}, {"laguerre(n,a,x)", 0, "n-ieme polynome de Laguerre (a=0 par defaut).", "10", 0, CAT_CATEGORY_POLYNOMIAL | XCAS_ONLY}, {"laplace(f,x,s)", 0, "Transformee de Laplace de f","sin(x),x,s", 0, CAT_CATEGORY_CALCULUS | XCAS_ONLY}, @@ -1110,6 +1117,7 @@ namespace giac { {"numer(x)", 0, "Numerateur de x.", "3/4", 0, CAT_CATEGORY_POLYNOMIAL | XCAS_ONLY}, {"octahedron(A,B,C)", 0, "Octaedre d'arete AB avec une face dans le plan ABC", "[0,0,0],[3,0,0],[0,1,0]", 0, CAT_CATEGORY_3D}, {"odesolve(f(t,y),[t,y],[t0,y0],t1)", 0, "Solution approchee d'equation differentielle y'=f(t,y) et y(t0)=y0, valeur en t1 (ajouter curve pour les valeurs intermediaires de y)", "sin(t*y),[t,y],[0,1],2", "0..pi,(t,v)->{[-v[1],v[0]]},[0,1]", CAT_CATEGORY_SOLVE | XCAS_ONLY}, + {"osculating_circle([x(t),y(t)],t,t0)", 0, "Cercle osculateur de la courbe parametree [x(t),y(t)] en t0", "[t,t^2],t,1", "[t,t^2],t", CAT_CATEGORY_CALCULUS | (CAT_CATEGORY_2D << 8) | XCAS_ONLY}, {"parabole(F,A)", 0, "Parabole donnee par foyer et sommet", "-2-i,2+i", 0, CAT_CATEGORY_2D}, {"parameq(objet)", 0, "Equations parametriques. Utiliser equation pour une equation cartesienne", "circle(0,1)", "ellipse(-1,1,3)", CAT_CATEGORY_2D | (CAT_CATEGORY_3D << 8) }, {"partfrac(p,x)", 0, "Decomposition en elements simples. Raccourci p=>+", "1/(x^4-1)", 0, CAT_CATEGORY_ALGEBRA | XCAS_ONLY}, @@ -1461,6 +1469,11 @@ const catalogFunc completeCaten[] = { // list of all functions (including some n {"iquo(a,b)", 0, "Integer quotient of a and b.", "23,13", 0, CAT_CATEGORY_ARIT}, {"irem(a,b)", 0,"Integer remainder of a and b.", "23,13", 0, CAT_CATEGORY_ARIT}, {"isprime(n)", 0, "Returns 1 if n is prime, 0 otherwise.", "11", "10", CAT_CATEGORY_ARIT}, + {"is_collinear(A,B,C)", 0, "Returns 1 if A, B, C are collinear, 0 otherwise", "1,i,-1", "i,0,-i", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_concyclic(A,B,C,D)", 0, "Returns 1 if A, B, C, D are concyclic, 0 otherwise", "1,i,-1,-i", "1,i,0,-i", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_element(A,G)", 0, "Returns 1 if A belongs to G, 0 otherwise.", "point(0),circle(0,1)", "point(i),square(0,1)", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_parallel(D,E)", 0, "Returns 1 if D and E are parallel, 0 otherwise", "line(y=x),line(y=-x)", "line(y=x),line(y=x+1)", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_perpendicular(D,E)", 0, "Returns 1 if D and E are perpendicular, 0 otherwise", "line(y=x),line(y=-x)", "line(y=x),line(y=x+1)", CAT_CATEGORY_2D | XCAS_ONLY }, {"jordan(A)", 0, "Jordan normal form of matrix A, returns P and D such that P^-1*A*P=D", "[[1,2],[3,4]]", "[[1,1,-1,2,-1],[2,0,1,-4,-1],[0,1,1,1,1],[0,1,2,0,1],[0,0,-3,3,-1]]", CAT_CATEGORY_MATRIX}, {"laguerre(n,a,x)", 0, "n-ieme Laguerre polynomial (default a=0).", "10", 0, CAT_CATEGORY_POLYNOMIAL}, {"laplace(f,x,s)", 0, "Laplace transform of f","sin(x),x,s", 0, CAT_CATEGORY_CALCULUS}, @@ -2267,6 +2280,109 @@ const catalogFunc completeCaten[] = { // list of all functions (including some n return i; } + // geo_print / geoprint + std::string _pnt2string(const giac::gen & g,const giac::context * contextptr){ + unsigned ta=taille(g,100); + if (ta>100) + return "Done"; + if (g.is_symb_of_sommet(giac::at_pnt)){ + giac::gen & f=g._SYMBptr->feuille; + giac::gen fp=remove_at_pnt(g); + if (fp.is_symb_of_sommet(giac::at_hyperplan)){ + return gettext("plan")+string("(")+_equation(g,contextptr).print(contextptr)+string(")"); + } + if (f.type==giac::_VECT && !f._VECTptr->empty()){ + giac::gen f0=f._VECTptr->front(); + if (f0.is_symb_of_sommet(giac::at_legende)){ + return g.print(contextptr); + } + if (f0.is_symb_of_sommet(giac::at_curve)){ + giac::gen f1=f[0]._SYMBptr->feuille; + if (f1.type==giac::_VECT && !f1._VECTptr->empty() ){ + giac::gen f1f=f1._VECTptr->front(); + if (f1f.type==giac::_VECT && f1f._VECTptr->size()>=4){ + giac::vecteur f1v=*f1f._VECTptr; + return "plotparam("+_pnt2string(f1v[0],contextptr)+","+f1v[1].print(contextptr)+"="+f1v[2].print(contextptr)+".."+f1v[3].print(contextptr)+")"; + } + } + } + if (f0.is_symb_of_sommet(giac::at_cercle) && f0._SYMBptr->feuille.type==giac::_VECT){ + if (f0._SYMBptr->feuille._VECTptr->size()==3 && ((*f0._SYMBptr->feuille._VECTptr)[2]!=giac::cst_two_pi || (*f0._SYMBptr->feuille._VECTptr)[1]!=0)) + return f0.print(contextptr); + giac::gen centre,rayon; + if (!giac::centre_rayon(f0,centre,rayon,true,0)) + return "cercle_error"; + if (!complex_mode(contextptr) && (centre.typebegin(),itend=f0._VECTptr->end(); + if ( itend-it==2){ + switch(f0.subtype){ + case giac::_LINE__VECT: + s=gettext("line")+string("("); + break; + case giac::_HALFLINE__VECT: + s=gettext("half_line")+string("("); + break; + case giac::_GROUP__VECT: + s=gettext("segment")+string("("); + break; + } + if (f0.subtype==giac::_LINE__VECT && it->type!=giac::_VECT){ // 2-d line + s += _equation(g,contextptr).print(contextptr) + ")"; + return s; + } + } + for (;it!=itend;){ + s += "point("; + if (!complex_mode(contextptr) && (it->typetype==giac::_FRAC) ) + s += giac::re(*it,contextptr).print(contextptr)+","+giac::im(*it,contextptr).print(contextptr); + else { + gen f=*it; + if (f.type==_VECT && f.subtype==_POINT__VECT) + f.subtype=_SEQ__VECT; + s += f.print(contextptr); + } + s+=")"; + ++it; + s += it==itend?")":","; + } + return s; + } + if ( (f0.type!=giac::_FRAC && f0.type>=giac::_IDNT) || is3d(g) || complex_mode(contextptr)){ + if (f0.type==_VECT && f0.subtype==_POINT__VECT) + f0.subtype=_SEQ__VECT; + return "point("+f0.print(contextptr)+")"; + } + else + return "point("+giac::re(f0,contextptr).print(contextptr)+","+giac::im(f0,contextptr).print(contextptr)+")"; + } + } + if (g.type==giac::_VECT && !g._VECTptr->empty() && g._VECTptr->back().is_symb_of_sommet(giac::at_pnt)){ + std::string s = "["; + giac::const_iterateur it=g._VECTptr->begin(),itend=g._VECTptr->end(); + for (;it!=itend;){ + s += _pnt2string(*it,contextptr); + ++it; + s += it==itend?"]":","; + } + return s; + } + return g.print(contextptr); + } + + std::string pnt2string(const giac::gen & g,const giac::context * contextptr){ + int p=python_compat(contextptr); + python_compat(0,contextptr); + string s=_pnt2string(g,contextptr); + python_compat(p,contextptr); + return s; + } + gen select_var(GIAC_CONTEXT){ kbd_interrupted=giac::ctrl_c=giac::interrupted=false; #ifdef QUICKJS @@ -2340,8 +2456,8 @@ const catalogFunc completeCaten[] = { // list of all functions (including some n vector vi(9); tailles(w,vi); total += vi[8]; - if (vi[8]<400) - vs[i]+=":="+w.print(contextptr); + if (vi[8]=0){ argcolor=0; return d; } + argcolor=M_PI; return -d; + } + double x=g._CPLXptr->_DOUBLE_val,y=(g._CPLXptr+1)->_DOUBLE_val; + argcolor=std::atan2(x,y); + double n=std::sqrt(x*x+y*y); // will be encoded in a float, no overflow care + return n; + } + // hpersurface encoded as a matrix // with lines containing 3 coordinates per point bool Graph2d::glsurface(int w,int h,int lcdz,GIAC_CONTEXT, @@ -6078,6 +6342,7 @@ namespace xcas { double hyperxymax=-1e307,hyperxymin=1e307; double3 tri[4]; for (int k=0;k >::const_iterator sbeg=hypv[k],send=hypv[k+1],sprec,scur; vector::const_iterator itprec,itcur,itprecend; for (sprec=sbeg,scur=sprec+1;scura; + z1 = ((float2 *)&z1)->f; + a2 = ((float2 *)&z2)->a; + z2 = ((float2 *)&z2)->f; + a3 = ((float2 *)&z3)->a; + z3 = ((float2 *)&z3)->f; + a4 = ((float2 *)&z4)->a; + z4 = ((float2 *)&z4)->f; + } yx1=y1-x1; yx2=y2-x2; yx3=y3-x3; yx4=y4-x4; #ifdef HYPERQUAD tri[0]=double3(x1,y1,z1); @@ -6146,7 +6422,16 @@ namespace xcas { if (xy123>hyperxymax) hyperxymax=xy123; do_transform(invtransform,x123,y123,z123,X,Y,Z); if (Z>=window_zmin && Z<=window_zmax && X>=window_xmin && X<=window_xmax && Y>=window_ymin && Y<=window_ymax ){ - hypertriangle_t res; res.colorptr=&hyp_color[k]; + hypertriangle_t res; + if (cplx){ + int idx=(a1+M_PI)*sizeof(tabcolorcplx)/(sizeof(int4)*2*M_PI); + if (idx<0 || idx >=sizeof(tabcolorcplx)/(sizeof(int4))) + idx = 0; + //CERR << idx << " "; + res.colorptr=&tabcolorcplx[idx]; + } + else + res.colorptr=&hyp_color[k]; compute(yx,tri,res); hypertriangles.push_back(res); } @@ -6237,7 +6522,7 @@ namespace xcas { if (plan_filled[k]){ only_hypertri=false; break; } } if (only_hypertri){ - if (hypertriangles.empty()) continue; + if (hypertriangles.empty()) goto suite3d; int effjmax=(hyperxymax-xc-yc)/yscale/2.0,effjmin=(hyperxymin-xc-yc)/yscale/2.0; if (effjmax+1 & selected,bool is3d){ + vecteur w(v); + vector s(selected); sort(s.begin(),s.end()); + int pos=0; + for (int i=0;i=s.size()) + break; + if (i==s[pos]){ + ++pos; + gen g=w[i]; + if (g.is_symb_of_sommet(at_pnt)){ + g=g._SYMBptr->feuille; + if (g.type==_VECT && g._VECTptr->size()>=2){ + vecteur gv(*g._VECTptr); + gv[1]=is3d?_CYAN:_BLUE; + g=gen(gv,g.subtype); + w[i]=symbolic(at_pnt,g); + } + } + } + } + return w; + } + + vecteur Graph2d::selected_names(bool allobjects,bool withdef) const { + vector::const_iterator it=selected.begin(),itend=selected.end(); + vecteur res; + for (;it!=itend;++it){ + gen g=symbolic_instructions[*it]; + if (g.is_symb_of_sommet(at_sto)){ + gen tmp=g._SYMBptr->feuille[0]; + if (allobjects || tmp.is_symb_of_sommet(at_point) || tmp.is_symb_of_sommet(at_element)) + res.push_back(withdef?g:g._SYMBptr->feuille[1]); + } + } + return res; + } + + void Graph2d::adjust_cursor_point_type(){ + if (hp){ + double newx,newy,newz; + find_xyz(current_i,current_j,current_depth,newx,newy,newz); + int pos=-1; + gen orig; + gen res=geometry_round(newx,newy,newz,find_eps(),orig,pos); + if (mode==0){ + if (pos>=0) + selected=vector(1,pos); + else + selected.clear(); + } + cursor_point_type=pos>=0?6:3; + } + } + + void Graph2d::update_g(){ + if (hp){ + adjust_cursor_point_type(); + find_title_plot(title_tmp,plot_tmp); + vecteur v(mergevecteur(get_current_animation(),trace_instructions)); + if (!is_undef(plot_tmp)) v.push_back(plot_tmp); + // geometry: update g from plot_instructions + g=mergevecteur(selected.empty()?plot_instructions:mark_selected(plot_instructions,selected,is3d),v); + if (is3d) + update_rotation(); + } + } + void Graph2d::update(){ + update_g(); update_scales(); - if (is3d) update_rotation(); + update_rotation(); } void mult4(double * c,double k,double * res){ @@ -7054,6 +7413,12 @@ namespace xcas { j=LCD_HEIGHT_PX/2-Z*lcdz+(Y+X)/9.6*LCD_WIDTH_PX; } + void Graph2d::xyz2ij(const double3 &d,double &i,double &j,double3 & d3) const { + do_transform(transform,d.x,d.y,d.z,d3.x,d3.y,d3.z); + i=LCD_WIDTH_PX/2+(d3.y-d3.x)/4.8*LCD_WIDTH_PX; + j=LCD_HEIGHT_PX/2-d3.z*lcdz+(d3.y+d3.x)/9.6*LCD_WIDTH_PX; + } + void Graph2d::XYZ2ij(const double3 &d,int &i,int &j) const { double X=d.x,Y=d.y,Z=d.z; i=LCD_WIDTH_PX/2+(Y-X)/4.8*LCD_WIDTH_PX; @@ -7061,6 +7426,8 @@ namespace xcas { } void Graph2d::update_rotation(){ + if (!is3d) + return; solid3d=false; double rx,ry,rz,theta; get_axis_angle_deg(q,rx,ry,rz,theta); @@ -7154,31 +7521,33 @@ namespace xcas { continue; } bool line=G.subtype==_LINE__VECT,halfline=G.subtype==_HALFLINE__VECT,segment= G.subtype==_GROUP__VECT; - if (G.type==_VECT && G._VECTptr->size()==2 && (line || halfline || segment)){ - gen a=evalf_double(G._VECTptr->front(),1,contextptr),b=evalf_double(G._VECTptr->back(),1,contextptr); - if (a.type==_VECT && b.type==_VECT && a._VECTptr->size()==3 && b._VECTptr->size()==3){ - vecteur & A=*a._VECTptr; - vecteur & B=*b._VECTptr; - if (A[0].type==_DOUBLE_ && A[1].type==_DOUBLE_ && A[2].type==_DOUBLE_ && B[0].type==_DOUBLE_ && B[1].type==_DOUBLE_ && B[2].type==_DOUBLE_ ){ - lines.push_back(ptr); - double x=A[0]._DOUBLE_val,y=A[1]._DOUBLE_val,z=A[2]._DOUBLE_val; + if (G.type==_VECT && G._VECTptr->size()>=2 && (line || halfline || segment)){ + for (int n=1;nsize();++n){ + gen a=evalf_double((*G._VECTptr)[n-1],1,contextptr),b=evalf_double((*G._VECTptr)[n],1,contextptr); + if (a.type==_VECT && b.type==_VECT && a._VECTptr->size()==3 && b._VECTptr->size()==3){ + vecteur & A=*a._VECTptr; + vecteur & B=*b._VECTptr; + if (A[0].type==_DOUBLE_ && A[1].type==_DOUBLE_ && A[2].type==_DOUBLE_ && B[0].type==_DOUBLE_ && B[1].type==_DOUBLE_ && B[2].type==_DOUBLE_ ){ + lines.push_back(ptr); + double x=A[0]._DOUBLE_val,y=A[1]._DOUBLE_val,z=A[2]._DOUBLE_val; #if 0 // ndef OLD_LINE_RENDERING - double3 prev(x,y,z); - linev.push_back(prev); + double3 prev(x,y,z); + linev.push_back(prev); #endif - double X,Y,Z; - do_transform(transform,x,y,z,X,Y,Z); - double3 M(X,Y,Z); - x=B[0]._DOUBLE_val;y=B[1]._DOUBLE_val;z=B[2]._DOUBLE_val; + double X,Y,Z; + do_transform(transform,x,y,z,X,Y,Z); + double3 M(X,Y,Z); + x=B[0]._DOUBLE_val;y=B[1]._DOUBLE_val;z=B[2]._DOUBLE_val; #if 0 // ndef OLD_LINE_RENDERING - linev.push_back(double3(x-prev.x,y-prev.y,z-prev.z)); -#endif - do_transform(transform,x,y,z,X,Y,Z); - double3 N(X,Y,Z); - double3 v(N.x-M.x,N.y-M.y,N.z-M.z); - linev.push_back(M); linev.push_back(v); - linetypev.push_back(G.subtype); - line_color.push_back(int4(u,d,du,dd)); + linev.push_back(double3(x-prev.x,y-prev.y,z-prev.z)); +#endif + do_transform(transform,x,y,z,X,Y,Z); + double3 N(X,Y,Z); + double3 v(N.x-M.x,N.y-M.y,N.z-M.z); + linev.push_back(M); linev.push_back(v); + linetypev.push_back(G.subtype); + line_color.push_back(int4(u,d,du,dd)); + } } } continue; @@ -7242,24 +7611,37 @@ namespace xcas { if (h.type==_VECT && h.subtype==_POLYEDRE__VECT) G=h; else if (ckmatrix(h,true)){ + bool cplx=has_i(h); // 4d hypersurface, encode color in a float+int + double argcplx; surfacev.push_back(vector< vector >(0)); vector< vector > & S=surfacev.back(); const vecteur & V=*h._VECTptr; S.reserve(V.size()); for (int j=0;j(0)); vector &S_=S.back(); S_.reserve(vj.size()); for (int k=0;kf = Z; + fptr->a = argcplx; + S_.push_back(Z); + } + else + S_.push_back(Z); } } - hyp_color.push_back(int4(u,d,du,dd)); + hyp_color.push_back(cplx?int4(0,0,0,0):int4(u,d,du,dd)); continue; } // end quad hypersurface } // end hypersurface @@ -7555,7 +7937,40 @@ namespace xcas { int mxw=LCD_WIDTH_PX,myw=LCD_HEIGHT_PX-STATUS_AREA_PX; double i0,j0,i0save,j0save,i1,j1; int fs=f.size(); - if ((fs==4) && (s==at_parameter)){ + if (fs>=4 && s==at_parameter && f[0].type==_IDNT){ + // display parameter from the left upper, f[0] name and f[3] value + char ch[128]; + strcpy(ch,f[0]._IDNTptr->id_name); + int pos=strlen(ch); + ch[pos]='='; + ++pos; + ch[pos]=0; + gen g=evalf_double(f[3],1,contextptr); + if (g.type==_DOUBLE_) + strcpy(ch+pos,g.print(contextptr).c_str()); + else { + ch[pos]='?'; + ++pos; + ch[pos]=0; + } + ++Mon_image.nparams; + int dw=fl_width(ch); + int fheight=14; + int ypos=(fheight+1)*Mon_image.nparams+fheight; + drawRectangle(1,ypos,dw,fheight-1,Mon_image.is3d?_BLACK:_WHITE); + os_draw_string_small_(1,ypos-fheight,ch); + if (Mon_image.pushed && Mon_image.moving_param){ + drawLine(64,ypos-2,192,ypos-2,Mon_image.is3d?_WHITE:_BLACK); + drawLine(64,ypos,64,ypos-fheight,Mon_image.is3d?_WHITE:_BLACK); + drawLine(192,ypos,192,ypos-fheight,Mon_image.is3d?_WHITE:_BLACK); + os_draw_string_small_(65,ypos-fheight-2,f[1].print(contextptr).c_str()); + os_draw_string_small_(193,ypos-fheight-2,f[2].print(contextptr).c_str()); + gen gxpos=64+128*(g-f[1])/(f[2]-f[1]); + if (gxpos.type==_DOUBLE_){ + int xpos=gxpos._DOUBLE_val; + drawLine(xpos,ypos,xpos,ypos-fheight,_RED); + } + } return ; } string the_legend; @@ -7656,7 +8071,7 @@ namespace xcas { return; } } // end circle -#if 0 +#if 1 if (point._SYMBptr->sommet==at_legende){ gen & f=point._SYMBptr->feuille; if (f.type==_VECT && f._VECTptr->size()==3){ @@ -7889,6 +8304,20 @@ namespace xcas { x/=n; y/=n; } + void Graph2d::adddepth(vector & polyg,const double3 &A,const double3 &B,int2 & IJmin) const { + if ((A.z-current_depth)*(B.z-current_depth)>0) + return; + double t=(current_depth-A.z)/(B.z-A.z); + double x=A.x+t*(B.x-A.x); + double y=A.y+t*(B.y-A.y); + int I,J; + XYZ2ij(double3(x,y,current_depth),I,J); + int2 IJ(I,J); + polyg.push_back(IJ); + if (IJ & polyg,double x,double y,double z,int2 & IJmin) const { int I,J; xyz2ij(double3(x,y,z),I,J); @@ -7898,7 +8327,193 @@ namespace xcas { IJmin=IJ; } + int roundint (double r) { + int tmp = static_cast (r); + tmp += (r-tmp>=.5) - (r-tmp<=-.5); + return tmp; + } + + bool Graph2d::find_dxdy(double & dx, double & dy) const { + double xmin=window_xmin,xmax=window_xmax; + int hp=LCD_WIDTH_PX-1; + dx=(xmax-xmin)/hp; + double ymin=window_ymin,ymax=window_ymax; + int vp=LCD_HEIGHT_PX-1; + dy=(ymax-ymin)/vp; + return abs(dx-dy) < 0.000001; + } + + void Graph2d::find_xy(double i,double j,double & x,double & y) const { + double xmin=window_xmin,xmax=window_xmax; + x=xmin+i*(xmax-xmin)/LCD_WIDTH_PX; + double ymin=window_ymin,ymax=window_ymax; + y=ymax-j*(ymax-ymin)/LCD_HEIGHT_PX; + } + + void Graph2d::round_xy(double & x, double & y) const { + double dx,dy; + find_dxdy(dx,dy); + double range = pow(10,log10(1.0/dx)); + x = roundint(x * range) / range; + y = roundint(y * range) / range; + } + + void round3(double & x,double xmin,double xmax){ + double dx=std::abs(xmax-xmin); + double logdx=std::log10(dx); + int ndec=int(logdx)-3; + double xpow=std::pow(10.0,ndec); + int newx=x>=0?int(x/xpow+0.5):int(x/xpow-0.5); + x=newx*xpow; + } + + vecteur Graph2d::param(double d) const { + const_iterateur it=plot_instructions.begin(),itend=plot_instructions.end(); + vecteur res; + double pos=0.5; + for (int i=0 ;it!=itend;++i,++it){ + gen tmp=*it; + if (tmp.is_symb_of_sommet(at_parameter)){ + tmp=tmp._SYMBptr->feuille; + if (tmp.type==_VECT && tmp._VECTptr->size()>=4){ + if (std::abs(d-pos)<0.50001){ + res.push_back(tmp); + res.push_back(i); + } + ++pos; + } + } + } + return res; + } + + void Graph2d::draw_decorations(const gen & title_tmp){ + if (args_tmp.empty()){ // add selected names + char s[256]; strcpy(s,modestr.c_str()); + int pos=0,modestrsize=modestr.size(); + pos += modestrsize; + s[pos++]=' '; + if (mode!=0 && drag_name.type==_IDNT){ + strcpy(s+pos,drag_name._IDNTptr->id_name); + pos += strlen(drag_name._IDNTptr->id_name); + } + else { + if (1 || mode==0 || mode==255){ // print selected names + vecteur v; + if (mode!=255) v=selected_names(true,false); + if (v.empty() && current_i<=192 && current_j<14*nparams+21){ + double d=current_j/14.-1; + v=param(d); + if (v.size()!=2) + v.clear(); + else + v=vecteur(1,v.front()[0]); + } + int vs=v.size(); + if (!vs){ // print current coordinates + double i=current_i,j=current_j,x,y,z; + if (is3d){ + find_xyz(i,j,current_depth,x,y,z); + round_xy(x,y); round3(z,window_zmin,window_zmax); + sprintf(s+pos," %.3g,%.3g,%.3g",x,y,z); + } + else { + find_xy(i,j,x,y); + // round to maximum pixel range + round_xy(x,y); + sprintf(s+pos," x=%.3g,y=%.3g",x,y); + } + pos=strlen(s); + } + for (int i=0;iid_name); + pos += strlen(v[i]._IDNTptr->id_name); + if (iptr()->s+('('+title_tmp.print(contextptr)+')'); // gen(symbolic(*function_final._FUNCptr,title_tmp)).print(contextptr); + } + else + mytitle=title; + if (!mytitle.empty()){ + int dt=int(fl_width(mytitle.c_str())); + if (dt>LCD_WIDTH_PX) + dt=LCD_WIDTH_PX; + os_draw_string_small_((LCD_WIDTH_PX-dt)/2,LCD_HEIGHT_PX-14,mytitle.c_str()); + } + } + if (hp || tracemode){ // draw cursor at current_i,current_j + int taille=(mode==255 && !tracemode) ?2:5; + fl_line(current_i-taille,current_j,current_i+taille,current_j,is3d?_CYAN:_BLUE); + fl_line(current_i,current_j-taille,current_i,current_j+taille,is3d?_CYAN:_BLUE); + if (cursor_point_type==6){ + fl_line(current_i-2,current_j+2,current_i+2,current_j+2,_RED); + fl_line(current_i-2,current_j+2,current_i+2,current_j+2,_RED); + fl_line(current_i-2,current_j-2,current_i-2,current_j+2,_RED); + fl_line(current_i+2,current_j-2,current_i+2,current_j+2,_RED); + } + } + } + + void displaypolyg(const vector & polyg,const int2 & IJmin,int color,int & Px,int & Py,GIAC_CONTEXT){ + if (polyg.empty()) + return; + // sort list of arguments + vector p; + for (int k=0;k > P; + for (int k=0;k vi(2); + vi[0]=p[k].i; + vi[1]=p[k].j; + P.push_back(vi); + } + draw_polygon(P,color + // | 0x400000 + ,contextptr); + Px=P[0][0]; + Py=P[0][1]; + } + void Graph2d::draw(){ + waitforvblank(); + nparams=0; // reset number of parameters (shown from left upper) + if (hp) history_plot(contextptr).clear(); if (is3d){ if (lang==1) statuslinemsg("Toolbox: aide"); @@ -7912,16 +8527,21 @@ namespace xcas { F(window_xmin,window_ymax,window_zmax), G(window_xmax,window_ymax,window_zmin), H(window_xmax,window_ymax,window_zmax); - xyz2ij(A,Ai,Aj); - xyz2ij(B,Bi,Bj); - xyz2ij(C,Ci,Cj); - xyz2ij(D,Di,Dj); - xyz2ij(E,Ei,Ej); - xyz2ij(F,Fi,Fj); - xyz2ij(G,Gi,Gj); - xyz2ij(H,Hi,Hj); + double3 A3,B3,C3,D3,E3,F3,G3,H3; + xyz2ij(A,Ai,Aj,A3); + xyz2ij(B,Bi,Bj,B3); + xyz2ij(C,Ci,Cj,C3); + xyz2ij(D,Di,Dj,D3); + xyz2ij(E,Ei,Ej,E3); + xyz2ij(F,Fi,Fj,F3); + xyz2ij(G,Gi,Gj,G3); + xyz2ij(H,Hi,Hj,H3); set_abort(); + int prec=precision; + if (mode==0 && precision<3) + precision += 2; glsurface(precision,precision,lcdz,contextptr,default_upcolor,default_downcolor,default_downupcolor,default_downdowncolor); + precision=prec; clear_abort(); if (show_edges){ // polyhedrons @@ -8049,10 +8669,31 @@ namespace xcas { drawLine(Ci,Cj,Gi,Gj,COLOR_GREEN | 0x800000); drawLine(Di,Dj,Hi,Hj,COLOR_GREEN | 0x800000); // Z - drawLine(Ai,Aj,Bi,Bj,12345 | 0x800000); - drawLine(Ci,Cj,Di,Dj,12345 | 0x800000); - drawLine(Ei,Ej,Fi,Fj,12345 | 0x800000); - drawLine(Gi,Gj,Hi,Hj,12345 | 0x800000); + drawLine(Ai,Aj,Bi,Bj,COLOR_CYAN | 0x800000); + drawLine(Ci,Cj,Di,Dj,COLOR_CYAN | 0x800000); + drawLine(Ei,Ej,Fi,Fj,COLOR_CYAN | 0x800000); + drawLine(Gi,Gj,Hi,Hj,COLOR_CYAN | 0x800000); + // current_depth + if (hp){ + vector polyg; int2 IJmin={RAND_MAX,RAND_MAX}; + // x: A3-C3, B3-D3; E3-G3,F3-H3 + adddepth(polyg,A3,C3,IJmin); + adddepth(polyg,B3,D3,IJmin); + adddepth(polyg,E3,G3,IJmin); + adddepth(polyg,F3,H3,IJmin); + // y: A3-E3; B3-F3; C3-G3, D3-H3 + adddepth(polyg,A3,E3,IJmin); + adddepth(polyg,B3,F3,IJmin); + adddepth(polyg,C3,G3,IJmin); + adddepth(polyg,D3,H3,IJmin); + // z: A3-B3, C3-D3, E3-F3, G3-H3 + adddepth(polyg,A3,B3,IJmin); + adddepth(polyg,C3,D3,IJmin); + adddepth(polyg,E3,F3,IJmin); + adddepth(polyg,G3,H3,IJmin); + int Px,Py; + displaypolyg(polyg,IJmin,COLOR_YELLOW | 0x400000,Px,Py,contextptr); + } // planes vecteur attrv(gen2vecteur(g)); for (int i=0;i=window_zmin && z<=window_zmax) addpolyg(polyg,window_xmax,window_ymax,z,IJmin); } - // sort list of arguments - vector p; - for (int k=0;k > P; - for (int k=0;k vi(2); - vi[0]=p[k].i; - vi[1]=p[k].j; - P.push_back(vi); - } - draw_polygon(P,upcolor - // | 0x400000 - ,contextptr); + int Px,Py; + displaypolyg(polyg,IJmin,upcolor,Px,Py,contextptr); if (nameptr){ int x=os_draw_string_small(0,0,0,upcolor,nameptr,true); - os_draw_string_small(P[0][0]-x,P[0][1],upcolor,0,nameptr); + os_draw_string_small(Px-x,Py,upcolor,0,nameptr); } } } // frame double xi=Ci-Ai,xj=Cj-Aj; normalize(xi,xj); - drawLine(20,20,20+20*xi,20+20*xj,COLOR_RED); - os_draw_string_small(20+20*xi,20+20*xj,COLOR_RED,COLOR_BLACK,"x"); + int decal=180; + drawLine(20,decal,20+20*xi,decal+20*xj,COLOR_RED); + os_draw_string_small(20+20*xi,decal+20*xj,COLOR_RED,COLOR_BLACK,"x"); double yi=Ei-Ai,yj=Ej-Aj; normalize(yi,yj); - drawLine(20,20,20+20*yi,20+20*yj,COLOR_GREEN); - os_draw_string_small(20+20*yi,20+20*yj,COLOR_GREEN,COLOR_BLACK,"y"); + drawLine(20,decal,20+20*yi,decal+20*yj,COLOR_GREEN); + os_draw_string_small(20+20*yi,decal+20*yj,COLOR_GREEN,COLOR_BLACK,"y"); double zi=Bi-Ai,zj=Bj-Aj; normalize(zi,zj); - drawLine(20,20,20+20*zi,20+20*zj,12345); - os_draw_string_small(20+20*zi,20+20*zj,12345,COLOR_BLACK,"z"); + drawLine(20,decal,20+20*zi,decal+20*zj,COLOR_CYAN); + os_draw_string_small(20+20*zi,decal+20*zj,COLOR_CYAN,COLOR_BLACK,"z"); } // end show_axes // now handle legend([x,y],string) vecteur V(gen2vecteur(g)); for (int i=0;ifeuille.type==_VECT){ + vecteur f=*attr._SYMBptr->feuille._VECTptr; + int fs=f.size(); + if (fs>=4 && f[0].type==_IDNT){ + // display parameter from the left upper, f[0] name and f[3] value + char ch[128]; + strcpy(ch,f[0]._IDNTptr->id_name); + int pos=strlen(ch); + ch[pos]='='; + ++pos; + ch[pos]=0; + gen g=evalf_double(f[3],1,contextptr); + if (g.type==_DOUBLE_) + strcpy(ch+pos,g.print(contextptr).c_str()); + else { + ch[pos]='?'; + ++pos; + ch[pos]=0; + } + ++nparams; + int dw=fl_width(ch); + int fheight=14; + int ypos=(fheight+1)*nparams+fheight; + drawRectangle(1,ypos-fheight,dw,fheight-1,_WHITE); + os_draw_string_small_(1,ypos-fheight,ch); + if (pushed && moving_param){ + drawLine(64,ypos-2,192,ypos-2,is3d?_WHITE:_BLACK); + drawLine(64,ypos,64,ypos-fheight,is3d?_WHITE:_BLACK); + drawLine(192,ypos,192,ypos-fheight,is3d?_WHITE:_BLACK); + os_draw_string_small_(65,ypos-fheight-2,f[1].print(contextptr).c_str()); + os_draw_string_small_(193,ypos-fheight-2,f[2].print(contextptr).c_str()); + gen gxpos=64+128*(g-f[1])/(f[2]-f[1]); + if (gxpos.type==_DOUBLE_){ + int xpos=gxpos._DOUBLE_val; + drawLine(xpos,ypos,xpos,ypos-fheight,_RED); + } + } + } + } // end parameter if (attr.is_symb_of_sommet(at_pnt)){ attr=attr._SYMBptr->feuille; if (attr.type==_VECT && attr._VECTptr->size()>1){ @@ -8200,11 +8858,13 @@ namespace xcas { } } #ifdef NSPIRE_NEWLIB - DefineStatusMessage((char*)"+-: zoom, pad: move, esc: quit", 1, 0, 0); + DefineStatusMessage((char*)"menu: menu, esc: quit", 1, 0, 0); #else - DefineStatusMessage((char*)"+-: zoom, pad: move, EXIT: quit", 1, 0, 0); + DefineStatusMessage((char*)"shift-1: help, home: menu, back: quit", 1, 0, 0); #endif DisplayStatusArea(); + if (hp || tracemode) + draw_decorations(title_tmp); return; } int save_clip_ymin=clip_ymin; @@ -8301,6 +8961,8 @@ namespace xcas { // draw fltk_draw(*this,g,x_scale,y_scale,clip_x,clip_y,clip_w,clip_h,contextptr); clip_ymin=save_clip_ymin; + if (hp || tracemode) + draw_decorations(title_tmp); } void Graph2d::left(double d){ @@ -8581,12 +9243,15 @@ namespace xcas { } // End logo mode } - - int displaygraph(const giac::gen & ge,GIAC_CONTEXT){ + int displaygraph(const giac::gen & ge,const gen & gs,GIAC_CONTEXT){ // graph display //if (aborttimer > 0) { Timer_Stop(aborttimer); Timer_Deinstall(aborttimer);} xcas::Graph2d gr(ge,contextptr); + if (gs!=0) gr.symbolic_instructions=gen2vecteur(gs); gr.show_axes=global_show_axes; + gr.init_tracemode(); + if (gr.tracemode & 4) + gr.orthonormalize(true); // initial setting for x and y if (ge.type==_VECT){ const_iterateur it=ge._VECTptr->begin(),itend=ge._VECTptr->end(); @@ -8627,159 +9292,2115 @@ namespace xcas { } } } - // UI -#ifdef NSPIRE_NEWLIB - DefineStatusMessage((char*)"+-: zoom, pad: move, esc: quit", 1, 0, 0); + return gr.ui(); + } + + vecteur Graph2d::get_current_animation() const { + if (animation_instructions_pos>=0 && animation_instructions_pos=2){ + gen function=(mode==int(args_tmp.size()))?function_final:function_tmp; + if (function.type==_FUNC){ + bool dim2=!is3d; + vecteur args2=args_tmp; + if ( *function._FUNCptr==(dim2?at_cercle:at_sphere)){ + gen argv1; +#ifdef NO_STDEXCEPT + argv1=evalf(args_tmp.back(),1,contextptr); + argv1=evalf_double(argv1,1,contextptr); #else - DefineStatusMessage((char*)"+-: zoom, pad: move, EXIT: quit", 1, 0, 0); + try { + argv1=evalf(args_tmp.back(),1,contextptr); + argv1=evalf_double(argv1,1,contextptr); + } + catch (std::runtime_error & e){ + argv1=undef; + } #endif - DisplayStatusArea(); - int saveprecision=gr.precision; - gr.precision += 2; // fast draw first - gr.draw(); - gr.precision=saveprecision; - bool redraw=true; - for (;;){ - int saveprec=gr.precision; - if (gr.doprecise){ - gr.doprecise=false; - gr.precision=1;//gr.precision-=2; - } - if (redraw) - gr.draw(); - redraw=true; - gr.precision=saveprec; - DisplayStatusArea(); + if (argv1.is_symb_of_sommet(at_pnt) ||argv1.type==_IDNT){ + argv1=remove_at_pnt(argv1); + if ( (argv1.type==_VECT && argv1.subtype==_POINT__VECT) || argv1.type==_CPLX || argv1.type==_IDNT) + args2.back()=args_tmp.back()-args_tmp.front(); + } + } + if (function==at_ellipse) + ; + title_tmp=gen(args2,_SEQ__VECT); + bool b=approx_mode(contextptr); + if (!b) + approx_mode(true,contextptr); + plot_tmp=symbolic(*function._FUNCptr,title_tmp); + if (!lidnt(title_tmp).empty()) + ; // cerr << plot_tmp << '\n'; + bool bb=io_graph(contextptr); + int locked=0; + if (bb){ +#ifdef HAVE_LIBPTHREAD + // cerr << "plot title lock" << '\n'; + locked=pthread_mutex_trylock(&interactive_mutex); +#endif + if (!locked) + io_graph(false,contextptr); + } + plot_tmp=protecteval(plot_tmp,1,contextptr); + if (bb && !locked){ + io_graph(bb,contextptr); +#ifdef HAVE_LIBPTHREAD + pthread_mutex_unlock(&interactive_mutex); + // cerr << "plot title unlock" << '\n'; +#endif + } + if (!b) + approx_mode(false,contextptr); + } // end function.type==_FUNC + else + title_tmp=gen(args_tmp,_SEQ__VECT); + } // end size()>=2 + else + title_tmp=args_tmp; + } + } + + void Graph2d::eval(int start){ + plot_instructions.resize(symbolic_instructions.size()); + if (plot_instructions.empty()) return; + int level=prog_eval_level_val(contextptr); + for (size_t i=start;ifeuille); + f=protecteval(f,1,contextptr); #ifdef NUMWORKS - os_draw_string(0,LCD_HEIGHT_PX-STATUS_AREA_PX-17,COLOR_BLACK,COLOR_WHITE,"toolbox: cfg"); + const int maxtrace=128; #else - os_draw_string(0,LCD_HEIGHT_PX-STATUS_AREA_PX-17,COLOR_BLACK,COLOR_WHITE,"menu: cfg"); + const int maxtrace=512; #endif - int key=-1; - GetKey(&key); - if (key==KEY_SHUTDOWN) - return key; -#if 1 - if (key==KEY_CTRL_CATALOG || key==KEY_BOOK ){ - char menu_xmin[32],menu_xmax[32],menu_ymin[32],menu_ymax[32],menu_zmin[32],menu_zmax[32]; - for (;;){ - string s; - s="xmin "+print_DOUBLE_(gr.window_xmin,contextptr); - strcpy(menu_xmin,s.c_str()); - s="xmax "+print_DOUBLE_(gr.window_xmax,contextptr); - strcpy(menu_xmax,s.c_str()); - s="ymin "+print_DOUBLE_(gr.window_ymin,contextptr); - strcpy(menu_ymin,s.c_str()); - s="ymax "+print_DOUBLE_(gr.window_ymax,contextptr); - strcpy(menu_ymax,s.c_str()); - s="zmin "+print_DOUBLE_(gr.window_zmin,contextptr); - strcpy(menu_zmin,s.c_str()); - s="zmax "+print_DOUBLE_(gr.window_zmax,contextptr); - strcpy(menu_zmax,s.c_str()); - Menu smallmenu; - smallmenu.numitems=15; - MenuItem smallmenuitems[smallmenu.numitems]; - smallmenu.items=smallmenuitems; - smallmenu.height=12; - //smallmenu.title = "KhiCAS"; - smallmenuitems[0].text = (char *) menu_xmin; - smallmenuitems[1].text = (char *) menu_xmax; - smallmenuitems[2].text = (char *) menu_ymin; - smallmenuitems[3].text = (char *) menu_ymax; - smallmenuitems[4].text = (char *) menu_zmin; - smallmenuitems[5].text = (char *) menu_zmax; - smallmenuitems[6].text = (char*) "Orthonormalize /"; - smallmenuitems[7].text = (char*) "Autoscale *"; - smallmenuitems[8].text = (char *) ("Zoom in +"); - smallmenuitems[9].text = (char *) ("Zoom out -"); - smallmenuitems[10].text = (char *) ("Y-Zoom out (-)"); - smallmenuitems[11].text = (char *) ((lang==1)?"raccourcis clavier":"3d shortcuts"); - smallmenuitems[12].text = (char*) ((lang==1)?"Voir axes":"Show axes"); - smallmenuitems[13].text = (char*) ((lang==1)?"Cacher axes":"Hide axes"); - smallmenuitems[14].text = (char*)((lang==1)?"Quitter":"Quit"); - drawRectangle(0,180,LCD_WIDTH_PX,60,_BLACK); - int sres = doMenu(&smallmenu); - if (sres == MENU_RETURN_EXIT) - break; - if (sres == MENU_RETURN_SELECTION || sres==KEY_CTRL_EXE) { - const char * ptr=0; - string s1; double d; - if (smallmenu.selection==1){ - d=gr.window_xmin; - if (inputdouble(menu_xmin,d,200,contextptr)){ - gr.window_xmin=d; - gr.update(); - } - } - if (smallmenu.selection==2){ - d=gr.window_xmax; - if (inputdouble(menu_xmax,d,200,contextptr)){ - gr.window_xmax=d; - gr.update(); - } - } - if (smallmenu.selection==3){ - d=gr.window_ymin; - if (inputdouble(menu_ymin,d,200,contextptr)){ - gr.window_ymin=d; - gr.update(); - } - } - if (smallmenu.selection==4){ - d=gr.window_ymax; - if (inputdouble(menu_ymax,d,200,contextptr)){ - gr.window_ymax=d; - gr.update(); - } + if (trace_instructions.size()>=maxtrace) + trace_instructions.erase(trace_instructions.begin(),trace_instructions.begin()+maxtrace/2); + trace_instructions.push_back(f); + } + } + is3d=false; + for (size_t i=0;idy && dz >dx){ + eps=npixels*dz/L; + eps *= 2; + } + return eps; + } + + void Graph2d::set_gen_value(int n,const giac::gen & g,bool exec){ + // set n-th entry value, if n==-1 add a level + if (!hp) return; + if (n==-1 || n>=symbolic_instructions.size()){ + symbolic_instructions.push_back(g); + n=symbolic_instructions.size()-1; + } else symbolic_instructions[n]=g; + hp->set_string_value(n,g.print(contextptr)); + if (exec) + eval(n); + } + + void Graph2d::find_xyz(double i,double j,double k,double & x,double & y,double & z) const { + if (is3d){ // FIXME + int horiz=LCD_WIDTH_PX/2,vert=horiz/2;//LCD_HEIGHT_PX/2; + double lcdz= LCD_HEIGHT_PX/4; + double xmin=-1,ymin=-1,xmax=1,ymax=1,xscale=0.6*(xmax-xmin)/horiz,yscale=0.6*(ymax-ymin)/vert; + double Z=current_depth; // -1..1 + double I=i-horiz; + double J=j-LCD_HEIGHT_PX/2+lcdz*Z; + double X=yscale*J-xscale*I; + double Y=yscale*J+xscale*I; + do_transform(invtransform,X,Y,Z,x,y,z); + } + else { + z=k; + x=window_xmin+i*(window_xmax-window_xmin)/LCD_WIDTH_PX; + y=window_ymax-j*(window_ymax-window_ymin)/LCD_HEIGHT_PX; + } + } + + gen geometry_round_numeric(double x,double y,double eps,bool approx){ + return approx?gen(x,y):exact_double(x,eps)+cst_i*exact_double(y,eps); + } + + gen geometry_round_numeric(double x,double y,double z,double eps,bool approx){ + return gen(approx?makevecteur(x,y,z):makevecteur(exact_double(x,eps),exact_double(y,eps),exact_double(z,eps)),_POINT__VECT); + } + + gen int2color(int couleur_){ + gen col; + if (couleur_){ + gen tmp; + int val; + vecteur colv; + if ( (val=(couleur_ & 0x0000ffff))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x00070000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x00380000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x01c00000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x0e000000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x30000000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x40000000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x80000000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if (colv.size()==1) + col=colv.front(); + else + col=symbolic(at_plus,gen(colv,_SEQ__VECT)); + } + return col; + } + + std::string print_color(int couleur){ + return int2color(couleur).print(context0); + } + + giac::gen add_attributs(const giac::gen & g,int couleur_,GIAC_CONTEXT) { + if (g.type!=_SYMB) + return g; + gen & f=g._SYMBptr->feuille; + if (g._SYMBptr->sommet==at_couleur && f.type==_VECT && !f._VECTptr->empty()){ + gen col=couleur_; + col.subtype=_INT_COLOR; + vecteur v(*f._VECTptr); + v.back()=col; + return symbolic(at_couleur,gen(v,_SEQ__VECT)); + } + if (couleur_==default_color(contextptr)) + return g; + if (g._SYMBptr->sommet==at_of){ + gen col=couleur_; + col.subtype=_INT_COLOR; + return symbolic(at_couleur,gen(makevecteur(g,col),_SEQ__VECT)); + } + vecteur v =gen2vecteur(f); + gen col=int2color(couleur_); + v.push_back(symbolic(at_equal,gen(makevecteur(at_display,col),_SEQ__VECT))); + return symbolic(g._SYMBptr->sommet,(v.size()==1 && f.type!=_VECT)?f:gen(v,f.type==_VECT?f.subtype:_SEQ__VECT)); + } + + void Graph2d::do_handle(const gen & g){ + if (hp){ + set_gen_value(hp_pos,g,true); + } + } + + std::string printn(const gen & g,int n){ + if (g.type!=_DOUBLE_) + return g.print(); + return giac::print_DOUBLE_(g._DOUBLE_val,n); + } + void Graph2d::tracemode_set(int operation){ + if (plot_instructions.empty()) + plot_instructions=gen2vecteur(g); + if (is_zero(plot_instructions.back())) // workaround for 0 at end in geometry (?) + plot_instructions.pop_back(); + gen sol(undef); + if (operation==1 || operation==8){ + double d=tracemode_mark; + if (!inputdouble(lang==1?"Valeur du parametre?":"Parameter value",d,contextptr)) + return; + if (operation==8) + tracemode_mark=d; + sol=d; + } + // handle curves with more than one connected component + vecteur tracemode_v; + for (int i=0;iempty() && g._VECTptr->front().is_symb_of_sommet(at_curve)){ + vecteur & v=*g._VECTptr; + for (int j=0;j0; + for (;tracemode_n=tracemode_v.size()){ + // retry + if (retry){ + for (tracemode_n=0;tracemode_n=tracemode_v.size()){ + tracemode=false; + return; + } + } + int p=python_compat(contextptr); + python_compat(0,contextptr); + gen G_orig(G); + G=remove_at_pnt(G); + tracemode_disp.clear(); + string curve_infos1,curve_infos2; + gen parameq,x,y,t,tmin,tmax,tstep; + // extract position at tracemode_i + if (G.is_symb_of_sommet(at_curve)){ + gen c=G._SYMBptr->feuille[0]; + parameq=c[0]; + // simple expand for i*ln(x) + bool b=do_lnabs(contextptr); + do_lnabs(false,contextptr); + reim(parameq,x,y,contextptr); + do_lnabs(b,contextptr); + t=c[1]; + gen x1=derive(x,t,contextptr); + gen x2=derive(x1,t,contextptr); + gen y1=derive(y,t,contextptr); + gen y2=derive(y1,t,contextptr); + sto(x,gen("x0",contextptr),contextptr); + sto(x1,gen("x1",contextptr),contextptr); + sto(x2,gen("x2",contextptr),contextptr); + sto(y,gen("y0",contextptr),contextptr); + sto(y1,gen("y1",contextptr),contextptr); + sto(y2,gen("y2",contextptr),contextptr); + tmin=c[2]; + tmax=c[3]; + tmin=evalf_double(tmin,1,contextptr); + tmax=evalf_double(tmax,1,contextptr); + if (tmin._DOUBLE_val>tracemode_mark) + tracemode_mark=tmin._DOUBLE_val; + if (tmax._DOUBLE_valfeuille[1]; + if (G.type==_VECT){ + vecteur &Gv=*G._VECTptr; + tstep=(tmax-tmin)/(Gv.size()-1); + } + double eps=1e-6; // epsilon(contextptr) + double curt=(tmin+tracemode_i*tstep)._DOUBLE_val; + if (abs(curt-tracemode_mark)size()>7 && centre_rayon(G_orig,C,R,false,contextptr,true) ) || + is_quadratic_wrt(parameq,t,A,B,C,contextptr) + ){ + if (C.type!=_VECT){ // x+i*y=A*t^2+B*t+C + curve_infos1="Parabola"; + curve_infos2=_equation(G_orig,contextptr).print(contextptr); + } + else { + vecteur V(*C._VECTptr); + curve_infos1=V[0].print(contextptr); + curve_infos1=curve_infos1.substr(1,curve_infos1.size()-2); + curve_infos1+=" O="; + curve_infos1+=V[1].print(contextptr); + curve_infos1+=", F="; + curve_infos1+=V[2].print(contextptr); + // curve_infos1=change_subtype(C,_SEQ__VECT).print(contextptr); + curve_infos2=change_subtype(R,_SEQ__VECT).print(contextptr); + } + } + else { + if (x==t) curve_infos1="Function "+y.print(contextptr); else curve_infos1="Parametric "+x.print(contextptr)+","+y.print(contextptr); + curve_infos2 = t.print(contextptr)+"="+tmin.print(contextptr)+".."+tmax.print(contextptr)+','; + curve_infos2 += (x==t?"xstep=":"tstep=")+tstep.print(contextptr); + } + } + if (operation==1) + curt=sol._DOUBLE_val; + if (operation==7) + sol=tracemode_mark=curt; + if (operation==2){ // root near curt + sol=newton(y,t,curt,NEWTON_DEFAULT_ITERATION,eps,1e-12,true,tmin._DOUBLE_val,tmax._DOUBLE_val,1,0,1,contextptr); + if (sol.type==_DOUBLE_){ + confirm(lang==1?"Racine en":"Root at",sol.print(contextptr).c_str()); + sto(sol,gen("Zero",contextptr),contextptr); + } + } + if (operation==4){ // horizontal tangent near curt + sol=newton(y1,t,curt,NEWTON_DEFAULT_ITERATION,eps,1e-12,true,tmin._DOUBLE_val,tmax._DOUBLE_val,1,0,1,contextptr); + if (sol.type==_DOUBLE_){ + confirm(lang==1?"y'=0, extremum/pt singulier en":"y'=0, extremum/singular pt at",sol.print(contextptr).c_str()); + sto(sol,gen("Extremum",contextptr),contextptr); + } + } + if (operation==5){ // vertical tangent near curt + if (x1==1) + do_confirm(lang==1?"Outil pour courbes parametriques!":"Tool for parametric curves!"); + else { + sol=newton(x1,t,curt,NEWTON_DEFAULT_ITERATION,eps,1e-12,true,tmin._DOUBLE_val,tmax._DOUBLE_val,1,0,1,contextptr); + if (sol.type==_DOUBLE_){ + confirm("x'=0, vertical or singular",sol.print(contextptr).c_str()); + sto(sol,gen("Vertical",contextptr),contextptr); + } + } + } + if (operation==6){ // inflexion + sol=newton(x1*y2-x2*y1,t,curt,NEWTON_DEFAULT_ITERATION,eps,1e-12,true,tmin._DOUBLE_val,tmax._DOUBLE_val,1,0,1,contextptr); + if (sol.type==_DOUBLE_){ + confirm("x'*y''-x''*y'=0",sol.print(contextptr).c_str()); + sto(sol,gen("Inflexion",contextptr),contextptr); + } + } + gen M(put_attributs(_point(subst(parameq,t,tracemode_mark,false,contextptr),contextptr),vecteur(1,_POINT_WIDTH_4 | _BLUE),contextptr)); + tracemode_disp.push_back(M); + gen f; + if (operation==9) + f=y*derive(x,t,contextptr); + if (operation==10){ + f=sqrt(pow(x1,2,contextptr)+pow(y1,2,contextptr),contextptr); + } + if (operation==9 || operation==10){ + double a=tracemode_mark,b=curt; + if (a>b) + swapdouble(a,b); + gen res=symbolic( (operation==9 && x==t?at_plotarea:at_integrate), + makesequence(f,symb_equal(t,symb_interval(a,b)))); + if (operation==9) + tracemode_disp.push_back(giac::eval(res,1,contextptr)); + string ss=res.print(contextptr); + if (!tegral(f,t,a,b,1e-6,1<<10,res,false,contextptr)) + confirm("Numerical Integration Error",ss.c_str()); + else { + confirm(ss.c_str(),res.print(contextptr).c_str()); + sto(res,gen((operation==9?"Area":"Arclength"),contextptr),contextptr); + } + } + if (operation>=1 && operation<=8 && sol.type==_DOUBLE_ && !is_zero(tstep)){ + tracemode_i=(sol._DOUBLE_val-tmin._DOUBLE_val)/tstep._DOUBLE_val; + G=subst(parameq,t,sol._DOUBLE_val,false,contextptr); + } + } + if (G.is_symb_of_sommet(at_cercle)){ + if (operation==-1){ + gen c,r; + centre_rayon(G,c,r,true,contextptr); + curve_infos1="Circle radius "+r.print(contextptr); + curve_infos2="Center "+_coordonnees(c,contextptr).print(contextptr); + } + G=G._SYMBptr->feuille[0]; + } + if (G.type==_VECT){ + vecteur & v=*G._VECTptr; + if (operation==-1 && curve_infos1.size()==0){ + if (v.size()==2) + curve_infos1=_equation(G_orig,contextptr).print(contextptr); + else if (v.size()==4) + curve_infos1="Triangle"; + else curve_infos1="Polygon"; + curve_infos2=G.print(contextptr); + } + int i=std::floor(tracemode_i); + double id=tracemode_i-i; + if (i>=int(v.size()-1)){ + tracemode_i=i=v.size()-1; + id=0; + } + if (i<0){ + tracemode_i=i=0; + id=0; + } + G=v[i]; + if (!is_zero(tstep) && id>0) + G=v[i]+id*tstep*(v[i+1]-v[i]); + } + G=evalf(G,1,contextptr); + if (operation==3){ // intersect this curve with all other curves + vecteur V; + for (int j=0;jfeuille; + if (f.type==_VECT && f._VECTptr->size()==3){ + f=f._VECTptr->back(); + curve_infos1 = f.print(contextptr)+": "+curve_infos1; + } + } + if (confirm(curve_infos1.c_str(),curve_infos2.c_str())==KEY_CTRL_F1 && tstep!=0){ + double t0=tmin._DOUBLE_val,ts=tstep._DOUBLE_val,t1=tmax._DOUBLE_val,tc=t0; + int ndisp=10,N=6; + for (;;){ + // table of values + drawRectangle(0,0,LCD_WIDTH_PX,LCD_HEIGHT_PX,_WHITE); + if (t==x){ + os_draw_string(0,0,_BLACK,_WHITE,"x"); + os_draw_string(120,0,_BLACK,_WHITE,y.print().c_str()); + } + else { + os_draw_string(0,0,_BLACK,_WHITE,"t"); + os_draw_string(107,0,_BLACK,_WHITE,"x"); + os_draw_string(214,0,_BLACK,_WHITE,"y"); + } + if (tct1) tc=t1-(ndisp-1)*ts; + for (int i=1;i<=ndisp;++i){ + double tcur=tc+(i-1)*ts; + os_draw_string(0,i*18,_BLACK,_WHITE,printn(tcur,N).c_str()); + if (t==x){ + gen cur=subst(y,t,tcur,false,contextptr); + os_draw_string(120,i*18,_BLACK,_WHITE,printn(cur,N).c_str()); + } + else { + gen cur=subst(x,t,tcur,false,contextptr); + os_draw_string(107,i*18,_BLACK,_WHITE,printn(cur,N).c_str()); + cur=subst(y,t,tcur,false,contextptr); + os_draw_string(214,i*18,_BLACK,_WHITE,printn(cur,N).c_str()); + } + } + int key=getkey(1); + if (key==KEY_CTRL_EXIT || key==KEY_CTRL_OK) + break; + if (key==KEY_CTRL_UP) + tc -= (ndisp/2)*ts; + if (key==KEY_CTRL_DOWN) + tc += (ndisp/2)*ts; + } + } + } + tracemode_add=""; + if (Gx.type==_DOUBLE_ && Gy.type==_DOUBLE_){ + tracemode_add += "x="+print_DOUBLE_(Gx._DOUBLE_val,3)+",y="+print_DOUBLE_(Gy._DOUBLE_val,3); + if (tstep!=0){ + gen curt=tmin+tracemode_i*tstep; + if (curt.type==_DOUBLE_){ + if (t!=x) + tracemode_add += ", t="+print_DOUBLE_(curt._DOUBLE_val,3); + if (tracemode & 2){ + gen G1=derive(parameq,t,contextptr); + gen G1t=subst(G1,t,curt,false,contextptr); + gen G1x,G1y; reim(G1t,G1x,G1y,contextptr); + gen m=evalf_double(G1y/G1x,1,contextptr); + if (m.type==_DOUBLE_) + tracemode_add += ", m="+print_DOUBLE_(m._DOUBLE_val,3); + gen T(_vector(makesequence(_point(G,contextptr),_point(G+G1t,contextptr)),contextptr)); + tracemode_disp.push_back(T); + gen G2(derive(G1,t,contextptr)); + gen G2t=subst(G2,t,curt,false,contextptr); + gen G2x,G2y; reim(G2t,G2x,G2y,contextptr); + gen det(G1x*G2y-G2x*G1y); + gen Tn=sqrt(G1x*G1x+G1y*G1y,contextptr); + gen R=evalf_double(Tn*Tn*Tn/det,1,contextptr); + gen centre=G+R*(-G1y+cst_i*G1x)/Tn; + if (tracemode & 4){ + gen N(_vector(makesequence(_point(G,contextptr),_point(centre,contextptr)),contextptr)); + tracemode_disp.push_back(N); + } + if (tracemode & 8){ + if (R.type==_DOUBLE_) + tracemode_add += ", R="+print_DOUBLE_(R._DOUBLE_val,3); + tracemode_disp.push_back(_cercle(makesequence(centre,R),contextptr)); + } + } + } + } + } + double x_scale=LCD_WIDTH_PX/(window_xmax-window_xmin); + double y_scale=LCD_HEIGHT_PX/(window_ymax-window_ymin); + double i,j; + findij(G,x_scale,y_scale,i,j,contextptr); + current_i=int(i+.5); + current_j=int(j+.5); + python_compat(p,contextptr); + } + + void Graph2d::invert_tracemode(){ + if (!tracemode) + init_tracemode(); + else + tracemode=0; + } + + void Graph2d::set_mode(const giac::gen & f_tmp,const giac::gen & f_final,int m,const string & help){ + approx=true; + mode=m; + selected.clear(); + redraw(); + args_help.clear(); + if (mode!=0 && mode!=255){ + int oldmode=calc_mode(contextptr); + calc_mode(0,contextptr); + gen g(help,contextptr); + calc_mode(oldmode,contextptr); + if (g.type==_VECT){ + const_iterateur it = g._VECTptr->begin(),itend=g._VECTptr->end(); + for (;it!=itend;++it) + args_help.push_back(it->print(contextptr)); + } + else + args_help.push_back(g.print(contextptr)); + } + if (mode==255) + modestr=gettext("Frame"); + else + modestr=mode?gen2string(f_final):gettext("Pointer"); + if (mode>=-1){ + pushed=false; + moving_param=moving=moving_frame=false; + // history_pos=-1; + mode=m; + function_final=f_final; + function_tmp=f_tmp; + args_tmp.clear(); + geo_handle(FL_MOVE,0); + update_g(); + } + } + + vecteur Graph2d::selection2vecteur(const vector & v){ + int n=v.size(); + vecteur res(n); + for (int i=0;i=hp->elements.size()) + selected.pop_back(); + } + + gen Graph2d::geometry_round(double x,double y,double z,double eps,gen & original,int & pos,bool selectfirstlevel,bool setscroller) { + if (!hp) + return undef; + gen tmp; + pos=-1; + geometry_round(x,y,z,eps,tmp,contextptr); + if (selected.empty()) + return tmp; + if (function_final==at_areaatraw || function_final==at_areaat || function_final==at_perimeteratraw || function_final==at_perimeterat){ + int p=findfirstclosedcurve(selection2vecteur(selected)); + if (p>0){ + pos=p; + } + } + if (pos==-1){ + if (selectfirstlevel){ + sort(selected.begin(),selected.end()); + // patch so that we move element and not the curve + int p=findfirstpoint(selection2vecteur(selected)); + if (p>0){ + pos=p; + } + } + else + pos=findfirstpoint(selection2vecteur(selected)); + } + gen g=symbolic_instructions[ (pos<0)?(pos=selected.front()):(pos=selected[pos]) ]; + if (pos>=0 && poselements.size()){ + // hp->_sel_begin=hp->_sel_end=pos; + // if (setscroller) hp->line=pos; + } + if (g.is_symb_of_sommet(at_plus) && g._SYMBptr->feuille.type==_VECT && !g._SYMBptr->feuille._VECTptr->empty()) + g=g._SYMBptr->feuille._VECTptr->front(); + if (g.is_symb_of_sommet(at_sto) && g._SYMBptr->feuille.type==_VECT ){ + vecteur & v = *g._SYMBptr->feuille._VECTptr; + if (v.size()==2){ + original = v[0]; + tmp = v[1]; + if (tmp.type==_IDNT){ + gen valeur=protecteval(original,1,contextptr); + if (valeur.is_symb_of_sommet(at_pnt)){ + gen & valf = valeur._SYMBptr->feuille; + if (valf.type==_VECT){ + vecteur & valv = *valf._VECTptr; + int s=v.size(); + if (s>1){ + gen valv1=valv[1]; + if (valv1.type==_VECT && valv1._VECTptr->size()>2){ + tmp=symbolic(at_extract_measure,v[1]); + } + } + } + } + } + } + } + return tmp; + } + + void Graph2d::autoname_plus_plus(){ + if (hp){ + string s=autoname(contextptr); + giac::autoname_plus_plus(s); + autoname(s,contextptr); + } + } + + int Graph2d::geo_handle(int event,int key){ + double eps=find_eps(); + int pos; + gen tmp,tmp2,decal; + if (event==FL_PUSH) + moving_param=false; + if ( pushed && !moving && !moving_frame && mode ==0 && in_area && event==FL_DRAG){ + // FIXME? redraw(); + return 1; + } + if (mode>=2 && event==FL_MOVE && args_tmp.size()>mode) + event=FL_RELEASE; + if ( in_area && ((mode!=1 && event==FL_DRAG) || event==FL_PUSH || event==FL_RELEASE || (mode>=2 && event==FL_MOVE)) ){ + double newx,newy,newz; + find_xyz(current_i,current_j,current_depth,newx,newy,newz); + round3(newx,window_xmin,window_xmax); + round3(newy,window_ymin,window_ymax); + if (is3d) + round3(newz,window_zmin,window_zmax); + tmp=geometry_round(newx,newy,newz,eps,tmp2,pos,mode==0 || (args_tmp.size()==mode && function_final.type==_FUNC && equalposcomp(transformation_functions,*function_final._FUNCptr)),event==FL_RELEASE); + if (tmp.type!=_IDNT && !tmp.is_symb_of_sommet(at_extract_measure)){ + bool done=false; + if (mode==0 && event==FL_PUSH && current_i<192 && current_j<14*nparams+21){ + double d=current_j/14.-1; + vecteur vp=param(d); + if (vp.size()==2){ + tmp=vp[0][0]; + tmp2=vp[0]; + pos=vp[1].val; + done=moving_param=true; + param_min=evalf_double(tmp2[1],1,contextptr)._DOUBLE_val; + param_max=evalf_double(tmp2[2],1,contextptr)._DOUBLE_val; + param_step=evalf_double(tmp2[4],1,contextptr)._DOUBLE_val; + param_orig=param_value=evalf_double(tmp2[3],1,contextptr)._DOUBLE_val; + } + } + if (!done){ + if (tmp.type==_VECT && tmp._VECTptr->size()==3){ + tmp.subtype=_SEQ__VECT; + tmp=symbolic(at_point,tmp); + } + else + tmp=symbolic(at_point,makevecteur(re(tmp,contextptr),im(tmp,contextptr))); + } + } + } + double newx,newy,newz; + if (is3d){ + double x1,y1,z1,x2,y2,z2; + find_xyz(current_i,current_j,current_depth,x1,y1,z1); + find_xyz(push_i,push_j,push_depth,x2,y2,z2); + newx=x1-x2; newy=y1-y2; newz=z1-z2; + } else { + int dw=LCD_WIDTH_PX,dh=LCD_HEIGHT_PX; + double dx=window_xmax-window_xmin; + double dy=window_ymax-window_ymin; + double x_scale=dx/dw,y_scale=dy/dh; + newx=(current_i-push_i)*x_scale; + newy=(push_j-current_j)*y_scale; + newz=0; + } + round3(newx,window_xmin,window_xmax); + round3(newy,window_ymin,window_ymax); + if (is3d){ + round3(newz,window_zmin,window_zmax); + decal=in_area?geometry_round_numeric(newx,newy,newz,eps,approx):0; + if (decal.type==_VECT && decal.subtype==_POINT__VECT) + decal.subtype=0; + } + else + decal=in_area?geometry_round_numeric(newx,newy,eps,approx):0; + // cerr << in_area << " " << decal << '\n'; + if (mode==0 || mode==255) { + if (event==FL_PUSH){ + // select object && flag to move it + if (mode==0 && pos>=0){ + if (tmp.type==_IDNT){ + drag_original_value=tmp2; + drag_name=tmp; + } + else { + drag_original_value=symbolic_instructions[pos]; + drag_name=0; + } + hp_pos=pos; + moving = true; + } + else { // nothing selected, move frame + if (!(display_mode & 0x80)) // disabled by default in 3-d + moving_frame=true; + } + return 1; + } + if (moving_frame && (event==FL_DRAG || event==FL_RELEASE) ){ + window_xmin -= newx; + window_xmax -= newx; + window_ymin -= newy; + window_ymax -= newy; + window_zmin -= newz; + window_zmax -= newz; + push_i = current_i; + push_j = current_j; + push_depth = current_depth; + redraw(); + if (event==FL_RELEASE) + moving_frame=false; + return 1; + } + if (mode==255) + return 0; + if (moving_param && (event==FL_DRAG || event==FL_RELEASE) ){ + // key -> + if (key==KEY_CTRL_EXIT) + param_value=param_orig; + double ps=param_step; + if (ps<=0) + ps=(param_max-param_min)/100; + if (key==KEY_CTRL_LEFT) + param_value -= ps; + if (key==KEY_SHIFT_LEFT) + param_value -= 10*ps; + if (key==KEY_CTRL_RIGHT) + param_value += ps; + if (key==KEY_SHIFT_RIGHT) + param_value += 10*ps; + if (param_valueparam_max) + param_value=param_max; + current_i=64+128*(param_value-param_min)/(param_max-param_min); + if (param_step<=0) + do_handle(symbolic(at_assume,symb_equal(drag_name,param_value))); + else { + gen newval=symbolic(at_element,makesequence(symb_interval(param_min,param_max),param_value)); + do_handle(symbolic(at_sto,makevecteur(newval,drag_name))); + } + if (event==FL_RELEASE){ + moving_param=moving=false; + } + return 1; + } + if (moving && (event==FL_DRAG || event==FL_RELEASE) ){ + // cerr << current_i << " " << current_j << '\n'; + // avoid point()+complex+complex+complex + gen newval=drag_original_value; + if (in_area && key!=KEY_CTRL_EXIT){ + if (drag_original_value.is_symb_of_sommet(at_plus) && drag_original_value._SYMBptr->feuille.type==_VECT && drag_original_value._SYMBptr->feuille._VECTptr->size()>=2){ + vecteur v=*drag_original_value._SYMBptr->feuille._VECTptr; + if (v[1].is_symb_of_sommet(at_nop)) + v[1]=v[1]._SYMBptr->feuille; + newval=symbolic(at_plus,makevecteur(v[0],symbolic(at_nop,ratnormal(_plus(vecteur(v.begin()+1,v.end()),contextptr)+decal)))); + } + else { + newval=is_zero(decal)?drag_original_value:symbolic(at_plus,makevecteur(drag_original_value,symbolic(at_nop,decal))); + } + } + int dclick = 0 || drag_original_value.type==_VECT; + if (!dclick){ + if (drag_name.type==_IDNT) + do_handle(symbolic(at_sto,makevecteur(newval,drag_name))); + else + do_handle(newval); + } + if (event==FL_RELEASE) + moving=false; + selected.clear(); + redraw(); + return 1; + } + return 0; + } + selected.clear(); + if (mode==1){ + if (function_final!=at_point){ + if (event==FL_RELEASE){ + string args=autoname(contextptr)+":="; + if (function_final.type==_FUNC) + args += function_final._FUNCptr->ptr()->s; + args +="("; + if (function_final==at_plotode) + args += fcnfield + "," + fcnvars + "," +tmp.print(contextptr) + ",plan)"; + else + args += tmp.print(contextptr) + ")"; + autoname_plus_plus(); + set_gen_value(-1,gen(args,contextptr),true); + } + if (event==FL_PUSH || event==FL_DRAG || event==FL_RELEASE) + return 1; + return 0; + } + // point|segment mode + if (event==FL_RELEASE){ + hp_pos=-1; + if (hp && !args_tmp.empty() && (std::abs(push_i-current_i)>npixels || std::abs(push_j-current_j)>npixels || (is3d && std::abs(push_depth-current_depth) >0)) ){ + // make a segment + gen val1,val2; + if (in_area && args_tmp.front().is_symb_of_sommet(at_point)){ + val1=gen(autoname(contextptr),contextptr); + // put in last history pack level + set_gen_value(-1,symbolic(at_sto,makevecteur(add_attributs(args_tmp.front(),couleur,contextptr),val1)),false); + hp_pos=hp->elements.size()-1; + autoname_plus_plus(); + } + else + val1=args_tmp.front(); + if (in_area && tmp.is_symb_of_sommet(at_point)){ + val2=gen(autoname(contextptr),contextptr); + gen tmp3=symbolic(at_sto,makevecteur(add_attributs(tmp,couleur,contextptr),val2)); + set_gen_value(-1,tmp3,false); + if (hp_pos<0) hp_pos=hp->elements.size()-1; + autoname_plus_plus(); + } + else + val2=tmp; + if (in_area){ + gen tmp3=add_attributs(symbolic(at_segment,makevecteur(val1,val2)),couleur,contextptr); + string v1v2=val1.print(contextptr)+val2.print(contextptr); + gen g1g2(v1v2,contextptr); + if (g1g2.type!=_IDNT) + g1g2=gen(v1v2+"_",contextptr); + tmp3=symbolic(at_sto,makevecteur(tmp3,g1g2)); + set_gen_value(-1,tmp3,false); + if (hp_pos<0) hp_pos=hp->elements.size()-1; + eval(hp_pos); + } + return 1; + } + if (in_area && tmp.type!=_IDNT) + do_handle(symbolic(at_sto,makevecteur(add_attributs(tmp,couleur,contextptr),gen(autoname(contextptr),contextptr)))); + // element + if (tmp.type==_IDNT && tmp2.type==_SYMB && !equalposcomp(point_sommet_tab_op,tmp2._SYMBptr->sommet)){ + // tmp2 is the geo object, find parameter value + double newx,newy,newz; + find_xyz(current_i,current_j,current_depth,newx,newy,newz); + round3(newx,window_xmin,window_xmax); + round3(newy,window_ymin,window_ymax); + gen t=projection(evalf(tmp2,1,contextptr),gen(newx,newy),contextptr); + if (is_undef(t)) + return 0; + gen tmp3=symbolic(at_element,( (t.type<_IDNT || t.type==_VECT)?gen(makevecteur(tmp,t),_SEQ__VECT):tmp)); + tmp3=symbolic(at_sto,makevecteur(add_attributs(tmp3,couleur,contextptr),gen(autoname(contextptr),contextptr))); + set_gen_value(-1,tmp3,false); + if (hp_pos<0) hp_pos=hp->elements.size()-1; + eval(hp_pos); + } + return 1; + } + if (event==FL_PUSH){ + args_tmp=vecteur(1,tmp); + return 1; + } + if (event==FL_DRAG){ + redraw(); + return 1; + } + return 0; + } + gen tmpval=remove_at_pnt(tmp.eval(1,contextptr)); + gen somm=symbolic(at_sommets,tmp); + int npoints=1; + if (!equalposcomp(nosplit_polygon_function,*function_final._FUNCptr)){ + if (tmpval.type==_VECT && tmpval.subtype==_GROUP__VECT) + npoints=tmpval._VECTptr->size(); + if (tmpval.is_symb_of_sommet(at_cercle)) + npoints=is3d?3:2; + } + unsigned args_size=args_tmp.size(); + // mode>=2 + if (event==FL_MOVE || event==FL_DRAG || event==FL_RELEASE || event==FL_PUSH){ + if (args_sizesize()==2){ + gen tmpa=remove_at_pnt(evalf(args_tmp[0],1,contextptr)); + gen tmpb=new_args_size==2?remove_at_pnt(evalf(args_tmp[1],1,contextptr)):undef; + if (npoints==2 && tmpa==tmp2._VECTptr->front() && tmpb!=tmp2._VECTptr->back()){ + tmp=symbolic(at_at,gen(makevecteur(somm,1),_SEQ__VECT)); + npoints=1; + } + if (npoints==2 && tmpa==tmp2._VECTptr->back() && tmpb!=tmp2._VECTptr->front()){ + tmp=symbolic(at_at,gen(makevecteur(somm,0),_SEQ__VECT)); + npoints=1; + } + if (npoints==2 && tmpb==tmp2._VECTptr->front() && tmpa!=tmp2._VECTptr->back() ){ + swapargs=true; + tmp=symbolic(at_at,gen(makevecteur(somm,1),_SEQ__VECT)); + npoints=1; + } + if (npoints==2 && tmpb==tmp2._VECTptr->back() && tmpa!=tmp2._VECTptr->front()){ + swapargs=true; + tmp=symbolic(at_at,gen(makevecteur(somm,0),_SEQ__VECT)); + npoints=1; + } + } + } + if (npoints+args_tmp.size()>mode) + npoints=1; + if (event==FL_MOVE || event==FL_DRAG || event==FL_RELEASE){ + if (args_size && args_tmp_push_size && args_push!=tmp_push){ + // replace by current mouse position + if (npoints==1) + args_tmp.push_back(tmp); + else { + gen somm=symbolic(at_sommets,tmp); + for (int i=0;i1 && s>=mode){ + if (s>mode){ + args_tmp=vecteur(args_tmp.begin(),args_tmp.begin()+mode); + s=mode; + } + gen tmp_plot; + if (in_area && function_final.type==_FUNC) { + gen res,objname=gen(autoname(contextptr),contextptr); + hp_pos=hp->elements.size(); + if (hp_pos && hp->elements[hp_pos-1].s.empty()) + --hp_pos; + // hp->update_pos=hp_pos; + int pos0=hp_pos; + unary_function_ptr * ptr=function_final._FUNCptr; + int ifinal=mode; + if (equalposcomp(measure_functions,*ptr)) + ifinal--; + // first replace points in args_tmp by assignations + for (int i=0;isize())>2){ + vecteur l; + if (res._VECTptr->back()==res._VECTptr->front()) + --ns; + if (function_final.type==_FUNC && equalposcomp(transformation_functions,*function_final._FUNCptr)){ + vecteur argv; + gen objn,som=symbolic(at_sommets,objname); + for (int i=1;i<=ns;++i){ + tmp_plot=symbolic(at_at,gen(makevecteur(som,i-1),_SEQ__VECT)); + objn=gen(autoname(contextptr)+print_INT_(i),contextptr); + argv.push_back(objn); + set_gen_value(hp_pos,symbolic(at_sto,gen(makevecteur(tmp_plot,objn),_SEQ__VECT)),false); + add_entry(hp_pos+1); + ++hp_pos; + } + for (int i=1;i<=ns;++i){ + tmp_plot=symbolic(at_segment,makevecteur(argv[i-1],argv[i%ns])); + set_gen_value(hp_pos,symbolic(at_sto,makevecteur(add_attributs(tmp_plot,couleur,contextptr),gen(autoname(contextptr)+print_INT_(ns+i),contextptr))),false); + add_entry(hp_pos+1); + ++hp_pos; + } + } + else { + for (int i=mode;iundo_position=save_undo_position; + eval(pos0); + } + args_tmp.clear(); + args_tmp_push_size=0; + } + redraw(); + return 1; + } + return 0; + } + + void geosave(textArea * text,GIAC_CONTEXT){ + string s=remove_extension(text->filename); + gen tmp(s,contextptr); + if (tmp.type==_IDNT){ + sto(makevecteur(at_pnt,string2gen(merge_area(text->elements),false)),tmp,contextptr); + return; + } + else { + for (int i=0;i<10;++i){ + string s1=s+print_INT_(i); + tmp=gen(s1,contextptr); + if (tmp.type==_IDNT){ + confirm(lang==1?"Nom de sauvegarde reserve":"Unable to use reserved name",((lang==1?"Nom utilise ":"Name used ")+s1).c_str()); + sto(makevecteur(at_pnt,string2gen(merge_area(text->elements),false)),tmp,contextptr); + return; + } + } + } + confirm(lang==1?"Nom de sauvegarde reserve":"Unable to use reserved name",lang==1?"Sauvegarde impossible":"Unable to save"); + } + + void geohelp(GIAC_CONTEXT){ + textArea text; + text.editable=false; + text.clipline=-1; + text.title = (char*)((lang==1)?"Aide":"Help"); + text.allowF1=false; + text.python=false; + add(&text,lang==1? + "x,n,t ou tab: etude courbe\nshift-2: info courbe\nshift-3: tangente, pente\nshift-4: normale\nshift-5: cercle osculateur\nshift-7: infos courbe on/off\nhaut/bas/droit/gauche: deplace pointeur ou change point de vue\nalpha-haut/bas/droit/gauche: modifie fenetre\ny^x ou e^x: trace 3d precis\nEsc/Back: quitte ou interrompt le trace 3d en cours\n( et ): modifie le rendu des surfaces raides 3d\n0: surfaces cachees 3d ON/OFF\n.: remplissage surface 3d raide ON/OFF\n5 reset 3d view\n7,8,9,1,2,3: deplacement 3d\n\nGeometrie\nF4: change le mode\nLe mode repere (shift 7) permet de changer le point de vue\nLe mode pointeur (shift 8) permet de bouger un objet et les objets dependants avec enter/OK et les touches de deplacement\nLes autres modes permettent de creer des objets\nEsc/Back: permet de passer en vue symbolique et de creer/modifier des objets par des commandes, taper enter/OK pour revenir en vue graphique\n4,6: modifie la profondeur du clic": + "x,n,t or tab: curve study\nshift-2: curve info\nshift-3: tangent, slope\nshift-4: normal\nshift-5: osculating circle\nshift-7: curve infos on/off\nup/down/right/left: move pointer or modify viewpoint\nalpha-up/down/right/left: move window\nEsc/Back: leave or interrupt 3d rendering\ny^x or e^x: precise 3d\n( and ): modify stiff surfaces 3d rendering\n0: hidden 3d surfaces ON/OFF\n.: fill stiff 3d surfacesON/OFF\n5 reset 3d view\n7,8,9,1,2,3: move 3d view\n\nGeometry\nF4: change geometry mode\nFrame mode (shift F1): modify viewpoint\nPointer mode (shift F2): select an object and move it with enter/OK and cursor keys\nOther modes: create an object\nEsc/Back: go to symbolic view where you can create/modify objects with commands, press enter/OK to go back to graphic view"); + int exec=doTextArea(&text,contextptr); + } + + string inputparam(char curname,int symbolic,GIAC_CONTEXT){ + Menu paramenu; + paramenu.numitems=7; + MenuItem paramenuitems[paramenu.numitems]; + paramenu.items=paramenuitems; + paramenu.height=8; + paramenu.title = (char *)"Parameter"; + char menu_xcur[32],menu_xmin[32],menu_xmax[32],menu_xstep[32],menu_name[16]="name a"; + menu_name[5]=curname; + double pcur=0,pmin=-5,pmax=5,pstep=0.1; + std::string s; + bool doit; + for (;;){ + s="cur "+giac::print_DOUBLE_(pcur,contextptr); + strcpy(menu_xcur,s.c_str()); + s="min "+giac::print_DOUBLE_(pmin,contextptr); + strcpy(menu_xmin,s.c_str()); + s="max "+giac::print_DOUBLE_(pmax,contextptr); + strcpy(menu_xmax,s.c_str()); + s="step "+giac::print_DOUBLE_(pstep,contextptr); + strcpy(menu_xstep,s.c_str()); + paramenuitems[0].text = (char *) "OK"; + paramenuitems[1].text = (char *) menu_name; + paramenuitems[2].text = (char *) menu_xcur; + paramenuitems[3].text = (char *) menu_xmin; + paramenuitems[4].text = (char *) menu_xmax; + paramenuitems[5].text = (char *) menu_xstep; + paramenuitems[6].text = (char *) "Symbolic"; + paramenuitems[6].type = MENUITEM_CHECKBOX; + paramenuitems[6].value = symbolic; + int sres = doMenu(¶menu); + doit = sres==MENU_RETURN_SELECTION || sres==KEY_CTRL_EXE; + if (doit) { + std::string s1; double d; + if (paramenu.selection==2){ + handle_f5(); + if (inputline(menu_name,(lang==1)?"Nouvelle valeur?":"New value?",s1,false)==KEY_CTRL_EXE && s1.size()>0 && isalpha(s1[0])){ + if (s1.size()>10) + s1=s1.substr(0,10); + strcpy(menu_name,("name "+s1).c_str()); + } + continue; + } + if (paramenu.selection==3){ + inputdouble(menu_xcur,pcur,contextptr); + continue; + } + if (paramenu.selection==4){ + inputdouble(menu_xmin,pmin,contextptr); + continue; + } + if (paramenu.selection==5){ + inputdouble(menu_xmax,pmax,contextptr); + continue; + } + if (paramenu.selection==6){ + inputdouble(menu_xstep,pstep,contextptr); + pstep=fabs(pstep); + continue; + } + if (paramenu.selection==7){ + symbolic=1-symbolic; + continue; + } + // if (paramenu.selection==6) break; + } // end menu + break; + } // end for (;;) + if (doit && pmin0){ + if (symbolic){ + s="assume("; + s += (menu_name+5); + s += "=["; + s += (menu_xcur+4); + s += ','; + s += (menu_xmin+4); + s += ','; + s += (menu_xmax+4); + s += ','; + s += (menu_xstep+5); + s += "])"; + } + else { + s=(menu_name+5); + s += ":=element("; + s += (menu_xmin+4); + s += ".."; + s += (menu_xmax+4); + s += ','; + s += (menu_xcur+4); + s += ")"; + } + } else s=""; + return s; + } + + void Graph2d::init_tracemode(){ + if (is3d){ + tracemode=0; + return; + } + tracemode_mark=0.0; + double w=LCD_WIDTH_PX; + double h=LCD_HEIGHT_PX-STATUS_AREA_PX; + double window_w=window_xmax-window_xmin,window_h=window_ymax-window_ymin; + double r=h/w*window_w/window_h; + tracemode=(r>0.7 && r<1.4)?7:3; + tracemode_set(); + } + + void Graph2d::curve_infos(){ + if (!tracemode) + init_tracemode(); + const char * + tab[]={ + lang==1?"Infos objet (shift-2)":"Object infos (shift-2)", // 0 +#ifdef NUMWORKS + lang==1?"Quitte mode etude (x,n,t)":"Quit study mode (x,n,t)", +#else + lang==1?"Quitte mode etude (tab)":"Quit study mode (tab)", +#endif + lang==1?"Entrer t ou x":"Set t or x", // 1 + lang==1?"y=0, racine":"y=0, root", + "Intersection", // 3 + "y'=0, extremum", + lang==1?"x'=0 (parametriques)":"x'=0 (parametric)", // 5 + "Inflexion", + lang==1?"Marquer la position":"Mark position", + lang==1?"Entrer t ou x, marquer":"Set t or x, mark", // 8 + lang==1?"Aire":"Area", + lang==1?"Longueur d'arc":"Arc length", // 10 + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,lang==1?"Etude courbes":"Curve study",true); + if (choix<0 || choix>s) + return; + if (choix==1) + tracemode=0; + else + tracemode_set(choix-1); + } + + int Graph2d::ui(){ + Graph2d & gr=*this; + // UI + int saveprecision=gr.precision; + gr.precision += 2; // fast draw first + gr.draw(); + gr.precision=saveprecision; + gr.must_redraw=true; + for (;;){ +#ifdef NSPIRE_NEWLIB + DefineStatusMessage((char*)"shift-1: help, menu: menu, esc: quit", 1, 0, 0); +#else + DefineStatusMessage((char*)"shift-1: help, home: menu, back: quit", 1, 0, 0); +#endif + DisplayStatusArea(); + int saveprec=gr.precision; + if (gr.doprecise){ + gr.doprecise=false; + gr.precision=1;//gr.precision-=2; + } + if (gr.must_redraw) + gr.draw(); + if (hp){ + string msg=hp->filename+":"+(mode==255?" Frame. Shift-1: help":modestr); + // help + int help_pos=args_tmp.empty()?0:args_tmp.size()-1; + if (help_pos='a' && key<='z'){ + bool found=false; + char ch=key; + gen tmp=gen(string("")+ch,contextptr); + if (tmp.type==_IDNT){ + int pos=0; + for (int i=0;ifeuille[0]; + ++pos; + if (name==tmp){ + current_j=7+14*pos; + found=true; + break; + } + } + } + } + if (found) + continue; + key -= 'a'-'A'; + } + if (key>='A' && key<='Z'){ + char ch=key; + gen tmp=gen(string("")+ch,contextptr); + if (tmp.type==_IDNT){ + tmp=evalf(tmp,1,contextptr); + if (tmp.is_symb_of_sommet(at_pnt)){ + tmp=remove_at_pnt(tmp); + if (tmp.is_symb_of_sommet(at_cercle)) + tmp=(tmp._SYMBptr->feuille[0]+tmp._SYMBptr->feuille[1])/2; + if (tmp.type==_SYMB) + tmp=tmp._SYMBptr->feuille; + if (tmp.type==_VECT && tmp.subtype!=_POINT__VECT && !tmp._VECTptr->empty()) + tmp=tmp._VECTptr->front(); + if (is3d && tmp.type==_VECT && tmp._VECTptr->size()==3 && tmp.subtype==_POINT__VECT){ + const vecteur & tv=*tmp._VECTptr; + gen x=tv[0],y=tv[1],z=tv[2]; + x=evalf_double(x,1,contextptr); + y=evalf_double(y,1,contextptr); + z=evalf_double(z,1,contextptr); + if (x.type==_DOUBLE_ && y.type==_DOUBLE_ && z.type==_DOUBLE_){ + double i,j; double3 d3; + xyz2ij(double3(x._DOUBLE_val,y._DOUBLE_val,z._DOUBLE_val),i,j,d3); + current_i=i; current_j=j; current_depth=d3.z; + } + } + if (!is3d && (tmp.type==_DOUBLE_ || tmp.type==_CPLX)){ + double x_scale=LCD_WIDTH_PX/(window_xmax-window_xmin); + double y_scale=LCD_HEIGHT_PX/(window_ymax-window_ymin); + double i,j; + findij(tmp,x_scale,y_scale,i,j,contextptr); + current_i=int(i+.5); + current_j=int(j+.5); + adjust_cursor_point_type(); + geo_handle(moving?FL_DRAG:FL_MOVE,key); + continue; + } + } + } + } + } + if (hp && (key==KEY_CTRL_CATALOG || key==KEY_BOOK )){ + tracemode=0; + const char * + tab[]={ + lang==1?"Mode repere":"Frame mode", // 0 + lang==1?"Pointeur":"Pointer", + lang==1?"Point":"Point", // 2 + is3d?"Sphere":"Circle", + lang==1?"Triangle":"Triangle", // 4 + lang==1?"Points":"Points", + lang==1?"Droites, plans":"Lines, planes", // 6 + lang==1?"Polygone, polyedre":"Polygon, polyhedron", + lang==1?"Cercle, conique, sphere":"Circle, conic, sphere", // 8 + lang==1?"Courbe, surface":"Curve, surface", // 9 + lang==1?"Curseur":"Cursor", // 10 + lang==1?"Transformations":"Transforms", + lang==1?"Mesures":"Mesures", // 12 + lang==1?"Effacer trace":"Clear trace", // -1 + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Mode",true); + if (choix<0 || choix>s) + continue; + if (choix==s-1){ + trace_instructions.clear(); + update_g(); + continue; + } + if (choix<=4){ + gen ftmp[]={0,0,at_point,at_segment,at_segment}; + gen ffinal[]={0,0,at_point,is3d?at_sphere:at_cercle,at_triangle}; + int mode[]={255,0,1,2,3}; + const char * help[]={"","","Point","Center,Point","Point1,Point2,Point3"}; + set_mode(ftmp[choix],ffinal[choix],mode[choix],help[choix]); + continue; + } + draw(); // for small choosebox, we must clean up previous choosebox + if (choix==5){ // Points + const char * + tab[]={ + lang==1?"Point":"Point", + lang==1?"Milieu":"Middle point", + lang==1?"Centre":"Center", + lang==1?"Intersection unique":"Single intersection", + lang==1?"Liste d'intersections":"List of intersections", + lang==1?"Element":"Element", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Points",true); + if (choix<0 || choix>s) + continue; + gen ftmp[]={at_point,at_segment,at_centre,at_inter_unique,at_inter,at_element}; + gen ffinal[]={at_point,at_milieu,at_centre,at_inter_unique,at_inter,at_element}; + int mode[]={1,2,1,2,2,1}; + const char * help[]={ + "Point", + "Point1,Point2", + "Circle", + "Line1,Line2", + "Curve1,Curve2", + "Curve", + }; + set_mode(ftmp[choix],ffinal[choix],mode[choix],help[choix]); + continue; + } + if (choix==6){ // Droites + const char * + tab[]={ + lang==1?"Segment":"Segment", + lang==1?"Vecteur":"Vector", + lang==1?"Demi-droite":"Halfline", + lang==1?"Droite":"Line", + lang==1?"Plan":"Plane", + lang==1?"Parallele":"Parallel", + lang==1?"Perpendiculaire":"Perpendicular", + lang==1?"Mediatrice":"Perpen_bisector", + lang==1?"Bissectrice":"Bisector", + lang==1?"Mediane":"Median line", + lang==1?"Tangente":"Tangent", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Droites, segments...",true); + if (choix<0 || choix>s) + continue; + gen ftmp[]={at_segment,at_vector,at_demi_droite,at_droite,at_segment,at_parallele,at_perpendiculaire,at_mediatrice,at_segment,at_segment,at_segment}; + gen ffinal[]={at_segment,at_vector,at_demi_droite,at_droite,at_plan,at_parallele,at_perpendiculaire,at_mediatrice,at_bissectrice,at_mediane,at_tangent}; + int mode[]={2,2,2,2,2,3,2,2,3,3,2}; + const char * help[]={ + "Point1,Point2", + "Point1,Point2", + "Point1,Point2", + "Point1,Point2", + "Point1,Point2,Point3", + "Point,Line", + "Point,Line", + "Point1,Point2", + "Sommet_angle,Point2,Point3", + "Sommet_angle,Point2,Point3", + "Curve,Point" + }; + set_mode(ftmp[choix],ffinal[choix],mode[choix],help[choix]); + continue; + } + if (choix==7){ // Polygons + const char * + tab[]={ + lang==1?"Triangle":"Triangle", + lang==1?"Triangle equilateral":"Equilateral triangle", + lang==1?"Carre":"Square", + lang==1?"Quadrilatere":"Quadrilateral", + lang==1?"Polygone":"Polygon", + lang==1?"Tetraedre (pyramide)":"Tetrahedron (Pyramid)", + lang==1?"Tetraedre regulier":"Regular tetrahedron", + lang==1?"Cube":"Cube", + lang==1?"Octaedre":"Octahedron", + lang==1?"Dodecaedre":"Dodecahedron", + lang==1?"Icosaedre":"Icosahedron", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Droites, segments...",true); + if (choix<0 || choix>s) + continue; + gen ftmp[]={at_polygone_ouvert,at_segment,at_segment,at_polygone_ouvert,at_polygone_ouvert,at_polygone_ouvert,at_polygone_ouvert,at_polygone_ouvert,at_polygone_ouvert,at_polygone_ouvert,at_polygone_ouvert}; + gen ffinal[]={at_triangle,at_triangle_equilateral,at_carre,at_quadrilatere,at_polygone,at_tetraedre,at_tetraedre,at_cube,at_octaedre,at_dodecaedre,at_icosaedre}; + int mode[]={3,2,2,4,5,4,3,3,3,3,3}; + int m=mode[choix]; + if (choix==4){ + double d=5; + if (inputdouble(lang==1?"Nombre de sommets?":"Number of vertices?",d,contextptr) && d==int(d) && d>=3 && d<20){ + m=d; + } + else continue; + } + const char * help[]={ + "Point1,Point2,Point3", + "Point1,Point2", + "Point1,Point2", + "Point1,Point2,Point3,Point4", + "Point1,Point2,Point3,Point4,Point5", + "Point1,Point2,Point3,Point4", + "Point1,Point2,Point3", + "Point1,Point2,Point3", + "Point1,Point2,Point3", + "Point1,Point2,Point3", + "Point1,Point2,Point3", + }; + set_mode(ftmp[choix],ffinal[choix],m,help[choix]); + continue; + } + if (choix==8){ // Conics + const char * + tab[]={ + lang==1?"cercle":"circle", + lang==1?"circonscrit":"circumcircle", + lang==1?"inscrit":"incircle", + lang==1?"ellipse":"ellipse", + lang==1?"hyperbole":"hyperbola", + lang==1?"parabole":"parabola", + lang==1?"sphere":"sphere", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Conic",true); + if (choix<0 || choix>s) + continue; + gen ftmp[]={at_segment,at_segment,at_segment,at_segment,at_segment,at_segment,at_segment}; + gen ffinal[]={at_cercle,at_circonscrit,at_inscrit,at_ellipse,at_hyperbole,at_parabole,at_sphere}; + int mode[]={2,3,3,3,3,2,2}; + const char * help[]={ + "Center,Point", + "Point1,Point2,Point3", + "Point1,Point2,Point3", + "Focus1,Focus2,Point_on_ellipse", + "Focus1,Focus2,Point_on_hyperbola", + "Focus,Point_or_line", + "Center,Point", + }; + set_mode(ftmp[choix],ffinal[choix],mode[choix],help[choix]); + continue; + } + if (choix==9){ // Curves + const char * + tab[]={ + lang==1?"Fonction plot(sin(x))":"Function plot(sin(x))", + lang==1?"Param. plotparam([x^2,x^3])":"Param. plotparam([x^2,x^3])", + lang==1?"Polaire plotpolar(x)":"Polar plotpolar(x)", + lang==1?"Implicit plot(x^2+y^4=6)":"Implicit plot(x^2+y^4=6)", + lang==1?"Champ des tangentes":"Plotfield", + lang==1?"Solution equa. diff.":"Diff. equa. solution", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Courbe",true); + if (choix<0 || choix>s) + continue; + const char * cmd[]={"plot()","plotparam()","plotpolar()","plot()","plotfield()","plotode()"}; + hp->line=hp->add_entry(-1); + string mycmd=autoname(contextptr)+":="+cmd[choix]; + autoname_plus_plus(); + hp->set_string_value(hp->line,mycmd); + hp->pos=mycmd.size()-1; + return KEY_CTRL_OK; + } + if (choix==10){ + gen param=0; + for (char ch='a';ch<='z';++ch){ + gen tmp(string("")+ch,contextptr); + if (tmp.type!=_IDNT) continue; + param=tmp.eval(1,contextptr); + if (param==tmp) + break; + } + if (param==0){ + confirm(lang==1?"Plus de variables libres.":"No more free variable available",lang==1?"Essayez purge(a) ou purge(b) ou ...":"Try purge(a) or purge(b) or ..."); + continue; + } + string mycmd=inputparam(param.print()[0],0,contextptr); + if (!mycmd.empty()){ + hp->line=hp->add_entry(-1); + // string mycmd=param.print()+":=element(0..1,0.5)"; + // autoname_plus_plus(); + hp->set_string_value(hp->line,mycmd); + hp->pos=mycmd.size()-1; + } + return KEY_CTRL_OK; + } + if (choix==11){ // Transforms + const char * + tab[]={ + lang==1?"symetrie":"reflexion", + lang==1?"rotation":"rotation", + lang==1?"translation":"translation", + lang==1?"projection":"projection", + lang==1?"homothetie":"homothety", + lang==1?"similitude":"similarity", + // lang==1?"":"", + // lang==1?"":"", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Transform",true); + if (choix<0 || choix>s) + continue; + gen ftmp[]={at_segment,at_polygone_ouvert,at_segment,at_segment,at_segment,at_polygone_ouvert}; + gen ffinal[]={at_symetrie,at_rotation,at_translation,at_projection,at_homothetie,at_similitude}; + int mode[]={2,3,2,2,2,3}; + const char * help[]={ + "Symmetry_center_axis,Object", + "Center,Angle,Object", + "Vector,Object", + "Curve,Object", + "Center,Ratio,Object", + "Center,Ratio,Angle,Object" + }; + set_mode(ftmp[choix],ffinal[choix],mode[choix],help[choix]); + continue; + } + if (choix==12){ // Mesures + const char * + tab[]={ + lang==1?"distance":"distance", + lang==1?"angle":"angle", + lang==1?"aire":"area", + lang==1?"perimetre":"perimeter", + lang==1?"pente":"slope", + lang==1?"distance seule":"distance raw", + lang==1?"angle seul":"angle raw", + lang==1?"aire seule":"area raw", + lang==1?"perimetre seul":"perimeter raw", + lang==1?"pente seule":"slope raw", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Mesures",true); + if (choix<0 || choix>s) + continue; + gen ftmp[]={at_segment,at_triangle,at_areaat,at_perimeterat,at_slopeat,at_segment,at_triangle,at_areaatraw,at_perimeteratraw,at_slopeatraw}; + gen ffinal[]={at_distanceat,at_angleat,at_areaat,at_perimeterat,at_slopeat,at_distanceatraw,at_angleatraw,at_areaatraw,at_perimeteratraw,at_slopeatraw}; + int mode[]={3,4,2,2,2,3,4,2,2,2}; + const char * help[]={ + "Object1,Object2,Position", + "Angle_vertex,Direction1,Direction2,Position", + "Object,Position", + "Object,Position", + "Object,Position", + "Object1,Object2,Position", + "Angle_vertex,Direction1,Direction2,Position", + "Object,Position", + "Object,Position", + "Object,Position", + }; + set_mode(ftmp[choix],ffinal[choix],mode[choix],help[choix]); + continue; + } + continue; + } + + if (key==KEY_CTRL_MENU || key==KEY_CTRL_F6 || + (!hp && (key==KEY_CTRL_CATALOG || key==KEY_BOOK))){ + char menu_xmin[32],menu_xmax[32],menu_ymin[32],menu_ymax[32],menu_zmin[32],menu_zmax[32],menu_depth[32]; + Menu smallmenu; + smallmenu.numitems=22; + MenuItem smallmenuitems[smallmenu.numitems]; + smallmenu.items=smallmenuitems; + smallmenu.height=12; + for (;;){ + string s; + s="xmin "+print_DOUBLE_(gr.window_xmin,contextptr); + strcpy(menu_xmin,s.c_str()); + s="xmax "+print_DOUBLE_(gr.window_xmax,contextptr); + strcpy(menu_xmax,s.c_str()); + s="ymin "+print_DOUBLE_(gr.window_ymin,contextptr); + strcpy(menu_ymin,s.c_str()); + s="ymax "+print_DOUBLE_(gr.window_ymax,contextptr); + strcpy(menu_ymax,s.c_str()); + s="zmin 3d "+print_DOUBLE_(gr.window_zmin,contextptr); + strcpy(menu_zmin,s.c_str()); + s="zmax 3d "+print_DOUBLE_(gr.window_zmax,contextptr); + strcpy(menu_zmax,s.c_str()); + s="depth 3d "+print_DOUBLE_(gr.current_depth,contextptr); + strcpy(menu_depth,s.c_str()); + //smallmenu.title = "KhiCAS"; + smallmenuitems[0].text = (char *) ((lang==1)?"Aide":"Help"); +#ifdef NUMWORKS + smallmenuitems[1].text = (char*) ((lang==1)?"Etude courbe (x,n,t)":"Curve study (x,n,t)"); +#else + smallmenuitems[1].text = (char*) ((lang==1)?"Etude courbe (tab)":"Curve study (tab)"); +#endif + smallmenuitems[2].text = (char *) menu_xmin; + smallmenuitems[3].text = (char *) menu_xmax; + smallmenuitems[4].text = (char *) menu_ymin; + smallmenuitems[5].text = (char *) menu_ymax; + smallmenuitems[6].text = (char *) menu_zmin; + smallmenuitems[7].text = (char *) menu_zmax; + smallmenuitems[8].text = (char *) menu_depth; + smallmenuitems[9].text = (char*) (lang==1?"Sauvegarder figure":"Save figure"); + smallmenuitems[10].text = (char*) (lang==1?"Sauvegarder comme":"Save as"); + smallmenuitems[11].text = (char*)((lang==1)?"Quitter":"Quit"); + smallmenuitems[12].text = (char*) "Orthonormalize /"; + smallmenuitems[13].text = (char*) "Autoscale *"; + smallmenuitems[14].text = (char *) ("Zoom in +"); + smallmenuitems[15].text = (char *) ("Zoom out -"); + smallmenuitems[16].text = (char *) ("Y-Zoom out (-)"); + smallmenuitems[17].text = (char*) ((lang==1)?"Voir axes":"Show axes"); + smallmenuitems[17].type = MENUITEM_CHECKBOX; + smallmenuitems[17].value = gr.show_axes; + smallmenuitems[18].text = (char*) ((lang==1)?"Voir tangente (F3)":"Show tangent (F3)"); + smallmenuitems[18].type = MENUITEM_CHECKBOX; + smallmenuitems[18].value = (gr.tracemode & 2)!=0; + smallmenuitems[19].text = (char*) ((lang==1)?"Voir normale (F4)":"Show normal (F4)"); + smallmenuitems[19].type = MENUITEM_CHECKBOX; + smallmenuitems[19].value = (gr.tracemode & 4)!=0; + smallmenuitems[20].text = (char*) ((lang==1)?"Voir cercle (F5)":"Show circle (F5)"); + smallmenuitems[20].type = MENUITEM_CHECKBOX; + smallmenuitems[20].value = (gr.tracemode & 8)!=0; + smallmenuitems[21].text = (char*) ((lang==1)?"Effacer traces geometrie":"Clear geometry traces"); + drawRectangle(0,180,LCD_WIDTH_PX,60,_BLACK); + int sres = doMenu(&smallmenu); + if (sres == MENU_RETURN_EXIT) + break; + if (sres == MENU_RETURN_SELECTION || sres==KEY_CTRL_EXE) { + const char * ptr=0; + string s1; double d; + if (smallmenu.selection==1){ + geohelp(contextptr); continue; + // gr.q=quaternion_double(0,0,0); gr.update(); + } + if (smallmenu.selection==2) + gr.curve_infos(); + if (smallmenu.selection==3){ + d=gr.window_xmin; + if (inputdouble(menu_xmin,d,200,contextptr)){ + gr.window_xmin=d; + gr.update(); + } + } + if (smallmenu.selection==4){ + d=gr.window_xmax; + if (inputdouble(menu_xmax,d,200,contextptr)){ + gr.window_xmax=d; + gr.update(); + } } if (smallmenu.selection==5){ + d=gr.window_ymin; + if (inputdouble(menu_ymin,d,200,contextptr)){ + gr.window_ymin=d; + gr.update(); + } + } + if (smallmenu.selection==6){ + d=gr.window_ymax; + if (inputdouble(menu_ymax,d,200,contextptr)){ + gr.window_ymax=d; + gr.update(); + } + } + if (smallmenu.selection==7){ d=gr.window_zmin; if (inputdouble(menu_zmin,d,200,contextptr)){ gr.window_zmin=d; gr.update(); } } - if (smallmenu.selection==6){ + if (smallmenu.selection==8){ d=gr.window_zmax; if (inputdouble(menu_zmax,d,200,contextptr)){ gr.window_zmax=d; gr.update(); } } - if (smallmenu.selection==7) + if (smallmenu.selection==9){ + d=gr.current_depth; + if (inputdouble(menu_depth,d,200,contextptr)){ + if (d<-1) d=-1; + if (d>1) d=1; + gr.current_depth=d; + gr.update(); + } + } + if (hp && smallmenu.selection==10){ + // save + geosave(hp,contextptr); + continue; + } + if (smallmenu.selection==10 || smallmenu.selection==11){ + // save as + char filename[MAX_FILENAME_SIZE+1]; + if (get_filename(filename,".py") && newgeo(contextptr)==0){ + geoptr->hp->filename=filename; + if (geoptr!=this && !symbolic_instructions.empty()){ + geoptr->symbolic_instructions=symbolic_instructions; + geoptr->hp->elements.clear(); + for (int i=0;ihp->set_string_value(i,symbolic_instructions[i].print(contextptr)); + } + geoloop(geoptr); + return 0; + } + } + } + if (smallmenu.selection==12) + return -4; + if (smallmenu.selection==13) gr.orthonormalize(); - if (smallmenu.selection==8) + if (smallmenu.selection==14) gr.autoscale(); - if (smallmenu.selection==9) + if (smallmenu.selection==15) gr.zoom(0.7); - if (smallmenu.selection==10) + if (smallmenu.selection==16) gr.zoom(1/0.7); - if (smallmenu.selection==11) + if (smallmenu.selection==17) gr.zoomy(1/0.7); - if (smallmenu.selection==12){ - xcas::textArea text; - text.editable=false; - text.clipline=-1; - text.title = (char*)((lang==1)?"Raccourcis clavier 3d":"3d Keyboard shortcuts"); - text.allowF1=false; - text.python=false; - add(&text,lang==1?"haut/bas/droit/gauche: change point de vue\ny^x ou e^x: trace precis\nON/Back: interrompt le trace en cours\n( et ): modifie le rendu des surfaces raides\n0: surfaces cachees ON/OFF\n.: remplissage surface raide ON/OFF\n5 reset view\n7,8,9,1,2,3: deplacement":"up/down/right/left: modify viewpoint\nON/Back: interrupt\ny^x or e^x: precise\n( and ): modify stiff surfaces rendering\n0: hidden surfaces ON/OFF\n.: fill stiff surfacesON/OFF\n5 reset view\n7,8,9,1,2,3: move view"); - int exec=doTextArea(&text,contextptr); - // gr.q=quaternion_double(0,0,0); gr.update(); + if (smallmenu.selection==18) + gr.show_axes=!gr.show_axes; + if (smallmenu.selection==19){ + if (gr.tracemode & 2) + gr.tracemode &= ~2; + else + gr.tracemode |= 2; + gr.tracemode_set(); } - if (smallmenu.selection==13) - gr.show_axes=true; - if (smallmenu.selection==14) - gr.show_axes=false; - if (smallmenu.selection==15) - break; + if (smallmenu.selection==20){ + if (gr.tracemode & 4) + gr.tracemode &= ~4; + else { + gr.tracemode |= 4; + gr.orthonormalize(); + } + gr.tracemode_set(); + } + if (smallmenu.selection==21){ + if (gr.tracemode & 8) + gr.tracemode &= ~8; + else { + gr.tracemode |= 8; + gr.orthonormalize(); + } + gr.tracemode_set(); + } + if (smallmenu.selection==19){ + gr.trace_instructions.clear(); + update_g(); + } + } + } + gr.draw(); + gr.must_redraw=false; + continue; + } + + if (hp && key==KEY_CTRL_OK){ + if (mode==255) + return key; + if (!moving){ + pushed=true; + push_i=current_i; + push_j=current_j; + push_depth = current_depth; + geo_handle(FL_PUSH,KEY_CTRL_OK); + if (moving){ + update_g(); + continue; } } + int res=geo_handle(FL_RELEASE,KEY_CTRL_OK); + pushed=false; + update_g(); + continue; + } + if (hp && key==KEY_CTRL_EXIT && mode!=255){ + if (mode==0){ // restore original value and reeval + geo_handle(FL_RELEASE,KEY_CTRL_EXIT); + // do_handle(symbolic(at_sto,makevecteur(drag_original_value,drag_name))); + if (!pushed) + set_mode(0,0,255,""); + } + else + if (args_tmp.empty()) + set_mode(0,0,255,""); + pushed=false; + moving=moving_frame=false; + args_tmp.clear(); + update_g(); + continue; } -#endif if (key==KEY_CTRL_EXIT || key==KEY_CTRL_OK){ os_hide_graph(); - break; + return key; } if (key==KEY_CHAR_NORMAL || key=='>'){ // shift-+ if (gr.is3d && gr.precision<9) @@ -8790,7 +11411,22 @@ namespace xcas { gr.precision--; } if (key==KEY_CTRL_UP){ - if (gr.is3d){ + if (tracemode && !alph){ + --tracemode_n; + tracemode_set(); + continue; + } + if (hp && mode!=255 && !alph){ + --current_j; + if (current_j<0){ + gr.up((gr.window_ymax-gr.window_ymin)/5); + current_j += LCD_HEIGHT_PX/5; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } + if (gr.is3d && !alph){ int curprec=gr.precision; gr.precision += 2; if (gr.precision>9) gr.precision=9; @@ -8803,7 +11439,7 @@ namespace xcas { gr.q=rotation_2_quaternion_double(0.707,0.707,0,15)*gr.q;// quaternion_double(15,0,0)*gr.q; gr.update_rotation(); gr.draw(); - redraw=gr.solid3d; + gr.must_redraw=gr.solid3d; #ifndef SIMU if (!iskeydown(KEY_CTRL_UP)) break; @@ -8814,13 +11450,43 @@ namespace xcas { gr.precision=curprec; continue; } - gr.up((gr.window_ymax-gr.window_ymin)/5); + gr.up((gr.window_ymax-gr.window_ymin)/16); } if (key==KEY_CTRL_PAGEUP) { - gr.up((gr.window_ymax-gr.window_ymin)/2); + if (tracemode && !alph){ + tracemode_n-=2; + tracemode_set(); + continue; + } + if (hp && mode!=255 && !alph){ + current_j-=LCD_HEIGHT_PX/5;; + if (current_j<0){ + gr.up((gr.window_ymax-gr.window_ymin)/2); + current_j += LCD_HEIGHT_PX/2; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } + gr.up((gr.window_ymax-gr.window_ymin)/4); } if (key==KEY_CTRL_DOWN) { - if (gr.is3d){ + if (tracemode && !alph){ + ++tracemode_n; + tracemode_set(); + continue; + } + if (hp && mode!=255 && !alph){ + ++current_j; + if (current_j>=LCD_HEIGHT_PX-24){ + gr.down((gr.window_ymax-gr.window_ymin)/5); + current_j -= LCD_HEIGHT_PX/5; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } + if (gr.is3d && !alph){ int curprec=gr.precision; gr.precision += 2; if (gr.precision>9) gr.precision=9; @@ -8833,7 +11499,7 @@ namespace xcas { gr.q=rotation_2_quaternion_double(0.707,0.707,0,-15)*gr.q; // quaternion_double(-15,0,0)*gr.q; gr.update_rotation(); gr.draw(); - redraw=gr.solid3d; + gr.must_redraw=gr.solid3d; #ifndef SIMU if (!iskeydown(KEY_CTRL_DOWN)) break; @@ -8844,13 +11510,46 @@ namespace xcas { gr.precision=curprec; continue; } - gr.down((gr.window_ymax-gr.window_ymin)/5); + gr.down((gr.window_ymax-gr.window_ymin)/16); } if (key==KEY_CTRL_PAGEDOWN) { - gr.down((gr.window_ymax-gr.window_ymin)/2); + if (tracemode && !alph){ + tracemode_n+=2; + tracemode_set(); + continue; + } + if (hp && mode!=255 && !alph){ + current_j += LCD_HEIGHT_PX/5; + if (current_j>=LCD_HEIGHT_PX-24){ + gr.down((gr.window_ymax-gr.window_ymin)/2); + current_j -= LCD_HEIGHT_PX/2; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } + gr.down((gr.window_ymax-gr.window_ymin)/4); } if (key==KEY_CTRL_LEFT) { - if (gr.is3d){ + if (tracemode && !alph){ + if (tracemode_i!=int(tracemode_i)) + tracemode_i=std::floor(tracemode_i); + else + --tracemode_i; + tracemode_set(); + continue; + } + if (hp && mode!=255 && !alph){ + --current_i; + if (current_i<0){ + gr.left((gr.window_xmax-gr.window_xmin)/5); + current_i += LCD_WIDTH_PX/5; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } + if (gr.is3d && !alph){ int curprec=gr.precision; gr.precision += 2; if (gr.precision>9) gr.precision=9; @@ -8858,7 +11557,7 @@ namespace xcas { gr.q=quaternion_double(0,15,0)*gr.q; gr.update_rotation(); gr.draw(); - redraw=gr.solid3d; + gr.must_redraw=gr.solid3d; #ifndef SIMU if (!iskeydown(KEY_CTRL_LEFT)) break; @@ -8869,11 +11568,46 @@ namespace xcas { gr.precision=curprec; continue; } - gr.left((gr.window_xmax-gr.window_xmin)/5); + gr.left((gr.window_xmax-gr.window_xmin)/16); + } + if (key==KEY_SHIFT_LEFT) { + if (tracemode && !alph){ + tracemode_i-=5; + tracemode_set(); + continue; + } + if (hp && mode!=255 && !alph){ + current_i -= LCD_WIDTH_PX/5; + if (current_i<0){ + gr.left((gr.window_xmax-gr.window_xmin)/2); + current_i += LCD_WIDTH_PX/2; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } + gr.left((gr.window_xmax-gr.window_xmin)/4); } - if (key==KEY_SHIFT_LEFT) { gr.left((gr.window_xmax-gr.window_xmin)/2); } if (key==KEY_CTRL_RIGHT) { - if (gr.is3d){ + if (tracemode && !alph){ + if (int(tracemode_i)!=tracemode_i) + tracemode_i=std::ceil(tracemode_i); + else + ++tracemode_i; + tracemode_set(); + continue; + } + if (hp && mode!=255 && !alph){ + ++current_i; + if (current_i>=LCD_WIDTH_PX){ + gr.right((gr.window_xmax-gr.window_xmin)/5); + current_i -= LCD_WIDTH_PX/5; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } + if (gr.is3d && !alph){ int curprec=gr.precision; gr.precision += 2; if (gr.precision>9) gr.precision=9; @@ -8881,7 +11615,7 @@ namespace xcas { gr.q=quaternion_double(0,-15,0)*gr.q; gr.update_rotation(); gr.draw(); - redraw=gr.solid3d; + gr.must_redraw=gr.solid3d; #ifndef SIMU if (!iskeydown(KEY_CTRL_RIGHT)) break; @@ -8892,9 +11626,26 @@ namespace xcas { gr.precision=curprec; continue; } - gr.right((gr.window_xmax-gr.window_xmin)/5); + gr.right((gr.window_xmax-gr.window_xmin)/16); + } + if (key==KEY_SHIFT_RIGHT) { + if (tracemode && !alph){ + tracemode_i+=5; + tracemode_set(); + continue; + } + if (hp && mode!=255 && !alph){ + current_i += LCD_WIDTH_PX/5; + if (current_i>=LCD_WIDTH_PX){ + gr.right((gr.window_xmax-gr.window_xmin)/2); + current_i -= LCD_WIDTH_PX/2; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } + gr.right((gr.window_xmax-gr.window_xmin)/4); } - if (key==KEY_SHIFT_RIGHT) { gr.right((gr.window_xmax-gr.window_xmin)/5); } if (key==KEY_CHAR_PLUS) { gr.zoom(0.7); } @@ -8920,6 +11671,14 @@ namespace xcas { if (key==KEY_CHAR_ANS){ gr.show_edges=!gr.show_edges; } + if (key==KEY_CHAR_4){ + if (current_depth>-1) + current_depth-=0.1; + } + if (key==KEY_CHAR_6){ + if (current_depth<1) + current_depth+=0.1; + } if (key==KEY_CHAR_5){ gr.q=quaternion_double(0,0,0); gr.update(); @@ -8955,8 +11714,17 @@ namespace xcas { if (key==KEY_CHAR_RPAR && gr.diffusionz>2) gr.diffusionz--; } - if (key==KEY_CTRL_VARS) { + if (key==KEY_CHAR_SIN) { gr.show_axes=!gr.show_axes; + gr.update(); + gr.draw(); + gr.must_redraw=false; + } + if (key==KEY_CTRL_VARS){ + select_var(contextptr); + gr.update(); + gr.draw(); + gr.must_redraw=false; } } // aborttimer = Timer_Install(0, check_execution_abort, 100); if (aborttimer > 0) { Timer_Start(aborttimer); } @@ -10208,7 +12976,7 @@ namespace xcas { return 0; } if (ispnt(ge)){ - if (displaygraph(ge,contextptr)==KEY_SHUTDOWN) + if (displaygraph(ge,g,contextptr)==KEY_SHUTDOWN) return KEY_SHUTDOWN; // aborttimer = Timer_Install(0, check_execution_abort, 100); if (aborttimer > 0) { Timer_Start(aborttimer); } return 0; @@ -10306,7 +13074,7 @@ namespace xcas { } } - int check_do_graph(giac::gen & ge,int do_logo_graph_eqw,GIAC_CONTEXT) { + int check_do_graph(giac::gen & ge,const gen & gs,int do_logo_graph_eqw,GIAC_CONTEXT) { if (ge.type==giac::_SYMB || (ge.type==giac::_VECT && !ge._VECTptr->empty() && !is_numericv(*ge._VECTptr)) ){ if (islogo(ge)){ if (do_logo_graph_eqw & 4){ @@ -10317,7 +13085,7 @@ namespace xcas { } if (ispnt(ge)){ if (do_logo_graph_eqw & 2){ - if (displaygraph(ge,contextptr)==KEY_SHUTDOWN) + if (displaygraph(ge,gs,contextptr)==KEY_SHUTDOWN) return KEY_SHUTDOWN; } // aborttimer = Timer_Install(0, check_execution_abort, 100); if (aborttimer > 0) { Timer_Start(aborttimer); } @@ -10472,12 +13240,13 @@ namespace xcas { } else { set_abort(); + gen gs=g; g=protecteval(g,1,contextptr); clear_abort(); giac::ctrl_c=false; kbd_interrupted=giac::interrupted=false; // define the function - if (check_do_graph(g,7,contextptr)==KEY_SHUTDOWN) + if (check_do_graph(g,gs,7,contextptr)==KEY_SHUTDOWN) return KEY_SHUTDOWN; DefineStatusMessage((char *)((lang==1)?"Syntaxe correcte":"Parse OK"),1,0,0); } @@ -10490,6 +13259,21 @@ namespace xcas { for (size_t i=1;ielements.size();++i){ edptr->elements[i].newLine=1; } + for (size_t i=0;ielements.size();++i){ + string S=edptr->elements[i].s; + const int cut=160; + if (S.size()>cut){ + // string too long, cut it + int j; + for (j=(4*cut)/5;j>=(2*cut)/5;--j){ + if (!giac::isalphanum(S[j])) + break; + } + textElement elem; elem.newLine=1; elem.s=S.substr(j,S.size()-j); + edptr->elements[i].s=S.substr(0,j); + edptr->elements.insert(edptr->elements.begin()+i+1,elem); + } + } } void fix_mini(textArea * edptr){ @@ -10566,6 +13350,50 @@ namespace xcas { fix_newlines(edptr); } + void textArea::set_string_value(int n,const string & s){ + if (n==-1 || n>=elements.size()){ + textElement t; t.s=s; + if (!elements.empty()) + t.newLine=1; + elements.push_back(t); + } + else { + elements[n].s=s; + if (n) + elements[n].newLine=1; + } + changed=true; + } + + int textArea::add_entry(int n){ + textElement t; + if (n==-1 || n>=elements.size()){ + if (elements.empty()) + elements.push_back(t); + else { + t.newLine=1; + if (!elements.back().s.empty()) + elements.push_back(t); + } + n=elements.size()-1; + } + else { + if (n) t.newLine=1; + elements.insert(elements.begin()+n,t); + } + return n; + } + + void Graph2d::add_entry(int n){ + if (!hp) + return; + if (n==-1 || n>=symbolic_instructions.size()){ + symbolic_instructions.push_back(0); + n=symbolic_instructions.size(); + } + hp->add_entry(n); + } + int find_indentation(const std::string & s){ size_t indent=0; for (;indenteditable; int showtitle = !editable && (text->title != NULL); std::vector & v=text->elements; + if (v.empty()) v.push_back(textElement()); //drawRectangle(text->x, text->y+24, text->width, LCD_HEIGHT_PX-24, COLOR_WHITE); // insure cursor is visible if (editable && !isFirstDraw){ @@ -11178,6 +14007,11 @@ namespace xcas { deltax=27; } } + if (v.empty()){ + textElement cur; + cur.s=""; + v.push_back(cur); + } int & clipline=text->clipline; int & clippos=text->clippos; int & textline=text->line; @@ -11222,6 +14056,8 @@ namespace xcas { waitforvblank(); int textX=text->x,saveY=textY; if(v[cur].newLine) { + if (v[cur].lineSpacing>4) // avoid large skip + v[cur].lineSpacing=4; textY=textY+text->lineHeight+v[cur].lineSpacing; } if (!isFirstDraw && clipline==-1){ @@ -11484,7 +14320,10 @@ namespace xcas { if (editable){ waitforvblank(); drawRectangle(0,205,LCD_WIDTH_PX,17,44444); - PrintMiniMini(0,205,text->python>0?"shift-1 test|2 loop|3 undo|4 misc|5 +-|6 logo|7 lin|8 list|9arit":"shift-1 test|2 loop|3 undo|4 misc|5 +-|6 logo|7 matr|8 cplx",4,44444,giac::_BLACK); + if (text->gr) + PrintMiniMini(0,205,"shift-1 pnts|2 lines|3 undo|4 disp|5 +-|6 curves|7 triangle|8 polygon|9 solid",4,giac::_CYAN,giac::_BLACK); + else + PrintMiniMini(0,205,text->python>0?"shift-1 test|2 loop|3 undo|4 misc|5 +-|6 logo|7 lin|8 list|9arit":"shift-1 test|2 loop|3 undo|4 misc|5 +-|6 logo|7 matr|8 cplx",4,44444,giac::_BLACK); //draw_menu(1); } #ifdef SCROLLBAR @@ -12059,12 +14898,16 @@ namespace xcas { (key >= KEY_CTRL_F6 && key <= KEY_CTRL_F16) ){ string le_menu; - if (xcas_python_eval==1)//text->python? - le_menu="F1 test\nif \nelse \n<\n>\n==\n!=\n&&\n||\nF2 loop\nfor \nfor in\nrange(\nwhile \nbreak\ndef\nreturn \n#\nF4 misc\n:\n;\n_\n!\n%\nfrom import *\nprint(\ninput(\nF6 tortue\nforward(\nbackward(\nleft(\nright(\npencolor(\ncircle(\nreset()\nfrom turtle import *\nF: plot\nplot(\ntext(\narrow(\nlinear_regression_plot(\nscatter(\naxis(\nbar(\nfrom matplotl import *\nF7 linalg\nadd(\nsub(\nmul(\ninv(\ndet(\nrref(\ntranspose(\nfrom linalg import *\nF< color\nred\nblue\ngreen\ncyan\nyellow\nmagenta\nblack\nwhite\nF; draw\nset_pixel(\ndraw_line(\ndraw_rectangle(\nfill_rect(\ndraw_polygon(\ndraw_circle(\ndraw_string(\nfrom graphic import *\nF8 numpy\narray(\nreshape(\narange(\nlinspace(\nsolve(\neig(\ninv(\nfrom numpy import *\nF9 arit\npow(\nisprime(\nnextprime(\nifactor(\ngcd(\nlcm(\niegcd(\nfrom arit import *\n"; - if (xcas_python_eval<=0) - le_menu="F1 test\nif \nelse \n<\n>\n==\n!=\nand\nor\nF2 loop\nfor \nfor in\nrange(\nwhile \nbreak\nf(x):=\nreturn \nvar\nF4 misc\n;\n:\n_\n!\n%\n&\nprint(\ninput(\nF6 tortue\navance\nrecule\ntourne_gauche\ntourne_droite\nrond\ndisque\nrepete\nefface\nF7 lin\nmatrix(\ndet(\nmatpow(\nranm(\nrref(\ntran(\negvl(\negv(\nF9 arit\n mod \nirem(\nifactor(\ngcd(\nisprime(\nnextprime(\npowmod(\niegcd(\nF< plot\nplot(\nplotseq(\nplotlist(\nplotparam(\nplotpolar(\nplotfield(\nhistogram(\nbarplot(\nF: misc\n<\n>\n_\n!\n % \nrand(\nbinomial(\nnormald(\nF8 cplx\nabs(\narg(\nre(\nim(\nconj(\ncsolve(\ncfactor(\ncpartfrac(\n"; - if (xcas_python_eval>=0) - le_menu += "F= list\nmakelist(\nrange(\nseq(\nlen(\nappend(\nranv(\nsort(\napply(\nF; real\nexact(\napprox(\nfloor(\nceil(\nround(\nsign(\nmax(\nmin(\nF> prog\n;\n:\n\\\n&\n?\n!\ndebug(\npython(\nF? geo\npoint(\nline(\nsegment(\ncircle(\ntriangle(\nplane(\nsphere(\nsingle_inter(\nF@ color\ncolor=\nred\ncyan\ngreen\nblue\nmagenta\nyellow\nlegend("; + if (text->gr) { // geometry menu + le_menu="F1 points\npoint(\nmidpoint(\ncenter(\nelement(\nsingle_inter(\ninter(\nlegende(\ntrace(\nF2 lines\nsegment(\nline(\nhalf_line(\nvector(\nparallel(\nperpendicular(\ntangent(\nplane(\ncircle(\nF4 disp\ndisplay=\nfilled\nred\nblue\ngreen\ncyan\nmagenta\nyellow\nF6 curves\ncircle(\nellipse(\nhyperbola(\nparabola(\nplot(\nplotparam(\nplotpolar(\nplotode(\nF7 triangle\ntriangle(\nequilateral_triangle(\nmedian(\nperpen_bisector(\nbisector(\nisobarycenter(\nF8 polygon\nsquare(\nrectangle(\nquadrilateral(\nhexagon(\npolygon(\nisopolygon(\nvertices(\nF9 3d\nplane(\ncube(\ntetrahedron(\nsphere(\ncone(\nhalf_cone(\ncylinder(\nplot3d(\nF: transf\nprojection(\nreflection(\ntranslation(\nrotation(\nhomothety(\nsimilarity(\nF; geodiff\ntangent(\nosculating_circle(\nevolute(\ncurvature(\nfrenet(\noctahedron(\ndodecahedron(\nicosahedron(\nF< mesures\ndistance(\ndistance2(\nradius(\naire(\nperimetre(\npente(\nangle(\nF= test\nis_collinear(\nis_concyclic(\nis_coplanar(\nis_cospherical(\nis_element(\nis_parallel(\nis_perpendicular(\nF> analyt\ncoordonnees(\nequation(\nparameq(\nabscisse(\nordonnee(\naffixe(\narg(\n"; + } else { + if (xcas_python_eval==1)//text->python? + le_menu="F1 test\nif \nelse \n<\n>\n==\n!=\n&&\n||\nF2 loop\nfor \nfor in\nrange(\nwhile \nbreak\ndef\nreturn \n#\nF4 misc\n:\n;\n_\n!\n%\nfrom import *\nprint(\ninput(\nF6 tortue\nforward(\nbackward(\nleft(\nright(\npencolor(\ncircle(\nreset()\nfrom turtle import *\nF: plot\nplot(\ntext(\narrow(\nlinear_regression_plot(\nscatter(\naxis(\nbar(\nfrom matplotl import *\nF7 linalg\nadd(\nsub(\nmul(\ninv(\ndet(\nrref(\ntranspose(\nfrom linalg import *\nF< color\nred\nblue\ngreen\ncyan\nyellow\nmagenta\nblack\nwhite\nF; draw\nset_pixel(\ndraw_line(\ndraw_rectangle(\nfill_rect(\ndraw_polygon(\ndraw_circle(\ndraw_string(\nfrom graphic import *\nF8 numpy\narray(\nreshape(\narange(\nlinspace(\nsolve(\neig(\ninv(\nfrom numpy import *\nF9 arit\npow(\nisprime(\nnextprime(\nifactor(\ngcd(\nlcm(\niegcd(\nfrom arit import *\n"; + if (xcas_python_eval<=0) + le_menu="F1 test\nif \nelse \n<\n>\n==\n!=\nand\nor\nF2 loop\nfor \nfor in\nrange(\nwhile \nbreak\nf(x):=\nreturn \nvar\nF4 misc\n;\n:\n_\n!\n%\n&\nprint(\ninput(\nF6 tortue\navance\nrecule\ntourne_gauche\ntourne_droite\nrond\ndisque\nrepete\nefface\nF7 lin\nmatrix(\ndet(\nmatpow(\nranm(\nrref(\ntran(\negvl(\negv(\nF9 arit\n mod \nirem(\nifactor(\ngcd(\nisprime(\nnextprime(\npowmod(\niegcd(\nF< plot\nplot(\nplotseq(\nplotlist(\nplotparam(\nplotpolar(\nplotfield(\nhistogram(\nbarplot(\nF: misc\n<\n>\n_\n!\n % \nrand(\nbinomial(\nnormald(\nF8 cplx\nabs(\narg(\nre(\nim(\nconj(\ncsolve(\ncfactor(\ncpartfrac(\n"; + if (xcas_python_eval>=0) + le_menu += "F= list\nmakelist(\nrange(\nseq(\nlen(\nappend(\nranv(\nsort(\napply(\nF; real\nexact(\napprox(\nfloor(\nceil(\nround(\nsign(\nmax(\nmin(\nF> prog\n;\n:\n\\\n&\n?\n!\ndebug(\npython(\nF? geo\npoint(\nline(\nsegment(\ncircle(\ntriangle(\nplane(\nsphere(\nsingle_inter(\nF@ color\ncolor=\nred\ncyan\ngreen\nblue\nmagenta\nyellow\nlegend("; + } // else not geometry const char * ptr=console_menu(key,(char*)(le_menu.c_str()),2); if (!ptr){ show_status(text,search,replace); @@ -12190,7 +15033,7 @@ namespace xcas { } continue; case KEY_CTRL_OK: - if (text->allowEXE || !text->editable) return TEXTAREA_RETURN_EXE; + if (text->gr || text->allowEXE || !text->editable) return TEXTAREA_RETURN_EXE; if (search.size()){ for (;;){ if (!move_to_word(text,search,replace,isFirstDraw,totalTextY,scroll,textY,contextptr)) @@ -12948,6 +15791,10 @@ namespace xcas { smallmenuitems[10].text = (char*) ((lang==1)?"Backup, mode examen (e^x)":"Backup, exam mode (e^x)"); #else smallmenuitems[10].text = (char*) ((lang==1)?"Mode examen (e^x)":"Exam mode (e^x)"); + if (osok==0) + smallmenuitems[10].text = (char*) ((lang==1)?"Incompatible mode examen":"Exam mode incompatible"); + if (osok==-1) + smallmenuitems[10].text = (char*) ((lang==1)?"Avertissement mode examen":"Exam mode warning"); #endif smallmenuitems[11].text = (char*) ((lang==1)?"A propos":"About"); smallmenuitems[14].text = (char*) "Quit"; @@ -13053,12 +15900,20 @@ namespace xcas { giac::language(lang,contextptr); break; } - if (smallmenu.selection == 11){ + if (smallmenu.selection==11 && osok==-1){ + confirm(lang==1?"Activez une fois le mode examen TI":"Activate one time TI exam mode",lang==1?"pour utiliser ensuite celui de KhiCAS":"to enable KhiCAS exam mode"); + continue; + } + if (smallmenu.selection==11 && osok==0){ + confirm(lang==1?"Ce modele n'est pas compatible":"This model is not compatible",lang==1?"avec le mode examen de KhiCAS":"with KhiCAS exam mode"); + continue; + } + if (smallmenu.selection == 11 && osok>0){ #ifdef NSPIRE_NEWLIB if (nspire_exam_mode==1 - && !is_cx2 + // && !is_cx2 ){ - if (confirm((lang==1?"Quitter Xcas pour relancer le mode examen":"Leave Xcas to re-enter exam mode"),(lang==1?"!enter OK, esc annul":"enter OK, esc cancel."))!=KEY_CTRL_F1) + if (confirm((lang==1?"Pour relancer le mode examen, il faudra":"To re-enter exam mode, you'll have"),(lang==1?"quitter Xcas. enter OK, esc annul":"to quit Xcas. enter OK, esc cancel."))!=KEY_CTRL_F1) break; do_restart(contextptr); clear_turtle_history(contextptr); @@ -13075,7 +15930,7 @@ namespace xcas { break; } else { - if (//1 || + if (osok>0 || !is_cx2){ if (do_confirm((lang==1)?"Lancer le mode examen avec CAS ?":"Run exam mode with CAS?")){ *logptr(contextptr) << (lang==1?"Patientez environ 2 minutes\n":"Please wait about 2 minutes\n"); @@ -13397,7 +16252,7 @@ namespace xcas { vout.erase(vout.begin()); vout.push_back(ge); } - if (check_do_graph(ge,do_logo_graph_eqw,contextptr)==KEY_SHUTDOWN) + if (check_do_graph(ge,g,do_logo_graph_eqw,contextptr)==KEY_SHUTDOWN) return KEY_SHUTDOWN; string s_; if (ge.type==giac::_STRNG) @@ -13442,6 +16297,8 @@ namespace xcas { } Line[Last_Line].str=0; Last_Line=start; + if (startLINE_DISP_MAX?Last_Line-LINE_DISP_MAX:0; Cursor.x=0; @@ -13455,19 +16312,32 @@ namespace xcas { //int j=Last_Line; Console_NewLine(LINE_TYPE_INPUT, 1); // Line[j].type=LINE_TYPE_INPUT; + Console_Disp(1,contextptr); + Bdisp_PutDisp_DD(); run(v[i].c_str(),6,contextptr); /* show logo and graph but not eqw */ // j=Last_Line; Console_NewLine(LINE_TYPE_OUTPUT, 1); // Line[j].type=LINE_TYPE_OUTPUT; - Console_Disp(1,contextptr); - Bdisp_PutDisp_DD(); } + int cl=Current_Line; Cursor.y += (Start_Line-savestartline); + if (Cursor.y<0) Cursor.y=0; Start_Line=savestartline; + if (Current_Line>cl || Cursor.y>10){ + if (cl>10){ + Start_Line=cl-10; + Cursor.y=10; + } + else { + Start_Line=0; + Cursor.y=cl; + } + } + Console_Disp(1,contextptr); + Bdisp_PutDisp_DD(); return 0; } - string khicas_state(GIAC_CONTEXT){ giac::gen g(giac::_VARS(-1,contextptr)); int b=python_compat(contextptr); @@ -14564,7 +17434,7 @@ namespace xcas { numworks_certify_internal(); Bdisp_AllClr_VRAM(); int x=0,y=0; - PrintMini(x,y,"KhiCAS 1.7 (c) 2022 B. Parisse",TEXT_MODE_NORMAL, COLOR_BLACK, COLOR_WHITE); + PrintMini(x,y,"KhiCAS 1.9 (c) 2022 B. Parisse",TEXT_MODE_NORMAL, COLOR_BLACK, COLOR_WHITE); y +=18; PrintMini(x,y,"et al, License GPL 2",TEXT_MODE_NORMAL,COLOR_BLACK, COLOR_WHITE); y += 18; @@ -15140,7 +18010,11 @@ namespace xcas { // smallmenuitems[2].text = (char*)(isRecording ? "Stop Recording" : "Record Script"); while(1) { // moved inside the loop because lang might change +#ifdef NUMWORKS smallmenuitems[0].text = (char*)"Applications (shift ANS)"; +#else + smallmenuitems[0].text = (char*)"Applications (shift doc)"; +#endif string sess=(lang==1)?"Enregistrer ":"Save "; sess += session_filename; smallmenuitems[1].text = (char *) (sess.c_str()); @@ -15350,80 +18224,10 @@ namespace xcas { break; } if (smallmenu.selection == 15){ - Menu paramenu; - paramenu.numitems=6; - MenuItem paramenuitems[paramenu.numitems]; - paramenu.items=paramenuitems; - paramenu.height=12; - paramenu.title = (char *)"Parameter"; - char menu_xcur[32],menu_xmin[32],menu_xmax[32],menu_xstep[32],menu_name[16]="name a"; static char curname='a'; - menu_name[5]=curname; - ++curname; - double pcur=0,pmin=-5,pmax=5,pstep=0.1; - std::string s; - bool doit; - for (;;){ - s="cur "+giac::print_DOUBLE_(pcur,contextptr); - strcpy(menu_xcur,s.c_str()); - s="min "+giac::print_DOUBLE_(pmin,contextptr); - strcpy(menu_xmin,s.c_str()); - s="max "+giac::print_DOUBLE_(pmax,contextptr); - strcpy(menu_xmax,s.c_str()); - s="step "+giac::print_DOUBLE_(pstep,contextptr); - strcpy(menu_xstep,s.c_str()); - paramenuitems[0].text = (char *) "OK"; - paramenuitems[1].text = (char *) menu_name; - paramenuitems[2].text = (char *) menu_xcur; - paramenuitems[3].text = (char *) menu_xmin; - paramenuitems[4].text = (char *) menu_xmax; - paramenuitems[5].text = (char *) menu_xstep; - int sres = doMenu(¶menu); - doit = sres==MENU_RETURN_SELECTION || sres==KEY_CTRL_EXE; - if (doit) { - std::string s1; double d; - if (paramenu.selection==2){ - handle_f5(); - if (inputline(menu_name,(lang==1)?"Nouvelle valeur?":"New value?",s1,false)==KEY_CTRL_EXE && s1.size()>0 && isalpha(s1[0])){ - if (s1.size()>10) - s1=s1.substr(0,10); - strcpy(menu_name,("name "+s1).c_str()); - } - continue; - } - if (paramenu.selection==3){ - inputdouble(menu_xcur,pcur,contextptr); - continue; - } - if (paramenu.selection==4){ - inputdouble(menu_xmin,pmin,contextptr); - continue; - } - if (paramenu.selection==5){ - inputdouble(menu_xmax,pmax,contextptr); - continue; - } - if (paramenu.selection==6){ - inputdouble(menu_xstep,pstep,contextptr); - pstep=fabs(pstep); - continue; - } - // if (paramenu.selection==6) break; - } // end menu - break; - } // end for (;;) - if (doit && pmin0){ - s="assume("; - s += (menu_name+5); - s += "=["; - s += (menu_xcur+4); - s += ','; - s += (menu_xmin+4); - s += ','; - s += (menu_xmax+4); - s += ','; - s += (menu_xstep+5); - s += "])"; + string s=inputparam(curname,1,contextptr); + if (!s.empty()){ + ++curname; return Console_Input((const char *)s.c_str()); } continue; @@ -15444,7 +18248,7 @@ namespace xcas { return CONSOLE_SUCCEEDED; #endif } - if (key==KEY_SHIFT_ANS){ // 3rd party app + if (key==KEY_SHIFT_ANS || key==KEY_CTRL_SD){ // 3rd party app int res=khicas_addins_menu(contextptr); if (res==KEY_CTRL_MENU) return res; @@ -16360,6 +19164,123 @@ namespace xcas { } #endif + Graph2d * geoptr=0; + + // return true if there is a syntax error and user asked to correct + bool geoparse(textArea *text,GIAC_CONTEXT){ + Graph2d * geoptr=text->gr; + if (!geoptr) + return false; + std::vector & v=text->elements; + geoptr->symbolic_instructions.resize(v.size()); + int pos=-1,i=0; + for (;isymbolic_instructions[i]=g; + if (lineerr){ + std::string tok=giac::error_token_name(contextptr); + if (lineerr==1){ + pos=v[i].s.find(tok); + const std::string & err=v[i].s; + if (pos>=err.size()) + pos=-1; + } + else { + tok=(lang==1)?"la fin":"end"; + pos=0; + } + if (pos>=0) + sprintf(status,(lang==1)?"Erreur ligne %i a %s":"Error line %i at %s",i+1,tok.c_str()); + else + sprintf(status,(lang==1)?"Erreur ligne %i %s":"Error line %i %s",i+1,(pos==-2?((lang==1)?", : manquant ?":", missing :?"):"")); + if (confirm(status,(lang==1)?"OK: corrige, back: continue":"OK: fix",1)==KEY_CTRL_F1){ + text->line=i; + if (pos>=0 && pospos=pos; + return true; + } + } + } // loop on lines + return false; + } + + int geoloop(Graph2d * geoptr){ + if (!geoptr || !geoptr->hp) return -1; + const context * contextptr=geoptr->contextptr; + textArea * text=geoptr->hp; + // main loop: alternate between plot and symb view + // start in plot view + // end plot view with EXIT or OK -> symb view editor + // end with OK or EXIT: OK will modify, EXIT will leave geo app + // (press twice EXIT to leave geo app from plot view) + for (;;){ + geoptr->eval(); + geoptr->update(); + if (geoptr->is3d) + geoptr->update_rotation(); + int key=geoptr->ui(); + if (key==KEY_SHUTDOWN){ + geosave(text,contextptr); + return key; + } + // symb view editor + for (;;){ + key=doTextArea(text,contextptr); + if (key== TEXTAREA_RETURN_EXIT || key==KEY_SHUTDOWN){ + geosave(text,contextptr); + return key; + } + // key was OK, parse step: synchronize symbolic_instructions from text + bool corrige=geoparse(text,contextptr); + if (!corrige) + break; + } // end edition loop + } // end plot/symb view infinite loop + } + + void cleargeo(){ + if (!geoptr) + return; + if (geoptr->hp) + delete geoptr->hp; + delete geoptr; + geoptr=0; + } + + int newgeo(GIAC_CONTEXT){ + if (!geoptr){ + geoptr=new Graph2d(0,contextptr); + geoptr->window_xmin=-5; + geoptr->window_ymin=-5; + geoptr->window_zmin=-5; + geoptr->window_xmax=5; + geoptr->window_ymax=5; + geoptr->window_zmax=5; + geoptr->orthonormalize(); + } + if (!geoptr) + return -1; + if (!geoptr->hp){ + geoptr->hp=new textArea; + geoptr->hp->filename="figure0.py"; + geoptr->hp->python=0; + } + if (!geoptr->hp) + return -2; + textArea * text=geoptr->hp; + text->editable=true; + text->clipline=-1; + text->gr=geoptr; + geoptr->set_mode(0,0,255,""); // start in frame mode + return 0; + } + tableur * sheetptr=0; string print_tableur(const tableur & t,GIAC_CONTEXT){ @@ -16372,6 +19293,11 @@ namespace xcas { vecteur & v=*g._VECTptr; for (int j=0;jsize()==3){ + vecteur vjv=*vj._VECTptr; + vjv[1]=0; + vj=gen(vjv,vj.subtype); + } printcell_current_col(contextptr)=j; s += vj.print(contextptr); if (j==t.ncols-1) @@ -16430,6 +19356,38 @@ namespace xcas { sheetptr=0; shutdown=do_shutdown; #ifdef NSPIRE_NEWLIB + unsigned osid=0,osidcx52noncasnont=0x1040E4D0; + osid=* (unsigned *) 0x10000020; + // values + // OS 5.2 cxcas 1040f3b0 + // OS 5.2 cx2 0x1040E4D0 + // OS 5.2 cx2t 0x1040EAE0 + // OS 5.3 cx2cas 10417da0 + // OS 5.3 cx2 10416cc0 + // OS 5.3 cx2t 10417460 + osok=osid!=osidcx52noncasnont?1:0; + if ((osid & 0xffff0000)==0x10410000){ + confirm("KhiCAS exammode is incompatible with OS 5.3","Downgrade to 5.2 with backSpire"); + } +#if 0 + if (osok && is_cx2){ + int N=0x800; + long int nand_offset = 5*64*N; + long int nand_size = 64*N; + char flashdata[N]; + const char erased_char=(char) 255; + int i; + for(i=0; i5) row=0; + // display table + drawRectangle(0,0,LCD_WIDTH_PX,LCD_HEIGHT_PX,_WHITE); + os_draw_string(0,0,_BLACK,_WHITE,lang==1?"Selectionner caractere":"Select char"); + for (int r=0;r<6;++r){ + for (int c=0;c<16;++c){ + char buf[2]={char(32+16*r+c),0}; + os_draw_string(20*c,20+20*r,_BLACK,(r==row && c==col?color_gris:_WHITE),buf); + } + } + string s("Current "); + int cur=32+16*row+col; + s += char(cur); + s += " "; + s += print_INT_(cur); + s += " "; + s += hexa_print_INT_(cur); + os_draw_string(0,160,_BLACK,_WHITE,s.c_str()); + os_draw_string(0,180,_BLACK,_WHITE,lang==1?"EXE: copier caractere":"EXE: copy char"); + // interaction + int key=getkey(1); + if (key==KEY_CTRL_EXIT) + return -1; + if (key==KEY_CTRL_OK || key==KEY_CTRL_EXE) + return cur; + if (key==KEY_CTRL_LEFT) + --col; + if (key==KEY_CTRL_RIGHT) + ++col; + if (key==KEY_CTRL_UP) + --row; + if (key==KEY_CTRL_DOWN) + ++row; + } + } + void delete_clipboard(){} bool clip_pasted=true; @@ -422,17 +462,15 @@ namespace giac { menuitem[0]='0'+cur; menuitem[1]=' '; menuitem[2]=0; - strcpy(menuitem+2,menu->items[curitem].text); } else { menuitem[0]=cur>=10?('0'+(cur/10)):' '; menuitem[1]='0'+(cur%10); menuitem[2]=' '; menuitem[3]=0; - strcpy(menuitem+3,menu->items[curitem].text); } } - //strncat(menuitem, menu->items[curitem].text, 68); + strncat(menuitem, menu->items[curitem].text, 250); if(menu->items[curitem].type != MENUITEM_SEPARATOR) { //make sure we have a string big enough to have background when item is selected: // MB_ElementCount is used instead of strlen because multibyte chars count as two with strlen, while graphically they are just one char, making fillerRequired become wrong @@ -943,6 +981,7 @@ namespace giac { {"csolve(equation,x)", 0, "Resolution exacte dans C d'une equation en x (ou d'un systeme polynomial).","x^2+x+1=0", 0, CAT_CATEGORY_SOLVE | (CAT_CATEGORY_COMPLEXNUM << 8) | XCAS_ONLY}, {"cube(A,B,C)", 0, "Cube d'arete AB avec une face dans le plan ABC", "[0,0,0],[1,0,0],[0,1,0]","[0,0,0],[0,2,sqrt(5)/2+3/2],[0,0,1]", CAT_CATEGORY_3D}, {"curl(u,vars)", 0, "Rotationnel du vecteur u.", "[2*x*y,x*z,y*z],[x,y,z]", 0, CAT_CATEGORY_LINALG | XCAS_ONLY}, + {"curvature([x(t),y(t)],t,t0)", 0, "Courbure de la courbe parametree [x(t),y(t)] en t0", "[t,t^2],t,1", "[t,t^2],t", CAT_CATEGORY_CALCULUS | (CAT_CATEGORY_2D << 8) | XCAS_ONLY}, {"cyan", "cyan", "Option d'affichage", "#display=cyan", 0, CAT_CATEGORY_PROGCMD}, {"cylinder(A,v,r,[h])", 0, "Cylindre d'axe A,v de rayon r et de hauteur optionnelle h", "[0,0,0],[0,1,0],2", "[0,0,0],[0,1,0],2,3", CAT_CATEGORY_3D}, {"debug(f(args))", 0, "Execute la fonction f en mode pas a pas.", 0, 0, CAT_CATEGORY_PROG | XCAS_ONLY}, @@ -989,6 +1028,7 @@ namespace giac { {"float(x)", 0, "Convertit x en nombre approche (flottant).", "pi", 0, CAT_CATEGORY_REAL}, {"floor(x)", 0, "Partie entiere de x", "pi", 0, CAT_CATEGORY_REAL}, {"fonction f(x)", "fonction", "Definition de fonction (Xcas). Par exemple\nfonction f(x)\n local y;\ny:=x*x;\nreturn y;\nffonction", 0, 0, CAT_CATEGORY_PROG | XCAS_ONLY}, + {"frenet([x(t),y(t)],t,t0)", 0, "Courbure, centre de courbure et repere de Frenet de la courbe parametree [x(t),y(t)] en t0", "[t,t^2],t,1", "[t,t^2],t", CAT_CATEGORY_CALCULUS | (CAT_CATEGORY_2D << 8) | XCAS_ONLY}, {"from arit import *", "from arit import *", "Instruction pour utiliser les fonctions d'arithmetique entiere en Python", "#from arit import *", "#import arit", CAT_CATEGORY_ARIT}, {"from cas import *", "from cas import *", "Permet d'utiliser le calcul formel depuis Python", "#from cas import *", "#import cas", CAT_CATEGORY_ALGEBRA|(CAT_CATEGORY_CALCULUS<<8)}, {"from cmath import *", "from cmath import *", "Instruction pour utiliser les fonctions de maths sur les complexes (trigo, exponentielle, log, ...) en Python", "#from cmath import *;i=1j", "#import cmath", CAT_CATEGORY_COMPLEXNUM}, @@ -1032,6 +1072,11 @@ namespace giac { {"iquo(a,b)", 0, "Quotient euclidien de deux entiers.", "23,13", 0, CAT_CATEGORY_ARIT | XCAS_ONLY}, {"irem(a,b)", 0,"Reste euclidien de deux entiers", "23,13", 0, CAT_CATEGORY_ARIT | XCAS_ONLY}, {"isprime(n)", 0, "Renvoie 1 si n est premier, 0 sinon.", "11", "10", CAT_CATEGORY_ARIT}, + {"is_collinear(A,B,C)", 0, "Renvoie 1 ou 2 si A, B, C sont alignes, 0 sinon.", "1,i,-1", "i,0,-i", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_concyclic(A,B,C,D)", 0, "Renvoie 1 si A, B, C, D sont cocyliques, 0 sinon.", "1,i,-1,-i", "1,i,0,-i", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_element(A,G)", 0, "Renvoie 1 si A appartient a G, 0 sinon.", "point(0),circle(0,1)", "point(i),square(0,1)", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_parallel(D,E)", 0, "Renvoie 1 si D et E sont paralleles, 0 sinon.", "line(y=x),line(y=-x)", "line(y=x),line(y=x+1)", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_perpendicular(D,E)", 0, "Renvoie 1 si D et E sont perpendiculaires, 0 sinon.", "line(y=x),line(y=-x)", "line(y=x),line(y=x+1)", CAT_CATEGORY_2D | XCAS_ONLY }, {"jordan(A)", 0, "Forme normale de Jordan de la matrice A, renvoie P et D tels que P^-1*A*P=D", "[[1,2],[3,4]]", "[[1,1,-1,2,-1],[2,0,1,-4,-1],[0,1,1,1,1],[0,1,2,0,1],[0,0,-3,3,-1]]", CAT_CATEGORY_MATRIX | XCAS_ONLY}, {"laguerre(n,a,x)", 0, "n-ieme polynome de Laguerre (a=0 par defaut).", "10", 0, CAT_CATEGORY_POLYNOMIAL | XCAS_ONLY}, {"laplace(f,x,s)", 0, "Transformee de Laplace de f","sin(x),x,s", 0, CAT_CATEGORY_CALCULUS | XCAS_ONLY}, @@ -1070,6 +1115,7 @@ namespace giac { {"numer(x)", 0, "Numerateur de x.", "3/4", 0, CAT_CATEGORY_POLYNOMIAL | XCAS_ONLY}, {"octahedron(A,B,C)", 0, "Octaedre d'arete AB avec une face dans le plan ABC", "[0,0,0],[3,0,0],[0,1,0]", 0, CAT_CATEGORY_3D}, {"odesolve(f(t,y),[t,y],[t0,y0],t1)", 0, "Solution approchee d'equation differentielle y'=f(t,y) et y(t0)=y0, valeur en t1 (ajouter curve pour les valeurs intermediaires de y)", "sin(t*y),[t,y],[0,1],2", "0..pi,(t,v)->{[-v[1],v[0]]},[0,1]", CAT_CATEGORY_SOLVE | XCAS_ONLY}, + {"osculating_circle([x(t),y(t)],t,t0)", 0, "Cercle osculateur de la courbe parametree [x(t),y(t)] en t0", "[t,t^2],t,1", "[t,t^2],t", CAT_CATEGORY_CALCULUS | (CAT_CATEGORY_2D << 8) | XCAS_ONLY}, {"parabole(F,A)", 0, "Parabole donnee par foyer et sommet", "-2-i,2+i", 0, CAT_CATEGORY_2D}, {"parameq(objet)", 0, "Equations parametriques. Utiliser equation pour une equation cartesienne", "circle(0,1)", "ellipse(-1,1,3)", CAT_CATEGORY_2D | (CAT_CATEGORY_3D << 8) }, {"partfrac(p,x)", 0, "Decomposition en elements simples. Raccourci p=>+", "1/(x^4-1)", 0, CAT_CATEGORY_ALGEBRA | XCAS_ONLY}, @@ -1421,6 +1467,11 @@ const catalogFunc completeCaten[] = { // list of all functions (including some n {"iquo(a,b)", 0, "Integer quotient of a and b.", "23,13", 0, CAT_CATEGORY_ARIT}, {"irem(a,b)", 0,"Integer remainder of a and b.", "23,13", 0, CAT_CATEGORY_ARIT}, {"isprime(n)", 0, "Returns 1 if n is prime, 0 otherwise.", "11", "10", CAT_CATEGORY_ARIT}, + {"is_collinear(A,B,C)", 0, "Returns 1 if A, B, C are collinear, 0 otherwise", "1,i,-1", "i,0,-i", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_concyclic(A,B,C,D)", 0, "Returns 1 if A, B, C, D are concyclic, 0 otherwise", "1,i,-1,-i", "1,i,0,-i", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_element(A,G)", 0, "Returns 1 if A belongs to G, 0 otherwise.", "point(0),circle(0,1)", "point(i),square(0,1)", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_parallel(D,E)", 0, "Returns 1 if D and E are parallel, 0 otherwise", "line(y=x),line(y=-x)", "line(y=x),line(y=x+1)", CAT_CATEGORY_2D | XCAS_ONLY }, + {"is_perpendicular(D,E)", 0, "Returns 1 if D and E are perpendicular, 0 otherwise", "line(y=x),line(y=-x)", "line(y=x),line(y=x+1)", CAT_CATEGORY_2D | XCAS_ONLY }, {"jordan(A)", 0, "Jordan normal form of matrix A, returns P and D such that P^-1*A*P=D", "[[1,2],[3,4]]", "[[1,1,-1,2,-1],[2,0,1,-4,-1],[0,1,1,1,1],[0,1,2,0,1],[0,0,-3,3,-1]]", CAT_CATEGORY_MATRIX}, {"laguerre(n,a,x)", 0, "n-ieme Laguerre polynomial (default a=0).", "10", 0, CAT_CATEGORY_POLYNOMIAL}, {"laplace(f,x,s)", 0, "Laplace transform of f","sin(x),x,s", 0, CAT_CATEGORY_CALCULUS}, @@ -2227,6 +2278,109 @@ const catalogFunc completeCaten[] = { // list of all functions (including some n return i; } + // geo_print / geoprint + std::string _pnt2string(const giac::gen & g,const giac::context * contextptr){ + unsigned ta=taille(g,100); + if (ta>100) + return "Done"; + if (g.is_symb_of_sommet(giac::at_pnt)){ + giac::gen & f=g._SYMBptr->feuille; + giac::gen fp=remove_at_pnt(g); + if (fp.is_symb_of_sommet(giac::at_hyperplan)){ + return gettext("plan")+string("(")+_equation(g,contextptr).print(contextptr)+string(")"); + } + if (f.type==giac::_VECT && !f._VECTptr->empty()){ + giac::gen f0=f._VECTptr->front(); + if (f0.is_symb_of_sommet(giac::at_legende)){ + return g.print(contextptr); + } + if (f0.is_symb_of_sommet(giac::at_curve)){ + giac::gen f1=f[0]._SYMBptr->feuille; + if (f1.type==giac::_VECT && !f1._VECTptr->empty() ){ + giac::gen f1f=f1._VECTptr->front(); + if (f1f.type==giac::_VECT && f1f._VECTptr->size()>=4){ + giac::vecteur f1v=*f1f._VECTptr; + return "plotparam("+_pnt2string(f1v[0],contextptr)+","+f1v[1].print(contextptr)+"="+f1v[2].print(contextptr)+".."+f1v[3].print(contextptr)+")"; + } + } + } + if (f0.is_symb_of_sommet(giac::at_cercle) && f0._SYMBptr->feuille.type==giac::_VECT){ + if (f0._SYMBptr->feuille._VECTptr->size()==3 && ((*f0._SYMBptr->feuille._VECTptr)[2]!=giac::cst_two_pi || (*f0._SYMBptr->feuille._VECTptr)[1]!=0)) + return f0.print(contextptr); + giac::gen centre,rayon; + if (!giac::centre_rayon(f0,centre,rayon,true,0)) + return "cercle_error"; + if (!complex_mode(contextptr) && (centre.typebegin(),itend=f0._VECTptr->end(); + if ( itend-it==2){ + switch(f0.subtype){ + case giac::_LINE__VECT: + s=gettext("line")+string("("); + break; + case giac::_HALFLINE__VECT: + s=gettext("half_line")+string("("); + break; + case giac::_GROUP__VECT: + s=gettext("segment")+string("("); + break; + } + if (f0.subtype==giac::_LINE__VECT && it->type!=giac::_VECT){ // 2-d line + s += _equation(g,contextptr).print(contextptr) + ")"; + return s; + } + } + for (;it!=itend;){ + s += "point("; + if (!complex_mode(contextptr) && (it->typetype==giac::_FRAC) ) + s += giac::re(*it,contextptr).print(contextptr)+","+giac::im(*it,contextptr).print(contextptr); + else { + gen f=*it; + if (f.type==_VECT && f.subtype==_POINT__VECT) + f.subtype=_SEQ__VECT; + s += f.print(contextptr); + } + s+=")"; + ++it; + s += it==itend?")":","; + } + return s; + } + if ( (f0.type!=giac::_FRAC && f0.type>=giac::_IDNT) || is3d(g) || complex_mode(contextptr)){ + if (f0.type==_VECT && f0.subtype==_POINT__VECT) + f0.subtype=_SEQ__VECT; + return "point("+f0.print(contextptr)+")"; + } + else + return "point("+giac::re(f0,contextptr).print(contextptr)+","+giac::im(f0,contextptr).print(contextptr)+")"; + } + } + if (g.type==giac::_VECT && !g._VECTptr->empty() && g._VECTptr->back().is_symb_of_sommet(giac::at_pnt)){ + std::string s = "["; + giac::const_iterateur it=g._VECTptr->begin(),itend=g._VECTptr->end(); + for (;it!=itend;){ + s += _pnt2string(*it,contextptr); + ++it; + s += it==itend?"]":","; + } + return s; + } + return g.print(contextptr); + } + + std::string pnt2string(const giac::gen & g,const giac::context * contextptr){ + int p=python_compat(contextptr); + python_compat(0,contextptr); + string s=_pnt2string(g,contextptr); + python_compat(p,contextptr); + return s; + } + gen select_var(GIAC_CONTEXT){ kbd_interrupted=giac::ctrl_c=giac::interrupted=false; #ifdef QUICKJS @@ -2300,8 +2454,8 @@ const catalogFunc completeCaten[] = { // list of all functions (including some n vector vi(9); tailles(w,vi); total += vi[8]; - if (vi[8]<400) - vs[i]+=":="+w.print(contextptr); + if (vi[8]=0) os_set_pixel(ih,z,color); @@ -5411,14 +5569,12 @@ namespace xcas { } if (z>=*zmax){ // mark only 1 point color=downcolor; - // drawRectangle(ih,*zmax,1,z-*zmax,color); - // drawRectangle(ih,*zmax,1,z-*zmax,_BLACK); + drawRectangle(ih,*zmax+1,1,z-*zmax-1,_BLACK); *zmax=z; } if (z<=*zmin){ // mark 1 point color=upcolor; - //drawRectangle(ih,z,1,*zmin-z,color); - //drawRectangle(ih,z,1,*zmin-z,_BLACK); + // drawRectangle(ih,z+1,1,*zmin-z-1,_BLACK); *zmin=z; } if (color>=0) os_set_pixel(ih,z,color); @@ -5666,30 +5822,21 @@ namespace xcas { double & cura1,double & curb1,double & curc1,double & curz1, double & cura2,double & curb2,double & curc2,double & curz2, int & u,int & d,int & du,int & dd){ - if (found){ - if (zcurz1){ + if (found){ // update cur2 found2=true; - cura2=a; curb2=b; curc2=c; curz2=z; - du=downupcolor; dd=downdowncolor; - return; - } - else { // need to update cur, and perhaps cur2 - if (!found2 || curz1curz2){ + found2=true; + cura2=a; curb2=b; curc2=c; curz2=z; + du=downupcolor; dd=downdowncolor; } - found=true; - cura1=a; curb1=b; curc1=c; curz1=z; - u=upcolor; d=downcolor; } @@ -5789,10 +5936,139 @@ namespace xcas { double y=m.y+t*v.y; double z=m.z+t*v.z; gr.XYZ2ij(double3(x,y,z),i,j); - } + } + + const int4 tabcolorcplx[]={ +{63488,47104,30720,14336}, +{63489,47105,30720,14336}, +{63491,47106,30721,14336}, +{63492,47107,30722,14337}, +{63494,47108,30723,14337}, +{63495,47109,30723,14337}, +{63497,47110,30724,14338}, +{63498,47111,30725,14338}, +{63500,47113,30726,14339}, +{63501,47114,30726,14339}, +{63503,47115,30727,14339}, +{63504,47116,30728,14340}, +{63506,47117,30729,14340}, +{63507,47118,30729,14340}, +{63509,47119,30730,14341}, +{63510,47120,30731,14341}, +{63512,47122,30732,14342}, +{63513,47123,30732,14342}, +{63515,47124,30733,14342}, +{63516,47125,30734,14343}, +{63518,47126,30735,14343}, +{63519,47127,30735,14343}, +{59423,45079,28687,14343}, +{57375,43031,28687,14343}, +{53279,40983,26639,12295}, +{51231,38935,24591,12295}, +{47135,34839,22543,10247}, +{45087,32791,22543,10247}, +{40991,30743,20495,10247}, +{38943,28695,18447,8199}, +{34847,26647,16399,8199}, +{32799,24599,16399,8199}, +{28703,22551,14351,6151}, +{26655,20503,12303,6151}, +{22559,16407,10255,4103}, +{20511,14359,10255,4103}, +{16415,12311,8207,4103}, +{14367,10263,6159,2055}, +{10271,8215,4111,2055}, +{8223,6167,4111,2055}, +{4127,4119,2063,7}, +{2079,2071,15,7}, +{2079,2071,2063,2055}, +{2175,2135,2095,2055}, +{2271,2199,2159,2087}, +{2367,2263,2191,2119}, +{2463,2359,2255,2151}, +{2559,2423,2287,2151}, +{2655,2487,2351,2183}, +{2751,2551,2383,2215}, +{2847,2647,2447,2247}, +{2943,2711,2479,2247}, +{3039,2775,2543,2279}, +{3135,2839,2575,2311}, +{3231,2935,2639,2343}, +{3327,2999,2671,2343}, +{3423,3063,2735,2375}, +{3519,3127,2767,2407}, +{3615,3223,2831,2439}, +{3711,3287,2863,2439}, +{3807,3351,2927,2471}, +{3903,3415,2959,2503}, +{3999,3511,3023,2535}, +{4063,3575,3055,2535}, +{4061,3574,3054,2535}, +{4060,3573,3054,2535}, +{4058,3572,3053,2534}, +{4057,3571,3052,2534}, +{4055,3569,3051,2533}, +{4054,3568,3051,2533}, +{4052,3567,3050,2533}, +{4051,3566,3049,2532}, +{4049,3565,3048,2532}, +{4048,3564,3048,2532}, +{4046,3563,3047,2531}, +{4045,3562,3046,2531}, +{4043,3560,3045,2530}, +{4042,3559,3045,2530}, +{4040,3558,3044,2530}, +{4039,3557,3043,2529}, +{4037,3556,3042,2529}, +{4036,3555,3042,2529}, +{4034,3554,3041,2528}, +{4033,3553,3040,2528}, +{4032,3552,3040,2528}, +{4032,3552,992,480}, +{8128,5600,3040,480}, +{10176,7648,5088,2528}, +{14272,9696,7136,2528}, +{16320,11744,7136,2528}, +{20416,13792,9184,4576}, +{22464,15840,11232,4576}, +{26560,19936,13280,6624}, +{28608,21984,13280,6624}, +{32704,24032,15328,6624}, +{34752,26080,17376,8672}, +{38848,28128,19424,8672}, +{40896,30176,19424,8672}, +{44992,32224,21472,10720}, +{47040,34272,23520,10720}, +{51136,38368,25568,12768}, +{53184,40416,25568,12768}, +{57280,42464,27616,12768}, +{59328,44512,29664,14816}, +{63424,46560,31712,14816}, +{65472,48608,31712,14816}, +{65376,48512,31648,14784}, +{65280,48448,31616,14784}, +{65184,48384,31552,14752}, +{65088,48320,31520,14720}, +{64992,48224,31456,14688}, +{64896,48160,31424,14688}, +{64800,48096,31360,14656}, +{64704,48032,31328,14624}, +{64608,47936,31264,14592}, +{64512,47872,31232,14592}, +{64416,47808,31168,14560}, +{64320,47744,31136,14528}, +{64224,47648,31072,14496}, +{64128,47584,31040,14496}, +{64032,47520,30976,14464}, +{63936,47456,30944,14432}, +{63840,47360,30880,14400}, +{63744,47296,30848,14400}, +{63648,47232,30784,14368}, +{63552,47168,30752,14336}, + }; struct hypertriangle_t { - int4 * colorptr; // hypersurface color + const int4 * colorptr; // hypersurface color double xmin,xmax,ymin,ymax; // minmax values intersection with plane y-x=Cte double a,b,c; // plane equation of triangle double zG; // altitude for gravity center @@ -5864,7 +6140,7 @@ namespace xcas { res.a,res.b,res.c); } #endif - + void update_hypertri(const vector & hypertriangles,double x,double y, bool & found,bool &found2, double3 & curabc1,double & curz1, @@ -5920,7 +6196,22 @@ namespace xcas { } } // end loop on k } - + + struct float2 { + float f,a; + } ; + double absarg(const gen & g,double & argcolor){ + if (g.type==_DOUBLE_){ + double d=g._DOUBLE_val; + if (d>=0){ argcolor=0; return d; } + argcolor=M_PI; return -d; + } + double x=g._CPLXptr->_DOUBLE_val,y=(g._CPLXptr+1)->_DOUBLE_val; + argcolor=std::atan2(x,y); + double n=std::sqrt(x*x+y*y); // will be encoded in a float, no overflow care + return n; + } + // hpersurface encoded as a matrix // with lines containing 3 coordinates per point bool Graph2d::glsurface(int w,int h,int lcdz,GIAC_CONTEXT, @@ -5929,9 +6220,7 @@ namespace xcas { if (h>9) h=9; if (h<1) h=1; // save zmin/zmax on the stack (4K required) const int jmintabsize=512; - ALLOCA(short int,jmintab,jmintabsize*sizeof(short int)); - ALLOCA(short int,jmaxtab,jmintabsize*sizeof(short int)); - // short int *jmintab=(short int *)alloca(jmintabsize*sizeof(short int)), * jmaxtab=(short int *)alloca(jmintabsize*sizeof(short int)); // assumes LCD_WIDTH_PX<=jmintabsize + short int *jmintab=(short int *)alloca(jmintabsize*sizeof(short int)), * jmaxtab=(short int *)alloca(jmintabsize*sizeof(short int)); // assumes LCD_WIDTH_PX<=jmintabsize for (int i=0;iLCD_HEIGHT_PX) jmax=LCD_HEIGHT_PX; jmin -= LCD_HEIGHT_PX/2; - jmax -= LCD_HEIGHT_PX/2; - // optimization caches for this vertical + jmax -= LCD_HEIGHT_PX/2; double yx=2*xscale*(i+(w-1)/2.0)+yc-xc; // poledrev indices for yx, and xmin/xmax/ymin/ymax values // (xmin/xmax should be enough, except limit cases) @@ -6052,6 +6340,7 @@ namespace xcas { double hyperxymax=-1e307,hyperxymin=1e307; double3 tri[4]; for (int k=0;k >::const_iterator sbeg=hypv[k],send=hypv[k+1],sprec,scur; vector::const_iterator itprec,itcur,itprecend; for (sprec=sbeg,scur=sprec+1;scura; + z1 = ((float2 *)&z1)->f; + a2 = ((float2 *)&z2)->a; + z2 = ((float2 *)&z2)->f; + a3 = ((float2 *)&z3)->a; + z3 = ((float2 *)&z3)->f; + a4 = ((float2 *)&z4)->a; + z4 = ((float2 *)&z4)->f; + } yx1=y1-x1; yx2=y2-x2; yx3=y3-x3; yx4=y4-x4; #ifdef HYPERQUAD tri[0]=double3(x1,y1,z1); @@ -6120,7 +6420,16 @@ namespace xcas { if (xy123>hyperxymax) hyperxymax=xy123; do_transform(invtransform,x123,y123,z123,X,Y,Z); if (Z>=window_zmin && Z<=window_zmax && X>=window_xmin && X<=window_xmax && Y>=window_ymin && Y<=window_ymax ){ - hypertriangle_t res; res.colorptr=&hyp_color[k]; + hypertriangle_t res; + if (cplx){ + int idx=(a1+M_PI)*sizeof(tabcolorcplx)/(sizeof(int4)*2*M_PI); + if (idx<0 || idx >=sizeof(tabcolorcplx)/(sizeof(int4))) + idx = 0; + //CERR << idx << " "; + res.colorptr=&tabcolorcplx[idx]; + } + else + res.colorptr=&hyp_color[k]; compute(yx,tri,res); hypertriangles.push_back(res); } @@ -6163,7 +6472,7 @@ namespace xcas { } } } - vector spheres(sphere_centerv.size()); // is plane y-x=yx intersecting sphere + vector spheres(sphere_centerv.size()); // is plane y-x=yx intersecting sphere, vector does not work with Keil for (int k=0;k=hyperxymin && x+y<=hyperxymax) + update_hypertri(hypertriangles,x,y,found,found2,curabc1,curz1,curabc2,curz2,upcolor,downcolor,downupcolor,downdowncolor); for (int ki=0;ki & cur=polyedrev[k]; @@ -6434,6 +6744,7 @@ namespace xcas { } } // end pixel vertical loop on j } // end else only_hypertri + suite3d: // update jmintab/jmaxtab if (i+horiz+w & selected,bool is3d){ + vecteur w(v); + vector s(selected); sort(s.begin(),s.end()); + int pos=0; + for (int i=0;i=s.size()) + break; + if (i==s[pos]){ + ++pos; + gen g=w[i]; + if (g.is_symb_of_sommet(at_pnt)){ + g=g._SYMBptr->feuille; + if (g.type==_VECT && g._VECTptr->size()>=2){ + vecteur gv(*g._VECTptr); + gv[1]=is3d?_CYAN:_BLUE; + g=gen(gv,g.subtype); + w[i]=symbolic(at_pnt,g); + } + } + } + } + return w; + } + + vecteur Graph2d::selected_names(bool allobjects,bool withdef) const { + vector::const_iterator it=selected.begin(),itend=selected.end(); + vecteur res; + for (;it!=itend;++it){ + gen g=symbolic_instructions[*it]; + if (g.is_symb_of_sommet(at_sto)){ + gen tmp=g._SYMBptr->feuille[0]; + if (allobjects || tmp.is_symb_of_sommet(at_point) || tmp.is_symb_of_sommet(at_element)) + res.push_back(withdef?g:g._SYMBptr->feuille[1]); + } + } + return res; + } + + void Graph2d::adjust_cursor_point_type(){ + if (hp){ + double newx,newy,newz; + find_xyz(current_i,current_j,current_depth,newx,newy,newz); + int pos=-1; + gen orig; + gen res=geometry_round(newx,newy,newz,find_eps(),orig,pos); + if (mode==0){ + if (pos>=0) + selected=vector(1,pos); + else + selected.clear(); + } + cursor_point_type=pos>=0?6:3; + } + } + + void Graph2d::update_g(){ + if (hp){ + adjust_cursor_point_type(); + find_title_plot(title_tmp,plot_tmp); + vecteur v(mergevecteur(get_current_animation(),trace_instructions)); + if (!is_undef(plot_tmp)) v.push_back(plot_tmp); + // geometry: update g from plot_instructions + g=mergevecteur(selected.empty()?plot_instructions:mark_selected(plot_instructions,selected,is3d),v); + if (is3d) + update_rotation(); + } + } + void Graph2d::update(){ + update_g(); update_scales(); - if (is3d) update_rotation(); + update_rotation(); } void mult4(double * c,double k,double * res){ @@ -7027,6 +7410,12 @@ namespace xcas { j=LCD_HEIGHT_PX/2-Z*lcdz+(Y+X)/9.6*LCD_WIDTH_PX; } + void Graph2d::xyz2ij(const double3 &d,double &i,double &j,double3 & d3) const { + do_transform(transform,d.x,d.y,d.z,d3.x,d3.y,d3.z); + i=LCD_WIDTH_PX/2+(d3.y-d3.x)/4.8*LCD_WIDTH_PX; + j=LCD_HEIGHT_PX/2-d3.z*lcdz+(d3.y+d3.x)/9.6*LCD_WIDTH_PX; + } + void Graph2d::XYZ2ij(const double3 &d,int &i,int &j) const { double X=d.x,Y=d.y,Z=d.z; i=LCD_WIDTH_PX/2+(Y-X)/4.8*LCD_WIDTH_PX; @@ -7034,6 +7423,8 @@ namespace xcas { } void Graph2d::update_rotation(){ + if (!is3d) + return; solid3d=false; double rx,ry,rz,theta; get_axis_angle_deg(q,rx,ry,rz,theta); @@ -7127,31 +7518,33 @@ namespace xcas { continue; } bool line=G.subtype==_LINE__VECT,halfline=G.subtype==_HALFLINE__VECT,segment= G.subtype==_GROUP__VECT; - if (G.type==_VECT && G._VECTptr->size()==2 && (line || halfline || segment)){ - gen a=evalf_double(G._VECTptr->front(),1,contextptr),b=evalf_double(G._VECTptr->back(),1,contextptr); - if (a.type==_VECT && b.type==_VECT && a._VECTptr->size()==3 && b._VECTptr->size()==3){ - vecteur & A=*a._VECTptr; - vecteur & B=*b._VECTptr; - if (A[0].type==_DOUBLE_ && A[1].type==_DOUBLE_ && A[2].type==_DOUBLE_ && B[0].type==_DOUBLE_ && B[1].type==_DOUBLE_ && B[2].type==_DOUBLE_ ){ - lines.push_back(ptr); - double x=A[0]._DOUBLE_val,y=A[1]._DOUBLE_val,z=A[2]._DOUBLE_val; + if (G.type==_VECT && G._VECTptr->size()>=2 && (line || halfline || segment)){ + for (int n=1;nsize();++n){ + gen a=evalf_double((*G._VECTptr)[n-1],1,contextptr),b=evalf_double((*G._VECTptr)[n],1,contextptr); + if (a.type==_VECT && b.type==_VECT && a._VECTptr->size()==3 && b._VECTptr->size()==3){ + vecteur & A=*a._VECTptr; + vecteur & B=*b._VECTptr; + if (A[0].type==_DOUBLE_ && A[1].type==_DOUBLE_ && A[2].type==_DOUBLE_ && B[0].type==_DOUBLE_ && B[1].type==_DOUBLE_ && B[2].type==_DOUBLE_ ){ + lines.push_back(ptr); + double x=A[0]._DOUBLE_val,y=A[1]._DOUBLE_val,z=A[2]._DOUBLE_val; #if 0 // ndef OLD_LINE_RENDERING - double3 prev(x,y,z); - linev.push_back(prev); + double3 prev(x,y,z); + linev.push_back(prev); #endif - double X,Y,Z; - do_transform(transform,x,y,z,X,Y,Z); - double3 M(X,Y,Z); - x=B[0]._DOUBLE_val;y=B[1]._DOUBLE_val;z=B[2]._DOUBLE_val; + double X,Y,Z; + do_transform(transform,x,y,z,X,Y,Z); + double3 M(X,Y,Z); + x=B[0]._DOUBLE_val;y=B[1]._DOUBLE_val;z=B[2]._DOUBLE_val; #if 0 // ndef OLD_LINE_RENDERING - linev.push_back(double3(x-prev.x,y-prev.y,z-prev.z)); -#endif - do_transform(transform,x,y,z,X,Y,Z); - double3 N(X,Y,Z); - double3 v(N.x-M.x,N.y-M.y,N.z-M.z); - linev.push_back(M); linev.push_back(v); - linetypev.push_back(G.subtype); - line_color.push_back(int4(u,d,du,dd)); + linev.push_back(double3(x-prev.x,y-prev.y,z-prev.z)); +#endif + do_transform(transform,x,y,z,X,Y,Z); + double3 N(X,Y,Z); + double3 v(N.x-M.x,N.y-M.y,N.z-M.z); + linev.push_back(M); linev.push_back(v); + linetypev.push_back(G.subtype); + line_color.push_back(int4(u,d,du,dd)); + } } } continue; @@ -7215,24 +7608,37 @@ namespace xcas { if (h.type==_VECT && h.subtype==_POLYEDRE__VECT) G=h; else if (ckmatrix(h,true)){ + bool cplx=has_i(h); // 4d hypersurface, encode color in a float+int + double argcplx; surfacev.push_back(vector< vector >(0)); vector< vector > & S=surfacev.back(); const vecteur & V=*h._VECTptr; S.reserve(V.size()); for (int j=0;j(0)); vector &S_=S.back(); S_.reserve(vj.size()); for (int k=0;kf = Z; + fptr->a = argcplx; + S_.push_back(Z); + } + else + S_.push_back(Z); } } - hyp_color.push_back(int4(u,d,du,dd)); + hyp_color.push_back(cplx?int4(0,0,0,0):int4(u,d,du,dd)); continue; } // end quad hypersurface } // end hypersurface @@ -7528,7 +7934,40 @@ namespace xcas { int mxw=LCD_WIDTH_PX,myw=LCD_HEIGHT_PX-STATUS_AREA_PX; double i0,j0,i0save,j0save,i1,j1; int fs=f.size(); - if ((fs==4) && (s==at_parameter)){ + if (fs>=4 && s==at_parameter && f[0].type==_IDNT){ + // display parameter from the left upper, f[0] name and f[3] value + char ch[128]; + strcpy(ch,f[0]._IDNTptr->id_name); + int pos=strlen(ch); + ch[pos]='='; + ++pos; + ch[pos]=0; + gen g=evalf_double(f[3],1,contextptr); + if (g.type==_DOUBLE_) + strcpy(ch+pos,g.print(contextptr).c_str()); + else { + ch[pos]='?'; + ++pos; + ch[pos]=0; + } + ++Mon_image.nparams; + int dw=fl_width(ch); + int fheight=14; + int ypos=(fheight+1)*Mon_image.nparams+fheight; + drawRectangle(1,ypos,dw,fheight-1,Mon_image.is3d?_BLACK:_WHITE); + os_draw_string_small_(1,ypos-fheight,ch); + if (Mon_image.pushed && Mon_image.moving_param){ + drawLine(64,ypos-2,192,ypos-2,Mon_image.is3d?_WHITE:_BLACK); + drawLine(64,ypos,64,ypos-fheight,Mon_image.is3d?_WHITE:_BLACK); + drawLine(192,ypos,192,ypos-fheight,Mon_image.is3d?_WHITE:_BLACK); + os_draw_string_small_(65,ypos-fheight-2,f[1].print(contextptr).c_str()); + os_draw_string_small_(193,ypos-fheight-2,f[2].print(contextptr).c_str()); + gen gxpos=64+128*(g-f[1])/(f[2]-f[1]); + if (gxpos.type==_DOUBLE_){ + int xpos=gxpos._DOUBLE_val; + drawLine(xpos,ypos,xpos,ypos-fheight,_RED); + } + } return ; } string the_legend; @@ -7629,7 +8068,7 @@ namespace xcas { return; } } // end circle -#if 0 +#if 1 if (point._SYMBptr->sommet==at_legende){ gen & f=point._SYMBptr->feuille; if (f.type==_VECT && f._VECTptr->size()==3){ @@ -7862,6 +8301,20 @@ namespace xcas { x/=n; y/=n; } + void Graph2d::adddepth(vector & polyg,const double3 &A,const double3 &B,int2 & IJmin) const { + if ((A.z-current_depth)*(B.z-current_depth)>0) + return; + double t=(current_depth-A.z)/(B.z-A.z); + double x=A.x+t*(B.x-A.x); + double y=A.y+t*(B.y-A.y); + int I,J; + XYZ2ij(double3(x,y,current_depth),I,J); + int2 IJ(I,J); + polyg.push_back(IJ); + if (IJ & polyg,double x,double y,double z,int2 & IJmin) const { int I,J; xyz2ij(double3(x,y,z),I,J); @@ -7871,7 +8324,184 @@ namespace xcas { IJmin=IJ; } + int roundint (double r) { + int tmp = static_cast (r); + tmp += (r-tmp>=.5) - (r-tmp<=-.5); + return tmp; + } + + bool Graph2d::find_dxdy(double & dx, double & dy) const { + double xmin=window_xmin,xmax=window_xmax; + int hp=LCD_WIDTH_PX-1; + dx=(xmax-xmin)/hp; + double ymin=window_ymin,ymax=window_ymax; + int vp=LCD_HEIGHT_PX-1; + dy=(ymax-ymin)/vp; + return abs(dx-dy) < 0.000001; + } + + void Graph2d::find_xy(double i,double j,double & x,double & y) const { + double xmin=window_xmin,xmax=window_xmax; + x=xmin+i*(xmax-xmin)/LCD_WIDTH_PX; + double ymin=window_ymin,ymax=window_ymax; + y=ymax-j*(ymax-ymin)/LCD_HEIGHT_PX; + } + + void Graph2d::round_xy(double & x, double & y) const { + double dx,dy; + find_dxdy(dx,dy); + double range = pow(10,log10(1.0/dx)); + x = roundint(x * range) / range; + y = roundint(y * range) / range; + } + + void round3(double & x,double xmin,double xmax){ + double dx=std::abs(xmax-xmin); + double logdx=std::log10(dx); + int ndec=int(logdx)-3; + double xpow=std::pow(10.0,ndec); + int newx=x>=0?int(x/xpow+0.5):int(x/xpow-0.5); + x=newx*xpow; + } + + vecteur Graph2d::param(double d) const { + const_iterateur it=plot_instructions.begin(),itend=plot_instructions.end(); + vecteur res; + double pos=0.5; + for (int i=0 ;it!=itend;++i,++it){ + gen tmp=*it; + if (tmp.is_symb_of_sommet(at_parameter)){ + tmp=tmp._SYMBptr->feuille; + if (tmp.type==_VECT && tmp._VECTptr->size()>=4){ + if (std::abs(d-pos)<0.50001){ + res.push_back(tmp); + res.push_back(i); + } + ++pos; + } + } + } + return res; + } + + void Graph2d::draw_decorations(const gen & title_tmp){ + if (args_tmp.empty()){ // add selected names + char s[256]; strcpy(s,modestr.c_str()); + int pos=0,modestrsize=modestr.size(); + pos += modestrsize; + s[pos++]=' '; + if (mode!=0 && drag_name.type==_IDNT){ + strcpy(s+pos,drag_name._IDNTptr->id_name); + pos += strlen(drag_name._IDNTptr->id_name); + } + else { + if (1 || mode==0 || mode==255){ // print selected names + vecteur v; + if (mode!=255) v=selected_names(true,false); + if (v.empty() && current_i<=192 && current_j<14*nparams+21){ + double d=current_j/14.-1; + v=param(d); + if (v.size()!=2) + v.clear(); + else + v=vecteur(1,v.front()[0]); + } + int vs=v.size(); + if (!vs){ // print current coordinates + double i=current_i,j=current_j,x,y,z; + if (is3d){ + find_xyz(i,j,current_depth,x,y,z); + round_xy(x,y); round3(z,window_zmin,window_zmax); + sprintf(s+pos," %.3g,%.3g,%.3g",x,y,z); + } + else { + find_xy(i,j,x,y); + // round to maximum pixel range + round_xy(x,y); + sprintf(s+pos," %.3g,%.3g",x,y); + } + pos=strlen(s); + } + for (int i=0;iid_name); + pos += strlen(v[i]._IDNTptr->id_name); + if (iptr()->s+('('+title_tmp.print(contextptr)+')'); // gen(symbolic(*function_final._FUNCptr,title_tmp)).print(contextptr); + } + else + mytitle=title; + if (!mytitle.empty()){ + int dt=int(fl_width(mytitle.c_str())); + if (dt>LCD_WIDTH_PX) + dt=LCD_WIDTH_PX; + os_draw_string_small_((LCD_WIDTH_PX-dt)/2,LCD_HEIGHT_PX-14,mytitle.c_str()); + } + } + if (hp){ // draw cursor at current_i,current_j + int taille=mode==255?2:5; + fl_line(current_i-taille,current_j,current_i+taille,current_j,is3d?_CYAN:_BLUE); + fl_line(current_i,current_j-taille,current_i,current_j+taille,is3d?_CYAN:_BLUE); + if (cursor_point_type==6){ + fl_line(current_i-2,current_j+2,current_i+2,current_j+2,_RED); + fl_line(current_i-2,current_j+2,current_i+2,current_j+2,_RED); + fl_line(current_i-2,current_j-2,current_i-2,current_j+2,_RED); + fl_line(current_i+2,current_j-2,current_i+2,current_j+2,_RED); + } + } + } + + void displaypolyg(const vector & polyg,const int2 & IJmin,int color,int & Px,int & Py,GIAC_CONTEXT){ + if (polyg.empty()) + return; + // sort list of arguments + vector p; + for (int k=0;k > P; + for (int k=0;k vi(2); + vi[0]=p[k].i; + vi[1]=p[k].j; + P.push_back(vi); + } + draw_polygon(P,color + // | 0x400000 + ,contextptr); + Px=P[0][0]; + Py=P[0][1]; + } + void Graph2d::draw(){ + waitforvblank(); + nparams=0; // reset number of parameters (shown from left upper) + if (hp) history_plot(contextptr).clear(); if (is3d){ if (lang==1) statuslinemsg("Toolbox: aide"); @@ -7885,16 +8515,21 @@ namespace xcas { F(window_xmin,window_ymax,window_zmax), G(window_xmax,window_ymax,window_zmin), H(window_xmax,window_ymax,window_zmax); - xyz2ij(A,Ai,Aj); - xyz2ij(B,Bi,Bj); - xyz2ij(C,Ci,Cj); - xyz2ij(D,Di,Dj); - xyz2ij(E,Ei,Ej); - xyz2ij(F,Fi,Fj); - xyz2ij(G,Gi,Gj); - xyz2ij(H,Hi,Hj); + double3 A3,B3,C3,D3,E3,F3,G3,H3; + xyz2ij(A,Ai,Aj,A3); + xyz2ij(B,Bi,Bj,B3); + xyz2ij(C,Ci,Cj,C3); + xyz2ij(D,Di,Dj,D3); + xyz2ij(E,Ei,Ej,E3); + xyz2ij(F,Fi,Fj,F3); + xyz2ij(G,Gi,Gj,G3); + xyz2ij(H,Hi,Hj,H3); set_abort(); + int prec=precision; + if (mode==0 && precision<3) + precision += 2; glsurface(precision,precision,lcdz,contextptr,default_upcolor,default_downcolor,default_downupcolor,default_downdowncolor); + precision=prec; clear_abort(); if (show_edges){ // polyhedrons @@ -8022,10 +8657,31 @@ namespace xcas { drawLine(Ci,Cj,Gi,Gj,COLOR_GREEN | 0x800000); drawLine(Di,Dj,Hi,Hj,COLOR_GREEN | 0x800000); // Z - drawLine(Ai,Aj,Bi,Bj,12345 | 0x800000); - drawLine(Ci,Cj,Di,Dj,12345 | 0x800000); - drawLine(Ei,Ej,Fi,Fj,12345 | 0x800000); - drawLine(Gi,Gj,Hi,Hj,12345 | 0x800000); + drawLine(Ai,Aj,Bi,Bj,COLOR_CYAN | 0x800000); + drawLine(Ci,Cj,Di,Dj,COLOR_CYAN | 0x800000); + drawLine(Ei,Ej,Fi,Fj,COLOR_CYAN | 0x800000); + drawLine(Gi,Gj,Hi,Hj,COLOR_CYAN | 0x800000); + // current_depth + if (hp){ + vector polyg; int2 IJmin={RAND_MAX,RAND_MAX}; + // x: A3-C3, B3-D3; E3-G3,F3-H3 + adddepth(polyg,A3,C3,IJmin); + adddepth(polyg,B3,D3,IJmin); + adddepth(polyg,E3,G3,IJmin); + adddepth(polyg,F3,H3,IJmin); + // y: A3-E3; B3-F3; C3-G3, D3-H3 + adddepth(polyg,A3,E3,IJmin); + adddepth(polyg,B3,F3,IJmin); + adddepth(polyg,C3,G3,IJmin); + adddepth(polyg,D3,H3,IJmin); + // z: A3-B3, C3-D3, E3-F3, G3-H3 + adddepth(polyg,A3,B3,IJmin); + adddepth(polyg,C3,D3,IJmin); + adddepth(polyg,E3,F3,IJmin); + adddepth(polyg,G3,H3,IJmin); + int Px,Py; + displaypolyg(polyg,IJmin,COLOR_YELLOW | 0x400000,Px,Py,contextptr); + } // planes vecteur attrv(gen2vecteur(g)); for (int i=0;i=window_zmin && z<=window_zmax) addpolyg(polyg,window_xmax,window_ymax,z,IJmin); } - // sort list of arguments - vector p; - for (int k=0;k > P; - for (int k=0;k vi(2); - vi[0]=p[k].i; - vi[1]=p[k].j; - P.push_back(vi); - } - draw_polygon(P,upcolor - // | 0x400000 - ,contextptr); + int Px,Py; + displaypolyg(polyg,IJmin,upcolor,Px,Py,contextptr); if (nameptr){ int x=os_draw_string_small(0,0,0,upcolor,nameptr,true); - os_draw_string_small(P[0][0]-x,P[0][1],upcolor,0,nameptr); + os_draw_string_small(Px-x,Py,upcolor,0,nameptr); } } } // frame double xi=Ci-Ai,xj=Cj-Aj; normalize(xi,xj); - drawLine(20,20,20+20*xi,20+20*xj,COLOR_RED); - os_draw_string_small(20+20*xi,20+20*xj,COLOR_RED,COLOR_BLACK,"x"); + int decal=180; + drawLine(20,decal,20+20*xi,decal+20*xj,COLOR_RED); + os_draw_string_small(20+20*xi,decal+20*xj,COLOR_RED,COLOR_BLACK,"x"); double yi=Ei-Ai,yj=Ej-Aj; normalize(yi,yj); - drawLine(20,20,20+20*yi,20+20*yj,COLOR_GREEN); - os_draw_string_small(20+20*yi,20+20*yj,COLOR_GREEN,COLOR_BLACK,"y"); + drawLine(20,decal,20+20*yi,decal+20*yj,COLOR_GREEN); + os_draw_string_small(20+20*yi,decal+20*yj,COLOR_GREEN,COLOR_BLACK,"y"); double zi=Bi-Ai,zj=Bj-Aj; normalize(zi,zj); - drawLine(20,20,20+20*zi,20+20*zj,12345); - os_draw_string_small(20+20*zi,20+20*zj,12345,COLOR_BLACK,"z"); + drawLine(20,decal,20+20*zi,decal+20*zj,COLOR_CYAN); + os_draw_string_small(20+20*zi,decal+20*zj,COLOR_CYAN,COLOR_BLACK,"z"); } // end show_axes // now handle legend([x,y],string) vecteur V(gen2vecteur(g)); for (int i=0;ifeuille.type==_VECT){ + vecteur f=*attr._SYMBptr->feuille._VECTptr; + int fs=f.size(); + if (fs>=4 && f[0].type==_IDNT){ + // display parameter from the left upper, f[0] name and f[3] value + char ch[128]; + strcpy(ch,f[0]._IDNTptr->id_name); + int pos=strlen(ch); + ch[pos]='='; + ++pos; + ch[pos]=0; + gen g=evalf_double(f[3],1,contextptr); + if (g.type==_DOUBLE_) + strcpy(ch+pos,g.print(contextptr).c_str()); + else { + ch[pos]='?'; + ++pos; + ch[pos]=0; + } + ++nparams; + int dw=fl_width(ch); + int fheight=14; + int ypos=(fheight+1)*nparams+fheight; + drawRectangle(1,ypos-fheight,dw,fheight-1,_WHITE); + os_draw_string_small_(1,ypos-fheight,ch); + if (pushed && moving_param){ + drawLine(64,ypos-2,192,ypos-2,is3d?_WHITE:_BLACK); + drawLine(64,ypos,64,ypos-fheight,is3d?_WHITE:_BLACK); + drawLine(192,ypos,192,ypos-fheight,is3d?_WHITE:_BLACK); + os_draw_string_small_(65,ypos-fheight-2,f[1].print(contextptr).c_str()); + os_draw_string_small_(193,ypos-fheight-2,f[2].print(contextptr).c_str()); + gen gxpos=64+128*(g-f[1])/(f[2]-f[1]); + if (gxpos.type==_DOUBLE_){ + int xpos=gxpos._DOUBLE_val; + drawLine(xpos,ypos,xpos,ypos-fheight,_RED); + } + } + } + } // end parameter if (attr.is_symb_of_sommet(at_pnt)){ attr=attr._SYMBptr->feuille; if (attr.type==_VECT && attr._VECTptr->size()>1){ @@ -8178,6 +8851,8 @@ namespace xcas { DefineStatusMessage((char*)"+-: zoom, pad: move, EXIT: quit", 1, 0, 0); #endif DisplayStatusArea(); + if (hp) + draw_decorations(title_tmp); return; } int save_clip_ymin=clip_ymin; @@ -8274,6 +8949,8 @@ namespace xcas { // draw fltk_draw(*this,g,x_scale,y_scale,clip_x,clip_y,clip_w,clip_h,contextptr); clip_ymin=save_clip_ymin; + if (hp) + draw_decorations(title_tmp); } void Graph2d::left(double d){ @@ -8554,11 +9231,11 @@ namespace xcas { } // End logo mode } - - int displaygraph(const giac::gen & ge,GIAC_CONTEXT){ + int displaygraph(const giac::gen & ge,const gen & gs,GIAC_CONTEXT){ // graph display //if (aborttimer > 0) { Timer_Stop(aborttimer); Timer_Deinstall(aborttimer);} xcas::Graph2d gr(ge,contextptr); + if (gs!=0) gr.symbolic_instructions=gen2vecteur(gs); gr.show_axes=global_show_axes; // initial setting for x and y if (ge.type==_VECT){ @@ -8600,86 +9277,1463 @@ namespace xcas { } } } - // UI -#ifdef NSPIRE_NEWLIB - DefineStatusMessage((char*)"+-: zoom, pad: move, esc: quit", 1, 0, 0); + return gr.ui(); + } + + vecteur Graph2d::get_current_animation() const { + if (animation_instructions_pos>=0 && animation_instructions_pos=2){ + gen function=(mode==int(args_tmp.size()))?function_final:function_tmp; + if (function.type==_FUNC){ + bool dim2=!is3d; + vecteur args2=args_tmp; + if ( *function._FUNCptr==(dim2?at_cercle:at_sphere)){ + gen argv1; +#ifdef NO_STDEXCEPT + argv1=evalf(args_tmp.back(),1,contextptr); + argv1=evalf_double(argv1,1,contextptr); #else - DefineStatusMessage((char*)"+-: zoom, pad: move, EXIT: quit", 1, 0, 0); + try { + argv1=evalf(args_tmp.back(),1,contextptr); + argv1=evalf_double(argv1,1,contextptr); + } + catch (std::runtime_error & e){ + argv1=undef; + } #endif - DisplayStatusArea(); - int saveprecision=gr.precision; - gr.precision += 2; // fast draw first - gr.draw(); - gr.precision=saveprecision; - bool redraw=true; - for (;;){ - int saveprec=gr.precision; - if (gr.doprecise){ - gr.doprecise=false; - gr.precision=1;//gr.precision-=2; - } - if (redraw) - gr.draw(); - redraw=true; - gr.precision=saveprec; - DisplayStatusArea(); + if (argv1.is_symb_of_sommet(at_pnt) ||argv1.type==_IDNT){ + argv1=remove_at_pnt(argv1); + if ( (argv1.type==_VECT && argv1.subtype==_POINT__VECT) || argv1.type==_CPLX || argv1.type==_IDNT) + args2.back()=args_tmp.back()-args_tmp.front(); + } + } + if (function==at_ellipse) + ; + title_tmp=gen(args2,_SEQ__VECT); + bool b=approx_mode(contextptr); + if (!b) + approx_mode(true,contextptr); + plot_tmp=symbolic(*function._FUNCptr,title_tmp); + if (!lidnt(title_tmp).empty()) + ; // cerr << plot_tmp << '\n'; + bool bb=io_graph(contextptr); + int locked=0; + if (bb){ +#ifdef HAVE_LIBPTHREAD + // cerr << "plot title lock" << '\n'; + locked=pthread_mutex_trylock(&interactive_mutex); +#endif + if (!locked) + io_graph(false,contextptr); + } + plot_tmp=protecteval(plot_tmp,1,contextptr); + if (bb && !locked){ + io_graph(bb,contextptr); +#ifdef HAVE_LIBPTHREAD + pthread_mutex_unlock(&interactive_mutex); + // cerr << "plot title unlock" << '\n'; +#endif + } + if (!b) + approx_mode(false,contextptr); + } // end function.type==_FUNC + else + title_tmp=gen(args_tmp,_SEQ__VECT); + } // end size()>=2 + else + title_tmp=args_tmp; + } + } + + void Graph2d::eval(int start){ + plot_instructions.resize(symbolic_instructions.size()); + if (plot_instructions.empty()) return; + int level=prog_eval_level_val(contextptr); + for (size_t i=start;ifeuille); + f=protecteval(f,1,contextptr); #ifdef NUMWORKS - os_draw_string(0,LCD_HEIGHT_PX-STATUS_AREA_PX-17,COLOR_BLACK,COLOR_WHITE,"toolbox: cfg"); + const int maxtrace=128; #else - os_draw_string(0,LCD_HEIGHT_PX-STATUS_AREA_PX-17,COLOR_BLACK,COLOR_WHITE,"menu: cfg"); + const int maxtrace=512; #endif - int key=-1; - GetKey(&key); - if (key==KEY_SHUTDOWN) - return key; -#if 1 - if (key==KEY_CTRL_CATALOG || key==KEY_BOOK ){ - char menu_xmin[32],menu_xmax[32],menu_ymin[32],menu_ymax[32],menu_zmin[32],menu_zmax[32]; - for (;;){ - string s; - s="xmin "+print_DOUBLE_(gr.window_xmin,contextptr); - strcpy(menu_xmin,s.c_str()); - s="xmax "+print_DOUBLE_(gr.window_xmax,contextptr); - strcpy(menu_xmax,s.c_str()); - s="ymin "+print_DOUBLE_(gr.window_ymin,contextptr); - strcpy(menu_ymin,s.c_str()); - s="ymax "+print_DOUBLE_(gr.window_ymax,contextptr); - strcpy(menu_ymax,s.c_str()); - s="zmin "+print_DOUBLE_(gr.window_zmin,contextptr); - strcpy(menu_zmin,s.c_str()); - s="zmax "+print_DOUBLE_(gr.window_zmax,contextptr); - strcpy(menu_zmax,s.c_str()); - Menu smallmenu; - smallmenu.numitems=15; - MenuItem smallmenuitems[smallmenu.numitems]; - smallmenu.items=smallmenuitems; - smallmenu.height=12; - //smallmenu.title = "KhiCAS"; - smallmenuitems[0].text = (char *) menu_xmin; - smallmenuitems[1].text = (char *) menu_xmax; - smallmenuitems[2].text = (char *) menu_ymin; - smallmenuitems[3].text = (char *) menu_ymax; - smallmenuitems[4].text = (char *) menu_zmin; - smallmenuitems[5].text = (char *) menu_zmax; - smallmenuitems[6].text = (char*) "Orthonormalize /"; - smallmenuitems[7].text = (char*) "Autoscale *"; - smallmenuitems[8].text = (char *) ("Zoom in +"); - smallmenuitems[9].text = (char *) ("Zoom out -"); - smallmenuitems[10].text = (char *) ("Y-Zoom out (-)"); - smallmenuitems[11].text = (char *) ((lang==1)?"raccourcis clavier":"3d shortcuts"); - smallmenuitems[12].text = (char*) ((lang==1)?"Voir axes":"Show axes"); - smallmenuitems[13].text = (char*) ((lang==1)?"Cacher axes":"Hide axes"); - smallmenuitems[14].text = (char*)((lang==1)?"Quitter":"Quit"); - drawRectangle(0,180,LCD_WIDTH_PX,60,_BLACK); - int sres = doMenu(&smallmenu); - if (sres == MENU_RETURN_EXIT) - break; - if (sres == MENU_RETURN_SELECTION || sres==KEY_CTRL_EXE) { - const char * ptr=0; - string s1; double d; - if (smallmenu.selection==1){ - d=gr.window_xmin; - if (inputdouble(menu_xmin,d,200,contextptr)){ + if (trace_instructions.size()>=maxtrace) + trace_instructions.erase(trace_instructions.begin(),trace_instructions.begin()+maxtrace/2); + trace_instructions.push_back(f); + } + } + is3d=false; + for (size_t i=0;idy && dz >dx){ + eps=npixels*dz/L; + eps *= 2; + } + return eps; + } + + void Graph2d::set_gen_value(int n,const giac::gen & g,bool exec){ + // set n-th entry value, if n==-1 add a level + if (!hp) return; + if (n==-1 || n>=symbolic_instructions.size()){ + symbolic_instructions.push_back(g); + n=symbolic_instructions.size()-1; + } else symbolic_instructions[n]=g; + hp->set_string_value(n,g.print(contextptr)); + if (exec) + eval(n); + } + + void Graph2d::find_xyz(double i,double j,double k,double & x,double & y,double & z) const { + if (is3d){ // FIXME + int horiz=LCD_WIDTH_PX/2,vert=horiz/2;//LCD_HEIGHT_PX/2; + double lcdz= LCD_HEIGHT_PX/4; + double xmin=-1,ymin=-1,xmax=1,ymax=1,xscale=0.6*(xmax-xmin)/horiz,yscale=0.6*(ymax-ymin)/vert; + double Z=current_depth; // -1..1 + double I=i-horiz; + double J=j-LCD_HEIGHT_PX/2+lcdz*Z; + double X=yscale*J-xscale*I; + double Y=yscale*J+xscale*I; + do_transform(invtransform,X,Y,Z,x,y,z); + } + else { + z=k; + x=window_xmin+i*(window_xmax-window_xmin)/LCD_WIDTH_PX; + y=window_ymax-j*(window_ymax-window_ymin)/LCD_HEIGHT_PX; + } + } + + gen geometry_round_numeric(double x,double y,double eps,bool approx){ + return approx?gen(x,y):exact_double(x,eps)+cst_i*exact_double(y,eps); + } + + gen geometry_round_numeric(double x,double y,double z,double eps,bool approx){ + return gen(approx?makevecteur(x,y,z):makevecteur(exact_double(x,eps),exact_double(y,eps),exact_double(z,eps)),_POINT__VECT); + } + + gen int2color(int couleur_){ + gen col; + if (couleur_){ + gen tmp; + int val; + vecteur colv; + if ( (val=(couleur_ & 0x0000ffff))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x00070000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x00380000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x01c00000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x0e000000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x30000000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x40000000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if ((val =(couleur_ & 0x80000000))){ + tmp=val; + tmp.subtype=_INT_COLOR; + colv.push_back(tmp); + } + if (colv.size()==1) + col=colv.front(); + else + col=symbolic(at_plus,gen(colv,_SEQ__VECT)); + } + return col; + } + + std::string print_color(int couleur){ + return int2color(couleur).print(context0); + } + + giac::gen add_attributs(const giac::gen & g,int couleur_,GIAC_CONTEXT) { + if (g.type!=_SYMB) + return g; + gen & f=g._SYMBptr->feuille; + if (g._SYMBptr->sommet==at_couleur && f.type==_VECT && !f._VECTptr->empty()){ + gen col=couleur_; + col.subtype=_INT_COLOR; + vecteur v(*f._VECTptr); + v.back()=col; + return symbolic(at_couleur,gen(v,_SEQ__VECT)); + } + if (couleur_==default_color(contextptr)) + return g; + if (g._SYMBptr->sommet==at_of){ + gen col=couleur_; + col.subtype=_INT_COLOR; + return symbolic(at_couleur,gen(makevecteur(g,col),_SEQ__VECT)); + } + vecteur v =gen2vecteur(f); + gen col=int2color(couleur_); + v.push_back(symbolic(at_equal,gen(makevecteur(at_display,col),_SEQ__VECT))); + return symbolic(g._SYMBptr->sommet,(v.size()==1 && f.type!=_VECT)?f:gen(v,f.type==_VECT?f.subtype:_SEQ__VECT)); + } + + void Graph2d::do_handle(const gen & g){ + if (hp){ + set_gen_value(hp_pos,g,true); + } + } + + void Graph2d::set_mode(const giac::gen & f_tmp,const giac::gen & f_final,int m,const string & help){ + approx=true; + mode=m; + selected.clear(); + redraw(); + args_help.clear(); + if (mode!=0 && mode!=255){ + int oldmode=calc_mode(contextptr); + calc_mode(0,contextptr); + gen g(help,contextptr); + calc_mode(oldmode,contextptr); + if (g.type==_VECT){ + const_iterateur it = g._VECTptr->begin(),itend=g._VECTptr->end(); + for (;it!=itend;++it) + args_help.push_back(it->print(contextptr)); + } + else + args_help.push_back(g.print(contextptr)); + } + if (mode==255) + modestr=gettext("Frame"); + else + modestr=mode?gen2string(f_final):gettext("Pointer"); + if (mode>=-1){ + pushed=false; + moving_param=moving=moving_frame=false; + // history_pos=-1; + mode=m; + function_final=f_final; + function_tmp=f_tmp; + args_tmp.clear(); + geo_handle(FL_MOVE,0); + update_g(); + } + } + + vecteur Graph2d::selection2vecteur(const vector & v){ + int n=v.size(); + vecteur res(n); + for (int i=0;i=hp->elements.size()) + selected.pop_back(); + } + + gen Graph2d::geometry_round(double x,double y,double z,double eps,gen & original,int & pos,bool selectfirstlevel,bool setscroller) { + if (!hp) + return undef; + gen tmp; + pos=-1; + geometry_round(x,y,z,eps,tmp,contextptr); + if (selected.empty()) + return tmp; + if (function_final==at_areaatraw || function_final==at_areaat || function_final==at_perimeteratraw || function_final==at_perimeterat){ + int p=findfirstclosedcurve(selection2vecteur(selected)); + if (p>0){ + pos=p; + } + } + if (pos==-1){ + if (selectfirstlevel){ + sort(selected.begin(),selected.end()); + // patch so that we move element and not the curve + int p=findfirstpoint(selection2vecteur(selected)); + if (p>0){ + pos=p; + } + } + else + pos=findfirstpoint(selection2vecteur(selected)); + } + gen g=symbolic_instructions[ (pos<0)?(pos=selected.front()):(pos=selected[pos]) ]; + if (pos>=0 && poselements.size()){ + // hp->_sel_begin=hp->_sel_end=pos; + // if (setscroller) hp->line=pos; + } + if (g.is_symb_of_sommet(at_plus) && g._SYMBptr->feuille.type==_VECT && !g._SYMBptr->feuille._VECTptr->empty()) + g=g._SYMBptr->feuille._VECTptr->front(); + if (g.is_symb_of_sommet(at_sto) && g._SYMBptr->feuille.type==_VECT ){ + vecteur & v = *g._SYMBptr->feuille._VECTptr; + if (v.size()==2){ + original = v[0]; + tmp = v[1]; + if (tmp.type==_IDNT){ + gen valeur=protecteval(original,1,contextptr); + if (valeur.is_symb_of_sommet(at_pnt)){ + gen & valf = valeur._SYMBptr->feuille; + if (valf.type==_VECT){ + vecteur & valv = *valf._VECTptr; + int s=v.size(); + if (s>1){ + gen valv1=valv[1]; + if (valv1.type==_VECT && valv1._VECTptr->size()>2){ + tmp=symbolic(at_extract_measure,v[1]); + } + } + } + } + } + } + } + return tmp; + } + + void Graph2d::autoname_plus_plus(){ + if (hp){ + string s=autoname(contextptr); + giac::autoname_plus_plus(s); + autoname(s,contextptr); + } + } + + int Graph2d::geo_handle(int event,int key){ + double eps=find_eps(); + int pos; + gen tmp,tmp2,decal; + if (event==FL_PUSH) + moving_param=false; + if ( pushed && !moving && !moving_frame && mode ==0 && in_area && event==FL_DRAG){ + // FIXME? redraw(); + return 1; + } + if (mode>=2 && event==FL_MOVE && args_tmp.size()>mode) + event=FL_RELEASE; + if ( in_area && ((mode!=1 && event==FL_DRAG) || event==FL_PUSH || event==FL_RELEASE || (mode>=2 && event==FL_MOVE)) ){ + double newx,newy,newz; + find_xyz(current_i,current_j,current_depth,newx,newy,newz); + round3(newx,window_xmin,window_xmax); + round3(newy,window_ymin,window_ymax); + if (is3d) + round3(newz,window_zmin,window_zmax); + tmp=geometry_round(newx,newy,newz,eps,tmp2,pos,mode==0 || (args_tmp.size()==mode && function_final.type==_FUNC && equalposcomp(transformation_functions,*function_final._FUNCptr)),event==FL_RELEASE); + if (tmp.type!=_IDNT && !tmp.is_symb_of_sommet(at_extract_measure)){ + bool done=false; + if (mode==0 && event==FL_PUSH && current_i<192 && current_j<14*nparams+21){ + double d=current_j/14.-1; + vecteur vp=param(d); + if (vp.size()==2){ + tmp=vp[0][0]; + tmp2=vp[0]; + pos=vp[1].val; + done=moving_param=true; + param_min=evalf_double(tmp2[1],1,contextptr)._DOUBLE_val; + param_max=evalf_double(tmp2[2],1,contextptr)._DOUBLE_val; + param_step=evalf_double(tmp2[4],1,contextptr)._DOUBLE_val; + param_orig=param_value=evalf_double(tmp2[3],1,contextptr)._DOUBLE_val; + } + } + if (!done){ + if (tmp.type==_VECT && tmp._VECTptr->size()==3){ + tmp.subtype=_SEQ__VECT; + tmp=symbolic(at_point,tmp); + } + else + tmp=symbolic(at_point,makevecteur(re(tmp,contextptr),im(tmp,contextptr))); + } + } + } + double newx,newy,newz; + if (is3d){ + double x1,y1,z1,x2,y2,z2; + find_xyz(current_i,current_j,current_depth,x1,y1,z1); + find_xyz(push_i,push_j,push_depth,x2,y2,z2); + newx=x1-x2; newy=y1-y2; newz=z1-z2; + } else { + int dw=LCD_WIDTH_PX,dh=LCD_HEIGHT_PX; + double dx=window_xmax-window_xmin; + double dy=window_ymax-window_ymin; + double x_scale=dx/dw,y_scale=dy/dh; + newx=(current_i-push_i)*x_scale; + newy=(push_j-current_j)*y_scale; + newz=0; + } + round3(newx,window_xmin,window_xmax); + round3(newy,window_ymin,window_ymax); + if (is3d){ + round3(newz,window_zmin,window_zmax); + decal=in_area?geometry_round_numeric(newx,newy,newz,eps,approx):0; + if (decal.type==_VECT && decal.subtype==_POINT__VECT) + decal.subtype=0; + } + else + decal=in_area?geometry_round_numeric(newx,newy,eps,approx):0; + // cerr << in_area << " " << decal << '\n'; + if (mode==0 || mode==255) { + if (event==FL_PUSH){ + // select object && flag to move it + if (mode==0 && pos>=0){ + if (tmp.type==_IDNT){ + drag_original_value=tmp2; + drag_name=tmp; + } + else { + drag_original_value=symbolic_instructions[pos]; + drag_name=0; + } + hp_pos=pos; + moving = true; + } + else { // nothing selected, move frame + if (!(display_mode & 0x80)) // disabled by default in 3-d + moving_frame=true; + } + return 1; + } + if (moving_frame && (event==FL_DRAG || event==FL_RELEASE) ){ + window_xmin -= newx; + window_xmax -= newx; + window_ymin -= newy; + window_ymax -= newy; + window_zmin -= newz; + window_zmax -= newz; + push_i = current_i; + push_j = current_j; + push_depth = current_depth; + redraw(); + if (event==FL_RELEASE) + moving_frame=false; + return 1; + } + if (mode==255) + return 0; + if (moving_param && (event==FL_DRAG || event==FL_RELEASE) ){ + // key -> + if (key==KEY_CTRL_EXIT) + param_value=param_orig; + double ps=param_step; + if (ps<=0) + ps=(param_max-param_min)/100; + if (key==KEY_CTRL_LEFT) + param_value -= ps; + if (key==KEY_SHIFT_LEFT) + param_value -= 10*ps; + if (key==KEY_CTRL_RIGHT) + param_value += ps; + if (key==KEY_SHIFT_RIGHT) + param_value += 10*ps; + if (param_valueparam_max) + param_value=param_max; + current_i=64+128*(param_value-param_min)/(param_max-param_min); + if (param_step<=0) + do_handle(symbolic(at_assume,symb_equal(drag_name,param_value))); + else { + gen newval=symbolic(at_element,makesequence(symb_interval(param_min,param_max),param_value)); + do_handle(symbolic(at_sto,makevecteur(newval,drag_name))); + } + if (event==FL_RELEASE){ + moving_param=moving=false; + } + return 1; + } + if (moving && (event==FL_DRAG || event==FL_RELEASE) ){ + // cerr << current_i << " " << current_j << '\n'; + // avoid point()+complex+complex+complex + gen newval=drag_original_value; + if (in_area && key!=KEY_CTRL_EXIT){ + if (drag_original_value.is_symb_of_sommet(at_plus) && drag_original_value._SYMBptr->feuille.type==_VECT && drag_original_value._SYMBptr->feuille._VECTptr->size()>=2){ + vecteur v=*drag_original_value._SYMBptr->feuille._VECTptr; + if (v[1].is_symb_of_sommet(at_nop)) + v[1]=v[1]._SYMBptr->feuille; + newval=symbolic(at_plus,makevecteur(v[0],symbolic(at_nop,ratnormal(_plus(vecteur(v.begin()+1,v.end()),contextptr)+decal)))); + } + else { + newval=is_zero(decal)?drag_original_value:symbolic(at_plus,makevecteur(drag_original_value,symbolic(at_nop,decal))); + } + } + int dclick = 0 || drag_original_value.type==_VECT; + if (!dclick){ + if (drag_name.type==_IDNT) + do_handle(symbolic(at_sto,makevecteur(newval,drag_name))); + else + do_handle(newval); + } + if (event==FL_RELEASE) + moving=false; + selected.clear(); + redraw(); + return 1; + } + return 0; + } + selected.clear(); + if (mode==1){ + if (function_final!=at_point){ + if (event==FL_RELEASE){ + string args=autoname(contextptr)+":="; + if (function_final.type==_FUNC) + args += function_final._FUNCptr->ptr()->s; + args +="("; + if (function_final==at_plotode) + args += fcnfield + "," + fcnvars + "," +tmp.print(contextptr) + ",plan)"; + else + args += tmp.print(contextptr) + ")"; + autoname_plus_plus(); + set_gen_value(-1,gen(args,contextptr),true); + } + if (event==FL_PUSH || event==FL_DRAG || event==FL_RELEASE) + return 1; + return 0; + } + // point|segment mode + if (event==FL_RELEASE){ + hp_pos=-1; + if (hp && !args_tmp.empty() && (std::abs(push_i-current_i)>npixels || std::abs(push_j-current_j)>npixels || (is3d && std::abs(push_depth-current_depth) >0)) ){ + // make a segment + gen val1,val2; + if (in_area && args_tmp.front().is_symb_of_sommet(at_point)){ + val1=gen(autoname(contextptr),contextptr); + // put in last history pack level + set_gen_value(-1,symbolic(at_sto,makevecteur(add_attributs(args_tmp.front(),couleur,contextptr),val1)),false); + hp_pos=hp->elements.size()-1; + autoname_plus_plus(); + } + else + val1=args_tmp.front(); + if (in_area && tmp.is_symb_of_sommet(at_point)){ + val2=gen(autoname(contextptr),contextptr); + gen tmp3=symbolic(at_sto,makevecteur(add_attributs(tmp,couleur,contextptr),val2)); + set_gen_value(-1,tmp3,false); + if (hp_pos<0) hp_pos=hp->elements.size()-1; + autoname_plus_plus(); + } + else + val2=tmp; + if (in_area){ + gen tmp3=add_attributs(symbolic(at_segment,makevecteur(val1,val2)),couleur,contextptr); + string v1v2=val1.print(contextptr)+val2.print(contextptr); + gen g1g2(v1v2,contextptr); + if (g1g2.type!=_IDNT) + g1g2=gen(v1v2+"_",contextptr); + tmp3=symbolic(at_sto,makevecteur(tmp3,g1g2)); + set_gen_value(-1,tmp3,false); + if (hp_pos<0) hp_pos=hp->elements.size()-1; + eval(hp_pos); + } + return 1; + } + if (in_area && tmp.type!=_IDNT) + do_handle(symbolic(at_sto,makevecteur(add_attributs(tmp,couleur,contextptr),gen(autoname(contextptr),contextptr)))); + // element + if (tmp.type==_IDNT && tmp2.type==_SYMB && !equalposcomp(point_sommet_tab_op,tmp2._SYMBptr->sommet)){ + // tmp2 is the geo object, find parameter value + double newx,newy,newz; + find_xyz(current_i,current_j,current_depth,newx,newy,newz); + round3(newx,window_xmin,window_xmax); + round3(newy,window_ymin,window_ymax); + gen t=projection(evalf(tmp2,1,contextptr),gen(newx,newy),contextptr); + if (is_undef(t)) + return 0; + gen tmp3=symbolic(at_element,( (t.type<_IDNT || t.type==_VECT)?gen(makevecteur(tmp,t),_SEQ__VECT):tmp)); + tmp3=symbolic(at_sto,makevecteur(add_attributs(tmp3,couleur,contextptr),gen(autoname(contextptr),contextptr))); + set_gen_value(-1,tmp3,false); + if (hp_pos<0) hp_pos=hp->elements.size()-1; + eval(hp_pos); + } + return 1; + } + if (event==FL_PUSH){ + args_tmp=vecteur(1,tmp); + return 1; + } + if (event==FL_DRAG){ + redraw(); + return 1; + } + return 0; + } + gen tmpval=remove_at_pnt(tmp.eval(1,contextptr)); + gen somm=symbolic(at_sommets,tmp); + int npoints=1; + if (!equalposcomp(nosplit_polygon_function,*function_final._FUNCptr)){ + if (tmpval.type==_VECT && tmpval.subtype==_GROUP__VECT) + npoints=tmpval._VECTptr->size(); + if (tmpval.is_symb_of_sommet(at_cercle)) + npoints=is3d?3:2; + } + unsigned args_size=args_tmp.size(); + // mode>=2 + if (event==FL_MOVE || event==FL_DRAG || event==FL_RELEASE || event==FL_PUSH){ + if (args_sizesize()==2){ + gen tmpa=remove_at_pnt(evalf(args_tmp[0],1,contextptr)); + gen tmpb=new_args_size==2?remove_at_pnt(evalf(args_tmp[1],1,contextptr)):undef; + if (npoints==2 && tmpa==tmp2._VECTptr->front() && tmpb!=tmp2._VECTptr->back()){ + tmp=symbolic(at_at,gen(makevecteur(somm,1),_SEQ__VECT)); + npoints=1; + } + if (npoints==2 && tmpa==tmp2._VECTptr->back() && tmpb!=tmp2._VECTptr->front()){ + tmp=symbolic(at_at,gen(makevecteur(somm,0),_SEQ__VECT)); + npoints=1; + } + if (npoints==2 && tmpb==tmp2._VECTptr->front() && tmpa!=tmp2._VECTptr->back() ){ + swapargs=true; + tmp=symbolic(at_at,gen(makevecteur(somm,1),_SEQ__VECT)); + npoints=1; + } + if (npoints==2 && tmpb==tmp2._VECTptr->back() && tmpa!=tmp2._VECTptr->front()){ + swapargs=true; + tmp=symbolic(at_at,gen(makevecteur(somm,0),_SEQ__VECT)); + npoints=1; + } + } + } + if (npoints+args_tmp.size()>mode) + npoints=1; + if (event==FL_MOVE || event==FL_DRAG || event==FL_RELEASE){ + if (args_size && args_tmp_push_size && args_push!=tmp_push){ + // replace by current mouse position + if (npoints==1) + args_tmp.push_back(tmp); + else { + gen somm=symbolic(at_sommets,tmp); + for (int i=0;i1 && s>=mode){ + if (s>mode){ + args_tmp=vecteur(args_tmp.begin(),args_tmp.begin()+mode); + s=mode; + } + gen tmp_plot; + if (in_area && function_final.type==_FUNC) { + gen res,objname=gen(autoname(contextptr),contextptr); + hp_pos=hp->elements.size(); + if (hp_pos && hp->elements[hp_pos-1].s.empty()) + --hp_pos; + // hp->update_pos=hp_pos; + int pos0=hp_pos; + unary_function_ptr * ptr=function_final._FUNCptr; + int ifinal=mode; + if (equalposcomp(measure_functions,*ptr)) + ifinal--; + // first replace points in args_tmp by assignations + for (int i=0;isize())>2){ + vecteur l; + if (res._VECTptr->back()==res._VECTptr->front()) + --ns; + if (function_final.type==_FUNC && equalposcomp(transformation_functions,*function_final._FUNCptr)){ + vecteur argv; + gen objn,som=symbolic(at_sommets,objname); + for (int i=1;i<=ns;++i){ + tmp_plot=symbolic(at_at,gen(makevecteur(som,i-1),_SEQ__VECT)); + objn=gen(autoname(contextptr)+print_INT_(i),contextptr); + argv.push_back(objn); + set_gen_value(hp_pos,symbolic(at_sto,gen(makevecteur(tmp_plot,objn),_SEQ__VECT)),false); + add_entry(hp_pos+1); + ++hp_pos; + } + for (int i=1;i<=ns;++i){ + tmp_plot=symbolic(at_segment,makevecteur(argv[i-1],argv[i%ns])); + set_gen_value(hp_pos,symbolic(at_sto,makevecteur(add_attributs(tmp_plot,couleur,contextptr),gen(autoname(contextptr)+print_INT_(ns+i),contextptr))),false); + add_entry(hp_pos+1); + ++hp_pos; + } + } + else { + for (int i=mode;iundo_position=save_undo_position; + eval(pos0); + } + args_tmp.clear(); + args_tmp_push_size=0; + } + redraw(); + return 1; + } + return 0; + } + + void geosave(textArea * text,GIAC_CONTEXT){ + string s=remove_extension(text->filename); + gen tmp(s,contextptr); + if (tmp.type==_IDNT){ + sto(makevecteur(at_pnt,string2gen(merge_area(text->elements),false)),tmp,contextptr); + return; + } + else { + for (int i=0;i<10;++i){ + string s1=s+print_INT_(i); + tmp=gen(s1,contextptr); + if (tmp.type==_IDNT){ + confirm(lang==1?"Nom de sauvegarde reserve":"Unable to use reserved name",((lang==1?"Nom utilise ":"Name used ")+s1).c_str()); + sto(makevecteur(at_pnt,string2gen(merge_area(text->elements),false)),tmp,contextptr); + return; + } + } + } + confirm(lang==1?"Nom de sauvegarde reserve":"Unable to use reserved name",lang==1?"Sauvegarde impossible":"Unable to save"); + } + + void geohelp(GIAC_CONTEXT){ + textArea text; + text.editable=false; + text.clipline=-1; + text.title = (char*)((lang==1)?"Aide":"Help"); + text.allowF1=false; + text.python=false; + add(&text,lang==1? + "haut/bas/droit/gauche: change point de vue\ny^x ou e^x: trace 3d precis\nEsc/Back: quitte ou interrompt le trace 3d en cours\n( et ): modifie le rendu des surfaces raides 3d\n0: surfaces cachees 3d ON/OFF\n.: remplissage surface 3d raide ON/OFF\n5 reset 3d view\n7,8,9,1,2,3: deplacement 3d\n\nGeometrie\nF4: change le mode\nLe mode repere (shift 7) permet de changer le point de vue\nLe mode pointeur (shift 8) permet de bouger un objet et les objets dependants avec enter/OK et les touches de deplacement\nLes autres modes permettent de creer des objets\nEsc/Back: permet de passer en vue symbolique et de creer/modifier des objets par des commandes, taper enter/OK pour revenir en vue graphique\n4,6: modifie la profondeur du clic": + "up/down/right/left: modify viewpoint\nEsc/Back: leave or interrupt 3d rendering\ny^x or e^x: precise 3d\n( and ): modify stiff surfaces 3d rendering\n0: hidden 3d surfaces ON/OFF\n.: fill stiff 3d surfacesON/OFF\n5 reset 3d view\n7,8,9,1,2,3: move 3d view\n\nGeometry\nF4: change geometry mode\nFrame mode (shift F1): modify viewpoint\nPointer mode (shift F2): select an object and move it with enter/OK and cursor keys\nOther modes: create an object\nEsc/Back: go to symbolic view where you can create/modify objects with commands, press enter/OK to go back to graphic view"); + int exec=doTextArea(&text,contextptr); + } + + string inputparam(char curname,int symbolic,GIAC_CONTEXT){ + Menu paramenu; + paramenu.numitems=7; + MenuItem paramenuitems[paramenu.numitems]; + paramenu.items=paramenuitems; + paramenu.height=8; + paramenu.title = (char *)"Parameter"; + char menu_xcur[32],menu_xmin[32],menu_xmax[32],menu_xstep[32],menu_name[16]="name a"; + menu_name[5]=curname; + double pcur=0,pmin=-5,pmax=5,pstep=0.1; + std::string s; + bool doit; + for (;;){ + s="cur "+giac::print_DOUBLE_(pcur,contextptr); + strcpy(menu_xcur,s.c_str()); + s="min "+giac::print_DOUBLE_(pmin,contextptr); + strcpy(menu_xmin,s.c_str()); + s="max "+giac::print_DOUBLE_(pmax,contextptr); + strcpy(menu_xmax,s.c_str()); + s="step "+giac::print_DOUBLE_(pstep,contextptr); + strcpy(menu_xstep,s.c_str()); + paramenuitems[0].text = (char *) "OK"; + paramenuitems[1].text = (char *) menu_name; + paramenuitems[2].text = (char *) menu_xcur; + paramenuitems[3].text = (char *) menu_xmin; + paramenuitems[4].text = (char *) menu_xmax; + paramenuitems[5].text = (char *) menu_xstep; + paramenuitems[6].text = (char *) "Symbolic"; + paramenuitems[6].type = MENUITEM_CHECKBOX; + paramenuitems[6].value = symbolic; + int sres = doMenu(¶menu); + doit = sres==MENU_RETURN_SELECTION || sres==KEY_CTRL_EXE; + if (doit) { + std::string s1; double d; + if (paramenu.selection==2){ + handle_f5(); + if (inputline(menu_name,(lang==1)?"Nouvelle valeur?":"New value?",s1,false)==KEY_CTRL_EXE && s1.size()>0 && isalpha(s1[0])){ + if (s1.size()>10) + s1=s1.substr(0,10); + strcpy(menu_name,("name "+s1).c_str()); + } + continue; + } + if (paramenu.selection==3){ + inputdouble(menu_xcur,pcur,contextptr); + continue; + } + if (paramenu.selection==4){ + inputdouble(menu_xmin,pmin,contextptr); + continue; + } + if (paramenu.selection==5){ + inputdouble(menu_xmax,pmax,contextptr); + continue; + } + if (paramenu.selection==6){ + inputdouble(menu_xstep,pstep,contextptr); + pstep=fabs(pstep); + continue; + } + if (paramenu.selection==7){ + symbolic=1-symbolic; + continue; + } + // if (paramenu.selection==6) break; + } // end menu + break; + } // end for (;;) + if (doit && pmin0){ + if (symbolic){ + s="assume("; + s += (menu_name+5); + s += "=["; + s += (menu_xcur+4); + s += ','; + s += (menu_xmin+4); + s += ','; + s += (menu_xmax+4); + s += ','; + s += (menu_xstep+5); + s += "])"; + } + else { + s=(menu_name+5); + s += ":=element("; + s += (menu_xmin+4); + s += ".."; + s += (menu_xmax+4); + s += ','; + s += (menu_xcur+4); + s += ")"; + } + } else s=""; + return s; + } + + int Graph2d::ui(){ + Graph2d & gr=*this; + // UI + int saveprecision=gr.precision; + gr.precision += 2; // fast draw first + gr.draw(); + gr.precision=saveprecision; + gr.must_redraw=true; +#ifdef NSPIRE_NEWLIB + const char * msg="+-: zoom, pad: move, esc: quit"; +#else + const char * msg="+-: zoom, pad: move, EXIT: quit"; +#endif + DefineStatusMessage((char *)msg,1,0,0); + DisplayStatusArea(); + for (;;){ + int saveprec=gr.precision; + if (gr.doprecise){ + gr.doprecise=false; + gr.precision=1;//gr.precision-=2; + } + if (gr.must_redraw) + gr.draw(); + if (hp){ + string msg=hp->filename+":"+(mode==255?" Frame. Shift-1: help":modestr); + // help + int help_pos=args_tmp.empty()?0:args_tmp.size()-1; + if (help_pos='a' && key<='z'){ + bool found=false; + char ch=key; + gen tmp=gen(string("")+ch,contextptr); + if (tmp.type==_IDNT){ + int pos=0; + for (int i=0;ifeuille[0]; + ++pos; + if (name==tmp){ + current_j=7+14*pos; + found=true; + break; + } + } + } + } + if (found) + continue; + key -= 'a'-'A'; + } + if (key>='A' && key<='Z'){ + char ch=key; + gen tmp=gen(string("")+ch,contextptr); + if (tmp.type==_IDNT){ + tmp=evalf(tmp,1,contextptr); + if (tmp.is_symb_of_sommet(at_pnt)){ + tmp=remove_at_pnt(tmp); + if (tmp.is_symb_of_sommet(at_cercle)) + tmp=(tmp._SYMBptr->feuille[0]+tmp._SYMBptr->feuille[1])/2; + if (tmp.type==_SYMB) + tmp=tmp._SYMBptr->feuille; + if (tmp.type==_VECT && tmp.subtype!=_POINT__VECT && !tmp._VECTptr->empty()) + tmp=tmp._VECTptr->front(); + if (is3d && tmp.type==_VECT && tmp._VECTptr->size()==3 && tmp.subtype==_POINT__VECT){ + const vecteur & tv=*tmp._VECTptr; + gen x=tv[0],y=tv[1],z=tv[2]; + x=evalf_double(x,1,contextptr); + y=evalf_double(y,1,contextptr); + z=evalf_double(z,1,contextptr); + if (x.type==_DOUBLE_ && y.type==_DOUBLE_ && z.type==_DOUBLE_){ + double i,j; double3 d3; + xyz2ij(double3(x._DOUBLE_val,y._DOUBLE_val,z._DOUBLE_val),i,j,d3); + current_i=i; current_j=j; current_depth=d3.z; + } + } + if (!is3d && (tmp.type==_DOUBLE_ || tmp.type==_CPLX)){ + double x_scale=LCD_WIDTH_PX/(window_xmax-window_xmin); + double y_scale=LCD_HEIGHT_PX/(window_ymax-window_ymin); + double i,j; + findij(tmp,x_scale,y_scale,i,j,contextptr); + current_i=int(i+.5); + current_j=int(j+.5); + adjust_cursor_point_type(); + geo_handle(moving?FL_DRAG:FL_MOVE,key); + continue; + } + } + } + } + } + if (hp && (key==KEY_CTRL_CATALOG || key==KEY_BOOK )){ + const char * + tab[]={ + lang==1?"Mode repere":"Frame mode", // 0 + lang==1?"Pointeur":"Pointer", + lang==1?"Point":"Point", // 2 + is3d?"Sphere":"Circle", + lang==1?"Triangle":"Triangle", // 4 + lang==1?"Points":"Points", + lang==1?"Droites, plans":"Lines, planes", // 6 + lang==1?"Polygone, polyedre":"Polygon, polyhedron", + lang==1?"Cercle, conique, sphere":"Circle, conic, sphere", // 8 + lang==1?"Courbe, surface":"Curve, surface", // 9 + lang==1?"Curseur":"Cursor", // 10 + lang==1?"Transformations":"Transforms", + lang==1?"Mesures":"Mesures", // 12 + lang==1?"Effacer trace":"Clear trace", // -1 + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Mode",true); + if (choix<0 || choix>s) + continue; + if (choix==s-1){ + trace_instructions.clear(); + update_g(); + continue; + } + if (choix<=4){ + gen ftmp[]={0,0,at_point,at_segment,at_segment}; + gen ffinal[]={0,0,at_point,is3d?at_sphere:at_cercle,at_triangle}; + int mode[]={255,0,1,2,3}; + const char * help[]={"","","Point","Center,Point","Point1,Point2,Point3"}; + set_mode(ftmp[choix],ffinal[choix],mode[choix],help[choix]); + continue; + } + draw(); // for small choosebox, we must clean up previous choosebox + if (choix==5){ // Points + const char * + tab[]={ + lang==1?"Point":"Point", + lang==1?"Milieu":"Middle point", + lang==1?"Centre":"Center", + lang==1?"Intersection unique":"Single intersection", + lang==1?"Liste d'intersections":"List of intersections", + lang==1?"Element":"Element", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Points",true); + if (choix<0 || choix>s) + continue; + gen ftmp[]={at_point,at_segment,at_centre,at_inter_unique,at_inter,at_element}; + gen ffinal[]={at_point,at_milieu,at_centre,at_inter_unique,at_inter,at_element}; + int mode[]={1,2,1,2,2,1}; + const char * help[]={ + "Point", + "Point1,Point2", + "Circle", + "Line1,Line2", + "Curve1,Curve2", + "Curve", + }; + set_mode(ftmp[choix],ffinal[choix],mode[choix],help[choix]); + continue; + } + if (choix==6){ // Droites + const char * + tab[]={ + lang==1?"Segment":"Segment", + lang==1?"Vecteur":"Vector", + lang==1?"Demi-droite":"Halfline", + lang==1?"Droite":"Line", + lang==1?"Plan":"Plane", + lang==1?"Parallele":"Parallel", + lang==1?"Perpendiculaire":"Perpendicular", + lang==1?"Mediatrice":"Perpen_bisector", + lang==1?"Bissectrice":"Bisector", + lang==1?"Mediane":"Median line", + lang==1?"Tangente":"Tangent", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Droites, segments...",true); + if (choix<0 || choix>s) + continue; + gen ftmp[]={at_segment,at_vector,at_demi_droite,at_droite,at_segment,at_parallele,at_perpendiculaire,at_mediatrice,at_segment,at_segment,at_segment}; + gen ffinal[]={at_segment,at_vector,at_demi_droite,at_droite,at_plan,at_parallele,at_perpendiculaire,at_mediatrice,at_bissectrice,at_mediane,at_tangent}; + int mode[]={2,2,2,2,2,3,2,2,3,3,2}; + const char * help[]={ + "Point1,Point2", + "Point1,Point2", + "Point1,Point2", + "Point1,Point2", + "Point1,Point2,Point3", + "Point,Line", + "Point,Line", + "Point1,Point2", + "Sommet_angle,Point2,Point3", + "Sommet_angle,Point2,Point3", + "Curve,Point" + }; + set_mode(ftmp[choix],ffinal[choix],mode[choix],help[choix]); + continue; + } + if (choix==7){ // Polygons + const char * + tab[]={ + lang==1?"Triangle":"Triangle", + lang==1?"Triangle equilateral":"Equilateral triangle", + lang==1?"Carre":"Square", + lang==1?"Quadrilatere":"Quadrilateral", + lang==1?"Polygone":"Polygon", + lang==1?"Tetraedre (pyramide)":"Tetrahedron (Pyramid)", + lang==1?"Tetraedre regulier":"Regular tetrahedron", + lang==1?"Cube":"Cube", + lang==1?"Octaedre":"Octahedron", + lang==1?"Dodecaedre":"Dodecahedron", + lang==1?"Icosaedre":"Icosahedron", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Droites, segments...",true); + if (choix<0 || choix>s) + continue; + gen ftmp[]={at_polygone_ouvert,at_segment,at_segment,at_polygone_ouvert,at_polygone_ouvert,at_polygone_ouvert,at_polygone_ouvert,at_polygone_ouvert,at_polygone_ouvert,at_polygone_ouvert,at_polygone_ouvert}; + gen ffinal[]={at_triangle,at_triangle_equilateral,at_carre,at_quadrilatere,at_polygone,at_tetraedre,at_tetraedre,at_cube,at_octaedre,at_dodecaedre,at_icosaedre}; + int mode[]={3,2,2,4,5,4,3,3,3,3,3}; + int m=mode[choix]; + if (choix==4){ + double d=5; + if (inputdouble(lang==1?"Nombre de sommets?":"Number of vertices?",d,contextptr) && d==int(d) && d>=3 && d<20){ + m=d; + } + else continue; + } + const char * help[]={ + "Point1,Point2,Point3", + "Point1,Point2", + "Point1,Point2", + "Point1,Point2,Point3,Point4", + "Point1,Point2,Point3,Point4,Point5", + "Point1,Point2,Point3,Point4", + "Point1,Point2,Point3", + "Point1,Point2,Point3", + "Point1,Point2,Point3", + "Point1,Point2,Point3", + "Point1,Point2,Point3", + }; + set_mode(ftmp[choix],ffinal[choix],m,help[choix]); + continue; + } + if (choix==8){ // Conics + const char * + tab[]={ + lang==1?"cercle":"circle", + lang==1?"circonscrit":"circumcircle", + lang==1?"inscrit":"incircle", + lang==1?"ellipse":"ellipse", + lang==1?"hyperbole":"hyperbola", + lang==1?"parabole":"parabola", + lang==1?"sphere":"sphere", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Conic",true); + if (choix<0 || choix>s) + continue; + gen ftmp[]={at_segment,at_segment,at_segment,at_segment,at_segment,at_segment,at_segment}; + gen ffinal[]={at_cercle,at_circonscrit,at_inscrit,at_ellipse,at_hyperbole,at_parabole,at_sphere}; + int mode[]={2,3,3,3,3,2,2}; + const char * help[]={ + "Center,Point", + "Point1,Point2,Point3", + "Point1,Point2,Point3", + "Focus1,Focus2,Point_on_ellipse", + "Focus1,Focus2,Point_on_hyperbola", + "Focus,Point_or_line", + "Center,Point", + }; + set_mode(ftmp[choix],ffinal[choix],mode[choix],help[choix]); + continue; + } + if (choix==9){ // Curves + const char * + tab[]={ + lang==1?"Fonction plot(sin(x))":"Function plot(sin(x))", + lang==1?"Param. plotparam([x^2,x^3])":"Param. plotparam([x^2,x^3])", + lang==1?"Polaire plotpolar(x)":"Polar plotpolar(x)", + lang==1?"Implicit plot(x^2+y^4=6)":"Implicit plot(x^2+y^4=6)", + lang==1?"Champ des tangentes":"Plotfield", + lang==1?"Solution equa. diff.":"Diff. equa. solution", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Courbe",true); + if (choix<0 || choix>s) + continue; + const char * cmd[]={"plot()","plotparam()","plotpolar()","plot()","plotfield()","plotode()"}; + hp->line=hp->add_entry(-1); + string mycmd=autoname(contextptr)+":="+cmd[choix]; + autoname_plus_plus(); + hp->set_string_value(hp->line,mycmd); + hp->pos=mycmd.size()-1; + return KEY_CTRL_OK; + } + if (choix==10){ + gen param=0; + for (char ch='a';ch<='z';++ch){ + gen tmp(string("")+ch,contextptr); + if (tmp.type!=_IDNT) continue; + param=tmp.eval(1,contextptr); + if (param==tmp) + break; + } + if (param==0){ + confirm(lang==1?"Plus de variables libres.":"No more free variable available",lang==1?"Essayez purge(a) ou purge(b) ou ...":"Try purge(a) or purge(b) or ..."); + continue; + } + string mycmd=inputparam(param.print()[0],0,contextptr); + if (!mycmd.empty()){ + hp->line=hp->add_entry(-1); + // string mycmd=param.print()+":=element(0..1,0.5)"; + // autoname_plus_plus(); + hp->set_string_value(hp->line,mycmd); + hp->pos=mycmd.size()-1; + } + return KEY_CTRL_OK; + } + if (choix==11){ // Transforms + const char * + tab[]={ + lang==1?"symetrie":"reflexion", + lang==1?"rotation":"rotation", + lang==1?"translation":"translation", + lang==1?"projection":"projection", + lang==1?"homothetie":"homothety", + lang==1?"similitude":"similarity", + // lang==1?"":"", + // lang==1?"":"", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Transform",true); + if (choix<0 || choix>s) + continue; + gen ftmp[]={at_segment,at_polygone_ouvert,at_segment,at_segment,at_segment,at_polygone_ouvert}; + gen ffinal[]={at_symetrie,at_rotation,at_translation,at_projection,at_homothetie,at_similitude}; + int mode[]={2,3,2,2,2,3}; + const char * help[]={ + "Symmetry_center_axis,Object", + "Center,Angle,Object", + "Vector,Object", + "Curve,Object", + "Center,Ratio,Object", + "Center,Ratio,Angle,Object" + }; + set_mode(ftmp[choix],ffinal[choix],mode[choix],help[choix]); + continue; + } + if (choix==12){ // Mesures + const char * + tab[]={ + lang==1?"distance":"distance", + lang==1?"angle":"angle", + lang==1?"aire":"area", + lang==1?"perimetre":"perimeter", + lang==1?"pente":"slope", + lang==1?"distance seule":"distance raw", + lang==1?"angle seul":"angle raw", + lang==1?"aire seule":"area raw", + lang==1?"perimetre seul":"perimeter raw", + lang==1?"pente seule":"slope raw", + 0}; + const int s=sizeof(tab)/sizeof(char *); + int choix=select_item(tab,"Mesures",true); + if (choix<0 || choix>s) + continue; + gen ftmp[]={at_segment,at_triangle,at_areaat,at_perimeterat,at_slopeat,at_segment,at_triangle,at_areaatraw,at_perimeteratraw,at_slopeatraw}; + gen ffinal[]={at_distanceat,at_angleat,at_areaat,at_perimeterat,at_slopeat,at_distanceatraw,at_angleatraw,at_areaatraw,at_perimeteratraw,at_slopeatraw}; + int mode[]={3,4,2,2,2,3,4,2,2,2}; + const char * help[]={ + "Object1,Object2,Position", + "Angle_vertex,Direction1,Direction2,Position", + "Object,Position", + "Object,Position", + "Object,Position", + "Object1,Object2,Position", + "Angle_vertex,Direction1,Direction2,Position", + "Object,Position", + "Object,Position", + "Object,Position", + }; + set_mode(ftmp[choix],ffinal[choix],mode[choix],help[choix]); + continue; + } + continue; + } + + if (key==KEY_CTRL_MENU || key==KEY_CTRL_F6){ + char menu_xmin[32],menu_xmax[32],menu_ymin[32],menu_ymax[32],menu_zmin[32],menu_zmax[32],menu_depth[32]; + for (;;){ + string s; + s="xmin "+print_DOUBLE_(gr.window_xmin,contextptr); + strcpy(menu_xmin,s.c_str()); + s="xmax "+print_DOUBLE_(gr.window_xmax,contextptr); + strcpy(menu_xmax,s.c_str()); + s="ymin "+print_DOUBLE_(gr.window_ymin,contextptr); + strcpy(menu_ymin,s.c_str()); + s="ymax "+print_DOUBLE_(gr.window_ymax,contextptr); + strcpy(menu_ymax,s.c_str()); + s="zmin 3d "+print_DOUBLE_(gr.window_zmin,contextptr); + strcpy(menu_zmin,s.c_str()); + s="zmax 3d "+print_DOUBLE_(gr.window_zmax,contextptr); + strcpy(menu_zmax,s.c_str()); + s="depth 3d "+print_DOUBLE_(gr.current_depth,contextptr); + strcpy(menu_depth,s.c_str()); + Menu smallmenu; + smallmenu.numitems=19; + MenuItem smallmenuitems[smallmenu.numitems]; + smallmenu.items=smallmenuitems; + smallmenu.height=12; + //smallmenu.title = "KhiCAS"; + smallmenuitems[0].text = (char *) menu_xmin; + smallmenuitems[1].text = (char *) menu_xmax; + smallmenuitems[2].text = (char *) menu_ymin; + smallmenuitems[3].text = (char *) menu_ymax; + smallmenuitems[4].text = (char *) menu_zmin; + smallmenuitems[5].text = (char *) menu_zmax; + smallmenuitems[6].text = (char *) menu_depth; + smallmenuitems[7].text = (char *) ((lang==1)?"Aide":"Help"); + smallmenuitems[8].text = (char*) (lang==1?"Sauvegarder figure":"Save figure"); + smallmenuitems[9].text = (char*) (lang==1?"Sauvegarder comme":"Save as"); + smallmenuitems[10].text = (char*)((lang==1)?"Quitter":"Quit"); + smallmenuitems[11].text = (char*) "Orthonormalize /"; + smallmenuitems[12].text = (char*) "Autoscale *"; + smallmenuitems[13].text = (char *) ("Zoom in +"); + smallmenuitems[14].text = (char *) ("Zoom out -"); + smallmenuitems[15].text = (char *) ("Y-Zoom out (-)"); + smallmenuitems[16].text = (char*) ((lang==1)?"Voir axes":"Show axes"); + smallmenuitems[17].text = (char*) ((lang==1)?"Cacher axes":"Hide axes"); + smallmenuitems[18].text = (char*) ((lang==1)?"Effacer trace":"Clear trace"); + drawRectangle(0,180,LCD_WIDTH_PX,60,_BLACK); + int sres = doMenu(&smallmenu); + if (sres == MENU_RETURN_EXIT) + break; + if (sres == MENU_RETURN_SELECTION || sres==KEY_CTRL_EXE) { + const char * ptr=0; + string s1; double d; + if (smallmenu.selection==1){ + d=gr.window_xmin; + if (inputdouble(menu_xmin,d,200,contextptr)){ gr.window_xmin=d; gr.update(); } @@ -8719,40 +10773,105 @@ namespace xcas { gr.update(); } } - if (smallmenu.selection==7) + if (smallmenu.selection==7){ + d=gr.current_depth; + if (inputdouble(menu_depth,d,200,contextptr)){ + if (d<-1) d=-1; + if (d>1) d=1; + gr.current_depth=d; + gr.update(); + } + } + if (smallmenu.selection==8){ + geohelp(contextptr); continue; + // gr.q=quaternion_double(0,0,0); gr.update(); + } + if (hp && smallmenu.selection==9){ + // save + geosave(hp,contextptr); + continue; + } + if (smallmenu.selection==9 || smallmenu.selection==10){ + // save as + char filename[MAX_FILENAME_SIZE+1]; + if (get_filename(filename,".py") && newgeo(contextptr)==0){ + geoptr->hp->filename=filename; + if (geoptr!=this && !symbolic_instructions.empty()){ + geoptr->symbolic_instructions=symbolic_instructions; + geoptr->hp->elements.clear(); + for (int i=0;ihp->set_string_value(i,symbolic_instructions[i].print(contextptr)); + } + geoloop(geoptr); + return 0; + } + } + } + if (smallmenu.selection==11) + return -4; + if (smallmenu.selection==12) gr.orthonormalize(); - if (smallmenu.selection==8) + if (smallmenu.selection==13) gr.autoscale(); - if (smallmenu.selection==9) + if (smallmenu.selection==14) gr.zoom(0.7); - if (smallmenu.selection==10) + if (smallmenu.selection==15) gr.zoom(1/0.7); - if (smallmenu.selection==11) + if (smallmenu.selection==16) gr.zoomy(1/0.7); - if (smallmenu.selection==12){ - xcas::textArea text; - text.editable=false; - text.clipline=-1; - text.title = (char*)((lang==1)?"Raccourcis clavier 3d":"3d Keyboard shortcuts"); - text.allowF1=false; - text.python=false; - add(&text,lang==1?"haut/bas/droit/gauche: change point de vue\ny^x ou e^x: trace precis\nON/Back: interrompt le trace en cours\n( et ): modifie le rendu des surfaces raides\n0: surfaces cachees ON/OFF\n.: remplissage surface raide ON/OFF\n5 reset view\n7,8,9,1,2,3: deplacement":"up/down/right/left: modify viewpoint\nON/Back: interrupt\ny^x or e^x: precise\n( and ): modify stiff surfaces rendering\n0: hidden surfaces ON/OFF\n.: fill stiff surfacesON/OFF\n5 reset view\n7,8,9,1,2,3: move view"); - int exec=doTextArea(&text,contextptr); - // gr.q=quaternion_double(0,0,0); gr.update(); - } - if (smallmenu.selection==13) + if (smallmenu.selection==17) gr.show_axes=true; - if (smallmenu.selection==14) + if (smallmenu.selection==18) gr.show_axes=false; - if (smallmenu.selection==15) - break; + if (smallmenu.selection==19){ + gr.trace_instructions.clear(); + update_g(); + } + } + } + gr.draw(); + gr.must_redraw=false; + continue; + } + + if (hp && key==KEY_CTRL_OK){ + if (mode==255) + return key; + if (!moving){ + pushed=true; + push_i=current_i; + push_j=current_j; + push_depth = current_depth; + geo_handle(FL_PUSH,KEY_CTRL_OK); + if (moving){ + update_g(); + continue; } } + int res=geo_handle(FL_RELEASE,KEY_CTRL_OK); + pushed=false; + update_g(); + continue; + } + if (hp && key==KEY_CTRL_EXIT && mode!=255){ + if (mode==0){ // restore original value and reeval + geo_handle(FL_RELEASE,KEY_CTRL_EXIT); + // do_handle(symbolic(at_sto,makevecteur(drag_original_value,drag_name))); + if (!pushed) + set_mode(0,0,255,""); + } + else + if (args_tmp.empty()) + set_mode(0,0,255,""); + pushed=false; + moving=moving_frame=false; + args_tmp.clear(); + update_g(); + continue; } -#endif if (key==KEY_CTRL_EXIT || key==KEY_CTRL_OK){ os_hide_graph(); - break; + return key; } if (key==KEY_CHAR_NORMAL || key=='>'){ // shift-+ if (gr.is3d && gr.precision<9) @@ -8763,6 +10882,16 @@ namespace xcas { gr.precision--; } if (key==KEY_CTRL_UP){ + if (hp && mode!=255){ + --current_j; + if (current_j<0){ + gr.up((gr.window_ymax-gr.window_ymin)/5); + current_j += LCD_HEIGHT_PX/5; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } if (gr.is3d){ int curprec=gr.precision; gr.precision += 2; @@ -8776,7 +10905,7 @@ namespace xcas { gr.q=rotation_2_quaternion_double(0.707,0.707,0,15)*gr.q;// quaternion_double(15,0,0)*gr.q; gr.update_rotation(); gr.draw(); - redraw=gr.solid3d; + gr.must_redraw=gr.solid3d; #ifndef SIMU if (!iskeydown(KEY_CTRL_UP)) break; @@ -8787,12 +10916,32 @@ namespace xcas { gr.precision=curprec; continue; } - gr.up((gr.window_ymax-gr.window_ymin)/5); + gr.up((gr.window_ymax-gr.window_ymin)/16); } if (key==KEY_CTRL_PAGEUP) { - gr.up((gr.window_ymax-gr.window_ymin)/2); + if (hp && mode!=255){ + current_j-=LCD_HEIGHT_PX/5;; + if (current_j<0){ + gr.up((gr.window_ymax-gr.window_ymin)/2); + current_j += LCD_HEIGHT_PX/2; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } + gr.up((gr.window_ymax-gr.window_ymin)/4); } if (key==KEY_CTRL_DOWN) { + if (hp && mode!=255){ + ++current_j; + if (current_j>=LCD_HEIGHT_PX-24){ + gr.down((gr.window_ymax-gr.window_ymin)/5); + current_j -= LCD_HEIGHT_PX/5; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } if (gr.is3d){ int curprec=gr.precision; gr.precision += 2; @@ -8806,7 +10955,7 @@ namespace xcas { gr.q=rotation_2_quaternion_double(0.707,0.707,0,-15)*gr.q; // quaternion_double(-15,0,0)*gr.q; gr.update_rotation(); gr.draw(); - redraw=gr.solid3d; + gr.must_redraw=gr.solid3d; #ifndef SIMU if (!iskeydown(KEY_CTRL_DOWN)) break; @@ -8817,12 +10966,32 @@ namespace xcas { gr.precision=curprec; continue; } - gr.down((gr.window_ymax-gr.window_ymin)/5); + gr.down((gr.window_ymax-gr.window_ymin)/16); } if (key==KEY_CTRL_PAGEDOWN) { - gr.down((gr.window_ymax-gr.window_ymin)/2); + if (hp && mode!=255){ + current_j += LCD_HEIGHT_PX/5; + if (current_j>=LCD_HEIGHT_PX-24){ + gr.down((gr.window_ymax-gr.window_ymin)/2); + current_j -= LCD_HEIGHT_PX/2; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } + gr.down((gr.window_ymax-gr.window_ymin)/4); } if (key==KEY_CTRL_LEFT) { + if (hp && mode!=255){ + --current_i; + if (current_i<0){ + gr.left((gr.window_xmax-gr.window_xmin)/5); + current_i += LCD_WIDTH_PX/5; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } if (gr.is3d){ int curprec=gr.precision; gr.precision += 2; @@ -8831,7 +11000,7 @@ namespace xcas { gr.q=quaternion_double(0,15,0)*gr.q; gr.update_rotation(); gr.draw(); - redraw=gr.solid3d; + gr.must_redraw=gr.solid3d; #ifndef SIMU if (!iskeydown(KEY_CTRL_LEFT)) break; @@ -8842,10 +11011,32 @@ namespace xcas { gr.precision=curprec; continue; } - gr.left((gr.window_xmax-gr.window_xmin)/5); + gr.left((gr.window_xmax-gr.window_xmin)/16); + } + if (key==KEY_SHIFT_LEFT) { + if (hp && mode!=255){ + current_i -= LCD_WIDTH_PX/5; + if (current_i<0){ + gr.left((gr.window_xmax-gr.window_xmin)/2); + current_i += LCD_WIDTH_PX/2; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } + gr.left((gr.window_xmax-gr.window_xmin)/4); } - if (key==KEY_SHIFT_LEFT) { gr.left((gr.window_xmax-gr.window_xmin)/2); } if (key==KEY_CTRL_RIGHT) { + if (hp && mode!=255){ + ++current_i; + if (current_i>=LCD_WIDTH_PX){ + gr.right((gr.window_xmax-gr.window_xmin)/5); + current_i -= LCD_WIDTH_PX/5; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } if (gr.is3d){ int curprec=gr.precision; gr.precision += 2; @@ -8854,7 +11045,7 @@ namespace xcas { gr.q=quaternion_double(0,-15,0)*gr.q; gr.update_rotation(); gr.draw(); - redraw=gr.solid3d; + gr.must_redraw=gr.solid3d; #ifndef SIMU if (!iskeydown(KEY_CTRL_RIGHT)) break; @@ -8865,9 +11056,21 @@ namespace xcas { gr.precision=curprec; continue; } - gr.right((gr.window_xmax-gr.window_xmin)/5); + gr.right((gr.window_xmax-gr.window_xmin)/16); + } + if (key==KEY_SHIFT_RIGHT) { + if (hp && mode!=255){ + current_i += LCD_WIDTH_PX/5; + if (current_i>=LCD_WIDTH_PX){ + gr.right((gr.window_xmax-gr.window_xmin)/2); + current_i -= LCD_WIDTH_PX/2; + } + geo_handle(moving?FL_DRAG:FL_MOVE,key); + update_g(); + continue; + } + gr.right((gr.window_xmax-gr.window_xmin)/4); } - if (key==KEY_SHIFT_RIGHT) { gr.right((gr.window_xmax-gr.window_xmin)/5); } if (key==KEY_CHAR_PLUS) { gr.zoom(0.7); } @@ -8893,6 +11096,14 @@ namespace xcas { if (key==KEY_CHAR_ANS){ gr.show_edges=!gr.show_edges; } + if (key==KEY_CHAR_4){ + if (current_depth>-1) + current_depth-=0.1; + } + if (key==KEY_CHAR_6){ + if (current_depth<1) + current_depth+=0.1; + } if (key==KEY_CHAR_5){ gr.q=quaternion_double(0,0,0); gr.update(); @@ -8928,8 +11139,17 @@ namespace xcas { if (key==KEY_CHAR_RPAR && gr.diffusionz>2) gr.diffusionz--; } - if (key==KEY_CTRL_VARS) { + if (key==KEY_CHAR_SIN) { gr.show_axes=!gr.show_axes; + gr.update(); + gr.draw(); + gr.must_redraw=false; + } + if (key==KEY_CTRL_VARS){ + select_var(contextptr); + gr.update(); + gr.draw(); + gr.must_redraw=false; } } // aborttimer = Timer_Install(0, check_execution_abort, 100); if (aborttimer > 0) { Timer_Start(aborttimer); } @@ -10181,7 +12401,7 @@ namespace xcas { return 0; } if (ispnt(ge)){ - if (displaygraph(ge,contextptr)==KEY_SHUTDOWN) + if (displaygraph(ge,g,contextptr)==KEY_SHUTDOWN) return KEY_SHUTDOWN; // aborttimer = Timer_Install(0, check_execution_abort, 100); if (aborttimer > 0) { Timer_Start(aborttimer); } return 0; @@ -10279,7 +12499,7 @@ namespace xcas { } } - int check_do_graph(giac::gen & ge,int do_logo_graph_eqw,GIAC_CONTEXT) { + int check_do_graph(giac::gen & ge,const gen & gs,int do_logo_graph_eqw,GIAC_CONTEXT) { if (ge.type==giac::_SYMB || (ge.type==giac::_VECT && !ge._VECTptr->empty() && !is_numericv(*ge._VECTptr)) ){ if (islogo(ge)){ if (do_logo_graph_eqw & 4){ @@ -10290,7 +12510,7 @@ namespace xcas { } if (ispnt(ge)){ if (do_logo_graph_eqw & 2){ - if (displaygraph(ge,contextptr)==KEY_SHUTDOWN) + if (displaygraph(ge,gs,contextptr)==KEY_SHUTDOWN) return KEY_SHUTDOWN; } // aborttimer = Timer_Install(0, check_execution_abort, 100); if (aborttimer > 0) { Timer_Start(aborttimer); } @@ -10445,12 +12665,13 @@ namespace xcas { } else { set_abort(); + gen gs=g; g=protecteval(g,1,contextptr); clear_abort(); giac::ctrl_c=false; kbd_interrupted=giac::interrupted=false; // define the function - if (check_do_graph(g,7,contextptr)==KEY_SHUTDOWN) + if (check_do_graph(g,gs,7,contextptr)==KEY_SHUTDOWN) return KEY_SHUTDOWN; DefineStatusMessage((char *)((lang==1)?"Syntaxe correcte":"Parse OK"),1,0,0); } @@ -10539,6 +12760,50 @@ namespace xcas { fix_newlines(edptr); } + void textArea::set_string_value(int n,const string & s){ + if (n==-1 || n>=elements.size()){ + textElement t; t.s=s; + if (!elements.empty()) + t.newLine=1; + elements.push_back(t); + } + else { + elements[n].s=s; + if (n) + elements[n].newLine=1; + } + changed=true; + } + + int textArea::add_entry(int n){ + textElement t; + if (n==-1 || n>=elements.size()){ + if (elements.empty()) + elements.push_back(t); + else { + t.newLine=1; + if (!elements.back().s.empty()) + elements.push_back(t); + } + n=elements.size()-1; + } + else { + if (n) t.newLine=1; + elements.insert(elements.begin()+n,t); + } + return n; + } + + void Graph2d::add_entry(int n){ + if (!hp) + return; + if (n==-1 || n>=symbolic_instructions.size()){ + symbolic_instructions.push_back(0); + n=symbolic_instructions.size(); + } + hp->add_entry(n); + } + int find_indentation(const std::string & s){ size_t indent=0; for (;indenteditable; int showtitle = !editable && (text->title != NULL); std::vector & v=text->elements; + if (v.empty()) v.push_back(textElement()); //drawRectangle(text->x, text->y+24, text->width, LCD_HEIGHT_PX-24, COLOR_WHITE); // insure cursor is visible if (editable && !isFirstDraw){ @@ -11151,6 +13417,11 @@ namespace xcas { deltax=27; } } + if (v.empty()){ + textElement cur; + cur.s=""; + v.push_back(cur); + } int & clipline=text->clipline; int & clippos=text->clippos; int & textline=text->line; @@ -11457,7 +13728,10 @@ namespace xcas { if (editable){ waitforvblank(); drawRectangle(0,205,LCD_WIDTH_PX,17,44444); - PrintMiniMini(0,205,text->python>0?"shift-1 test|2 loop|3 undo|4 misc|5 +-|6 logo|7 lin|8 list|9arit":"shift-1 test|2 loop|3 undo|4 misc|5 +-|6 logo|7 matr|8 cplx",4,44444,giac::_BLACK); + if (text->gr) + PrintMiniMini(0,205,"shift-1 pnts|2 lines|3 undo|4 disp|5 +-|6 curves|7 triangle|8 polygon|9 solid",4,giac::_CYAN,giac::_BLACK); + else + PrintMiniMini(0,205,text->python>0?"shift-1 test|2 loop|3 undo|4 misc|5 +-|6 logo|7 lin|8 list|9arit":"shift-1 test|2 loop|3 undo|4 misc|5 +-|6 logo|7 matr|8 cplx",4,44444,giac::_BLACK); //draw_menu(1); } #ifdef SCROLLBAR @@ -12032,12 +14306,16 @@ namespace xcas { (key >= KEY_CTRL_F6 && key <= KEY_CTRL_F16) ){ string le_menu; - if (xcas_python_eval==1)//text->python? - le_menu="F1 test\nif \nelse \n<\n>\n==\n!=\n&&\n||\nF2 loop\nfor \nfor in\nrange(\nwhile \nbreak\ndef\nreturn \n#\nF4 misc\n:\n;\n_\n!\n%\nfrom import *\nprint(\ninput(\nF6 tortue\nforward(\nbackward(\nleft(\nright(\npencolor(\ncircle(\nreset()\nfrom turtle import *\nF: plot\nplot(\ntext(\narrow(\nlinear_regression_plot(\nscatter(\naxis(\nbar(\nfrom matplotl import *\nF7 linalg\nadd(\nsub(\nmul(\ninv(\ndet(\nrref(\ntranspose(\nfrom linalg import *\nF< color\nred\nblue\ngreen\ncyan\nyellow\nmagenta\nblack\nwhite\nF; draw\nset_pixel(\ndraw_line(\ndraw_rectangle(\nfill_rect(\ndraw_polygon(\ndraw_circle(\ndraw_string(\nfrom graphic import *\nF8 numpy\narray(\nreshape(\narange(\nlinspace(\nsolve(\neig(\ninv(\nfrom numpy import *\nF9 arit\npow(\nisprime(\nnextprime(\nifactor(\ngcd(\nlcm(\niegcd(\nfrom arit import *\n"; - if (xcas_python_eval<=0) - le_menu="F1 test\nif \nelse \n<\n>\n==\n!=\nand\nor\nF2 loop\nfor \nfor in\nrange(\nwhile \nbreak\nf(x):=\nreturn \nvar\nF4 misc\n;\n:\n_\n!\n%\n&\nprint(\ninput(\nF6 tortue\navance\nrecule\ntourne_gauche\ntourne_droite\nrond\ndisque\nrepete\nefface\nF7 lin\nmatrix(\ndet(\nmatpow(\nranm(\nrref(\ntran(\negvl(\negv(\nF9 arit\n mod \nirem(\nifactor(\ngcd(\nisprime(\nnextprime(\npowmod(\niegcd(\nF< plot\nplot(\nplotseq(\nplotlist(\nplotparam(\nplotpolar(\nplotfield(\nhistogram(\nbarplot(\nF: misc\n<\n>\n_\n!\n % \nrand(\nbinomial(\nnormald(\nF8 cplx\nabs(\narg(\nre(\nim(\nconj(\ncsolve(\ncfactor(\ncpartfrac(\n"; - if (xcas_python_eval>=0) - le_menu += "F= list\nmakelist(\nrange(\nseq(\nlen(\nappend(\nranv(\nsort(\napply(\nF; real\nexact(\napprox(\nfloor(\nceil(\nround(\nsign(\nmax(\nmin(\nF> prog\n;\n:\n\\\n&\n?\n!\ndebug(\npython(\nF? geo\npoint(\nline(\nsegment(\ncircle(\ntriangle(\nplane(\nsphere(\nsingle_inter(\nF@ color\ncolor=\nred\ncyan\ngreen\nblue\nmagenta\nyellow\nlegend("; + if (text->gr) { // geometry menu + le_menu="F1 points\npoint(\nmidpoint(\ncenter(\nelement(\nsingle_inter(\ninter(\nlegende(\ntrace(\nF2 lines\nsegment(\nline(\nhalf_line(\nvector(\nparallel(\nperpendicular(\ntangent(\nplane(\ncircle(\nF4 disp\ndisplay=\nfilled\nred\nblue\ngreen\ncyan\nmagenta\nyellow\nF6 curves\ncircle(\nellipse(\nhyperbola(\nparabola(\nplot(\nplotparam(\nplotpolar(\nplotode(\nF7 triangle\ntriangle(\nequilateral_triangle(\nmedian(\nperpen_bisector(\nbisector(\nisobarycenter(\nF8 polygon\nsquare(\nrectangle(\nquadrilateral(\nhexagon(\npolygon(\nisopolygon(\nvertices(\nF9 3d\nplane(\ncube(\ntetrahedron(\nsphere(\ncone(\nhalf_cone(\ncylinder(\nplot3d(\nF: transf\nprojection(\nreflection(\ntranslation(\nrotation(\nhomothety(\nsimilarity(\nF; geodiff\ntangent(\nosculating_circle(\nevolute(\ncurvature(\nfrenet(\noctahedron(\ndodecahedron(\nicosahedron(\nF< mesures\ndistance(\ndistance2(\nradius(\naire(\nperimetre(\npente(\nangle(\nF= test\nis_collinear(\nis_concyclic(\nis_coplanar(\nis_cospherical(\nis_element(\nis_parallel(\nis_perpendicular(\nF> analyt\ncoordonnees(\nequation(\nparameq(\nabscisse(\nordonnee(\naffixe(\narg(\n"; + } else { + if (xcas_python_eval==1)//text->python? + le_menu="F1 test\nif \nelse \n<\n>\n==\n!=\n&&\n||\nF2 loop\nfor \nfor in\nrange(\nwhile \nbreak\ndef\nreturn \n#\nF4 misc\n:\n;\n_\n!\n%\nfrom import *\nprint(\ninput(\nF6 tortue\nforward(\nbackward(\nleft(\nright(\npencolor(\ncircle(\nreset()\nfrom turtle import *\nF: plot\nplot(\ntext(\narrow(\nlinear_regression_plot(\nscatter(\naxis(\nbar(\nfrom matplotl import *\nF7 linalg\nadd(\nsub(\nmul(\ninv(\ndet(\nrref(\ntranspose(\nfrom linalg import *\nF< color\nred\nblue\ngreen\ncyan\nyellow\nmagenta\nblack\nwhite\nF; draw\nset_pixel(\ndraw_line(\ndraw_rectangle(\nfill_rect(\ndraw_polygon(\ndraw_circle(\ndraw_string(\nfrom graphic import *\nF8 numpy\narray(\nreshape(\narange(\nlinspace(\nsolve(\neig(\ninv(\nfrom numpy import *\nF9 arit\npow(\nisprime(\nnextprime(\nifactor(\ngcd(\nlcm(\niegcd(\nfrom arit import *\n"; + if (xcas_python_eval<=0) + le_menu="F1 test\nif \nelse \n<\n>\n==\n!=\nand\nor\nF2 loop\nfor \nfor in\nrange(\nwhile \nbreak\nf(x):=\nreturn \nvar\nF4 misc\n;\n:\n_\n!\n%\n&\nprint(\ninput(\nF6 tortue\navance\nrecule\ntourne_gauche\ntourne_droite\nrond\ndisque\nrepete\nefface\nF7 lin\nmatrix(\ndet(\nmatpow(\nranm(\nrref(\ntran(\negvl(\negv(\nF9 arit\n mod \nirem(\nifactor(\ngcd(\nisprime(\nnextprime(\npowmod(\niegcd(\nF< plot\nplot(\nplotseq(\nplotlist(\nplotparam(\nplotpolar(\nplotfield(\nhistogram(\nbarplot(\nF: misc\n<\n>\n_\n!\n % \nrand(\nbinomial(\nnormald(\nF8 cplx\nabs(\narg(\nre(\nim(\nconj(\ncsolve(\ncfactor(\ncpartfrac(\n"; + if (xcas_python_eval>=0) + le_menu += "F= list\nmakelist(\nrange(\nseq(\nlen(\nappend(\nranv(\nsort(\napply(\nF; real\nexact(\napprox(\nfloor(\nceil(\nround(\nsign(\nmax(\nmin(\nF> prog\n;\n:\n\\\n&\n?\n!\ndebug(\npython(\nF? geo\npoint(\nline(\nsegment(\ncircle(\ntriangle(\nplane(\nsphere(\nsingle_inter(\nF@ color\ncolor=\nred\ncyan\ngreen\nblue\nmagenta\nyellow\nlegend("; + } // else not geometry const char * ptr=console_menu(key,(char*)(le_menu.c_str()),2); if (!ptr){ show_status(text,search,replace); @@ -12163,7 +14441,7 @@ namespace xcas { } continue; case KEY_CTRL_OK: - if (text->allowEXE || !text->editable) return TEXTAREA_RETURN_EXE; + if (text->gr || text->allowEXE || !text->editable) return TEXTAREA_RETURN_EXE; if (search.size()){ for (;;){ if (!move_to_word(text,search,replace,isFirstDraw,totalTextY,scroll,textY,contextptr)) @@ -13370,7 +15648,7 @@ namespace xcas { vout.erase(vout.begin()); vout.push_back(ge); } - if (check_do_graph(ge,do_logo_graph_eqw,contextptr)==KEY_SHUTDOWN) + if (check_do_graph(ge,g,do_logo_graph_eqw,contextptr)==KEY_SHUTDOWN) return KEY_SHUTDOWN; string s_; if (ge.type==giac::_STRNG) @@ -14537,7 +16815,7 @@ namespace xcas { numworks_certify_internal(); Bdisp_AllClr_VRAM(); int x=0,y=0; - PrintMini(x,y,"KhiCAS 1.7 (c) 2022 B. Parisse",TEXT_MODE_NORMAL, COLOR_BLACK, COLOR_WHITE); + PrintMini(x,y,"KhiCAS 1.9 (c) 2022 B. Parisse",TEXT_MODE_NORMAL, COLOR_BLACK, COLOR_WHITE); y +=18; PrintMini(x,y,"et al, License GPL 2",TEXT_MODE_NORMAL,COLOR_BLACK, COLOR_WHITE); y += 18; @@ -15323,80 +17601,10 @@ namespace xcas { break; } if (smallmenu.selection == 15){ - Menu paramenu; - paramenu.numitems=6; - MenuItem paramenuitems[paramenu.numitems]; - paramenu.items=paramenuitems; - paramenu.height=12; - paramenu.title = (char *)"Parameter"; - char menu_xcur[32],menu_xmin[32],menu_xmax[32],menu_xstep[32],menu_name[16]="name a"; static char curname='a'; - menu_name[5]=curname; - ++curname; - double pcur=0,pmin=-5,pmax=5,pstep=0.1; - std::string s; - bool doit; - for (;;){ - s="cur "+giac::print_DOUBLE_(pcur,contextptr); - strcpy(menu_xcur,s.c_str()); - s="min "+giac::print_DOUBLE_(pmin,contextptr); - strcpy(menu_xmin,s.c_str()); - s="max "+giac::print_DOUBLE_(pmax,contextptr); - strcpy(menu_xmax,s.c_str()); - s="step "+giac::print_DOUBLE_(pstep,contextptr); - strcpy(menu_xstep,s.c_str()); - paramenuitems[0].text = (char *) "OK"; - paramenuitems[1].text = (char *) menu_name; - paramenuitems[2].text = (char *) menu_xcur; - paramenuitems[3].text = (char *) menu_xmin; - paramenuitems[4].text = (char *) menu_xmax; - paramenuitems[5].text = (char *) menu_xstep; - int sres = doMenu(¶menu); - doit = sres==MENU_RETURN_SELECTION || sres==KEY_CTRL_EXE; - if (doit) { - std::string s1; double d; - if (paramenu.selection==2){ - handle_f5(); - if (inputline(menu_name,(lang==1)?"Nouvelle valeur?":"New value?",s1,false)==KEY_CTRL_EXE && s1.size()>0 && isalpha(s1[0])){ - if (s1.size()>10) - s1=s1.substr(0,10); - strcpy(menu_name,("name "+s1).c_str()); - } - continue; - } - if (paramenu.selection==3){ - inputdouble(menu_xcur,pcur,contextptr); - continue; - } - if (paramenu.selection==4){ - inputdouble(menu_xmin,pmin,contextptr); - continue; - } - if (paramenu.selection==5){ - inputdouble(menu_xmax,pmax,contextptr); - continue; - } - if (paramenu.selection==6){ - inputdouble(menu_xstep,pstep,contextptr); - pstep=fabs(pstep); - continue; - } - // if (paramenu.selection==6) break; - } // end menu - break; - } // end for (;;) - if (doit && pmin0){ - s="assume("; - s += (menu_name+5); - s += "=["; - s += (menu_xcur+4); - s += ','; - s += (menu_xmin+4); - s += ','; - s += (menu_xmax+4); - s += ','; - s += (menu_xstep+5); - s += "])"; + string s=inputparam(curname,1,contextptr); + if (!s.empty()){ + ++curname; return Console_Input((const char *)s.c_str()); } continue; @@ -16333,6 +18541,123 @@ namespace xcas { } #endif + Graph2d * geoptr=0; + + // return true if there is a syntax error and user asked to correct + bool geoparse(textArea *text,GIAC_CONTEXT){ + Graph2d * geoptr=text->gr; + if (!geoptr) + return false; + std::vector & v=text->elements; + geoptr->symbolic_instructions.resize(v.size()); + int pos=-1,i=0; + for (;isymbolic_instructions[i]=g; + if (lineerr){ + std::string tok=giac::error_token_name(contextptr); + if (lineerr==1){ + pos=v[i].s.find(tok); + const std::string & err=v[i].s; + if (pos>=err.size()) + pos=-1; + } + else { + tok=(lang==1)?"la fin":"end"; + pos=0; + } + if (pos>=0) + sprintf(status,(lang==1)?"Erreur ligne %i a %s":"Error line %i at %s",i+1,tok.c_str()); + else + sprintf(status,(lang==1)?"Erreur ligne %i %s":"Error line %i %s",i+1,(pos==-2?((lang==1)?", : manquant ?":", missing :?"):"")); + if (confirm(status,(lang==1)?"OK: corrige, back: continue":"OK: fix",1)==KEY_CTRL_F1){ + text->line=i; + if (pos>=0 && pospos=pos; + return true; + } + } + } // loop on lines + return false; + } + + int geoloop(Graph2d * geoptr){ + if (!geoptr || !geoptr->hp) return -1; + const context * contextptr=geoptr->contextptr; + textArea * text=geoptr->hp; + // main loop: alternate between plot and symb view + // start in plot view + // end plot view with EXIT or OK -> symb view editor + // end with OK or EXIT: OK will modify, EXIT will leave geo app + // (press twice EXIT to leave geo app from plot view) + for (;;){ + geoptr->eval(); + geoptr->update(); + if (geoptr->is3d) + geoptr->update_rotation(); + int key=geoptr->ui(); + if (key==KEY_SHUTDOWN){ + geosave(text,contextptr); + return key; + } + // symb view editor + for (;;){ + key=doTextArea(text,contextptr); + if (key== TEXTAREA_RETURN_EXIT || key==KEY_SHUTDOWN){ + geosave(text,contextptr); + return key; + } + // key was OK, parse step: synchronize symbolic_instructions from text + bool corrige=geoparse(text,contextptr); + if (!corrige) + break; + } // end edition loop + } // end plot/symb view infinite loop + } + + void cleargeo(){ + if (!geoptr) + return; + if (geoptr->hp) + delete geoptr->hp; + delete geoptr; + geoptr=0; + } + + int newgeo(GIAC_CONTEXT){ + if (!geoptr){ + geoptr=new Graph2d(0,contextptr); + geoptr->window_xmin=-5; + geoptr->window_ymin=-5; + geoptr->window_zmin=-5; + geoptr->window_xmax=5; + geoptr->window_ymax=5; + geoptr->window_zmax=5; + geoptr->orthonormalize(); + } + if (!geoptr) + return -1; + if (!geoptr->hp){ + geoptr->hp=new textArea; + geoptr->hp->filename="figure0.py"; + geoptr->hp->python=0; + } + if (!geoptr->hp) + return -2; + textArea * text=geoptr->hp; + text->editable=true; + text->clipline=-1; + text->gr=geoptr; + geoptr->set_mode(0,0,255,""); // start in frame mode + return 0; + } + tableur * sheetptr=0; string print_tableur(const tableur & t,GIAC_CONTEXT){ @@ -16345,6 +18670,11 @@ namespace xcas { vecteur & v=*g._VECTptr; for (int j=0;jsize()==3){ + vecteur vjv=*vj._VECTptr; + vjv[1]=0; + vj=gen(vjv,vj.subtype); + } printcell_current_col(contextptr)=j; s += vj.print(contextptr); if (j==t.ncols-1) @@ -16974,7 +19304,7 @@ int select_item(const char ** ptr,const char * title,bool askfor1){ Menu smallmenu; smallmenu.numitems=nitems; smallmenu.items=smallmenuitems; - smallmenu.height=12; + smallmenu.height=nitems<12?nitems+1:12; smallmenu.scrollbar=1; smallmenu.scrollout=1; smallmenu.title = (char*) title; diff --git a/apps/KhiCAS/src/giac-1.6.0/src/kdisplay.h b/apps/KhiCAS/src/giac-1.6.0/src/kdisplay.h index f57937cf1..243bc2e40 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/kdisplay.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/kdisplay.h @@ -164,6 +164,60 @@ namespace xcas { void replace_selection(Equation & eq,const giac::gen & tmp,giac::gen * gsel,const std::vector * gotoptr,const giac::context *); int eqw_select_leftright(xcas::Equation & g,bool left,int exchange,const giac::context *); + typedef short int color_t; + typedef struct + { + std::string s; + color_t color=giac::_BLACK; + short int newLine=0; // if 1, new line will be drawn before the text + short int spaceAtEnd=0; + short int lineSpacing=0; + short int minimini=0; + int nlines=1; + } textElement; + +#define TEXTAREATYPE_NORMAL 0 +#define TEXTAREATYPE_INSTANT_RETURN 1 + class Graph2d; + typedef struct + { + int x=0; + int y=0; + int line=0,undoline=0; + int pos=0,undopos=0; + int clipline,undoclipline; + int clippos,undoclippos; + int width=LCD_WIDTH_PX; + int lineHeight=17; + std::vector elements,undoelements; + const char* title = NULL; + std::string filename; + int scrollbar=1; + bool allowEXE=false; //whether to allow EXE to exit the screen + bool allowF1=false; //whether to allow F1 to exit the screen + bool OKparse=true; + bool editable=false; + bool changed=false; + int python=0; + int type=TEXTAREATYPE_NORMAL; + int cursorx,cursory; // where the last cursor was displayed + Graph2d * gr=0; + void set_string_value(int n,const std::string & s); // set n-th entry value + int add_entry(int pos); // return line position + } textArea; + +#define TEXTAREA_RETURN_EXIT 0 +#define TEXTAREA_RETURN_EXE 1 +#define TEXTAREA_RETURN_F1 2 + int doTextArea(textArea* text,const giac::context * contextptr); //returns 0 when user EXITs, 1 when allowEXE is true and user presses EXE, 2 when allowF1 is true and user presses F1. + std::string merge_area(const std::vector & v); + void save_script(const char * filename,const std::string & s); + void add(textArea *edptr,const std::string & s); + + extern textArea * edptr; + std::string get_searchitem(std::string & replace); + int check_leave(textArea * text); + void reload_edptr(const char * filename,textArea *edptr,const giac::context *); typedef double float3d; // typedef float float3d; struct double3 { @@ -212,7 +266,17 @@ namespace xcas { #define giac3d_default_downcolor 12345 #define giac3d_default_downupcolor 18432 // 12297 #define giac3d_default_downdowncolor 22539 + + enum { + FL_PUSH=0, + FL_MOVE=1, + FL_DRAG=2, + FL_RELEASE=3, + FL_KEYBOARD=4, + }; + giac::gen add_attributs(const giac::gen & g,int couleur_,const giac::context *) ; + class Graph2d{ public: double window_xmin,window_xmax,window_ymin,window_ymax,window_zmin,window_zmax, @@ -223,7 +287,10 @@ namespace xcas { // only 12 used, last line [0,0,0,1], usual matrices, not transposed int display_mode,show_axes,show_edges,show_names,labelsize,lcdz,default_upcolor,default_downcolor,default_downupcolor,default_downdowncolor; short int precision,diffusionz,diffusionz_limit; - bool is3d,doprecise,hide2nd,interval,solid3d; + bool is3d,doprecise,hide2nd,interval,solid3d,must_redraw; + int tracemode; + // bit0=(x,y), bit1=tangent(x',y'), m=pente (ou singulier), + // bit2=normal(-y',x'), bit3=osculateur, R_courbure double Ai,Aj,Bi,Bj,Ci,Cj,Di,Dj,Ei,Ej,Fi,Fj,Gi,Gj,Hi,Hj; // visualization cube coordinates std::vector< std::vector< std::vector > > surfacev; std::vector plan_pointv; // point in plan @@ -244,13 +311,76 @@ namespace xcas { std::vector pointv; std::vector points; // legende std::vector hyp_color,plan_color,sphere_color,polyedre_color,line_color,curve_color,point_color; - giac::gen g; + giac::gen g; // concatenation of plot_instructions, trace_instructions... const giac::context * contextptr; + /* geometry data */ + double current_i,current_j; + int mode=0; // 0 pointer, 1 1-arg, 2 2-args, etc. + // plot_tmp=function_tmp(args_tmp) or function_final(args_tmp) + // depends whether args.tmp.size()==mode + giac::gen function_tmp,function_final,args_push; + giac::vecteur args_tmp; // WARNING should only contain numeric value + unsigned args_tmp_push_size; + std::vector args_help; + std::string title,x_axis_name,x_axis_unit,y_axis_name,y_axis_unit,z_axis_name,z_axis_unit,fcnfield,fcnvars; + int npixels; // max # of pixels distance for click + giac::vecteur plot_instructions,symbolic_instructions,animation_instructions,trace_instructions; + double animation_dt; // rate for animated plot + bool paused; + double animation_last; // clock value at last display + int animation_instructions_pos; + int rotanim_type,rotanim_danim,rotanim_nstep; + double rotanim_rx,rotanim_ry,rotanim_rz,rotanim_tstep; + int couleur; // used for new point creation in geometry + bool approx; // exact or approx click mouse? + std::vector selected; // all items selected in plot_instructions + giac::gen drag_original_value,drag_name; + int hp_pos; // Position in hp for modification + xcas::textArea * hp; // null pointer if normal graph (not geometry) + giac::gen title_tmp,plot_tmp; + std::string modestr; + double push_depth,current_depth; + int push_i,push_j,cursor_point_type; // position of mouse push/drag + bool pushed=false,moving=false,moving_frame=false,in_area=true; + bool moving_param; double param_orig,param_value,param_min,param_max,param_step; + int nparams; + int tracemode_n; double tracemode_i; string tracemode_add; giac::vecteur tracemode_disp; double tracemode_mark; + /* end geometry data */ + giac::vecteur param(double d) const; + void adjust_cursor_point_type(); + void autoname_plus_plus(); + void do_handle(const giac::gen & g); + void redraw() { must_redraw=true; } + void geometry_round(double x,double y,double z,double eps,giac::gen & tmp,const giac::context *) ; + giac::gen geometry_round(double x,double y,double z,double eps,giac::gen & original,int & pos,bool selectfirstlevel=false,bool setscroller=false); + giac::vecteur selection2vecteur(const std::vector & v); + void set_mode(const giac::gen & f_tmp,const giac::gen & f_final,int m,const std::string & help); + void invert_tracemode(); + void tracemode_set(int operation=0); // operation==1 if user is setting the value of t on a parametric curve, operation==2 for root, operation==3 for extremum, operation==4 mark current position, operation=5 for area + void add_entry(int pos); + double find_eps() const; + void find_xyz(double i,double j,double k,double & x,double & y,double & z) const; + void set_gen_value(int n,const giac::gen & g,bool exec=true); // set n-th entry value + int geo_handle(int event,int key); + int ui(); + void curve_infos(); + void init_tracemode(); + giac::vecteur selected_names(bool allobjects,bool withdef) const; + void find_title_plot(giac::gen & title_tmp,giac::gen & plot_tmp); + void draw_decorations(const giac::gen & title_tmp); + bool find_dxdy(double & dx, double & dy) const; + void find_xy(double i,double j,double & x,double & y) const ; + void round_xy(double & x, double & y) const; + void eval(int start=0); // eval symbolic_instructions to plot_instructions + void update_g(); // geometry: plot_instructions, trace/animation -> g + giac::vecteur get_current_animation() const; bool findij(const giac::gen & e0,double x_scale,double y_scale,double & i0,double & j0,const giac::context * ) const; void xyz2ij(const double3 & d,int &i,int &j) const; // d not transformed void xyz2ij(const double3 & d,double &i,double &j) const; // d not transformed + void xyz2ij(const double3 & d,double &i,double &j,double3 & d3) const; // d not transformed, d3 is void XYZ2ij(const double3 & d,int &i,int &j) const; // d is transformed void addpolyg(vector & polyg,double x,double y,double z,int2 & IJmin) const ; + void adddepth(vector & polyg,const double3 &A,const double3 &B,int2 & IJmin) const; void update_scales(); void update(); void update_rotation(); // update grot @@ -271,6 +401,8 @@ namespace xcas { Graph2d(const giac::gen & g_,const giac::context * ); }; + extern Graph2d * geoptr; + struct Turtle { void draw(); #ifdef TURTLETAB @@ -285,59 +417,9 @@ namespace xcas { }; int run(const char * s,int do_logo_graph_eqw,const giac::context * contextptr); - int displaygraph(const giac::gen & ge, const giac::context * contextptr); + int displaygraph(const giac::gen & ge, const giac::gen & gs,const giac::context * contextptr); // ge evaled, gs instruction int displaylogo(); giac::gen eqw(const giac::gen & ge,bool editable,const giac::context * contextptr); - typedef short int color_t; - typedef struct - { - std::string s; - color_t color=giac::_BLACK; - short int newLine=0; // if 1, new line will be drawn before the text - short int spaceAtEnd=0; - short int lineSpacing=0; - short int minimini=0; - int nlines=1; - } textElement; - -#define TEXTAREATYPE_NORMAL 0 -#define TEXTAREATYPE_INSTANT_RETURN 1 - typedef struct - { - int x=0; - int y=0; - int line=0,undoline=0; - int pos=0,undopos=0; - int clipline,undoclipline; - int clippos,undoclippos; - int width=LCD_WIDTH_PX; - int lineHeight=17; - std::vector elements,undoelements; - const char* title = NULL; - std::string filename; - int scrollbar=1; - bool allowEXE=false; //whether to allow EXE to exit the screen - bool allowF1=false; //whether to allow F1 to exit the screen - bool OKparse=true; - bool editable=false; - bool changed=false; - int python=0; - int type=TEXTAREATYPE_NORMAL; - int cursorx,cursory; // where the last cursor was displayed - } textArea; - -#define TEXTAREA_RETURN_EXIT 0 -#define TEXTAREA_RETURN_EXE 1 -#define TEXTAREA_RETURN_F1 2 - int doTextArea(textArea* text,const giac::context * contextptr); //returns 0 when user EXITs, 1 when allowEXE is true and user presses EXE, 2 when allowF1 is true and user presses F1. - std::string merge_area(const std::vector & v); - void save_script(const char * filename,const std::string & s); - void add(textArea *edptr,const std::string & s); - - extern textArea * edptr; - std::string get_searchitem(std::string & replace); - int check_leave(textArea * text); - void reload_edptr(const char * filename,textArea *edptr,const giac::context *); void print(int &X,int&Y,const char * buf,int color,bool revert,bool fake,bool minimini); void save_session(const giac::context * ); @@ -472,9 +554,14 @@ namespace xcas { void fix_sheet(tableur & t,const giac::context *); std::string print_tableur(const tableur & t,const giac::context *); - int check_do_graph(giac::gen & ge,int do_logo_graph_eqw,const giac::context *); + int check_do_graph(giac::gen & ge,const giac::gen & gs,int do_logo_graph_eqw,const giac::context *); int get_filename(char * filename,const char * extension); int find_color(const char * s,const giac::context *); + void geosave(textArea * text,const giac::context *); + int newgeo(const giac::context *); + void cleargeo(); + int geoloop(Graph2d * geoptr); + bool geoparse(textArea *text,const giac::context *); #ifndef NO_NAMESPACE_XCAS } // namespace xcas diff --git a/apps/KhiCAS/src/giac-1.6.0/src/kdisplay.h~ b/apps/KhiCAS/src/giac-1.6.0/src/kdisplay.h~ index 43df12fdc..f57937cf1 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/kdisplay.h~ +++ b/apps/KhiCAS/src/giac-1.6.0/src/kdisplay.h~ @@ -30,6 +30,7 @@ extern char* fmenu_cfg; #ifdef MICROPY_LIB extern "C" { + void py_ck_ctrl_c(); int do_file(const char *file); char * micropy_init(int stack_size,int heap_size); int micropy_eval(const char * line); @@ -222,17 +223,20 @@ namespace xcas { // only 12 used, last line [0,0,0,1], usual matrices, not transposed int display_mode,show_axes,show_edges,show_names,labelsize,lcdz,default_upcolor,default_downcolor,default_downupcolor,default_downdowncolor; short int precision,diffusionz,diffusionz_limit; - bool is3d,doprecise,hide2nd,interval; + bool is3d,doprecise,hide2nd,interval,solid3d; double Ai,Aj,Bi,Bj,Ci,Cj,Di,Dj,Ei,Ej,Fi,Fj,Gi,Gj,Hi,Hj; // visualization cube coordinates std::vector< std::vector< std::vector > > surfacev; std::vector plan_pointv; // point in plan std::vector plan_abcv; // plan equation z=a*x+b*y+c + std::vector plan_filled; std::vector sphere_centerv; std::vector sphere_radiusv; giac::vecteur sphere_quadraticv; // matrix of the transformed quad. form + std::vector sphere_isclipped; std::vector< std::vector > polyedrev; std::vector polyedre_abcv; std::vector polyedre_xyminmax; + std::vector polyedre_faceisclipped,polyedre_filled; std::vector linev; // 2 double3 per object std::vector linetypev; std::vector lines; // legende @@ -489,6 +493,8 @@ namespace giac { // exec=0 or MENU_RETURN_SELECTION, KEY_CHAR_ANS or KEY_CTRL_EXE std::string help_insert(const char * cmdline,int & back,int exec,const giac::context *,bool warn=true); void copy_clipboard(const std::string & s,bool status); + int chartab(); + #define TEXT_MODE_NORMAL 0 #define TEXT_MODE_INVERT 1 #define MENUITEM_NORMAL 0 diff --git a/apps/KhiCAS/src/giac-1.6.0/src/lin.cc b/apps/KhiCAS/src/giac-1.6.0/src/lin.cc index ce5e1296f..e93fae7d4 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/lin.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/lin.cc @@ -693,7 +693,7 @@ namespace giac { if (!n) return gensizeerr(contextptr); if (std::pow(double(n),double(k))>MAX_PROD_EXPAND_SIZE) - return pow(v[0],v[1],contextptr); + return recursive_ratnormal(symb_pow(v[0],v[1]),contextptr); vecteur res; gen p; for (int i=k;i>=0;--i){ @@ -1743,6 +1743,8 @@ namespace giac { } sort(xymin.begin(),xymin.end()); for (int i=1;i #include #endif +#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS +#else +#include "signalprocessing.h" +#endif #ifndef HAVE_PNG_H #undef HAVE_LIBPNG #endif @@ -412,6 +416,7 @@ namespace giac { intvar_counter=0; realvar_counter=0; if (args==at_solve) return 1; + //clear_context((context *) contextptr); init_context((context *) ((void *) contextptr)); gen res= _rm_all_vars(args,contextptr); *logptr(contextptr) << "============== restarted ===============" << '\n'; @@ -508,7 +513,7 @@ namespace giac { gen _time(const gen & a,GIAC_CONTEXT){ if ( a.type==_STRNG && a.subtype==-1) return a; if (a.type==_VECT && a.subtype==_SEQ__VECT){ -#if defined VISUALC || defined __MINGW_H +#if !defined GIAC_HAS_STO_38 && (defined VISUALC || defined __MINGW_H) struct _timeb timebuffer; _ftime(&timebuffer); return timebuffer.time+double(timebuffer.millitm)/1000; @@ -567,7 +572,7 @@ namespace giac { eval(a,level,contextptr); return (emcctime()-t1)/1e6; #endif -#if defined VISUALC || defined __MINGW_H +#if !defined GIAC_HAS_STO_38 && (defined VISUALC || defined __MINGW_H) struct _timeb timebuffer0,timebuffer1; _ftime(&timebuffer0); for (;i<1000;){ // do it 10 times more @@ -1860,6 +1865,7 @@ namespace giac { } } +#ifdef KHICAS bool read_audio(vecteur & v,int & channels,int & sample_rate,int & bits_per_sample,unsigned int & data_size){ convert_double_int(v); if (v.size()>1 && v[1].type!=_VECT) @@ -2297,6 +2303,7 @@ namespace giac { define_unary_function_ptr5( at_writewav ,alias_at_writewav,&__writewav,0,true); #endif // RTOS_THREADX +#endif static gen animate2d3d(const gen & g,bool dim3,GIAC_CONTEXT){ int s=0,frames=10; @@ -2462,9 +2469,11 @@ namespace giac { #endif // LIBPNG gen _writergb(const gen & g,GIAC_CONTEXT){ - if ( g.type==_STRNG && g.subtype==-1) return g; + if ( g.type==_STRNG && g.subtype==-1) return g; + if (g.type!=_VECT || g.subtype!=_SEQ__VECT || g._VECTptr->size()!=2 || g._VECTptr->front().type!=_STRNG) + return gensizeerr(contextptr); vecteur v(gen2vecteur(g)); - if (ckmatrix(v[1])){ + if (v.size()>=2 && ckmatrix(v[1])){ int l,c; mdims(*v[1]._VECTptr,l,c); vecteur w(1,makevecteur(v.size()==2?1:4,c,l)); @@ -2475,8 +2484,14 @@ namespace giac { } v=makevecteur(v[0],w); } - if (v.size()!=2 || v[0].type!=_STRNG || v[1].type!=_VECT) + if (v.size()<2 || v[0].type!=_STRNG || v[1].type!=_VECT) return gensizeerr(); +#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS || defined EMCC || defined EMCC2 +#else + rgba_image *img=rgba_image::from_gen(v[1]); + if (img!=NULL) + return img->write_png(v[0]._STRNGptr->c_str())==0?1:0; +#endif vecteur w=*v[1]._VECTptr; // w[0]==[d,w,h], w[1..4]=data bool ok= writergb(*v[0]._STRNGptr,w); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/maple.h b/apps/KhiCAS/src/giac-1.6.0/src/maple.h index bf30f3752..7877aae6c 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/maple.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/maple.h @@ -85,8 +85,8 @@ namespace giac { gen _Nullspace(const gen & g,GIAC_CONTEXT); gen _assign(const gen & g,GIAC_CONTEXT); gen _implicitplot3d(const gen & g,GIAC_CONTEXT); - gen _readwav(const gen & g,GIAC_CONTEXT); - gen _writewav(const gen & g,GIAC_CONTEXT); + //gen _readwav(const gen & g,GIAC_CONTEXT); + //gen _writewav(const gen & g,GIAC_CONTEXT); gen _animate(const gen & g,GIAC_CONTEXT); gen _animate3d(const gen & g,GIAC_CONTEXT); gen _even(const gen & g,GIAC_CONTEXT); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/misc.cc b/apps/KhiCAS/src/giac-1.6.0/src/misc.cc index 4c9e8f7b9..3bd132872 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/misc.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/misc.cc @@ -53,9 +53,10 @@ using namespace std; #include "sparse.h" #include "giacintl.h" #if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS -inline bool is_graphe(const giac::gen &g,std::string &disp_out,const giac::context *){ return false; } +inline bool is_graphe(const giac::gen &g){ return false; } inline giac::gen _graph_charpoly(const giac::gen &g,const giac::context *){ return g;} #else +#include "signalprocessing.h" #include "graphtheory.h" #endif @@ -2189,6 +2190,19 @@ namespace giac { gen _normalize(const gen & a,GIAC_CONTEXT){ if ( a.type==_STRNG && a.subtype==-1) return a; +#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS || defined EMCC || defined EMCC2 +#else +#if defined GIAC_LMCHANGES && !defined EMCC && !defined EMCC2 // changes by L. Marohnić + audio_clip *clip; + if (a.type==_VECT && a.subtype==_SEQ__VECT && a._VECTptr->size()==2 && + (clip=audio_clip::from_gen(a._VECTptr->front()))!=NULL) { + if (!is_real_number(a._VECTptr->back(),contextptr)) + return gentypeerr(contextptr); + clip->normalize(to_real_number(a._VECTptr->back(),contextptr).to_double(contextptr)); + return *clip; + } +#endif +#endif return a/_l2norm(a,contextptr); } static const char _normalize_s []="normalize"; @@ -2280,8 +2294,10 @@ namespace giac { define_unary_function_ptr5( at_eigenvalues ,alias_at_eigenvalues,&__eigenvalues,0,true); gen _charpoly(const gen & args,GIAC_CONTEXT){ - string s; - if (is_graphe(args.subtype==_SEQ__VECT?args._VECTptr->front():args,s,contextptr)) + gen arg0=args.type==_VECT && !args._VECTptr->empty() && args.subtype==_SEQ__VECT?args._VECTptr->front():args; + if (ckmatrix(arg0)) + return _pcar(args,contextptr); + if (is_graphe(arg0)) return _graph_charpoly(args,contextptr); return _pcar(args,contextptr); } @@ -6140,8 +6156,12 @@ static define_unary_function_eval (__hamdist,&_hamdist,_hamdist_s); decimal_digits(nd,contextptr); return pnt_attrib(gen(res,_GROUP__VECT),attributs,contextptr); } // end s==2 - if (s>=3) - v[2]=_floor(v[2],contextptr); + if (s>=3){ + if (v[2].type==_DOUBLE_ || v[2].type==_FRAC) + v[2]=_floor((b-a)/v[2],contextptr); + else + v[2]=_floor(v[2],contextptr); + } if (s>=3 && v[2].type==_INT_){ int n=v[2].val; if (n<1) @@ -6487,7 +6507,18 @@ static define_unary_function_eval (__os_version,&_os_version,_os_version_s); #endif gen _flatten(const gen & args,GIAC_CONTEXT){ - if ( args.type==_STRNG && args.subtype==-1) return args; + if (args.type==_STRNG && args.subtype==-1) return args; +#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS || defined EMCC || defined EMCC2 +#else +#if defined GIAC_LMCHANGES && !defined EMCC && !defined EMCC2 // changes by L. Marohnić + rgba_image *img=rgba_image::from_gen(args); + if (img!=NULL) { + vecteur flv; + img->flatten(flv); + return flv; + } +#endif +#endif if (args.type!=_VECT) return gensizeerr(contextptr); vecteur res; aplatir(*args._VECTptr,res,true); @@ -6557,7 +6588,7 @@ static define_unary_function_eval (__os_version,&_os_version,_os_version_s); if (args._STRNGptr->size()>8 && args._STRNGptr->substr(0,8)=="timeout "){ string t=args._STRNGptr->substr(8,args._STRNGptr->size()-8); double f=atof(t.c_str()); - if (f>=0 && f<24*60){ + if (f>=0 && f<24*60*60){ caseval_maxtime=f; caseval_n=0; caseval_mod=10; @@ -9277,6 +9308,11 @@ static define_unary_function_eval (__os_version,&_os_version,_os_version_s); giac::freeze=true; } + int rgb888to565(int c){ + int r=(c>>16)&0xff,g=(c>>8)&0xff,b=c&0xff; + return (((r*32)/256)<<11) | (((g*64)/256)<<5) | (b*32/256); + } + int rgb565to888(int c){ c &= 0xffff; int r=(c>>11)&0x1f,g=(c>>5)&0x3f,b=c&0x1f; @@ -9428,6 +9464,12 @@ void sync_screen(){} //Uses the Bresenham line algorithm void draw_line(int x1, int y1, int x2, int y2, int color,GIAC_CONTEXT) { + if ( (absint(x1) & 0x7ffff000) || + (absint(x2) & 0x7ffff000) || + (absint(y1) & 0x7ffff000) || + (absint(y2) & 0x7ffff000) + ) + return; int w =(color & 0x00070000) >> 16; ++w; int type_line =(color & 0x01c00000) >> 22,mask=0xffff; // 3 bits @@ -9623,6 +9665,7 @@ void sync_screen(){} } void draw_polygon(vector< vector > & v1,int color,GIAC_CONTEXT){ + if (v1.empty()) return; if (!(v1.back()==v1.front())) v1.push_back(v1.front()); int n=v1.size()-1; diff --git a/apps/KhiCAS/src/giac-1.6.0/src/misc.cc~ b/apps/KhiCAS/src/giac-1.6.0/src/misc.cc~ index 11a601037..0fd5b52f2 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/misc.cc~ +++ b/apps/KhiCAS/src/giac-1.6.0/src/misc.cc~ @@ -2281,7 +2281,10 @@ namespace giac { gen _charpoly(const gen & args,GIAC_CONTEXT){ string s; - if (is_graphe(args.subtype==_SEQ__VECT?args._VECTptr->front():args,s,contextptr)) + gen arg0=args.type==_VECT && !args._VECTptr->empty() && args.subtype==_SEQ__VECT?args._VECTptr->front():args; + if (ckmatrix(arg0)) + return _pcar(args,contextptr); + if (is_graphe(arg0,s,contextptr)) return _graph_charpoly(args,contextptr); return _pcar(args,contextptr); } @@ -6140,8 +6143,12 @@ static define_unary_function_eval (__hamdist,&_hamdist,_hamdist_s); decimal_digits(nd,contextptr); return pnt_attrib(gen(res,_GROUP__VECT),attributs,contextptr); } // end s==2 - if (s>=3) - v[2]=_floor(v[2],contextptr); + if (s>=3){ + if (v[2].type==_DOUBLE_ || v[2].type==_FRAC) + v[2]=_floor((b-a)/v[2],contextptr); + else + v[2]=_floor(v[2],contextptr); + } if (s>=3 && v[2].type==_INT_){ int n=v[2].val; if (n<1) @@ -6557,7 +6564,7 @@ static define_unary_function_eval (__os_version,&_os_version,_os_version_s); if (args._STRNGptr->size()>8 && args._STRNGptr->substr(0,8)=="timeout "){ string t=args._STRNGptr->substr(8,args._STRNGptr->size()-8); double f=atof(t.c_str()); - if (f>=0 && f<24*60){ + if (f>=0 && f<24*60*60){ caseval_maxtime=f; caseval_n=0; caseval_mod=10; @@ -9277,6 +9284,11 @@ static define_unary_function_eval (__os_version,&_os_version,_os_version_s); giac::freeze=true; } + int rgb888to565(int c){ + int r=(c>>16)&0xff,g=(c>>8)&0xff,b=c&0xff; + return (((r*32)/256)<<11) | (((g*64)/256)<<5) | (b*32/256); + } + int rgb565to888(int c){ c &= 0xffff; int r=(c>>11)&0x1f,g=(c>>5)&0x3f,b=c&0x1f; @@ -9587,8 +9599,12 @@ void sync_screen(){} if (impair[k]){ int x1=giacmax(xmin,int(lxj[k][0]+.5)); int x2=k==lxjs-1?xmax:giacmin(xmax,int(lxj[k+1][0]+.5)); +#ifdef NUMWORKS + os_fill_rect(x1,y,x2-x1+1,1,color); +#else for (;x1<=x2;++x1) set_pixel(x1,y,color,contextptr); +#endif } } } // end if y>=ymin @@ -9619,6 +9635,7 @@ void sync_screen(){} } void draw_polygon(vector< vector > & v1,int color,GIAC_CONTEXT){ + if (v1.empty()) return; if (!(v1.back()==v1.front())) v1.push_back(v1.front()); int n=v1.size()-1; @@ -9656,9 +9673,17 @@ void sync_screen(){} define_unary_function_ptr5( at_draw_polygon ,alias_at_draw_polygon,&__draw_polygon,0,true); void draw_rectangle(int x, int y, int width, int height, unsigned short color,GIAC_CONTEXT){ + if (width<0){ + width=-width; + x-=width; // adapt for Casio + } + if (height<0){ + height=-height; + y-=height; // adapt for Casio + } if (x<0){ width+=x; x=0;} if (y<0){ height+=y; y=0;} - if (width<0 || height<0) return; + // if (width<0 || height<0) return; #ifdef KHICAS os_fill_rect(x,y,width,height,color); #else diff --git a/apps/KhiCAS/src/giac-1.6.0/src/misc.h b/apps/KhiCAS/src/giac-1.6.0/src/misc.h index d772ccf96..da4d6306b 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/misc.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/misc.h @@ -262,6 +262,7 @@ namespace giac { bool has_undef_stringerr(const gen & g,std::string & err); gen _is_polynomial(const gen & args,GIAC_CONTEXT); + bool is_periodic(const gen & f,const gen & x,gen & periode,GIAC_CONTEXT); // step by step utilities // poi=point of interest, tvi=table of variation diff --git a/apps/KhiCAS/src/giac-1.6.0/src/modpoly.cc b/apps/KhiCAS/src/giac-1.6.0/src/modpoly.cc index 1765de833..ed5368a94 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/modpoly.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/modpoly.cc @@ -49,6 +49,7 @@ using namespace std; #if defined GIAC_CACHEW && GIAC_PRECOND #undef GIAC_PRECOND // incompatible #endif +//#undef GIAC_PRECOND // vector class version 1 by Agner Fog https://github.com/vectorclass // this might be faster for CPU with AVX512DQ instruction set @@ -2557,12 +2558,13 @@ namespace giac { vector A,B,Wp,tmp0; to_fft(a,p,w,Wp,N,tmp0,1,false,false); A.swap(tmp0); to_fft(b,p,w,Wp,N,tmp0,1,false,false); B.swap(tmp0); - fft_aoverb_p(A,B,tmp0,p); - fft_reverse(Wp,p); - from_fft(tmp0,p,Wp,q,true,false); - fast_trim_inplace(q,p); - if (q.size()==s) - return 2; + if (fft_aoverb_p(A,B,tmp0,p)){ + fft_reverse(Wp,p); + from_fft(tmp0,p,Wp,q,true,false); + fast_trim_inplace(q,p); + if (q.size()==s) + return 2; + } } } } @@ -5535,7 +5537,7 @@ namespace giac { #endif } - void fft_aoverb_p(const vector &a,const vector &b,vector & res,int p){ + bool fft_aoverb_p(const vector &a,const vector &b,vector & res,int p){ int s=a.size(); res.resize(s); for (int i=0;i>31)&p; res[i]=(longlong(a[i])*bi)%p; } + return true; } void fft_ab_cd_p(const vector &a,const vector &b,const vector & c,const vector &d,vector & res,int p){ @@ -5773,10 +5778,16 @@ namespace giac { } } +#ifdef GIAC_PRECOND inline int precond_mulmodp(unsigned A,unsigned W,unsigned Winvp,int p){ #if 1 longlong t = ulonglong(A)*W-((ulonglong(A)*Winvp)>>32)*p; - return t+ ((t>>31)&p); + t += ((t>>31)&p); + return t; + unsigned s=(ulonglong(A)*W)%p; + if (t!=s) + CERR << '\n'; + return s; #else longlong t = ulonglong(A)*W-((ulonglong(A)*Winvp)>>32)*p; //return t- (t>>63)*p; @@ -5787,6 +5798,11 @@ namespace giac { return s; #endif } +#else + inline int precond_mulmodp(unsigned A,unsigned W,unsigned Winvp,int p){ + return (ulonglong(A)*W)%p; + } +#endif inline int mulmodp(int a,int b,int p){ return (longlong(a)*b) % p; @@ -5841,7 +5857,7 @@ namespace giac { #else unsigned u=1+((1ULL<<32)*ww)/unsigned(p); // quotient ceiling #endif - W[N+i]=u; + W[N+i]=u; // stored as an int but it's an unsigned ww=precond_mulmodp(w,ww,u,p); // ww=(ww*longlong(w))%p; // if (www!=ww) @@ -6899,6 +6915,9 @@ namespace giac { memcpy(b,&*q.begin(),bs*sizeof(int)); int * t; for (;b!=bend;swapab=!swapab){ + if (*b % m==0){ // make sure leading coeff of b is not 0 + ++b; continue; + } rem(a,aend,b,bend,m,qcur,0); t=a; a=b; b=t; t=aend; aend=bend; bend=t; @@ -12278,6 +12297,7 @@ namespace giac { // inplace fft with positive representant static inline int addmod(int a, int b, int p) { + // if (a<0 || b<0) CERR << '\n'; int t=(a-p)+b; #if defined(EMCC) || defined(EMCC2) if (t<0) return t+p; else return t; @@ -12287,6 +12307,7 @@ namespace giac { #endif } static inline int submod(int a, int b, int p) { + // if (a<0 || b<0) CERR << '\n'; int t=a-b; #if defined(EMCC) || defined(EMCC2) if (t<0) return t+p; else return t; @@ -12861,7 +12882,7 @@ namespace giac { #endif -#if !defined NUMWORKS // !defined VISUALC && !defined USE_GMP_REPLACEMENTS && defined GIAC_PRECOND // de-recurse +#if !defined NUMWORKS && defined GIAC_PRECOND // !defined VISUALC && !defined USE_GMP_REPLACEMENTS // de-recurse static void fft2pnopermafter( int *A, int n, int *W,int p,double invp,int step) { if (n==0) CERR << "bug\n"; diff --git a/apps/KhiCAS/src/giac-1.6.0/src/modpoly.h b/apps/KhiCAS/src/giac-1.6.0/src/modpoly.h index 63476e526..19e39dd87 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/modpoly.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/modpoly.h @@ -273,8 +273,8 @@ namespace giac { void fft(const std::vector & f,const std::vector & w ,std::vector & res,int modulo); // res=a .* b mod p void fft_ab_p(const std::vector &a,const std::vector &b,std::vector & res,int p); - // res=a ./ b mod p - void fft_aoverb_p(const std::vector &a,const std::vector &b,std::vector & res,int p); + // res=a ./ b mod p, returns false if a division fails + bool fft_aoverb_p(const std::vector &a,const std::vector &b,std::vector & res,int p); // reverse the table of root of unity^k for inverse fft void fft_reverse(std::vector & W,int p); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/moyal.cc b/apps/KhiCAS/src/giac-1.6.0/src/moyal.cc index 63f449ef0..e1dabaf07 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/moyal.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/moyal.cc @@ -4241,6 +4241,8 @@ namespace giac { complex w; // initial guess w=2.0*(M_E*z+1.0); + if (std::abs(w)<1e-13) + return -1.0; if (std::abs(w)<0.1 && (n==0 || ( n==1 && z.imag()<0) || (n==-1 && z.imag()>0))){ // near -1/e, set p=sqrt(2(ez+1)), -1+p-1/3*p^2+11/72*p^3+... w=std::sqrt(w); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/plot.cc b/apps/KhiCAS/src/giac-1.6.0/src/plot.cc index 37bd61891..7e1aef1d2 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/plot.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/plot.cc @@ -128,10 +128,11 @@ extern "C" { #endif #if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS -inline bool is_graphe(const giac::gen &g,std::string &disp_out,const giac::context *){ return false; } +inline bool is_graphe(const giac::gen &g){ return false; } inline giac::gen _graph_vertices(const giac::gen &g,const giac::context *){ return g;} inline giac::gen _is_planar(const giac::gen &g,const giac::context *){ return g;} #else +#include "signalprocessing.h" #include "graphtheory.h" #endif @@ -567,6 +568,7 @@ namespace giac { } #endif + bool gnuplot_opengl=false; #ifdef WITH_GNUPLOT vecteur plot_instructions; @@ -1067,8 +1069,23 @@ namespace giac { if (s[i]=='.') break; } - if (i+ndigits+1 i + for (;j15?15:ndigits; @@ -1083,29 +1100,28 @@ namespace giac { k %= 126; if (k<0) k += 126; - if (k<21){ - r=251; g=0; b=12*k; + if (k<63){ + if (k<21){ + r=251; g=0; b=12*k; return; + } + if (k>=21 && k<42){ + r=251-(12*(k-21)); g=0; b=251; return ; + } + if (k>=42 && k<63){ + r=0; g=(k-42)*12; b=251; return; + } + } + else { + if (k>=63 && k<84){ + r=0; g=251; b=251-(k-63)*12; return; + } + if (k>=84 && k<105){ + r=(k-84)*12; g=251; b=0; return; + } + if (k>=105 && k<126){ + r=251; g=251-(k-105)*12; b=0; return; + } } - if (k>=21 && k<42){ - r=251-(12*(k-21)); g=0; b=251; - } - if (k>=42 && k<63){ - r=0; g=(k-42)*12; b=251; - } - if (k>=63 && k<84){ - r=0; g=251; b=251-(k-63)*12; - } - if (k>=84 && k<105){ - r=(k-84)*12; g=251; b=0; - } - if (k>=105 && k<126){ - r=251; g=251-(k-105)*12; b=0; - } - } - - int rgb888to565(int c){ - int r=(c>>16)&0xff,g=(c>>8)&0xff,b=c&0xff; - return (((r*32)/256)<<11) | (((g*64)/256)<<5) | (b*32/256); } static const int arc_en_ciel_colors=15; @@ -1540,7 +1556,7 @@ namespace giac { if (debug_infolevel) CERR << y << " not real at " << i << " value " << yy << " type " << int(yy.type) << '\n'; if (!chemin.empty()) - res.push_back(pnt_attrib(symb_curve(gen(makevecteur(vars+cst_i*f,vars,xmin,i,showeq),_PNT__VECT),gen(chemin,_GROUP__VECT)),attributs.empty()?color:attributs,contextptr)); + res.push_back(pnt_attrib(symb_curve(gen(makevecteur(vars+cst_i*f,vars,xmin,i-step,showeq),_PNT__VECT),gen(chemin,_GROUP__VECT)),attributs.empty()?color:attributs,contextptr)); xmin=i; chemin.clear(); continue; @@ -1582,7 +1598,7 @@ namespace giac { CERR << y << " step at " << i << " " << yy << '\n'; CERR << "curve " << chemin.size() << " " << chemin.front() << " .. " << chemin.back() << '\n'; } - res.push_back(pnt_attrib(symb_curve(gen(makevecteur(vars+cst_i*f,vars,xmin,i,showeq),_PNT__VECT),gen(chemin,_GROUP__VECT)),attributs.empty()?color:attributs,contextptr)); + res.push_back(pnt_attrib(symb_curve(gen(makevecteur(vars+cst_i*f,vars,xmin,i-step,showeq),_PNT__VECT),gen(chemin,_GROUP__VECT)),attributs.empty()?color:attributs,contextptr)); } xmin=i; chemin=vecteur(1,gen(i,j)); @@ -1770,7 +1786,7 @@ namespace giac { if (fval._DOUBLE_val>fmax) fmax=fval._DOUBLE_val; } -#if defined KHICAS || defined GIAC_HAS_STO_38 // FIXME format is not translatable, etc. +#if defined KHICAS || defined GIAC_HAS_STO_38 // || defined HYPERSURFACE3 FIXME format is not translatable, etc. if (!densityplot){ tmp.push_back(x); tmp.push_back(y); tmp.push_back(fval); } @@ -3491,8 +3507,8 @@ namespace giac { #else ee.subtype=-1; #endif - history_plot(contextptr).push_back(ee); #ifndef KHICAS + history_plot(contextptr).push_back(ee); if (io_graph(contextptr)) __interactive.op(ee,contextptr); #endif @@ -6074,6 +6090,8 @@ namespace giac { loop=false; else if (res.type==_SYMB && has_i(res)) loop=false; + if (res.is_symb_of_sommet(at_curve)) + loop=true; /* workaround for ggb area([circle(x^(2)+4y^(2)=1)]) */ if (loop){ res=0; for (unsigned i=0;isize();++i) @@ -7533,8 +7551,7 @@ namespace giac { gen _sommets(const gen & args,GIAC_CONTEXT){ if ( args.type==_STRNG && args.subtype==-1) return args; - string s; - if (is_graphe(args,s,contextptr)) + if (is_graphe(args)) return _graph_vertices(args,contextptr); if (args.type==_VECT && args.subtype==_SEQ__VECT && args._VECTptr->size()==2){ gen g=_sommets(args._VECTptr->front(),contextptr); @@ -7555,8 +7572,7 @@ namespace giac { gen _faces(const gen & args,GIAC_CONTEXT){ if ( args.type==_STRNG && args.subtype==-1) return args; - string s; - if (is_graphe(args,s,contextptr)){ + if (is_graphe(args)){ identificateur faces; gen ret=_is_planar(makesequence(args,faces),contextptr); gen retval=is_one(ret)?_eval(faces,contextptr):ret; @@ -8718,7 +8734,13 @@ namespace giac { chemin.push_back(gen(i,j)); else { if (!chemin.empty()) - res.push_back(symb_pnt(symb_curve(gen(makevecteur(fC,vars,function_tmin,t,0,equation,parameq,vparam),_PNT__VECT),gen(chemin,_GROUP__VECT)),attribut,contextptr)); + res.push_back(symb_pnt(symb_curve(gen(makevecteur(fC,vars,function_tmin, +#if 0 + t, +#else + t-function_tstep, +#endif + 0,equation,parameq,vparam),_PNT__VECT),gen(chemin,_GROUP__VECT)),attribut,contextptr)); function_tmin=t; chemin=vecteur(1,gen(i,j)); } @@ -8726,7 +8748,13 @@ namespace giac { oldj=j; } if (!chemin.empty()) - res.push_back(symb_pnt(symb_curve(gen(makevecteur(fC,vars,function_tmin,function_tmax,0,equation,parameq,vparam),_PNT__VECT),gen(chemin,_GROUP__VECT)),attribut,contextptr)); + res.push_back(symb_pnt(symb_curve(gen(makevecteur(fC,vars,function_tmin, +#if 0 + function_tmax, +#else + t-function_tstep, +#endif + 0,equation,parameq,vparam),_PNT__VECT),gen(chemin,_GROUP__VECT)),attribut,contextptr)); leave(protect,localvar,newcontextptr); // io_graph(old_io_graph,contextptr); #if !defined(WIN32) && defined(WITH_GNUPLOT) @@ -8961,6 +8989,26 @@ namespace giac { if (g.type==_VECT){ v=*g._VECTptr; int s=int(v.size()),nd=0,nargs=0; + if (s){ + vecteur attributs(1,default_color(contextptr)); + int a=read_attributs(v,attributs,contextptr); + if (a==s-1 && attributs!=vecteur(1,default_color(contextptr))){ + gen res=_plot(a==1?v.front():gen(vecteur(v.begin(),v.begin()+a),g.subtype),contextptr); + if (res.type==_VECT){ + vecteur w=*res._VECTptr; + for (int i=0;i1){ + gen valv0=valv[0]; + if (valv0.is_symb_of_sommet(at_legende)){ + valv0=valv0._SYMBptr->feuille; + valv0=valv0[1]; + if (valv0.type==_STRNG){ + valv0=gen(*valv0._STRNGptr,contextptr); + if (valv0.type<=_SYMB) + return valv0; + } + } gen valv1=valv[1]; if (valv1.type==_VECT && valv1._VECTptr->size()>2){ tmp=(*valv1._VECTptr)[1]; @@ -11126,6 +11194,36 @@ namespace giac { gen _couleur(const gen & a,GIAC_CONTEXT){ if (is_undef(a)) return a; +#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS || defined EMCC || defined EMCC2 +#else + /* display image, addition by L. Marohnić */ + rgba_image *img; + gen x=0,y=0; + if (a.type==_VECT && a.subtype==_SEQ__VECT && a._VECTptr->size()>1 && + (img=rgba_image::from_gen(a._VECTptr->front()))!=NULL) { + if ((a._VECTptr->size()>2 && (!is_real_number(x=a._VECTptr->at(1),contextptr) || !is_real_number(y=a._VECTptr->at(2),contextptr)))) + return gensizeerr(gettext("Invalid image position")); + if (a._VECTptr->size()==2) { + if (a._VECTptr->back().type==_CPLX) { + x=re(a._VECTptr->back(),contextptr); + y=im(a._VECTptr->back(),contextptr); + } else if (is_real_number(a._VECTptr->back(),contextptr)) + x=a._VECTptr->back(); + else return gensizeerr(gettext("Invalid image position")); + } + } else img=rgba_image::from_gen(a); + if (img!=NULL) { + if (!img->assure_on_disk()) + return gensizeerr(gettext("Failed to write image to disk")); + vecteur drawing; + drawing.push_back(symb_equal(change_subtype(_AXES,_INT_PLOT),0)); + drawing.push_back(symb_equal(change_subtype(_GL_ORTHO,_INT_PLOT),1)); + drawing.push_back(symbolic(at_rectangle,makesequence(gen(x,y),gen(x+img->width(),y),fraction(img->height(),img->width()), + symb_equal(change_subtype(_GL_TEXTURE,_INT_PLOT),string2gen(img->file_name(),false))))); + return drawing; + } + /* end display image */ +#endif if (a.type==_STRNG){ *logptr(contextptr) << gettext("Use pencolor for the turtle") << '\n'; return _couleur(gen(*a._STRNGptr,contextptr),contextptr); @@ -11834,6 +11932,8 @@ namespace giac { is >> type; if (type==_FL_WIDGET_POINTER && fl_widget_unarchive_function) return fl_widget_unarchive_function(is); + case _USER: + return unarchive(is,contextptr); case _ZINT: return unarchivezint(is,contextptr); #if 0 // ndef USE_GMP_REPLACEMENTS @@ -12002,6 +12102,8 @@ namespace giac { if (galois_field * gf=dynamic_cast(e._USERptr)){ return os << et << "GF(" << gf->p << "," << gf->P << "," << gf->x << "," << gf->a << ")" << '\n'; } + os << et << " "; + return archive(os,e._USERptr->giac_constructor(contextptr),contextptr); } #endif default: @@ -12200,8 +12302,9 @@ namespace giac { g=_floor(g,0); if (g.type!=_INT_) return false; // setsizeerr(contextptr); -#ifdef WITH_GNUPLOT int i=g.val; + gnuplot_opengl=(i/4) %2; +#ifdef WITH_GNUPLOT gnuplot_hidden3d=(i %2)!=0; i =i/2; gnuplot_pm3d=(i%2)!=0; @@ -12253,7 +12356,7 @@ namespace giac { v.push_back(axes); v.push_back(class_min); v.push_back(class_size); - v.push_back(int(gnuplot_hidden3d+2*gnuplot_pm3d)); + v.push_back(int(gnuplot_hidden3d+2*gnuplot_pm3d+4*gnuplot_opengl)); return symbolic(at_xyztrange,v); } gen _xyztrange(const gen & args,GIAC_CONTEXT){ @@ -16576,6 +16679,16 @@ gen _vers(const gen & g,GIAC_CONTEXT){ // moved from plot3d.cc for implicittex_plot_sommets_alias gen _plot3d(const gen & g,const context * contextptr){ if ( g.type==_STRNG && g.subtype==-1) return g; + if (g.type!=_VECT){ + vecteur v(lidnt(eval(g,1,contextptr))); + if (v.size()==2) + return _plot3d(makesequence(g,v.front(),v.back()),contextptr); + if (v.size()==1){ + gen z=v.front(); + gen G=subst(g,z,x__IDNT_e+cst_i*y__IDNT_e,false,contextptr); + return _plot3d(makesequence(G,x__IDNT_e,y__IDNT),contextptr); + } + } if (g.type!=_VECT || g._VECTptr->size()<2) return symbolic(at_plot3d,g); vecteur v=*g._VECTptr; diff --git a/apps/KhiCAS/src/giac-1.6.0/src/plot.h b/apps/KhiCAS/src/giac-1.6.0/src/plot.h index efc5b9bf9..303144693 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/plot.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/plot.h @@ -246,6 +246,7 @@ namespace giac { when all fork/child etc. will be removed */ extern vecteur plot_instructions; #endif + extern bool gnuplot_opengl; int gnuplot_show_pnt(const symbolic & e,GIAC_CONTEXT); gen rationalparam2equation(const gen & at_orig,const gen & t_orig,const gen &x,const gen & y,GIAC_CONTEXT); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/plot3d.cc b/apps/KhiCAS/src/giac-1.6.0/src/plot3d.cc index 51d879cdb..def5dc1e4 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/plot3d.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/plot3d.cc @@ -1062,7 +1062,7 @@ namespace giac { for (int j=0;j<=nv;++j,y+=dy){ vals[1]=y; gen tmppnt=evalf_double(subst(f,vars,vals,false,contextptr),1,contextptr); -#if defined KHICAS || defined GIAC_HAS_STO_38 +#if defined KHICAS || defined GIAC_HAS_STO_38 // defined HYPERSURFACE3 tmp.push_back(tmppnt[0]); tmp.push_back(tmppnt[1]); tmp.push_back(tmppnt[2]); @@ -1557,6 +1557,49 @@ namespace giac { return segments2polygone(res,contextptr); } +#if 1 + gen volume_polyedre(const vecteur & p,GIAC_CONTEXT){ + const_iterateur it=p.begin(),itend=p.end(); + gen V=0,c=0; int n=0; + // find isobarycenter + for (it=p.begin();it!=itend;++it){ + if (it->type!=_VECT) + continue; + vecteur v=*it->_VECTptr; + int s=int(v.size()); + if (s && v.front()==v.back()) + --s; + if (s<3) + continue; + for (int i=0;itype!=_VECT) + continue; + vecteur v=*it->_VECTptr; + int s=int(v.size()); + if (s && v.front()==v.back()) + --s; + if (s<3) + continue; + gen a=v[0]; + for (int i=2;ifront()._VECTptr; res += cur[1]*prec[0]-cur[0]*prec[1]; } - return abs(res,contextptr); + return res;//abs(res,contextptr); } static bool infe(const gen & a,const gen &b){ @@ -1647,16 +1690,20 @@ namespace giac { // compute volume by Simpson formula int s=Z.size(); gen prev=area_polyedre_z(p,Z.front(),contextptr); + // CERR << 0 << " " << prev << '\n'; gen V=0; for (int i=1;iindex.front()==rdeg-1) - a1=Tnextcoeff(it,itend); + if (1 && qdeg && it!=itend && it->index.front()==rdeg-1){ // FIXME, fails for integrate((e*x+d)^(3/2)*(c*x^2+b*x+a)^p,x); + a1=Tnextcoeff(it,itend); #if defined GIAC_VECTOR || defined NSPIRE // fix for * on arm compiler tensor tmp(q.dim); tmp.coord=q.coord*b1.coord; a1.TSub(tmp,a1); #else - a1.TSub(q*b1,a1); // a1=a1-q*b1; + a1.TSub(q*b1,a1); + // a1=a1-q*b1; #endif q=q.untrunc1(qdeg); if (!a1.Texactquotient(b0,q1,allowrational)) @@ -1036,7 +1036,8 @@ namespace giac { tmp.coord=q.coord*b.coord; r.TSub(tmp,r); // r=r-q*b; #else - r.TSub(q*b,r); // r=r-q*b; + r.TSub(q*b,r); + //r=r-q*b; #endif if (r.coord.empty()) return true; diff --git a/apps/KhiCAS/src/giac-1.6.0/src/prog.cc b/apps/KhiCAS/src/giac-1.6.0/src/prog.cc index fecd6bcde..e9ced4b23 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/prog.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/prog.cc @@ -7453,6 +7453,27 @@ namespace giac { static define_unary_function_eval (__inferieur_strict_sort,&_inferieur_strict_sort,_inferieur_strict_sort_s); define_unary_function_ptr5( at_inferieur_strict_sort ,alias_at_inferieur_strict_sort,&__inferieur_strict_sort,0,true); +#if 0 + void mysort(iterateur it,iterateur itend,const gen & f,GIAC_CONTEXT){ + int s=itend-it; + for (;;){ + bool ok=true; + for (int i=0;isize()==2){ + gen & obj=g._VECTptr->front(); + vecteur & ptr=*obj._VECTptr; + return makevecteur((longlong) (&ptr),(int) taille(obj,RAND_MAX),tailles(obj)); + } + vecteur & ptr=*g._VECTptr; + return (longlong) (&ptr); + } + static const char _addr_s []="addr"; + static define_unary_function_eval (__addr,&_addr,_addr_s); + define_unary_function_ptr5( at_addr ,alias_at_addr,&__addr,0,true); + #ifdef NSPIRE_NEWLIB gen _read_nand(const gen & args,GIAC_CONTEXT){ if ( args.type==_STRNG && args.subtype==-1) @@ -8527,7 +8561,7 @@ namespace giac { int n=args._VECTptr->back().val; if (n<=0 || !is_address(args._VECTptr->front(),addr)) return undef; - // void read_nandd(void* dest, int size, int nand_offset, int unknown, int percent_max, void* progress_cb); // terminer par (...,0,0,NULL) + // void read_nand(void* dest, int size, int nand_offset, int unknown, int percent_max, void* progress_cb); // terminer par (...,0,0,NULL) char * dest=(char *)malloc(4*n); read_nand(dest,4*n,addr,0,0,NULL); char buf[5]="aaaa"; @@ -8594,6 +8628,8 @@ namespace giac { gen tmp=eval(*it,1,contextptr); if (it->type==_IDNT){ gen tmp2=*it; + if (tmp.type==_USER) + tmp=tmp._USERptr->giac_constructor(contextptr); inf << symb_sto(tmp,tmp2) << ";" << '\n'; } else @@ -8635,9 +8671,10 @@ namespace giac { return _read32(args,contextptr); if (args.type==_VECT){ vecteur v=*args._VECTptr; + if (v.empty()) return gensizeerr(contextptr); + gen vf=v.front(),vb=v.back(); size_t addr; - if (v.size()==2 && is_address(v.front(),addr)){ - gen vb=v.back(); + if (v.size()==2 && is_address(vf,addr)){ unsigned * ptr =(unsigned *) addr; if (vb.type==_INT_){ *ptr=vb.val; diff --git a/apps/KhiCAS/src/giac-1.6.0/src/quater.cc b/apps/KhiCAS/src/giac-1.6.0/src/quater.cc index 34cc5c4b4..10a8a41b1 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/quater.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/quater.cc @@ -441,6 +441,10 @@ namespace giac { return ""; } + gen galois_field::giac_constructor(GIAC_CONTEXT) const { + return symbolic(at_galois_field,makesequence(p,P,x,a)); + } + string galois_field::texprint(GIAC_CONTEXT) const { gen xid(x); gen A(a); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/quater.h b/apps/KhiCAS/src/giac-1.6.0/src/quater.h index cad4f7399..a5312e11f 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/quater.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/quater.h @@ -75,6 +75,7 @@ namespace giac { virtual gen inv () const ; virtual std::string print (GIAC_CONTEXT) const ; virtual std::string texprint (GIAC_CONTEXT) const ; + virtual gen giac_constructor (GIAC_CONTEXT) const ; virtual bool operator == (const gen &) const ; virtual bool is_zero() const; virtual bool is_one() const; diff --git a/apps/KhiCAS/src/giac-1.6.0/src/series.cc b/apps/KhiCAS/src/giac-1.6.0/src/series.cc index 6924df050..24a84ccb1 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/series.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/series.cc @@ -516,15 +516,53 @@ namespace giac { } } new_seq.push_back( monome(res ,old_pow )); + final_seq.clear(); + sparse_poly1::const_iterator it=new_seq.begin(); + sparse_poly1::const_iterator itend=new_seq.end(); + const int MAXS=512; + int m=MAXS,M=-MAXS,N=itend-it; + final_seq.reserve(N); +#ifdef FXCG + if (Nexponent.type!=_INT_) + break; + int cur=it->exponent.val; + if (curM) + M=cur; + } + if (it==itend){ + gen tab[M-m+1]; + memset(tab,sizeof(tab),0); + for (it=new_seq.begin();it!=itend;++it){ + tab[it->exponent.val-m] += it->coeff; + } + for (int i=m;i<=M;++i){ + gen res=tab[i-m]; + if (is_zero(res)) + continue; + if (is_undef(res)){ + final_seq.push_back(monome(res,i)); + return true; + } + if (series_flags(contextptr) & 0x1) + res=recursive_normal(res,contextptr); + if (!is_zero(res)) + final_seq.push_back(monome(res,i)); + } + return true; + } + } +#endif // COUT << new_seq << '\n'; // sort by asc. power sort( new_seq.begin(),new_seq.end(),monome_less()); // COUT << "Sorted" << new_seq << '\n'; // add terms with same power - sparse_poly1::const_iterator it=new_seq.begin(); - sparse_poly1::const_iterator itend=new_seq.end(); - final_seq.clear(); - final_seq.reserve(itend-it); + it=new_seq.begin(); + // itend=new_seq.end(); while (it!=itend){ gen res=it->coeff; gen pow=it->exponent; @@ -1616,6 +1654,11 @@ namespace giac { return false; for (int i=1;ifeuille.type==_VECT && v[i]._SYMBptr->feuille._VECTptr->size()==4){ vecteur & vv=*v[i]._SYMBptr->feuille._VECTptr; - if (derive(vv[2],x,contextptr)==0 && derive(vv[2],x,contextptr)==0) + if (derive(vv[2],x,contextptr)==0 && derive(vv[3],x,contextptr)==0) continue; } if (!convert_to_euler_mac_laurin(v[i],x,tmp,contextptr)) @@ -2522,8 +2570,18 @@ namespace giac { return gen(res,e0.subtype); } if (_about(x,contextptr)!=x){ - identificateur xprime(" "+print_INT_(giac_rand(contextptr))); - return in_limit(quotesubst(e0,x,xprime,contextptr),xprime,lim_point,direction,contextptr); + vecteur l(lvar(e0)); + for (int i=0;;++i){ + gen X("x"+print_INT_(i),contextptr); + if (X.type!=_IDNT || equalposcomp(l,X)) + continue; + if (_about(X,contextptr)!=X) + continue; + return in_limit(quotesubst(e0,x,X,contextptr),*X._IDNTptr,lim_point,direction,contextptr); + } + // never reached + gen xprime("x"+print_INT_(giac_rand(contextptr)),contextptr); + return in_limit(quotesubst(e0,x,xprime,contextptr),*xprime._IDNTptr,lim_point,direction,contextptr); } gen e=Heavisidetosign(when2sign(piecewise2when(e0,contextptr),contextptr),contextptr); // Adjust direction for +/- inf limits @@ -2535,9 +2593,10 @@ namespace giac { if (has_i(lop(e,at_ln))) e=recursive_normal(expln2trig(e,contextptr),contextptr); vecteur vsign(loptab(e,sign_floor_ceil_round_tab)); - if (0 && direction && !vsign.empty() && !equalposcomp(sign_floor_ceil_round_tab,e._SYMBptr->sommet)){ + if (//0 && + direction && !vsign.empty() && !equalposcomp(sign_floor_ceil_round_tab,e._SYMBptr->sommet)){ // evaluate vsign first - vecteur res; + vecteur res(vsign.size()); for (int i=0;i plus_inf bool dont_invert=is_zero(in_limit(faster_var.front(),x,plus_inf,0,contextptr)); vecteur faster_var_tmp(faster_var); +#if 1 // FXCG + tri_rlvarx(faster_var); +#else stable_sort(faster_var.begin(),faster_var.end(),symb_size_less_t()); - identificateur w(" w"); +#endif + vecteur ecopyv(lidnt(ecopy)); + string ws("w"); + identificateur w(ws); + // create free identifier, not present in ecopy + while (equalposcomp(ecopyv,w)){ + ws+='_'; + w=identificateur(ws); + } vecteur faster_var_subst(1,w); gen g=faster_var.front()._SYMBptr->feuille; iterateur it=faster_var.begin()+1,itend=faster_var.end(); @@ -2970,6 +3040,8 @@ namespace giac { f=subst(f,w,inv(w,contextptr),false,contextptr); if (faster_var.front().is_symb_of_sommet(at_exp)){ // replace ln(exp(g)^k*...) by k*g+ln(...) + // where g=ln(w) + gen effg(g); // symbolic(at_ln,w)); does not work vecteur lf(lop(f,at_ln)),lf1,lf2; iterateur it=lf.begin(),itend=lf.end(); for (;it!=itend;++it){ @@ -2979,7 +3051,7 @@ namespace giac { if (!is_zero(p.front().exponent)) argln=argln*symbolic(at_pow,gen(makevecteur(w,-p.front().exponent),_SEQ__VECT)); lf1.push_back(*it); - lf2.push_back(p.front().exponent*(dont_invert?g:-g)+symbolic(at_ln,argln)); + lf2.push_back(p.front().exponent*(dont_invert?effg:-effg)+symbolic(at_ln,argln)); } } if (!lf1.empty()) @@ -3584,14 +3656,14 @@ namespace giac { gen f0=f._VECTptr->front(); gen x =f[1]; if (x.type!=_IDNT){ - *logptr(contextptr) << gettext("Unable to convert to euler mac laurin"); + *logptr(contextptr) << gettext("Unable to convert to euler mac laurin") << ' '; return false; } gen f0prime=derive(f0,x,contextptr), f03=derive(f0prime,x,contextptr); f03=derive(f03,x,contextptr); if (is_undef(f03)) return false; l=in_limit(f03/f0prime,n,plus_inf,1,contextptr); - if (!is_zero(l)) + if (!is_zero(l)) return false; gen remains; gen F0=integrate_gen_rem(f0,x,remains,0,contextptr); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/solve.cc b/apps/KhiCAS/src/giac-1.6.0/src/solve.cc index 985151d1d..167a6a2c9 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/solve.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/solve.cc @@ -652,7 +652,7 @@ namespace giac { // A*exp(a*x+b)+C*x+D=0, t=a*x+b // A*exp(t)+C*(t-b)/a+D=0 -> A*exp(t)+C/a*t+D-C*b/a=0 gen a_(A),b_(C/a),c_(D-C*b/a); - gen delta=a_/b_*exp(-c_/b_,contextptr); + gen delta=ratnormal(a_/b_*exp(-c_/b_,contextptr),contextptr); if (is_strictly_greater(m1,delta,contextptr)) return; // no solution gen sol=-_LambertW(delta,contextptr)-c_/b_; @@ -1890,12 +1890,12 @@ namespace giac { // tmp=a*tmplv[0]+c*tmplv[1]+d if (tmplv[0]._SYMBptr->sommet==at_sin && tmplv[1]._SYMBptr->sommet==at_cos){ // a*sin(x)+c*cos(x)=C*sin(x+phi) where exp(i*phi)=a+i*c; - gen phi=arg(halftan(a+cst_i*c,contextptr),contextptr); + gen phi=is_zero(d)?atan(halftan(c/a,contextptr),contextptr):arg(halftan(a+cst_i*c,contextptr),contextptr); tmp=sqrt(a*a+c*c,contextptr)*sin(tmplv[0]._SYMBptr->feuille+phi,contextptr)+d; } if (tmplv[0]._SYMBptr->sommet==at_cos && tmplv[1]._SYMBptr->sommet==at_sin){ // a*cos(x)+c*sin(x)=C*sin(x+phi) where exp(i*phi)=c+i*a; - gen phi=arg(halftan(c+cst_i*a,contextptr),contextptr); + gen phi=is_zero(d)?atan(halftan(a/c,contextptr),contextptr):arg(halftan(c+cst_i*a,contextptr),contextptr); tmp=sqrt(a*a+c*c,contextptr)*sin(tmplv[0]._SYMBptr->feuille+phi,contextptr)+d; } } @@ -1904,12 +1904,12 @@ namespace giac { // tmp=a*tmplv[0]+c*tmplv[1]+d if (tmplv[1]._SYMBptr->sommet==at_sin && tmplv[0]._SYMBptr->sommet==at_cos){ // a*sin(x)+c*cos(x)=C*sin(x+phi) where exp(i*phi)=a+i*c; - gen phi=arg(halftan(a+cst_i*c,contextptr),contextptr); + gen phi=is_zero(d)?atan(halftan(c/a,contextptr),contextptr):arg(halftan(a+cst_i*c,contextptr),contextptr); tmp=sqrt(a*a+c*c,contextptr)*sin(tmplv[1]._SYMBptr->feuille+phi,contextptr)+d; } if (tmplv[1]._SYMBptr->sommet==at_cos && tmplv[0]._SYMBptr->sommet==at_sin){ // a*cos(x)+c*sin(x)=C*sin(x+phi) where exp(i*phi)=c+i*a; - gen phi=arg(halftan(c+cst_i*a,contextptr),contextptr); + gen phi=is_zero(d)?atan(halftan(a/c,contextptr),contextptr):arg(halftan(c+cst_i*a,contextptr),contextptr); tmp=sqrt(a*a+c*c,contextptr)*sin(tmplv[1]._SYMBptr->feuille+phi,contextptr)+d; } } @@ -1963,7 +1963,10 @@ namespace giac { if (real && has_i(tmp)) continue; #ifdef HAVE_LIBMPFR - tmp=_evalf(makesequence(tmp,100),contextptr); + if (has_op(sol[i],*at_LambertW)) // workaround for solve([(a)*(k)=1, (a)*(exp((3)*(k)))=(3)*(e)],[a, k]);, eval with 100 digits in moyal.cc takes too much time + tmp=_evalf(makesequence(tmp,30),contextptr); + else + tmp=_evalf(makesequence(tmp,100),contextptr); #endif tmp=evalf_double(tmp,1,contextptr); if (real && tmp.type==_CPLX) @@ -2014,6 +2017,20 @@ namespace giac { } if (expr.is_symb_of_sommet(at_neg)) expr=expr._SYMBptr->feuille; + if (expr.is_symb_of_sommet(at_inv)){ + // if expr has tan inside, subst tan by 1/x then x->0 if it's 0 we have additional solutions if arg of tan=pi/2 + vecteur lv(lvarx(expr,x)); + if (lv.size()==1 && lv[0].is_symb_of_sommet(at_tan)){ + gen chk=subst(expr,lv[0],inv(x,contextptr),false,contextptr); + chk=limit(chk,x,0,0,contextptr); + if (chk==0){ + chk=cos(lv[0]._SYMBptr->feuille,contextptr); + vecteur v1(solve_cleaned(chk,e_check,x,isolate_mode,contextptr)); + return v1; + } + } + return vecteur(0); + } if (expr.is_symb_of_sommet(at_prod)){ vecteur v=gen2vecteur(expr._SYMBptr->feuille),res; for (unsigned i=0;i=3){ + gen tst=tsimplify(_lin(a1/a2,contextptr),contextptr); + w=lvarx(tst,v.back()); + if (w.size()==1) + return _solve(makesequence(tst-1,v.back()),contextptr); + } gen a1arg,a2arg; bool a1log=is_log10(a1,a1arg),a2log=is_log10(a2,a2arg); if (a1log && a2log){ @@ -2983,6 +3009,14 @@ namespace giac { } gen _solve(const gen & args,GIAC_CONTEXT){ if ( args.type==_STRNG && args.subtype==-1) return args; + if (is_equal(args) && args._SYMBptr->feuille[1]==0 && args._SYMBptr->feuille[0].type==_INT_){ + int v=args._SYMBptr->feuille[0].val; + if (v==16 || v==10 || v==8 || v==2){ + *logptr(contextptr) << "Integer format set to " << v << '\n'; + integer_format(v,contextptr); + return vecteur(0); + } + } gen res=_solve_uncompressed(args,contextptr); if (res.type==_VECT){ vecteur v=*res._VECTptr; @@ -3837,7 +3871,12 @@ namespace giac { if (s==2 && v[1].type==_IDNT){ // no initial guess, check for poly-like equation vecteur lv(lvar(v0)); - lv=lvar(evalf(lv,1,contextptr)); + if (contextptr && contextptr->quoted_global_vars){ + contextptr->quoted_global_vars->push_back(lv[1]); + lv=lvar(evalf(lv,1,contextptr)); // this should not evalf v[1], otherwise x:=10; solve(x^(3/2)=3.,x); will fail + contextptr->quoted_global_vars->pop_back(); + } else + lv=lvar(evalf(lv,1,contextptr)); int lvs=int(lv.size()); bool poly=true; for (unsigned i=0;iprint(contextptr))); } } + // if one equation factors recurse with each factor + for (size_t i=0;i2){ + vecteur res; + for (size_t j=0;j=2){ // try by resultant + //eq=*eqs._VECTptr; + gen r=0; + for (size_t i=1;isize()==1){ + if (!is_zero(G._VECTptr->front())) + return vecteur(0); // system was equivalent to 1=0 + gensizeerr("solve.cc internal error"); + } if (G.type==_VECT && G._VECTptr->size()==var.size()+4 && G._VECTptr->front().type==_INT_ && G._VECTptr->front().val==_RUR_REVLEX){ vecteur Gv=*G._VECTptr,S; gen rurvar=var.front(); @@ -7035,7 +7112,7 @@ namespace giac { const_iterateur xt=xsol.begin(),xtend=xsol.end(); for (;xt!=xtend;++xt){ // current[xpos]=*xt; - if (is_inequation(*xt)){ // FIXME is_inequation + if (is_inequation(*xt) || xt->is_symb_of_sommet(at_and) || xt->is_symb_of_sommet(at_ou)){ // FIXME is_inequation gen id=lidnt(*xt); if (id.type==_VECT && id._VECTptr->size()==1){ id=id._VECTptr->front(); @@ -7706,6 +7783,10 @@ namespace giac { eqs.erase(eqs.begin()+i); for (unsigned k=0;kg._VECTptr->at(2)._VECTptr->size(), m = gc->g._VECTptr->at(1)._VECTptr->size(); + double *x; +#ifndef NO_STDEXCEPT + try { + x = new double[n]; + } catch (const std::bad_alloc &e) { + return COBYLA_ENOMEM; + } +#else + x = (double *) malloc (n*sizeof(double)); + if (!x) return COBYLA_ENOMEM; +#endif + for (int i = 0; i < n; ++i) + { + gen tmp = evalf_double(x0[i], 1, gc->contextptr); + if (tmp.type != _DOUBLE_) + return COBYLA_EINVAL; + x[i] = tmp._DOUBLE_val; + } + int cres = cobyla(n, m, x, x[0] / 100, eps, msg, &maxiter, cobyla_giac_function, gc); + vecteur res(n); + for (int i = 0; i < n; ++i) + x0[i] = x[i]; +#ifndef NO_STDEXCEPT + delete[] x; +#else + free(x); +#endif + return cres; + } + #endif // GIAC_HAS_STO_38 + #ifndef NO_NAMESPACE_GIAC } // namespace giac #endif // ndef NO_NAMESPACE_GIAC diff --git a/apps/KhiCAS/src/giac-1.6.0/src/solve.h b/apps/KhiCAS/src/giac-1.6.0/src/solve.h index 7cd1b04df..3067cc709 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/solve.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/solve.h @@ -155,6 +155,20 @@ namespace giac { // returns an error or the vecteur of coordinates of variables // and sets min_value to f at this point gen fmin_cobyla(const gen & f,const vecteur & constraints,const vecteur & variables,const vecteur & guess,const gen & eps0,const gen & maxiter0,GIAC_CONTEXT); + // gen-context struct (moved from solve.cc by L. Marohnić) + typedef struct gen_context { + gen g; // should be a vector [function,conditions,variables] + const context * contextptr; + } cobyla_gc; + // minimize F subject to CON. (added by L. Marohnić) + // F: the expression to be minimized + // CON: list of expressions that must be positive for feasibility + // X: list of variables + // X0: on input, initial point; on output, the last obtained point + // MAXITER: on input, maximum allowed number of function evaluations; on output, the total number of evaluations + // EPS: tolerance, a positive number + // MSG: verbosity level for COBYLA algorithm; from 0 (no output) to 3 (full output) + int giac_cobyla(cobyla_gc *gc,vecteur &x0,int &maxiter,double eps=1e-8,int msg=0); #ifndef NO_NAMESPACE_GIAC } // namespace giac diff --git a/apps/KhiCAS/src/giac-1.6.0/src/subst.cc b/apps/KhiCAS/src/giac-1.6.0/src/subst.cc index 3622cbdaf..d1189d920 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/subst.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/subst.cc @@ -1768,10 +1768,13 @@ namespace giac { if (e._SYMBptr->feuille.type==_VECT){ vecteur & v=*e._SYMBptr->feuille._VECTptr; if (e._SYMBptr->sommet==at_pow && v[1].type!=_INT_ && !(v[1].type==_FRAC && is_integer(v[0]))){ - gen g=pow2expln(v[0],contextptr); - if (g.is_symb_of_sommet(at_exp)) - return symb_exp(g._SYMBptr->feuille*pow2expln(v[1],contextptr)); - return symb_exp(pow2expln(v[1],contextptr)*symb_ln(g)); + gen v0; + if (1 || !has_evalf(v[0],v0,1,contextptr)){ + gen g=pow2expln(v[0],contextptr); + if (g.is_symb_of_sommet(at_exp)) + return symb_exp(g._SYMBptr->feuille*pow2expln(v[1],contextptr)); + return symb_exp(pow2expln(v[1],contextptr)*symb_ln(g)); + } } } return e._SYMBptr->sommet(pow2expln(e._SYMBptr->feuille,contextptr),contextptr); @@ -2033,6 +2036,8 @@ namespace giac { vecteur & ligne=*m[i]._VECTptr; gen res(plus_one); for (int j=0;jFFTMUL_SIZE) // exponent too large for further simplifications + return e; res=res*pow(independant[j],ligne[j],contextptr); } newl[i]=res; diff --git a/apps/KhiCAS/src/giac-1.6.0/src/sym2poly.cc b/apps/KhiCAS/src/giac-1.6.0/src/sym2poly.cc index 5cf3d97fc..59252dba3 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/sym2poly.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/sym2poly.cc @@ -2364,6 +2364,11 @@ namespace giac { f=min_pol(*(pp._EXTptr+1)); // f is a _VECT if (is_undef(f)) return f; + if (keep_algext(contextptr)){ + gen value=r2sym(*pp._EXTptr,lt,ltend,contextptr); + f=r2sym(f,lt,ltend,contextptr); + return algebraic_EXTension(value,f); + } if (f._VECTptr->size()==3){ gen value; if (!has_rootof_value(f,value,contextptr)) @@ -2735,6 +2740,22 @@ namespace giac { return symbolic(at_prod,gen(res,_SEQ__VECT)); } + gen rewrite_exp_integer(const gen & e,GIAC_CONTEXT){ + vecteur v(lop(e,at_exp)); + if (v.size()<2) + return e; + gen g; + for (unsigned i=0;ifeuille); // gcd of arg of exp + vecteur w(v); + for (unsigned i=0;ifeuille/g,contextptr); + if (r.type==_INT_ && r.val!=1) + w[i]=symbolic(at_pow,makesequence(symb_exp(g),r)); + } + return v==w?e:subst(e,v,w,false,contextptr); + } + static gen in_normalize_sqrt(const gen & e,vecteur & L,bool keep_abs,GIAC_CONTEXT){ if (complex_mode(contextptr) || has_i(e)) return e; @@ -2857,7 +2878,7 @@ namespace giac { gen normalize_sqrt(const gen & e,GIAC_CONTEXT,bool keep_abs){ vecteur L; - return in_normalize_sqrt(e,L,keep_abs,contextptr); + return in_normalize_sqrt(rewrite_exp_integer(e,contextptr),L,keep_abs,contextptr); } static bool has_embedded_fractions(const gen & g){ @@ -2935,7 +2956,7 @@ namespace giac { } } - gen normal(const gen & e,bool distribute_div,GIAC_CONTEXT){ + gen normal(const gen & e,bool distribute_div,bool allow_embeded_recursion,GIAC_CONTEXT){ if (has_num_coeff(e)) return ratnormal(e,contextptr); // COUT << e << "\n"; @@ -3060,7 +3081,7 @@ namespace giac { if (has_embedded_fractions(f.num) || has_embedded_fractions(f.den)){ gen res=r2sym(f,l,contextptr); purgeassumelist(L,contextptr); - return normal(res,distribute_div,contextptr); + return allow_embeded_recursion?normal(res,distribute_div,false,contextptr):res; } if (distribute_div && f.num.type==_POLY && f.num._POLYptr->dim && f.den.type<_POLY){ gen res=r2sym(gen(*f.num._POLYptr/f.den),l,contextptr); @@ -3088,6 +3109,10 @@ namespace giac { return ee; // ratnormal(ee,contextptr); // for sqrt(1-a^2)/sqrt(1-a) } + gen normal(const gen & e,bool distribute_div,GIAC_CONTEXT){ + return normal(e,distribute_div,true,contextptr); + } + gen normal(const gen & e,GIAC_CONTEXT){ return normal(e,true,contextptr); } @@ -3106,6 +3131,8 @@ namespace giac { if (g.type==_FUNC) return 1; if (g.type==_VECT){ + if (g.subtype==_PNT__VECT) + return 0; const_iterateur it=g._VECTptr->begin(),itend=g._VECTptr->end(); for (;it!=itend;++it){ if (it->type==_STRNG) @@ -4071,6 +4098,11 @@ namespace giac { } } if (v[0].type==_VECT && v[1].type==_VECT){ +#ifdef FXCG + gen res; + subresultant(*v[0]._VECTptr,*v[1]._VECTptr,res); + return res; +#else gen g1,g2; int t1=coefftype(*v[0]._VECTptr,g1),t2=coefftype(*v[1]._VECTptr,g2); double eps=epsilon(contextptr); @@ -4094,7 +4126,7 @@ namespace giac { vecteur2vector_int(B,m.val,b); return makemod(resultant_int(a,b,tmp1,tmp2,m.val),m); } -#if defined INT128 && !defined USE_GMP_REPLACEMENTS && !defined BF2GMP_H +#if defined INT128 && !defined USE_GMP_REPLACEMENTS && !defined BF2GMP_H if (m.type==_ZINT && sizeinbase2(m)<61){ longlong p=mpz_get_si(*m._ZINTptr); int n=giacmax(A.size(),B.size()); @@ -4109,6 +4141,7 @@ namespace giac { #endif return makemod(mod_resultant(A,B,eps),m); } +#endif // FXCG // not very efficient... gen g(identificateur("tresultant")); v[0]=_poly2symb(makesequence(v[0],g),contextptr); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/symbolic.cc b/apps/KhiCAS/src/giac-1.6.0/src/symbolic.cc index 9b62bc474..9345ceff0 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/symbolic.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/symbolic.cc @@ -1658,8 +1658,12 @@ namespace giac { unsigned taille(const gen & g,unsigned max){ + if (g.type==_ZINT) + return 1+mpz_sizeinbase(*g._ZINTptr,16)/4; if (g.type<=_IDNT) return 1; + if (g.type==_STRNG) + return g._STRNGptr->size()/4+1; if (g.type==_FRAC) return 1+taille(g._FRACptr->num,max)+taille(g._FRACptr->den,max); if (g.type==_SYMB){ diff --git a/apps/KhiCAS/src/giac-1.6.0/src/tex.cc b/apps/KhiCAS/src/giac-1.6.0/src/tex.cc index d3b39a582..5d21b071c 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/tex.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/tex.cc @@ -36,11 +36,6 @@ using namespace std; #include "rpn.h" #include "plot.h" #include "giacintl.h" -#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS -inline bool is_graphe(const giac::gen &g,std::string &disp_out,const giac::context *){ return false; } -#else -#include "graphtheory.h" -#endif #if !defined NSPIRE && !defined FXCG && !defined GIAC_HAS_STO_38 && !defined KHICAS && !defined NSPIRE_NEWLIB #include @@ -975,16 +970,26 @@ namespace giac { } } if (g.type==_VECT ){ - if (!curve && g.subtype==_GROUP__VECT && !has_i(g) && !g._VECTptr->empty() && g._VECTptr->front().type!=_VECT){ // "compressed" hypersurface + if (!curve && g.subtype==_GROUP__VECT && !g._VECTptr->empty() && g._VECTptr->front().type!=_VECT){ // "compressed" hypersurface? vecteur v=*evalf_double(g,1,contextptr)._VECTptr; int s=v.size(); if (s%3==0){ - for (int i=0;i(v[s-1]-v[0]) || (M-m)<0.01*(v[s-1]-v[0])){ - M=v[s-1]; - m=v[0]; - zoom(m,M,1.1); + bool b=(M-m)<0.01*(v[s-1]-v[0]); + if (fullview || 1.75*(M-m)>(v[s-1]-v[0]) || b){ + if (b) + zoom(m,M,3); + else { + M=v[s-1]; + m=v[0]; + zoom(m,M,1.1); + } } else zoom(m,M,1/0.8); @@ -1398,11 +1408,6 @@ namespace giac { case _VECT: if (e.subtype==_SPREAD__VECT) return spread2tex(*e._VECTptr,1,contextptr); - if (e.subtype==_GRAPH__VECT){ - string s; - if (is_graphe(e,s,contextptr)) - return "\\mbox{"+s+'}'; - } if (!e._VECTptr->empty() && e._VECTptr->back().is_symb_of_sommet(at_pnt) && !is3d(e._VECTptr->back()) ) return vectpnt2tex(e,contextptr); if (ckmatrix(*e._VECTptr)) diff --git a/apps/KhiCAS/src/giac-1.6.0/src/tex.cc~ b/apps/KhiCAS/src/giac-1.6.0/src/tex.cc~ new file mode 100755 index 000000000..ad2b6c6e1 --- /dev/null +++ b/apps/KhiCAS/src/giac-1.6.0/src/tex.cc~ @@ -0,0 +1,1771 @@ +// -*- mode:C++ ; compile-command: "g++-3.4 -I.. -g -c tex.cc" -*- +#include "giacPCH.h" + +/* + * Copyright (C) 2002,2014 B. Parisse, Institut Fourier, 38402 St Martin d'Heres + * Figure printing adapted from eukleides (c) 2002, Christian Obrecht + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +//#include +#include +#include +#ifdef __ANDROID__ +using std::vector; +#endif + +using namespace std; +#include "gen.h" +#include "gausspol.h" +#include "identificateur.h" +#include "symbolic.h" +#include "poly.h" +#include "usual.h" +#include "tex.h" +#include "prog.h" +#include "rpn.h" +#include "plot.h" +#include "giacintl.h" +#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS +inline bool is_graphe(const giac::gen &g,std::string &disp_out,const giac::context *){ return false; } +#else +#include "graphtheory.h" +#endif + +#if !defined NSPIRE && !defined FXCG && !defined GIAC_HAS_STO_38 && !defined KHICAS && !defined NSPIRE_NEWLIB +#include +#endif + +#ifndef NO_NAMESPACE_GIAC +namespace giac { +#endif // ndef NO_NAMESPACE_GIAC + + // find if a*x+b*y=c intersects the rectangle xmin..xmax,ymin..ymax + // if true set x0,y0 and x1,y1 to the intersections + bool is_clipped(double a,double xmin,double xmax,double b,double ymin,double ymax,double c,double & x0,double &y0,double & x1,double &y1){ + int found=0; + // find the intersects with x=xmin/x=xmax + double x,y; + // test whether a or b is too small + double theta=std::atan2(b,a); + if (absdouble(M_PI/2-absdouble(theta))<1e-3){ + // line y=cst + x0=xmin; + x1=xmax; + y0=y1=c/b; + return y0>=ymin && y0<=ymax; + } + if (absdouble(theta)<1e-3 || (M_PI-absdouble(theta))<1e-3){ + // line x=cst + y0=ymin; + y1=ymax; + x0=x1=c/a; + return x0>=xmin && x0<=xmax; + } + y=(c-a*xmin)/b; + if (y>=ymin && y<=ymax){ + ++found; + x0=xmin; + y0=y; + } + y=(c-a*xmax)/b; + if (y>=ymin && y<=ymax){ + if (found){ + x1=xmax; + y1=y; + return true; + } + ++found; + x0=xmax; + y0=y; + } + x=(c-b*ymin)/a; + if (x>=xmin && x<=xmax){ + if (found){ + x1=x; + y1=ymin; + return true; + } + ++found; + x0=x; + y0=ymin; + } + x=(c-b*ymax)/a; + if (x>=xmin && x<=xmax){ + if (found){ + x1=x; + y1=ymax; + return true; + } + ++found; + x0=x; + y0=ymax; + } + return false; + } + + bool in_rectangle(double ax,double ay,double xmin,double ymin,double xmax,double ymax){ + return (ax>=xmin && ax<=xmax && ay>=ymin && ay<=ymax); + } + + // clip line or segment or halfline, result in xa,ya xb,yb + // mode can be _LINE__VECT (line), _HALFLINE__VECT (halfline) + // anything else is considered to be a segment + // return true if there is something to draw + bool clip_line(double x1,double y1,double x2,double y2,double xmin,double ymin,double xmax,double ymax,int mode,double & xa,double & ya,double & xb,double & yb){ + bool in1=in_rectangle(x1,y1,xmin,ymin,xmax,ymax); + bool in2=in_rectangle(x2,y2,xmin,ymin,xmax,ymax); + if (mode!=_LINE__VECT && mode !=_HALFLINE__VECT && in1 && in2){ + xa=x1; ya=y1; xb=x2; yb=y2; + return true; + } + // Line equation is (y2-y1)*x-(x2-x1)*y=(y2*x1-x2*y1) + double dy=y2-y1; + double dx=x2-x1; + double c=(y2*x1-x2*y1); + bool a=false,b=false; + // Find 2 intersections y of x=xmin and x=xmax with line + // Check if they are inside clip region >=ymin and <=ymax + if (dx){ + double y=(dy*xmin-c)/dx; + if (y>=ymin && y<=ymax){ + xa=xmin; + ya=y; + a=true; + } + y=(dy*xmax-c)/dx; + if (y>=ymin && y<=ymax){ + if (a){ xb=xmax; yb=y; b=true; } + else { xa=xmax; ya=y; a=true; } + } + } + // Find 2 intersections of y=ymin and y=ymax with line + if (!b && dy){ + double x=(dx*ymin+c)/dy; + if (x>=xmin && x<=xmax){ + if (a){ xb=x; yb=ymin; b=true; } + else { xa=x; ya=ymin; a=true;} + } + x=(dx*ymax+c)/dy; + if (x>=xmin && x<=xmax){ + if (a){ xb=x; yb=ymax; b=true; } + else { xa=x; ya=ymax; a=true;} + } + } + if (a && b){ // if not true there is nothing to draw + // First case is line, we are done + if (mode==_LINE__VECT) + return true; + if (mode!=_HALFLINE__VECT){ // segment + // we know that both points are not inside + if (!in1 && !in2) // both are outside, it's like a line + return (xa-xmin)*(xb-xmin)<0; + if (in1){ // 1 is in, 2 not, find if a is between 1 and 2 + if ((xa-x1)*(x2-x1)>0 || (ya-y1)*(y2-y1)>0){ + xb=x1; yb=y1; + } + else { + xa=x1; ya=y1; + } + return true; + } + if (in2){ // 2 is in, 1 not, find if a is between 2 and 1 + if ((xa-x2)*(x1-x2)>0 || (ya-y2)*(y1-y2)>0){ + xb=x2; yb=y2; + } + else { + xa=x2; ya=y2; + } + return true; + } + } + } + return false; + } + + // dimension of the LaTeX output figures default 12 cm x 12 cm + double horiz_latex=12.; + double vert_latex=12.; + const char tex_preamble[]="\\documentclass{article} \n\\usepackage{pst-plot,color} \n\\usepackage{graphicx} \n\\begin{document}\n"; +#if defined RTOS_THREADX || defined POCKETCAS + const char tex_color[]=""; +#else + const char tex_color[]="\\newrgbcolor{fltkcolor0}{0 0 0}\n\\newrgbcolor{fltkcolor1}{0.9961 0 0}\n\\newrgbcolor{fltkcolor2}{0 0.9961 0}\n\\newrgbcolor{fltkcolor3}{0.9961 0.9961 0}\n\\newrgbcolor{fltkcolor4}{0 0 0.9961}\n\\newrgbcolor{fltkcolor5}{0.9961 0 0.9961}\n\\newrgbcolor{fltkcolor6}{0 0.9961 0.9961}\n\\newrgbcolor{fltkcolor7}{0.9961 0.9961 0.9961}\n\\newrgbcolor{fltkcolor8}{0.332 0.332 0.332}\n\\newrgbcolor{fltkcolor9}{0.7734 0.4414 0.4414}\n\\newrgbcolor{fltkcolor10}{0.4414 0.7734 0.4414}\n\\newrgbcolor{fltkcolor11}{0.5547 0.5547 0.2188}\n\\newrgbcolor{fltkcolor12}{0.4414 0.4414 0.7734}\n\\newrgbcolor{fltkcolor13}{0.5547 0.2188 0.5547}\n\\newrgbcolor{fltkcolor14}{0.2188 0.5547 0.5547}\n\\newrgbcolor{fltkcolor15}{0 0 0.5}\n\\newrgbcolor{fltkcolor16}{0.6562 0.6562 0.5938}\n\\newrgbcolor{fltkcolor17}{0.9062 0.9062 0.8438}\n\\newrgbcolor{fltkcolor18}{0.4062 0.4062 0.3438}\n\\newrgbcolor{fltkcolor19}{0.5938 0.6562 0.6562}\n\\newrgbcolor{fltkcolor20}{0.8438 0.9062 0.9062}\n\\newrgbcolor{fltkcolor21}{0.3438 0.4062 0.4062}\n\\newrgbcolor{fltkcolor22}{0.6094 0.6094 0.6562}\n\\newrgbcolor{fltkcolor23}{0.8594 0.8594 0.9062}\n\\newrgbcolor{fltkcolor24}{0.3594 0.3594 0.4062}\n\\newrgbcolor{fltkcolor25}{0.6094 0.6562 0.6094}\n\\newrgbcolor{fltkcolor26}{0.8594 0.9062 0.8594}\n\\newrgbcolor{fltkcolor27}{0.3594 0.4062 0.3594}\n\\newrgbcolor{fltkcolor28}{0.5625 0.5625 0.5625}\n\\newrgbcolor{fltkcolor29}{0.75 0.75 0.75}\n\\newrgbcolor{fltkcolor30}{0.3125 0.3125 0.3125}\n\\newrgbcolor{fltkcolor31}{0.625 0.625 0.625}\n\\newrgbcolor{fltkcolor32}{0 0 0}\n\\newrgbcolor{fltkcolor33}{0.05078 0.05078 0.05078}\n\\newrgbcolor{fltkcolor34}{0.1016 0.1016 0.1016}\n\\newrgbcolor{fltkcolor35}{0.1484 0.1484 0.1484}\n\\newrgbcolor{fltkcolor36}{0.1914 0.1914 0.1914}\n\\newrgbcolor{fltkcolor37}{0.2383 0.2383 0.2383}\n\\newrgbcolor{fltkcolor38}{0.2812 0.2812 0.2812}\n\\newrgbcolor{fltkcolor39}{0.332 0.332 0.332}\n\\newrgbcolor{fltkcolor40}{0.3711 0.3711 0.3711}\n\\newrgbcolor{fltkcolor41}{0.4141 0.4141 0.4141}\n\\newrgbcolor{fltkcolor42}{0.457 0.457 0.457}\n\\newrgbcolor{fltkcolor43}{0.5 0.5 0.5}\n\\newrgbcolor{fltkcolor44}{0.5391 0.5391 0.5391}\n\\newrgbcolor{fltkcolor45}{0.582 0.582 0.582}\n\\newrgbcolor{fltkcolor46}{0.625 0.625 0.625}\n\\newrgbcolor{fltkcolor47}{0.6641 0.6641 0.6641}\n\\newrgbcolor{fltkcolor48}{0.707 0.707 0.707}\n\\newrgbcolor{fltkcolor49}{0.75 0.75 0.75}\n\\newrgbcolor{fltkcolor50}{0.793 0.793 0.793}\n\\newrgbcolor{fltkcolor51}{0.832 0.832 0.832}\n\\newrgbcolor{fltkcolor52}{0.875 0.875 0.875}\n\\newrgbcolor{fltkcolor53}{0.9141 0.9141 0.9141}\n\\newrgbcolor{fltkcolor54}{0.957 0.957 0.957}\n\\newrgbcolor{fltkcolor55}{0.9961 0.9961 0.9961}\n\\newrgbcolor{fltkcolor56}{0 0 0}\n\\newrgbcolor{fltkcolor57}{0 0.1406 0}\n\\newrgbcolor{fltkcolor58}{0 0.2812 0}\n\\newrgbcolor{fltkcolor59}{0 0.4258 0}\n\\newrgbcolor{fltkcolor60}{0 0.5664 0}\n\\newrgbcolor{fltkcolor61}{0 0.7109 0}\n\\newrgbcolor{fltkcolor62}{0 0.8516 0}\n\\newrgbcolor{fltkcolor63}{0 0.9961 0}\n\\newrgbcolor{fltkcolor64}{0.2461 0 0}\n\\newrgbcolor{fltkcolor65}{0.2461 0.1406 0}\n\\newrgbcolor{fltkcolor66}{0.2461 0.2812 0}\n\\newrgbcolor{fltkcolor67}{0.2461 0.4258 0}\n\\newrgbcolor{fltkcolor68}{0.2461 0.5664 0}\n\\newrgbcolor{fltkcolor69}{0.2461 0.7109 0}\n\\newrgbcolor{fltkcolor70}{0.2461 0.8516 0}\n\\newrgbcolor{fltkcolor71}{0.2461 0.9961 0}\n\\newrgbcolor{fltkcolor72}{0.4961 0 0}\n\\newrgbcolor{fltkcolor73}{0.4961 0.1406 0}\n\\newrgbcolor{fltkcolor74}{0.4961 0.2812 0}\n\\newrgbcolor{fltkcolor75}{0.4961 0.4258 0}\n\\newrgbcolor{fltkcolor76}{0.4961 0.5664 0}\n\\newrgbcolor{fltkcolor77}{0.4961 0.7109 0}\n\\newrgbcolor{fltkcolor78}{0.4961 0.8516 0}\n\\newrgbcolor{fltkcolor79}{0.4961 0.9961 0}\n\\newrgbcolor{fltkcolor80}{0.7461 0 0}\n\\newrgbcolor{fltkcolor81}{0.7461 0.1406 0}\n\\newrgbcolor{fltkcolor82}{0.7461 0.2812 0}\n\\newrgbcolor{fltkcolor83}{0.7461 0.4258 0}\n\\newrgbcolor{fltkcolor84}{0.7461 0.5664 0}\n\\newrgbcolor{fltkcolor85}{0.7461 0.7109 0}\n\\newrgbcolor{fltkcolor86}{0.7461 0.8516 0}\n\\newrgbcolor{fltkcolor87}{0.7461 0.9961 0}\n\\newrgbcolor{fltkcolor88}{0.9961 0 0}\n\\newrgbcolor{fltkcolor89}{0.9961 0.1406 0}\n\\newrgbcolor{fltkcolor90}{0.9961 0.2812 0}\n\\newrgbcolor{fltkcolor91}{0.9961 0.4258 0}\n\\newrgbcolor{fltkcolor92}{0.9961 0.5664 0}\n\\newrgbcolor{fltkcolor93}{0.9961 0.7109 0}\n\\newrgbcolor{fltkcolor94}{0.9961 0.8516 0}\n\\newrgbcolor{fltkcolor95}{0.9961 0.9961 0}\n\\newrgbcolor{fltkcolor96}{0 0 0.2461}\n\\newrgbcolor{fltkcolor97}{0 0.1406 0.2461}\n\\newrgbcolor{fltkcolor98}{0 0.2812 0.2461}\n\\newrgbcolor{fltkcolor99}{0 0.4258 0.2461}\n\\newrgbcolor{fltkcolor100}{0 0.5664 0.2461}\n\\newrgbcolor{fltkcolor101}{0 0.7109 0.2461}\n\\newrgbcolor{fltkcolor102}{0 0.8516 0.2461}\n\\newrgbcolor{fltkcolor103}{0 0.9961 0.2461}\n\\newrgbcolor{fltkcolor104}{0.2461 0 0.2461}\n\\newrgbcolor{fltkcolor105}{0.2461 0.1406 0.2461}\n\\newrgbcolor{fltkcolor106}{0.2461 0.2812 0.2461}\n\\newrgbcolor{fltkcolor107}{0.2461 0.4258 0.2461}\n\\newrgbcolor{fltkcolor108}{0.2461 0.5664 0.2461}\n\\newrgbcolor{fltkcolor109}{0.2461 0.7109 0.2461}\n\\newrgbcolor{fltkcolor110}{0.2461 0.8516 0.2461}\n\\newrgbcolor{fltkcolor111}{0.2461 0.9961 0.2461}\n\\newrgbcolor{fltkcolor112}{0.4961 0 0.2461}\n\\newrgbcolor{fltkcolor113}{0.4961 0.1406 0.2461}\n\\newrgbcolor{fltkcolor114}{0.4961 0.2812 0.2461}\n\\newrgbcolor{fltkcolor115}{0.4961 0.4258 0.2461}\n\\newrgbcolor{fltkcolor116}{0.4961 0.5664 0.2461}\n\\newrgbcolor{fltkcolor117}{0.4961 0.7109 0.2461}\n\\newrgbcolor{fltkcolor118}{0.4961 0.8516 0.2461}\n\\newrgbcolor{fltkcolor119}{0.4961 0.9961 0.2461}\n\\newrgbcolor{fltkcolor120}{0.7461 0 0.2461}\n\\newrgbcolor{fltkcolor121}{0.7461 0.1406 0.2461}\n\\newrgbcolor{fltkcolor122}{0.7461 0.2812 0.2461}\n\\newrgbcolor{fltkcolor123}{0.7461 0.4258 0.2461}\n\\newrgbcolor{fltkcolor124}{0.7461 0.5664 0.2461}\n\\newrgbcolor{fltkcolor125}{0.7461 0.7109 0.2461}\n\\newrgbcolor{fltkcolor126}{0.7461 0.8516 0.2461}\n\\newrgbcolor{fltkcolor127}{0.7461 0.9961 0.2461}\n\\newrgbcolor{fltkcolor128}{0.9961 0 0.2461}\n\\newrgbcolor{fltkcolor129}{0.9961 0.1406 0.2461}\n\\newrgbcolor{fltkcolor130}{0.9961 0.2812 0.2461}\n\\newrgbcolor{fltkcolor131}{0.9961 0.4258 0.2461}\n\\newrgbcolor{fltkcolor132}{0.9961 0.5664 0.2461}\n\\newrgbcolor{fltkcolor133}{0.9961 0.7109 0.2461}\n\\newrgbcolor{fltkcolor134}{0.9961 0.8516 0.2461}\n\\newrgbcolor{fltkcolor135}{0.9961 0.9961 0.2461}\n\\newrgbcolor{fltkcolor136}{0 0 0.4961}\n\\newrgbcolor{fltkcolor137}{0 0.1406 0.4961}\n\\newrgbcolor{fltkcolor138}{0 0.2812 0.4961}\n\\newrgbcolor{fltkcolor139}{0 0.4258 0.4961}\n\\newrgbcolor{fltkcolor140}{0 0.5664 0.4961}\n\\newrgbcolor{fltkcolor141}{0 0.7109 0.4961}\n\\newrgbcolor{fltkcolor142}{0 0.8516 0.4961}\n\\newrgbcolor{fltkcolor143}{0 0.9961 0.4961}\n\\newrgbcolor{fltkcolor144}{0.2461 0 0.4961}\n\\newrgbcolor{fltkcolor145}{0.2461 0.1406 0.4961}\n\\newrgbcolor{fltkcolor146}{0.2461 0.2812 0.4961}\n\\newrgbcolor{fltkcolor147}{0.2461 0.4258 0.4961}\n\\newrgbcolor{fltkcolor148}{0.2461 0.5664 0.4961}\n\\newrgbcolor{fltkcolor149}{0.2461 0.7109 0.4961}\n\\newrgbcolor{fltkcolor150}{0.2461 0.8516 0.4961}\n\\newrgbcolor{fltkcolor151}{0.2461 0.9961 0.4961}\n\\newrgbcolor{fltkcolor152}{0.4961 0 0.4961}\n\\newrgbcolor{fltkcolor153}{0.4961 0.1406 0.4961}\n\\newrgbcolor{fltkcolor154}{0.4961 0.2812 0.4961}\n\\newrgbcolor{fltkcolor155}{0.4961 0.4258 0.4961}\n\\newrgbcolor{fltkcolor156}{0.4961 0.5664 0.4961}\n\\newrgbcolor{fltkcolor157}{0.4961 0.7109 0.4961}\n\\newrgbcolor{fltkcolor158}{0.4961 0.8516 0.4961}\n\\newrgbcolor{fltkcolor159}{0.4961 0.9961 0.4961}\n\\newrgbcolor{fltkcolor160}{0.7461 0 0.4961}\n\\newrgbcolor{fltkcolor161}{0.7461 0.1406 0.4961}\n\\newrgbcolor{fltkcolor162}{0.7461 0.2812 0.4961}\n\\newrgbcolor{fltkcolor163}{0.7461 0.4258 0.4961}\n\\newrgbcolor{fltkcolor164}{0.7461 0.5664 0.4961}\n\\newrgbcolor{fltkcolor165}{0.7461 0.7109 0.4961}\n\\newrgbcolor{fltkcolor166}{0.7461 0.8516 0.4961}\n\\newrgbcolor{fltkcolor167}{0.7461 0.9961 0.4961}\n\\newrgbcolor{fltkcolor168}{0.9961 0 0.4961}\n\\newrgbcolor{fltkcolor169}{0.9961 0.1406 0.4961}\n\\newrgbcolor{fltkcolor170}{0.9961 0.2812 0.4961}\n\\newrgbcolor{fltkcolor171}{0.9961 0.4258 0.4961}\n\\newrgbcolor{fltkcolor172}{0.9961 0.5664 0.4961}\n\\newrgbcolor{fltkcolor173}{0.9961 0.7109 0.4961}\n\\newrgbcolor{fltkcolor174}{0.9961 0.8516 0.4961}\n\\newrgbcolor{fltkcolor175}{0.9961 0.9961 0.4961}\n\\newrgbcolor{fltkcolor176}{0 0 0.7461}\n\\newrgbcolor{fltkcolor177}{0 0.1406 0.7461}\n\\newrgbcolor{fltkcolor178}{0 0.2812 0.7461}\n\\newrgbcolor{fltkcolor179}{0 0.4258 0.7461}\n\\newrgbcolor{fltkcolor180}{0 0.5664 0.7461}\n\\newrgbcolor{fltkcolor181}{0 0.7109 0.7461}\n\\newrgbcolor{fltkcolor182}{0 0.8516 0.7461}\n\\newrgbcolor{fltkcolor183}{0 0.9961 0.7461}\n\\newrgbcolor{fltkcolor184}{0.2461 0 0.7461}\n\\newrgbcolor{fltkcolor185}{0.2461 0.1406 0.7461}\n\\newrgbcolor{fltkcolor186}{0.2461 0.2812 0.7461}\n\\newrgbcolor{fltkcolor187}{0.2461 0.4258 0.7461}\n\\newrgbcolor{fltkcolor188}{0.2461 0.5664 0.7461}\n\\newrgbcolor{fltkcolor189}{0.2461 0.7109 0.7461}\n\\newrgbcolor{fltkcolor190}{0.2461 0.8516 0.7461}\n\\newrgbcolor{fltkcolor191}{0.2461 0.9961 0.7461}\n\\newrgbcolor{fltkcolor192}{0.4961 0 0.7461}\n\\newrgbcolor{fltkcolor193}{0.4961 0.1406 0.7461}\n\\newrgbcolor{fltkcolor194}{0.4961 0.2812 0.7461}\n\\newrgbcolor{fltkcolor195}{0.4961 0.4258 0.7461}\n\\newrgbcolor{fltkcolor196}{0.4961 0.5664 0.7461}\n\\newrgbcolor{fltkcolor197}{0.4961 0.7109 0.7461}\n\\newrgbcolor{fltkcolor198}{0.4961 0.8516 0.7461}\n\\newrgbcolor{fltkcolor199}{0.4961 0.9961 0.7461}\n\\newrgbcolor{fltkcolor200}{0.7461 0 0.7461}\n\\newrgbcolor{fltkcolor201}{0.7461 0.1406 0.7461}\n\\newrgbcolor{fltkcolor202}{0.7461 0.2812 0.7461}\n\\newrgbcolor{fltkcolor203}{0.7461 0.4258 0.7461}\n\\newrgbcolor{fltkcolor204}{0.7461 0.5664 0.7461}\n\\newrgbcolor{fltkcolor205}{0.7461 0.7109 0.7461}\n\\newrgbcolor{fltkcolor206}{0.7461 0.8516 0.7461}\n\\newrgbcolor{fltkcolor207}{0.7461 0.9961 0.7461}\n\\newrgbcolor{fltkcolor208}{0.9961 0 0.7461}\n\\newrgbcolor{fltkcolor209}{0.9961 0.1406 0.7461}\n\\newrgbcolor{fltkcolor210}{0.9961 0.2812 0.7461}\n\\newrgbcolor{fltkcolor211}{0.9961 0.4258 0.7461}\n\\newrgbcolor{fltkcolor212}{0.9961 0.5664 0.7461}\n\\newrgbcolor{fltkcolor213}{0.9961 0.7109 0.7461}\n\\newrgbcolor{fltkcolor214}{0.9961 0.8516 0.7461}\n\\newrgbcolor{fltkcolor215}{0.9961 0.9961 0.7461}\n\\newrgbcolor{fltkcolor216}{0 0 0.9961}\n\\newrgbcolor{fltkcolor217}{0 0.1406 0.9961}\n\\newrgbcolor{fltkcolor218}{0 0.2812 0.9961}\n\\newrgbcolor{fltkcolor219}{0 0.4258 0.9961}\n\\newrgbcolor{fltkcolor220}{0 0.5664 0.9961}\n\\newrgbcolor{fltkcolor221}{0 0.7109 0.9961}\n\\newrgbcolor{fltkcolor222}{0 0.8516 0.9961}\n\\newrgbcolor{fltkcolor223}{0 0.9961 0.9961}\n\\newrgbcolor{fltkcolor224}{0.2461 0 0.9961}\n\\newrgbcolor{fltkcolor225}{0.2461 0.1406 0.9961}\n\\newrgbcolor{fltkcolor226}{0.2461 0.2812 0.9961}\n\\newrgbcolor{fltkcolor227}{0.2461 0.4258 0.9961}\n\\newrgbcolor{fltkcolor228}{0.2461 0.5664 0.9961}\n\\newrgbcolor{fltkcolor229}{0.2461 0.7109 0.9961}\n\\newrgbcolor{fltkcolor230}{0.2461 0.8516 0.9961}\n\\newrgbcolor{fltkcolor231}{0.2461 0.9961 0.9961}\n\\newrgbcolor{fltkcolor232}{0.4961 0 0.9961}\n\\newrgbcolor{fltkcolor233}{0.4961 0.1406 0.9961}\n\\newrgbcolor{fltkcolor234}{0.4961 0.2812 0.9961}\n\\newrgbcolor{fltkcolor235}{0.4961 0.4258 0.9961}\n\\newrgbcolor{fltkcolor236}{0.4961 0.5664 0.9961}\n\\newrgbcolor{fltkcolor237}{0.4961 0.7109 0.9961}\n\\newrgbcolor{fltkcolor238}{0.4961 0.8516 0.9961}\n\\newrgbcolor{fltkcolor239}{0.4961 0.9961 0.9961}\n\\newrgbcolor{fltkcolor240}{0.7461 0 0.9961}\n\\newrgbcolor{fltkcolor241}{0.7461 0.1406 0.9961}\n\\newrgbcolor{fltkcolor242}{0.7461 0.2812 0.9961}\n\\newrgbcolor{fltkcolor243}{0.7461 0.4258 0.9961}\n\\newrgbcolor{fltkcolor244}{0.7461 0.5664 0.9961}\n\\newrgbcolor{fltkcolor245}{0.7461 0.7109 0.9961}\n\\newrgbcolor{fltkcolor246}{0.7461 0.8516 0.9961}\n\\newrgbcolor{fltkcolor247}{0.7461 0.9961 0.9961}\n\\newrgbcolor{fltkcolor248}{0.9961 0 0.9961}\n\\newrgbcolor{fltkcolor249}{0.9961 0.1406 0.9961}\n\\newrgbcolor{fltkcolor250}{0.9961 0.2812 0.9961}\n\\newrgbcolor{fltkcolor251}{0.9961 0.4258 0.9961}\n\\newrgbcolor{fltkcolor252}{0.9961 0.5664 0.9961}\n\\newrgbcolor{fltkcolor253}{0.9961 0.7109 0.9961}\n\\newrgbcolor{fltkcolor254}{0.9961 0.8516 0.9961}\n\\newrgbcolor{fltkcolor255}{0.9961 0.9961 0.9961}\n"; +#endif + const char tex_end[]="\n\\end{document}"; + const char mbox_begin[]="\\mathrm{"; // ("\\mbox{"); + const char mbox_end[]="}"; + + string spread2tex(const matrice & m,int formule,GIAC_CONTEXT){ + int l=int(m.size()); + if (!l) + return "\\mbox{empty_spread}"; + int c=int(m.front()._VECTptr->size()); + string s("\\ \\mbox{\\begin{tabular}{|"); + for (int j=0;j<=c;++j) + s += "r|"; + s += "}\\hline\n & "; + for (int k=0;;){ // write first line + string tmp; + int i=k; + for(int j=0;;++j){ + tmp=char('A'+i%26-(j!=0))+tmp; + i=i/26; + if (!i) + break; + } + s += tmp; + ++k; + if (k==c){ + s += " \\\\\\hline\n"; + break; + } + else + s += " & "; + } + for (int i=0;isize()); + string s("\\left(\\begin{array}{"); + for (int j=0;jtype==_CPLX && !is_zero(*it->_CPLXptr) && !is_zero(*(it->_CPLXptr+1))) || (it->type==_SYMB && ( it->_SYMBptr->sommet==at_plus || (it->_SYMBptr->sommet==at_neg && need_parenthesis(it->_SYMBptr->feuille)) ) ) ) + s += string("(")+gen2tex(*it,contextptr)+string(")"); + else + s += gen2tex(*it,contextptr); + ++it; + if (it==itend) + return s; + if (it->type<=_IDNT || (it->type==_SYMB && + (it->_SYMBptr->sommet==at_neg || (it->_SYMBptr->sommet.ptr()->printsommet && it->_SYMBptr->feuille.type==_VECT && !it->_SYMBptr->feuille._VECTptr->empty() && it->_SYMBptr->feuille._VECTptr->front().type<=_IDNT)) + )) // second part of the test added for e.g. latex('2*3*5^2') + s += "\\cdot "; + else + s += " "; + } + } + + string translate_underscore(const string & s){ + string res; + string::const_iterator it=s.begin(),itend=s.end(); + for (;it!=itend;++it){ + switch (*it){ + case '_': + res += "\\_"; + break; + case '^': + res += "{\\tt\\symbol{94}}"; + break; + case '~': + res += "{\\tt\\symbol{126}}"; + break; + case '<': + res += "{\\tt\\symbol{60}}"; + break; + case '>': + res += "{\\tt\\symbol{62}}"; + break; + case '\n': + res += "\\\\\n"; + break; + case '&': + res += "\\&"; + break; + case '{': + res += "\\{"; + break; + case '}': + res += "\\}"; + break; + case '\\': + res += "$\\backslash $"; + break; + case '%': + res += "\\%"; + break; + case '#': + res += "\\#"; + break; + case '$': + res += "\\$"; + break; + default: + res += *it; + } + } + string s0; + greek2tex(res,s0,false); + return s0; + } + + static string fill_flag(bool flag){ + if (flag) + return "linestyle=none,fillstyle=solid,"; + else + return ""; + } + + /* + static string line_flag(int flag){ + switch(flag) { + case _STYLE_FULL : return ""; + case _STYLE_DOTTED : return "[linestyle=dotted]"; + case _STYLE_DASHED : return "[linestyle=dashed]"; + } + return "error"; + } + */ + + static string vector_flag(int flag){ + switch(flag) { + case _VECTOR__VECT : return "{->}"; + // case BACKARROW : return "{<-}"; + // case DOUBLEARROW : return "{<->}"; + default : return ""; + } + } + + static string point_flag(int flag){ + switch(flag) { + case _STYLE_BOX : return "[dotstyle=square*]"; + case _STYLE_CROSS : return "[dotstyle=x]"; + case _STYLE_PLUS : return "[dotstyle=+]"; + default : return "[dotstyle=*]"; + } + } + +#ifdef GIAC_HAS_STO_38 + static string flcolor2pstrickscolor(int color){ + switch(color) { + case FL_BLACK: return "black"; + case FL_WHITE: return "white"; + case FL_DARK1: return "darkgray"; + case FL_GRAY: return "gray"; + } + return "unknown"; + } +#else + + static string flcolor2pstrickscolor(int color){ + switch(color) { + case FL_BLACK: return "black"; + case FL_DARK1: return "darkgray"; + case FL_GRAY: return "gray"; + case FL_LIGHT1 : return "lightgray"; +#ifdef HAVE_LIBFLTK + case _WHITE: return "white"; +#endif + case FL_WHITE : return "white"; +#ifdef HAVE_LIBFLTK + case _RED: return "red"; +#endif + case FL_RED : return "red"; +#ifdef HAVE_LIBFLTK + case _GREEN: return "green"; +#endif + case FL_GREEN : return "green"; +#ifdef HAVE_LIBFLTK + case _BLUE: return "blue"; +#endif + case FL_BLUE : return "blue"; +#ifdef HAVE_LIBFLTK + case _CYAN: return "cyan"; +#endif + case FL_CYAN : return "cyan"; +#ifdef HAVE_LIBFLTK + case _MAGENTA: return "magenta"; +#endif + case FL_MAGENTA : return "magenta"; +#ifdef HAVE_LIBFLTK + case _YELLOW: return "yellow"; +#endif + case FL_YELLOW : return "yellow"; + default: return "black"; + } + return "fltkcolor"+print_INT_(color); + } +#endif // GIAC_HAS_STO_38 + + static string double2tex(double d){ + char s[32]; + +#if 0 // def BESTA_OS + assert(0); + // returning an auto-var, when the string is constructed before the copy? + // not the niceest of things to do.... + // BP: I don't understand where you see a problem, a string is constructed from s + // then the std::string is returned +#else + if (d<=-1e30 || d>=1e30) + sprintfdouble(s,"%13g",d); + else + sprintfdouble(s,"%13.6f",d); +#endif + return s; + } + + // convert UTF-8 string to wchar_t *, return adjusted length + // FIXME: use utf82unicode instead? + static unsigned int utf8(wchar_t * wline,const char * line,unsigned int n){ + unsigned int i=0,j=0,c; + for (;i=2;--j){ + if (s0[j]>32 && isalpha(s0[j])) + break; + } + string s=s0.substr(0,j+1),sadd; + if (j=2){ + if (v[1].type==_INT_) + ensemble_attributs=v[1].val; + if (v[1].type==_VECT){ + vecteur & w=*v[1]._VECTptr; + if (!w.empty() && (w.front().type==_INT_) ) + ensemble_attributs=w.front().val; + } + } + int width =(ensemble_attributs & 0x00070000) >> 16; // 3 bits + // FIXME should be used! + // int epaisseur_point =(ensemble_attributs & 0x00380000) >> 19; // 3 bits + // int type_line =(ensemble_attributs & 0x01c00000) >> 22; // 3 bits + int type_point =(ensemble_attributs & 0x0e000000) >> 25; // 3 bits + labelpos =(ensemble_attributs & 0x30000000) >> 28; // 2 bits + bool fill_polygon =((ensemble_attributs & 0x40000000) >> 30)!=0; + couleur =(ensemble_attributs & 0x0000ffff); + string col(flcolor2pstrickscolor(couleur)); + ++width; + if (file) + fprintf(file,"\\psset{linecolor=%s}\n\\psset{linewidth=%.4fpt}\n", col.c_str(),width*0.5); + if (sres) + *sres += "\\psset{linecolor="+col+"}\n\\psset{linewidth="+double2tex(width*0.5)+"pt}\n"; + // draw point/line/parametric + gen point=v[0],x,y; + // point is either a symb that evals to a complex or a param curve + // or a vector of complex points + // next line should be replaced by postscript (rpn) translation of curve + // equation if possible + if ( (point.type==_SYMB) && (point._SYMBptr->sommet==at_curve) && (point._SYMBptr->feuille.type==_VECT) && (point._SYMBptr->feuille._VECTptr->size()) ) + point=point._SYMBptr->feuille._VECTptr->back(); + if ( (point.type==_SYMB) && (point._SYMBptr->sommet==at_cercle)){ + vecteur v=*point._SYMBptr->feuille._VECTptr; + gen diametre=remove_at_pnt(v[0]); + gen e1=diametre._VECTptr->front().evalf(1,contextptr),e2=diametre._VECTptr->back().evalf(1,contextptr); + gen centre=rdiv(e1+e2,gen(2.0),contextptr),rayon=abs(rdiv(e2-e1,gen(2.0),contextptr),contextptr); + x=evalf_double(re(centre,contextptr),1,contextptr); + y=evalf_double(im(centre,contextptr),1,contextptr); + if ( (x.type==_DOUBLE_) && (y.type==_DOUBLE_) && (rayon.type==_DOUBLE_) ){ + xd=x._DOUBLE_val; + yd=y._DOUBLE_val; + if (v.size()>2){ + gen theta1=evalf_double(v[1],1,contextptr),theta2=evalf_double(v[2],1,contextptr); + //grad + int mode=get_mode_set_radian(contextptr); + gen angle=arg(e2-e1,contextptr).evalf_double(1,contextptr); + angle_mode(mode, contextptr); + + if (theta1.type==_DOUBLE_ && theta2.type==_DOUBLE_ && angle.type==_DOUBLE_){ + double t1=theta1._DOUBLE_val,t2=theta2._DOUBLE_val; + if (t1>t2){ + double tmp=t1; + t1=t2; + t2=tmp; + } + t1=(t1+angle._DOUBLE_val)*rad2deg_d; + t2=(t2+angle._DOUBLE_val)*rad2deg_d; + if (file) + fprintf (file,"\\pswedge[%sfillcolor=%s](%.4f,%.4f){%.4f}{%.4f}{%.4f}\n",fill_flag(fill_polygon).c_str(),col.c_str(),xd,yd,rayon._DOUBLE_val,t1,t2); // was psarc + if (sres) + *sres += "\\pswedge[" + fill_flag(fill_polygon) + + "fillcolor=" + col + "](" + + double2tex(xd)+","+double2tex(yd)+"){" + + double2tex(rayon._DOUBLE_val) + "}{" + + double2tex(t1)+ "}{" + double2tex(t2) + "}\n"; + xd=x._DOUBLE_val+rayon._DOUBLE_val*std::cos(t1); + yd=y._DOUBLE_val+rayon._DOUBLE_val*std::sin(t1); + return true; + } + } + if (file) + fprintf(file,"\\pscircle[%sfillcolor=%s](%.4f,%.4f){%.4f}\n",fill_flag(fill_polygon).c_str(),col.c_str(),xd,yd,rayon._DOUBLE_val); + if (sres) + *sres += "\\pscircle["+fill_flag(fill_polygon)+"fillcolor="+col+ + "]("+ double2tex(xd)+","+double2tex(yd)+"){"+ + double2tex(rayon._DOUBLE_val)+"}\n"; + xd=x._DOUBLE_val+rayon._DOUBLE_val; + return true; + } + return false; + } // end cercle + if (point.type!=_VECT){ // single point + point=evalf_double(point,1,contextptr); + x=re(point,contextptr); + y=im(point,contextptr).evalf(1,contextptr); + if ( (x.type==_DOUBLE_) && (y.type==_DOUBLE_) ){ + xd=x._DOUBLE_val; + yd=y._DOUBLE_val; + if (file) + fprintf(file,"\\psdots%s(%.4f,%.4f)\n", point_flag(type_point).c_str(), xd, yd); + if (sres) + *sres += "\\psdots"+point_flag(type_point)+"("+double2tex(xd)+","+double2tex(yd)+")\n"; + return true; + } + return false; + } + vecteur & w=*point._VECTptr; + int ws=int(w.size()); + if (ws==2){ + gen A=w[0].evalf(1,contextptr),B=w[1].evalf(1,contextptr); + gen Ax=re(A,contextptr),Ay=im(A,contextptr).evalf(1,contextptr), + Bx=re(B,contextptr),By=im(B,contextptr).evalf(1,contextptr); + if ( (Ax.type==_DOUBLE_) && (Ay.type==_DOUBLE_) + && (Bx.type==_DOUBLE_) && (By.type==_DOUBLE_) ){ + double ax=Ax._DOUBLE_val,ay=Ay._DOUBLE_val,bx=Bx._DOUBLE_val,by=By._DOUBLE_val; + xd=(ax+bx)/2.; + yd=(ay+by)/2.; + if (point.subtype==_GROUP__VECT) + drawlegende=false; + double x1,y1,x2,y2; + if (point.subtype!=_HALFLINE__VECT){ + clip_line(ax,ay,bx,by,xmin,ymin,xmax,ymax,point.subtype,x1,y1,x2,y2); + if (file) + fprintf(file,"\\psline%s(%.4f,%.4f)(%.4f,%.4f)\n",vector_flag(point.subtype).c_str(), x1,y1,x2,y2); + if (sres) + *sres += "\\psline"+vector_flag(point.subtype)+ + "("+double2tex(x1)+","+double2tex(y1)+")("+ + double2tex(x2)+","+double2tex(y2)+")\n"; + return true; + } + double vx=bx-ax,vy=by-ay; + // check for line/halfline + bx=bx+5*vx; + by=by+5*vy; + // FIXME: improve clipping!! Removed here + if (file) + fprintf(file,"\\psline%s(%.4f,%.4f)(%.4f,%.4f)\n",vector_flag(point.subtype).c_str(),ax,ay,bx,by); + if (sres) + *sres += "\\psline"+vector_flag(point.subtype)+"("+double2tex(ax)+","+double2tex(ay)+")("+double2tex(bx)+","+double2tex(by)+")\n"; + return true; + } // end DOUBLE types + return false; + } // end w.size()==2 + // multi-line + string prefixstr,printstring; + if (fill_polygon) + printstring="\\pspolygon["+fill_flag(fill_polygon)+"fillcolor="+col+"]"; + else + prefixstr = "\\psline[fillcolor="+col+"]"; + double xprec=0,yprec=0,xa,ya,xb,yb; + for (int i=0;ibegin(),itend=g._VECTptr->end(); + for (;it!=itend;++it) + invectpnt2tex(file,*it,X1,X2,Y1,Y2,xunit,yunit,resptr,contextptr); + } + else { + if (g.is_symb_of_sommet(at_pnt) && !is3d(g)){ + gen & feu = g._SYMBptr->feuille; + if (feu.type==_VECT){ + vecteur & arg=*feu._VECTptr; + double xd,yd; + bool drawlegende; + int labelpos,couleur; + if (pnt2tex(file,arg,X1,Y1,X2,Y2,xd,yd,drawlegende,labelpos,couleur,resptr,contextptr)){ + if (drawlegende && (arg.size()>2)){ + xunit=(gnuplot_xmax-gnuplot_xmin); + pnt2texlegende(file,arg,xd,yd,xunit,couleur,labelpos,resptr); + } + } + } + } + } + } + + // evalf_double of a and splt re/im + void evalfdouble2reim(const gen & a,gen & e,gen & f0,gen & f1,GIAC_CONTEXT){ + if (a.type==_CPLX){ + f0=a._CPLXptr->evalf2double(1,contextptr); + f1=(a._CPLXptr+1)->evalf2double(1,contextptr); + if (a._CPLXptr->type==_DOUBLE_ && (a._CPLXptr+1)->type==_DOUBLE_) + e=a; + else + e=gen(f0._DOUBLE_val,f1._DOUBLE_val); + return ; + } +#ifndef NO_STDEXCEPT + try { +#endif + e=a.evalf_double(1,contextptr); // FIXME? level 1 does not work for non 0 context +#ifndef NO_STDEXCEPT + } catch (std::runtime_error & error ){ + last_evaled_argptr(contextptr)=NULL; + CERR << error.what() << '\n'; + } +#endif + if (e.type==_CPLX){ + f0=*e._CPLXptr; + f1=*(e._CPLXptr+1); + } + else { + f0=e; + f1=0.0; + } + } + + static bool in_autoscale(const gen & g,vector & vx,vector & vy,vector & vz,GIAC_CONTEXT,bool curve=false){ + if (g.type==_VECT && g.subtype==_POINT__VECT && g._VECTptr->size()==3){ + vecteur v=*evalf_double(g,1,contextptr)._VECTptr; + if (v[2].type==_CPLX) + v[2]=abs(v[2],contextptr); + if (v[0].type==_DOUBLE_ && v[1].type==_DOUBLE_ && v[2].type==_DOUBLE_ ){ + vx.push_back(v[0]._DOUBLE_val); + vy.push_back(v[1]._DOUBLE_val); + vz.push_back(v[2]._DOUBLE_val); + return false; + } + } + if (g.type==_VECT ){ + if (!curve && g.subtype==_GROUP__VECT && !g._VECTptr->empty() && g._VECTptr->front().type!=_VECT){ // "compressed" hypersurface? + vecteur v=*evalf_double(g,1,contextptr)._VECTptr; + int s=v.size(); + if (s%3==0){ + int i; + for (i=0;ibegin(),itend=g._VECTptr->end(); + for (;it!=itend;++it){ + ortho = ortho | in_autoscale(*it,vx,vy,vz,contextptr); + } + return ortho; + } + if (g.is_symb_of_sommet(at_curve)){ + gen & gf=g._SYMBptr->feuille; + if (gf.type==_VECT && gf._VECTptr->size()>1){ + gen tmp=(*gf._VECTptr)[1]; + if (is_undef(tmp)){ + tmp=(*gf._VECTptr)[0]; + if (tmp.type==_VECT && tmp._VECTptr->size()>4) + tmp=(*tmp._VECTptr)[4]; + } + in_autoscale(tmp,vx,vy,vz,contextptr,true); + } + return false; + } + if (g.is_symb_of_sommet(at_hypersurface)){ + gen & g0=g._SYMBptr->feuille; + if (g0.type==_VECT && g0._VECTptr->size()>2){ + gen & gf=g0._VECTptr->front(); + if (gf.type==_VECT && gf._VECTptr->size()>4){ + in_autoscale((*gf._VECTptr)[4],vx,vy,vz,contextptr); + } + } + return false; + } + if (g.is_symb_of_sommet(at_hyperplan)){ + gen & g0=g._SYMBptr->feuille; + if (g0.type==_VECT && g0._VECTptr->size()>=2){ + gen n=evalf_double(g0._VECTptr->front(),1,contextptr); + gen P=evalf_double(g0._VECTptr->back(),1,contextptr); + if (n.type==_VECT && n._VECTptr->size()==3 && P.type==_VECT && P._VECTptr->size()==3){ + vecteur & N=*n._VECTptr; + vecteur & M=*P._VECTptr; + if (M[0].type==_DOUBLE_ && M[1].type==_DOUBLE_ && M[2].type==_DOUBLE_ && N[0].type==_DOUBLE_ && N[1].type==_DOUBLE_ && N[2].type==_DOUBLE_){ + double d=M[0]._DOUBLE_val,r=(std::abs(N[0]._DOUBLE_val)+std::abs(N[1]._DOUBLE_val)+std::abs(N[2]._DOUBLE_val))/3; + vx.push_back(d-r); vx.push_back(d+r); + d=M[1]._DOUBLE_val; + vy.push_back(d-r); vy.push_back(d+r); + d=M[2]._DOUBLE_val; + vz.push_back(d-r); vz.push_back(d+r); + return false; + } + } + } + return false; + } + if (g.is_symb_of_sommet(at_cercle)){ + gen c,r; + centre_rayon(g,c,r,false,contextptr); + if (is_zero(r)) r=1; + vecteur v; + if (g._SYMBptr->feuille.type==_VECT && g._SYMBptr->feuille._VECTptr->size()>=3){ + v=*g._SYMBptr->feuille._VECTptr; + gen v2=evalf_double(v[2],1,contextptr); + gen v1=evalf_double(v[1],1,contextptr); + gen delta=v2-v1; + v=makevecteur(c,c+r*exp(cst_i*(v1-0.1*delta),contextptr), + c+r*exp(cst_i*v1,contextptr), + c+r*exp(cst_i*(3*v1+v2)/gen(4),contextptr), + c+r*exp(cst_i*(v1+v2)/gen(2),contextptr), + c+r*exp(cst_i*(v1+3*v2)/gen(4),contextptr), + c+r*exp(cst_i*v2,contextptr), + c+r*exp(cst_i*(v2+0.1*delta),contextptr)); + } + else + v=makevecteur(c-r,c+r,c-cst_i*r,c+cst_i*r); + in_autoscale(v,vx,vy,vz,contextptr); + return true; + } + if (g.is_symb_of_sommet(at_hypersphere)){ + vecteur & v=*g._SYMBptr->feuille._VECTptr; + gen c=evalf_double(v[0],1,contextptr),R=evalf_double(v[1],1,contextptr); + if (c.type==_VECT && c._VECTptr->size()==3){ + vecteur & M=*c._VECTptr; + if (M[0].type==_DOUBLE_ && M[1].type==_DOUBLE_ && M[2].type==_DOUBLE_ && R.type==_DOUBLE_){ + double r=R._DOUBLE_val; + double d=M[0]._DOUBLE_val; + vx.push_back(d-r); vx.push_back(d+r); + d=M[1]._DOUBLE_val; + vy.push_back(d-r); vy.push_back(d+r); + d=M[2]._DOUBLE_val; + vz.push_back(d-r); vz.push_back(d+r); + return true; + } + } + } + // FIXME sphere etc. + if (g.type!=_VECT){ + gen e,f0,f1; + evalfdouble2reim(g,e,f0,f1,contextptr); + if (f0.type==_DOUBLE_ && f1.type==_DOUBLE_){ + vx.push_back(f0._DOUBLE_val); + vy.push_back(f1._DOUBLE_val); + } + } + return false; + } + + bool autoscaleg(const gen & g,vector & vx,vector & vy,vector & vz,GIAC_CONTEXT){ + if (g.type==_VECT){ + bool ortho=false; + const_iterateur it=g._VECTptr->begin(),itend=g._VECTptr->end(); + for (;it!=itend;++it) + ortho = ortho | autoscaleg(*it,vx,vy,vz,contextptr); + return ortho; + } + if (g.is_symb_of_sommet(at_pnt)){ + gen & gf=g._SYMBptr->feuille; + if (gf.type==_VECT && !gf._VECTptr->empty()){ + gen & f=gf._VECTptr->front(); + return in_autoscale(f,vx,vy,vz,contextptr); + } + } + if (g.is_symb_of_sommet(at_equal) && g._SYMBptr->feuille.type==_VECT && g._SYMBptr->feuille._VECTptr->size()==2 && g._SYMBptr->feuille._VECTptr->front()==_GL_ORTHO && !is_zero(g._SYMBptr->feuille._VECTptr->back())) + return true; + return false; + } + + // returns true if axes are drawn + bool overwrite_viewbox(const gen & g,double & window_xmin,double & window_xmax,double & window_ymin,double & window_ymax,double &window_zmin,double & window_zmax){ + bool res=true; + if (g.type==_VECT){ + vecteur v =*g._VECTptr; + for (int i=0;ifeuille; + if (f.type==_VECT && f._VECTptr->size()==2){ + gen optname= f._VECTptr->front(),optvalue=f._VECTptr->back(); + if (optname.type==_INT_ && optname.subtype==_INT_PLOT && optname.val==_AXES && optvalue==0) + res=false; + if (optvalue.is_symb_of_sommet(at_interval) && optname.type==_INT_ && optname.subtype==_INT_PLOT && optname.val>=_GL_X && optname.val<=_GL_Z){ + gen optvf=evalf_double(optvalue._SYMBptr->feuille,1,context0); + if (optvf.type==_VECT && optvf._VECTptr->size()==2){ + gen a=optvf._VECTptr->front(); + gen b=optvf._VECTptr->back(); + if (a.type==_DOUBLE_ && b.type==_DOUBLE_){ + switch (optname.val){ + case _GL_X: + window_xmin=a._DOUBLE_val; + window_xmax=b._DOUBLE_val; + break; + case _GL_Y: + window_ymin=a._DOUBLE_val; + window_ymax=b._DOUBLE_val; + break; + case _GL_Z: + window_zmin=a._DOUBLE_val; + window_zmax=b._DOUBLE_val; + break; + } + } + } + } + } + } + return res; + } + + void title_legende(const gen & g,plot_attr & p){ + if (g.type==_VECT){ + vecteur v =*g._VECTptr; + for (int i=0;ifeuille; + if (f.type==_VECT && f._VECTptr->size()==2){ + gen optname= f._VECTptr->front(),optvalue=f._VECTptr->back(); + if (optname.type==_INT_ && optname.subtype==_INT_PLOT){ + string s=optvalue.type==_STRNG?*optvalue._STRNGptr:optvalue.print(context0); + switch (optname.val){ + case _TITLE: + p.title=s; + break; + case _GL_X_AXIS_NAME: + p.xlegende=s; + break; + case _GL_Y_AXIS_NAME: + p.ylegende=s; + break; + } + } + } + } + } + + static void zoom(double &m,double & M,double d){ + double x_center=(M+m)/2; + double dx=(M-m); + double s=absdouble(m)+absdouble(M); + if (dx<=1e-5*s){ + dx=s; + if (dx<=1e-5) + dx=1; + } + dx *= d/2; + m = x_center - dx; + M = x_center + dx; + } + + void autoscaleminmax(vector & v,double & m,double & M,bool fullview){ + int s=int(v.size()); + for (int i=0;i1){ + sort(v.begin(),v.end()); + m=v[s/10]; + M=v[9*s/10]; + if (fullview || 1.75*(M-m)>(v[s-1]-v[0]) || (M-m)<0.01*(v[s-1]-v[0])){ + M=v[s-1]; + m=v[0]; + zoom(m,M,1.1); + } + else + zoom(m,M,1/0.8); + // include origin if not too far + if ( (m>-M/10 && mM/2) ) + m=-M/10; + } + } + + static string vectpnt2tex(const gen & g,GIAC_CONTEXT){ + string res; + double X1=gnuplot_xmin,X2=gnuplot_xmax,Y1=gnuplot_ymin,Y2=gnuplot_ymax; + vector vx,vy,vz; + autoscaleg(g,vx,vy,vz,contextptr); + autoscaleminmax(vx,X1,X2,false); + autoscaleminmax(vy,Y1,Y2,false); + double xunit=horiz_latex/(X2-X1); + double yunit=(X2-X1)/(Y2-Y1)*xunit; + res="\\begin{pspicture}("+double2tex(X1*xunit)+","+double2tex(Y1*xunit)+ + ")("+double2tex(X2*xunit)+","+double2tex(Y2*xunit)+ + ")\n\\psset{unit="+double2tex(xunit)+ + "cm}\n\\psset{linewidth=.5pt}\n\\psset{arrowsize=2pt 4}\n"; + res+="\\psset{linecolor=black}\n"; + if (show_axes(contextptr) && (Y2>=0) && (Y1<=0) ) + res+="\\psline[linestyle=dashed]{->}("+double2tex(X1)+","+double2tex(0.0)+")("+double2tex(X2)+","+double2tex(0.0)+")\n"; + if (show_axes(contextptr) && (X2>=0) && (X1<=0) ) + res+="\\psline[linestyle=dashed]{->}("+double2tex(0.0)+","+double2tex(Y1)+")("+double2tex(0.0)+","+double2tex(Y2)+")\n"; + invectpnt2tex(0,g,X1,X2,Y1,Y2,xunit,yunit,&res,contextptr); + res += "\\end{pspicture}\n"; + return res; + } + + static string symbolic2tex(const symbolic & mys,GIAC_CONTEXT){ + const gen &feu=mys.feuille; + if (mys.sommet==at_pnt && feu.type==_VECT && !is3d(mys)) + return vectpnt2tex(mys,contextptr); + if (mys.sommet==at_program && feu.type==_VECT && feu._VECTptr->size()>=3){ + const vecteur & v=*feu._VECTptr; + gen f=v[2]; + if (!f.is_symb_of_sommet(at_local)){ + return gen2tex(v[0],contextptr)+" \\rightarrow "+gen2tex(f,contextptr); + } + } + if (mys.sommet.ptr()->texprint) + return mys.sommet.ptr()->texprint(feu,mys.sommet.ptr()->s,contextptr); + if (mys.sommet==at_abs) + return '|'+gen2tex(feu,contextptr)+'|'; + if (mys.sommet==at_unit) + return texprintsommetasoperator(feu,"\\_",contextptr); + string opstring=idnt2tex(mys.sommet.ptr()->print(contextptr)); + if ( (feu.type==_VECT) && (feu._VECTptr->empty()) ) + return opstring+string("()"); + if ( (feu.type!=_VECT) || (feu._VECTptr->front().type==_VECT && mys.sommet!=at_pow) ){ + if ((mys.sommet==at_neg) || (mys.sommet==at_plus)){ + if (feu.type!=_SYMB) + return opstring+gen2tex(feu,contextptr) ; + if (feu._SYMBptr->sommet==at_inv || !need_parenthesis(feu._SYMBptr->feuille)) + return opstring+gen2tex(feu,contextptr) ; + return opstring+string("\\left(") + gen2tex(feu,contextptr) +string("\\right)"); + } + if (mys.sommet==at_inv && (feu.is_symb_of_sommet(at_prod) || feu.is_symb_of_sommet(at_plus) || feu.is_symb_of_sommet(at_pow) || feu.type<=_IDNT) ){ + if (feu.type==_IDNT) + return gen2tex(feu,contextptr)+"^{-1}"; + return string("\\frac{1}{") + gen2tex(feu,contextptr) +string("}"); + } + return opstring + "\\left(" + gen2tex(feu,contextptr) +"\\right)" ; + } + string s; + int l=int(feu._VECTptr->size()); + if ( mys.sommet==at_plus ){ + for (int i=0;isommet==at_neg)){ + s += "-"; + if (e._SYMBptr->feuille.type!=_CPLX && (e._SYMBptr->feuille.type!=_SYMB || e._SYMBptr->feuille._SYMBptr->sommet==at_inv || e._SYMBptr->feuille._SYMBptr->sommet==at_prod|| !need_parenthesis(e._SYMBptr->feuille)) ) + s += gen2tex(e._SYMBptr->feuille,contextptr) ; + else + s += "\\left(" + gen2tex(e._SYMBptr->feuille,contextptr) + "\\right)"; + } + else { + if ( e.type<=_REAL && !is_positive(e,0) ) + s += e.print(contextptr); + else { + string sadd=gen2tex(e,contextptr); + if (i){ + if (opstring=="+" && !sadd.empty() && sadd[0]=='-') + ; + else + s += opstring; + } + s += sadd; + } + } + } // end_for + return s; + } + if (mys.sommet==at_prod) { + vecteur num; + vecteur den; + for (int i=0;isommet==at_inv) ) + den.push_back(e._SYMBptr->feuille); + else { + if (!den.empty()){ + s += "\\frac{"+prod_vect2tex(num,contextptr)+"}{"+prod_vect2tex(den,contextptr)+"} \\cdot "; + num.clear(); + den.clear(); + } + num.push_back(e); + } + } + if (den.empty()) + return s+prod_vect2tex(num,contextptr); + return s+"\\frac{"+prod_vect2tex(num,contextptr)+"}{"+prod_vect2tex(den,contextptr)+'}'; + } // end if sommet_is_prod + if (mys.sommet==at_pow){ + vecteur & v=*feu._VECTptr; + if ( (v.back()==plus_one_half) ) + return "\\sqrt{"+gen2tex(v.front(),contextptr)+"}"; + if ( v.back()==minus_one_half || v.back()==fraction(minus_one,plus_two) ) + return "\\frac{1}{\\sqrt{"+gen2tex(v.front(),contextptr)+"}}"; + string res=gen2tex(v.front(),contextptr); + bool par = (v.front().type>=_CPLX || is_strictly_positive(-v.front(),contextptr) ) && v.front().type!=_IDNT && !ckmatrix(v.front()); + if (par && !v.front().is_symb_of_sommet(at_plus)){ + int ress=int(res.size()),i; + for (i=1;iempty() && e._VECTptr->back().is_symb_of_sommet(at_pnt) && !is3d(e._VECTptr->back()) ) + return vectpnt2tex(e,contextptr); + if (ckmatrix(*e._VECTptr)) + return matrix2tex(*e._VECTptr,contextptr); + else + return _VECT2tex(*e._VECTptr,e.subtype,contextptr); + case _POLY: + return mbox_begin+string("polynome")+mbox_end+" "; + case _SPOL1: + return gen2tex(spol12gen(*e._SPOL1ptr,contextptr),contextptr); + case _FRAC: + return string("\\frac{")+gen2tex(e._FRACptr->num,contextptr)+"}{"+gen2tex(e._FRACptr->den,contextptr)+'}'; + case _EXT: + return ""; + case _STRNG: + return idnt2tex(*e._STRNGptr); + case _FUNC: + return idnt2tex(e.print(contextptr)); + case _USER: + return e._USERptr->texprint(contextptr); + case _MOD: + return gen2tex(*e._MODptr,contextptr)+"\\%"+gen2tex(*(e._MODptr+1),contextptr); + case _POINTER_: + if (e.subtype==_FL_WIDGET_POINTER &&fl_widget_texprint_function ) + return fl_widget_texprint_function(e._POINTER_val); + return "Done"; + default: + return "Error in Tex conversion for "+e.print(contextptr); + } + return 0; + } +#if defined USE_GMP_REPLACEMENTS || defined GIAC_GGB || defined EMCC || defined EMCC2 || defined KHICAS || defined NSPIRE_NEWLIB + bool has_improved_latex_export(const gen &g,string &s,bool override_texmacs,GIAC_CONTEXT){ + return false; + } + void enable_texmacs_compatible_latex_export(bool yes){ + } +#endif + gen _latex(const gen & g,GIAC_CONTEXT){ + if ( g.type==_STRNG && g.subtype==-1) return g; + if (g.type==_VECT && g._VECTptr->size()==2 && g._VECTptr->front().type==_STRNG && *g._VECTptr->front()._STRNGptr=="legacy"){ + bool b=is_zero(g._VECTptr->back()); + legacy=!b; + return legacy; + } +#if !defined NSPIRE && !defined FXCG && !defined GIAC_HAS_STO_38 && !defined KHICAS && !defined NSPIRE_NEWLIB + if (!secure_run && g.type==_VECT && g.subtype==_SEQ__VECT && g._VECTptr->size()==2 && (*g._VECTptr)[1].type==_STRNG){ + ofstream of((*g._VECTptr)[1]._STRNGptr->c_str()); + of << gen2tex(g._VECTptr->front(),contextptr) << '\n'; + return plus_one; + } +#endif + string s; + if (legacy || !has_improved_latex_export(g,s,true,contextptr)) + s=gen2tex(g,contextptr); + return string2gen(s,false); + } + static const char _latex_s []="latex"; + static define_unary_function_eval (__latex,&_latex,_latex_s); + define_unary_function_ptr5( at_latex ,alias_at_latex,&__latex,0,true); + + static const char _TeX_s []="TeX"; + static define_unary_function_eval (__TeX,&_latex,_TeX_s); + define_unary_function_ptr5( at_TeX ,alias_at_TeX,&__TeX,0,true); + + + + int graph2tex(FILE * file,const vecteur & v,double X1,double X2,double Y1,double Y2,double Unit,const char * filename,bool logo,GIAC_CONTEXT){ + return graph2tex(file,v,X1,X2,Y1,Y2,Unit,Unit,filename,logo,contextptr); + } + + static int ingraph2tex(FILE * file,const vecteur & v,double xunit,double yunit,double xmin, double ymin,double xmax,double ymax,GIAC_CONTEXT){ + vecteur w; + const_iterateur it=v.begin(),itend=v.end(); + for (;it!=itend;++it){ + gen sortie=*it; + // CERR << "graph2tex " << *it << '\n'; + if (sortie.type==_POINTER_ && sortie.subtype==_FL_WIDGET_POINTER && fl_widget_updatepict_function) + sortie = fl_widget_updatepict_function(sortie); + if (sortie.type!=_VECT) + w=vecteur(1,sortie); + else + w=*sortie._VECTptr; + const_iterateur jt=w.begin(),jtend=w.end(); + for (;jt!=jtend;++jt){ + if (jt->type==_VECT) + ingraph2tex(file,*jt->_VECTptr,xunit,yunit,xmin,ymin,xmax,ymax,contextptr); + if ( (jt->type!=_SYMB) || (jt->_SYMBptr->sommet!=at_pnt) ) + continue; + gen & g=jt->_SYMBptr->feuille; + if (g.type!=_VECT) + continue; + vecteur & arg=*g._VECTptr; + double xd,yd; + bool drawlegende; + int labelpos,couleur; + if (pnt2tex(file,arg,xmin,ymin,xmax,ymax,xd,yd,drawlegende,labelpos,couleur,0,contextptr) && drawlegende && (arg.size()>2)) + pnt2texlegende(file,arg,xd,yd,xunit,couleur,labelpos,0); + } + } + return 1; + } + + int graph2tex(FILE * file,const vecteur & v,double X1,double X2,double Y1,double Y2,double xunit,double yunit,const char * filename,bool logo,GIAC_CONTEXT){ + double z(0); + if (filename) + fprintf(file,"\n%%file %s",filename); + fprintf(file,"\n%% Generated by xcas\n\\noindent\n"); + // BUG xunit/yunit do not work for circles, FIXME + if (xunit!=yunit) + fprintf(file,"\\begin{pspicture}(%.4f,%.4f)(%.4f,%.4f)\n\\psset{unit=%.4fcm}\n\\psset{xunit=%.4fcm}\n\\psset{yunit=%.4fcm}\n\\psset{linewidth=.5pt}\n\\psset{arrowsize=2pt 4}\n", X1*xunit,Y1*yunit,X2*xunit,Y2*yunit,xunit,xunit,yunit); + else + fprintf(file,"\\begin{pspicture}(%.4f,%.4f)(%.4f,%.4f)\n\\psset{unit=%.4fcm}\n\\psset{linewidth=.5pt}\n\\psset{arrowsize=2pt 4}\n", X1*xunit, Y1*xunit, X2*xunit, Y2*xunit,xunit); + fprintf(file,"\\psset{linecolor=black}\n"); +#ifndef KHICAS + if (logo){ + // fprintf(file,"\\psframe[fillstyle=solid,fillcolor=gray](%.4f,%.4f)(%.4f,%.4f)\n",X1,Y1,X2,Y2); + vector w=vecteur2turtlevect(v); + vector * turtleptr=&w; + int l=int(turtleptr->size()); + if (l>0){ + double labelsep(0.1/xunit),angle(45); + fprintf(file,"%s{%.4f}[%.4f](%.4f,%.4f){%s%i}\n","%\\uput",labelsep,angle,X2-100,Y2-25, "x ",int(turtleptr->back().x+.5)); + fprintf(file,"%s{%.4f}[%.4f](%.4f,%.4f){%s%i}\n","%\\uput",labelsep,angle,X2-100,Y2-48, "y ",int(turtleptr->back().y+.5)); + fprintf(file,"%s{%.4f}[%.4f](%.4f,%.4f){%s%i}\n","%\\uput",labelsep,angle,X2-100,Y2-65, "t ",int(turtleptr->back().theta+.5)); + logo_turtle prec =(*turtleptr)[0]; + for (int k=1;k0){ + int r=current.radius & 0x1ff; // bit 0-8 + double theta1,theta2; + if (current.direct){ + theta1=prec.theta+double((current.radius >> 9) & 0x1ff); // bit 9-17 + theta2=prec.theta+double((current.radius >> 18) & 0x1ff); // bit 18-26 + } + else { + theta1=prec.theta-double((current.radius >> 9) & 0x1ff); // bit 9-17 + theta2=prec.theta-double((current.radius >> 18) & 0x1ff); // bit 18-26 + } + bool rempli=(current.radius >> 27) & 0x1; + double angle; + double x,y; + angle = M_PI/180*(theta2-90); + if (current.direct){ + x=current.x - r*std::cos(angle); + y=current.y - r*std::sin(angle); + } + else { + x=current.x + r*std::cos(angle); + y=current.y + r*std::sin(angle); + } + if (current.direct){ + if (rempli){ + fprintf(file,"\\pswedge*[fillcolor="); + fprintf(file,"%s",flcolor2pstrickscolor(prec.color).c_str()); + fprintf(file,"]"); + } + else + fprintf(file,"\\psarc"); + fprintf(file,"(%.4f,%.4f){%.4f}{%.4f}{%.4f}\n",x,y,double(r),theta1-90,theta2-90); + } + else { + if (rempli){ + fprintf(file,"\\pswedge*[fillcolor="); + fprintf(file,"%s",flcolor2pstrickscolor(prec.color).c_str()); + fprintf(file,"]"); + } + else + fprintf(file,"\\psarc"); + fprintf(file,"(%.4f,%.4f){%.4f}{%.4f}{%.4f}\n",x,y,double(r),theta2+90,theta1+90); + } + } // end radius>0 + else { + if (prec.mark && (prec.x!=current.x || prec.y!=current.y) ){ + fprintf(file,"\\psline(%.4f,%.4f)(%.4f,%.4f)\n", prec.x,prec.y,current.x,current.y); + } + } + if (current.radius<-1 && k+current.radius>=0){ + // poly-line from (*turtleptr)[k+current.radius] to (*turtleptr)[k] + string printstring("\\pspolygon[linestyle=none,fillstyle=solid,fillcolor="+flcolor2pstrickscolor(prec.color)+"]"); + for (int i=0;i>=current.radius;--i){ + logo_turtle & t=(*turtleptr)[k+i]; + printstring += "("+double2tex(t.x)+","+double2tex(t.y)+")"; + } + printstring += "("+double2tex(current.x)+","+double2tex(current.y)+")\n"; + fprintf(file,"%s",printstring.c_str()); + } + } // end else (non-string turtle record) + prec=current; + } // end for (all turtle records) + logo_turtle & t = (*turtleptr)[l-1]; + double x=t.x,y=t.y; + double cost=std::cos(t.theta*deg2rad_d); + double sint=std::sin(t.theta*deg2rad_d); + double Dx=turtle_length*cost/2; + double Dy=turtle_length*sint/2; + string col(flcolor2pstrickscolor(prec.color)); + fprintf(file,"\\psset{linecolor=%s}\n", col.c_str()); + if (t.visible){ + fprintf(file,"\\psline(%.4f,%.4f)(%.4f,%.4f)\n", x+Dy, y-Dx, x-Dy, y+Dx); + // fl_line(deltax+x+Dy,deltay+h()-(y-Dx),deltax+x-Dy,deltay+h()-(y+Dx)); + if (!t.mark){ + string col(flcolor2pstrickscolor(t.color+1)); + fprintf(file,"\\psset{linecolor=%s}\n", col.c_str()); + } + fprintf(file,"\\psline(%.4f,%.4f)(%.4f,%.4f)\n", x+Dy, y-Dx, x+3*Dx, y+3*Dy); + fprintf(file,"\\psline(%.4f,%.4f)(%.4f,%.4f)\n", x-Dy, y+Dx, x+3*Dx, y+3*Dy); + } // end if t.visible + } // end if l>0 + } // end if logo + else +#endif + { + if (show_axes(contextptr) && (Y2>=0) && (Y1<=0) ) + fprintf(file,"\\psline[linestyle=dashed]{->}(%.4f,%.4f)(%.4f,%.4f)\n",X1,z,X2,z); + if (show_axes(contextptr) && (X2>=0) && (X1<=0) ) + fprintf(file,"\\psline[linestyle=dashed]{->}(%.4f,%.4f)(%.4f,%.4f)\n",z,Y1,z,Y2); + ingraph2tex(file,v,xunit,yunit,X1,Y1,X2,Y2,contextptr); + } + fprintf(file,"\\end{pspicture} \n\n"); + return 1; + } + + int graph2tex(const string &s,const vecteur & v,double X1,double X2,double Y1,double Y2,double Unit,bool logo,GIAC_CONTEXT){ + return graph2tex(s,v,X1,X2,Y1,Y2,Unit,Unit,logo,contextptr); + } + + std::string get_path(const string & st){ + int s=int(st.size()),i; + for (i=s-1;i>=0;--i){ + if (st[i]=='/') + break; + } + return st.substr(0,i+1); + } + + std::string remove_path(const std::string & st){ + int s=int(st.size()),i; + for (i=s-1;i>=0;--i){ + if (st[i]=='/') + break; + } + return st.substr(i+1,s-i-1); + } + + + int graph2tex(const string &s,const vecteur & v,double X1,double X2,double Y1,double Y2,double xunit,double yunit,bool logo,GIAC_CONTEXT){ + if (is_undef(check_secure())) + return 0; + // int file; + // file = open (s.c_str(), O_WRONLY); + // if (file==-1) + // return file; + // int savestdout; + // dup2(STDOUT_FILENO,savestdout); + // dup2(file,STDOUT_FILENO); + // Begin eukleides code with redirected stdout + FILE * filecol=fopen((get_path(s)+"fltkcol.tex").c_str(),"w"); + if (!filecol){ + CERR << "Unable to open color file fltkcol.tex" << '\n'; + return 0; + } + fprintf(filecol,"%s",tex_color); + fclose(filecol); + FILE * file=fopen(s.c_str(), "w"); + if (!file){ + CERR << "Unable to open file "+s << '\n'; + return 0; + } + fprintf(file,"%s",tex_preamble); + fprintf(file,"\\input fltkcol.tex"); + graph2tex(file,v,X1,X2,Y1,Y2,xunit,yunit,s.c_str(),logo,contextptr); + fprintf(file,"\\end{document}\n"); + fclose(file); + return 1; + // End eukleides code, restore stdout + // dup2(savestdout,STDOUT_FILENO); + } + + gen _graph2tex(const gen & args,GIAC_CONTEXT){ + if ( args.type==_STRNG && args.subtype==-1) return args; + int i=erase_pos(contextptr); + vecteur hist(history_out(contextptr).begin()+i,history_out(contextptr).end()); + return graph2tex(args,hist,contextptr); + } + + gen graph2tex(const gen & args,const vecteur & hist,GIAC_CONTEXT){ + if (args.type==_STRNG){ + double horiz_unit=horiz_latex/(gnuplot_xmax-gnuplot_xmin); + double vert_unit=vert_latex/(gnuplot_ymax-gnuplot_ymin); + double unit=horiz_unit; + if (horiz_unit>vert_unit) + unit=vert_unit; + return graph2tex(*args._STRNGptr,hist,gnuplot_xmin,gnuplot_xmax,gnuplot_ymin,gnuplot_ymax,unit,false,contextptr); + } + if ( (args.type!=_VECT) || (args._VECTptr->size()<2) ) + return symbolic(at_graph2tex,args); + vecteur & v=*args._VECTptr; + int vs=int(v.size()); + if ( (v[0].type!=_STRNG) || (v[1].type!=_DOUBLE_) ) + return gensizeerr(); + if ( (vs>2) && (v[2].type==_DOUBLE_) ) + gnuplot_xmin=v[2]._DOUBLE_val; + if ( (vs>3) && (v[3].type==_DOUBLE_) ) + gnuplot_xmax=v[3]._DOUBLE_val; + if ( (vs>4) && (v[4].type==_DOUBLE_) ) + gnuplot_ymin=v[4]._DOUBLE_val; + if ( (vs>5) && (v[5].type==_DOUBLE_) ) + gnuplot_ymax=v[5]._DOUBLE_val; + return graph2tex(*v[0]._STRNGptr,hist,gnuplot_xmin,gnuplot_xmax,gnuplot_ymin,gnuplot_ymax,v[1]._DOUBLE_val,false,contextptr); + } + static const char _graph2tex_s []="graph2tex"; + static define_unary_function_eval (__graph2tex,&_graph2tex,_graph2tex_s); + define_unary_function_ptr5( at_graph2tex ,alias_at_graph2tex,&__graph2tex,0,true); + + gen _graph3d2tex(const gen & args,GIAC_CONTEXT){ + if ( args.type==_STRNG && args.subtype==-1) return args; + gen tmp=check_secure(); + if (is_undef(tmp)) return tmp; + if (args.type==_STRNG){ + string & s=*args._STRNGptr; +#ifdef WITH_GNUPLOT + bool clrplot; + int out_handle; + FILE * gnuplot_out_readstream,* stream = open_gnuplot(clrplot,gnuplot_out_readstream,out_handle); + latex_replot(stream,s); + gnuplot_wait(out_handle,gnuplot_out_readstream,5); +#endif + return string2gen(s,false); + } + else { // search in history for the last plot command answer == to an int + int s=giacmin(int(history_out(contextptr).size()),int(history_in(contextptr).size())); + for (int i=s-1;i>=0;--i){ + if (history_out(contextptr)[i].is_symb_of_sommet(at_pnt) && history_out(contextptr)[i].subtype>=0) + return history_out(contextptr)[i].subtype; + if ( history_out(contextptr)[i].type==_INT_ && history_in(contextptr)[i].type==_SYMB && ( equalposcomp(implicittex_plot_sommets,history_in(contextptr)[i]._SYMBptr->sommet) || equalposcomp(notexprint_plot_sommets,history_in(contextptr)[i]._SYMBptr->sommet) ) ) + return history_out(contextptr)[i]; + } + return undef; + } + } + static const char _graph3d2tex_s []="graph3d2tex"; + static define_unary_function_eval (__graph3d2tex,&_graph3d2tex,_graph3d2tex_s); + define_unary_function_ptr5( at_graph3d2tex ,alias_at_graph3d2tex,&__graph3d2tex,0,true); +#ifndef NO_NAMESPACE_GIAC +} // namespace giac +#endif // ndef NO_NAMESPACE_GIAC diff --git a/apps/KhiCAS/src/giac-1.6.0/src/threaded.cc b/apps/KhiCAS/src/giac-1.6.0/src/threaded.cc index e92039777..fe761f2b3 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/threaded.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/threaded.cc @@ -388,7 +388,8 @@ mpz_class smod(const mpz_class & a,int reduce){ pcontxn.reserve(256); current.reserve(256); tmp.reserve(256); reste.reserve(256); for (;it!=itend;){ current.clear(); - current.push_back(it->g); + if (!is_zero(it->g)) + current.push_back(it->g); curu=it->u; ++it; for (;it!=itend;++it){ @@ -396,12 +397,13 @@ mpz_class smod(const mpz_class & a,int reduce){ if ( newu < u ){ break; } - if (curu>newu+var2) + if (curu>newu+var2 && !current.empty()) current.insert(current.end(),(curu-newu)/var2-1,T(0)); - current.push_back(it->g); + if (!is_zero(it->g) || !current.empty()) + current.push_back(it->g); curu=newu; } - if (curu>u) + if (curu>u && !current.empty()) current.insert(current.end(),(curu-u)/var2,T(0)); #ifdef TIMEOUT control_c(); @@ -418,7 +420,8 @@ mpz_class smod(const mpz_class & a,int reduce){ u=(p.front().u/var)*var; for (;it!=itend;){ current.clear(); - current.push_back(it->g); + if (!is_zero(it->g)) + current.push_back(it->g); curu=it->u; ++it; for (;it!=itend;++it){ @@ -426,12 +429,13 @@ mpz_class smod(const mpz_class & a,int reduce){ if ( newu < u ){ break; } - if (curu>newu+var2) + if (curu>newu+var2 && !current.empty()) current.insert(current.end(),(curu-newu)/var2-1,T(0)); - current.push_back(it->g); + if (!is_zero(it->g) || !current.empty()) + current.push_back(it->g); curu=newu; } - if (curu>u) + if (curu>u && !current.empty()) current.insert(current.end(),(curu-u)/var2,T(0)); #ifdef TIMEOUT control_c(); @@ -3039,7 +3043,7 @@ mpz_class smod(const mpz_class & a,int reduce){ } } // end for (int thread=0;thread * gcd_call_param_v=(gcd_call_param *)alloca(nthreads*sizeof(gcd_call_param)); + ALLOCA(gcd_call_param,gcd_call_param_v,nthreads*sizeof(gcd_call_param)); // gcd_call_param * gcd_call_param_v=(gcd_call_param *)alloca(nthreads*sizeof(gcd_call_param)); for (int i=0;i + void ck_getkey(int * keyptr); } #endif #ifdef KHICAS @@ -1771,6 +1772,8 @@ namespace giac { gen g_=eval(g,1,contextptr); if (g_.type==_STRNG) g_=gen(*g_._STRNGptr,contextptr); + if (is_integer(g_)) + return g_; return _floor(evalf(g_,1,contextptr),contextptr); } else @@ -2206,13 +2209,29 @@ namespace giac { control_c(); int key=getkey(0); return key; +#else +#ifdef FXCG + clear_abort(); + int key; + ck_getkey(&key); + set_abort(); + if (key==KEY_CTRL_LEFT) + return 0; + if (key==KEY_CTRL_UP) + return 1; + if (key==KEY_CTRL_DOWN) + return 2; + if (key==KEY_CTRL_RIGHT) + return 3; + if (key==KEY_CTRL_EXE) + return 4; + if (key==KEY_CTRL_EXIT) + return 5; + return key; #else if (interactive_op_tab && interactive_op_tab[4]) return interactive_op_tab[4](g,contextptr); if ( g.type==_STRNG && g.subtype==-1) return g; -#ifdef FXCG - return PRGM_GetKey(); -#else char ch; CERR << "Waiting for a keystroke in konsole screen" << '\n'; CIN >> ch; @@ -2229,7 +2248,11 @@ namespace giac { define_unary_function_ptr5( at_getKey ,alias_at_getKey,&__getKey,0,true); static const char _get_key_s[]="get_key"; +#ifdef FXCG + static define_unary_function_eval(__get_key,&_getKey,_get_key_s); +#else unary_function_eval __get_key(0,&_getKey,_get_key_s); +#endif define_unary_function_ptr5( at_get_key ,alias_at_get_key,&__get_key,0,true); gen _keydown(const gen & g,GIAC_CONTEXT){ diff --git a/apps/KhiCAS/src/giac-1.6.0/src/unary.cc b/apps/KhiCAS/src/giac-1.6.0/src/unary.cc index c576239ca..6e41cdf57 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/unary.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/unary.cc @@ -107,6 +107,9 @@ namespace giac { */ const char * unary_function_eval::print(GIAC_CONTEXT) const { +#ifdef FXCG + return s; +#else if (abs_calc_mode(contextptr)==38){ if (calc_mode(contextptr)==38){ const char * maj = hp38_display_in_maj(s); @@ -124,6 +127,7 @@ namespace giac { } } return s; +#endif } #else // NO_UNARY_FUNCTION_COMPOSE @@ -158,6 +162,7 @@ namespace giac { */ const char * unary_function_abstract::print(GIAC_CONTEXT) const { +#ifndef FXCG if (abs_calc_mode(contextptr)==38){ if (calc_mode(contextptr)==38){ const char * maj = hp38_display_in_maj(s); @@ -165,6 +170,7 @@ namespace giac { } return s; } +#endif int lang=language(contextptr); multimap::iterator it=back_lexer_localization_map().find(s),backend=back_lexer_localization_map().end(),itend=back_lexer_localization_map().upper_bound(s); if (it!=backend){ @@ -205,12 +211,14 @@ namespace giac { */ gen apply(const gen & e,const unary_function_ptr & f,GIAC_CONTEXT){ +#ifndef FXCG if (e.type==_MAP){ gen_map res; gen g(res); map_apply(*e._MAPptr,f,*g._MAPptr,contextptr); return g; } +#endif if (e.type!=_VECT) return f(e,contextptr); const_iterateur it=e._VECTptr->begin(),itend=e._VECTptr->end(); @@ -258,12 +266,14 @@ namespace giac { } gen apply(const gen & e, gen (* f) (const gen &,const context *),GIAC_CONTEXT ){ +#ifndef FXCG if (e.type==_MAP){ gen_map res; gen g(res); map_apply(*e._MAPptr,*g._MAPptr,contextptr,f); return g; } +#endif if (e.type!=_VECT) return f(e,contextptr); const_iterateur it=e._VECTptr->begin(),itend=e._VECTptr->end(); @@ -321,12 +331,14 @@ namespace giac { } gen apply(const gen & e, const context * contextptr,const gen_op_context & f ){ +#ifndef FXCG if (e.type==_MAP){ gen_map res; gen g(res); map_apply(*e._MAPptr,*g._MAPptr,contextptr,f); return g; } +#endif if (e.type!=_VECT) return f(e,contextptr); const_iterateur it=e._VECTptr->begin(),itend=e._VECTptr->end(); @@ -615,6 +627,9 @@ namespace giac { } string texprintsommetasoperator(const gen & feuille,const char * sommetstr_orig,GIAC_CONTEXT){ +#ifdef FXCG + return ""; +#else if (feuille.type!=_VECT) return feuille.print(contextptr); string sommetstr(sommetstr_orig); @@ -640,6 +655,8 @@ namespace giac { s += sommetstr + gen2tex(*itb,contextptr); ++itb; } + return s; +#endif } #ifdef NO_UNARY_FUNCTION_COMPOSE diff --git a/apps/KhiCAS/src/giac-1.6.0/src/usual.cc b/apps/KhiCAS/src/giac-1.6.0/src/usual.cc index 7f5f711da..f9a814bb4 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/usual.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/usual.cc @@ -2749,8 +2749,12 @@ namespace giac { // static symbolic symb_acosh(const gen & e){ return symbolic(at_cosh,e); } static gen acoshasln(const gen & x,GIAC_CONTEXT){ - if (re(x,contextptr)==x) - return ln(x+sqrt(x*x-1,contextptr),contextptr); // avoid multiple sqrt but it's the opposite for example for x non real + if (re(x,contextptr)==x){ + gen res=ln(x+sqrt(x*x-1,contextptr),contextptr); + if (is_positive(-x,contextptr)) + return -res; // avoid multiple sqrt but it's the opposite for example for x non real + return res; + } return ln(x+sqrt(x+1,contextptr)*sqrt(x-1,contextptr),contextptr); } gen acosh(const gen & e0,GIAC_CONTEXT){ @@ -6452,8 +6456,8 @@ namespace giac { static symbolic symb_quorem(const gen & a,const gen & b){ return symbolic(at_quorem,makevecteur(a,b)); } gen quorem(const gen & a,const gen & b){ - if ((a.type!=_VECT) || (b.type!=_VECT)) - return symb_quorem(a,b); + if (a.type!=_VECT || b.type!=_VECT) + return quorem(gen2vecteur(a),gen2vecteur(b)); if (b._VECTptr->empty()) return gensizeerr(gettext("Division by 0")); vecteur q,r; @@ -6472,7 +6476,8 @@ namespace giac { return _revlist(_greduce(gen(v,_SEQ__VECT),contextptr),contextptr); } vecteur & a =*args._VECTptr; - if ( (a.front().type==_VECT) && (a[1].type==_VECT)) + if ( // a.front().type==_VECT && + a[1].type==_VECT ) return quorem(a.front(),a[1]); if ( (a.front().type==_POLY) && (a[1].type==_POLY)){ int dim=a.front()._POLYptr->dim; @@ -9163,10 +9168,12 @@ namespace giac { // by series expansion at x=0 // x*sum( (-1)^n*(x^2)^n/n!/(2*n+1),n=0..inf) complex_long_double z2=z*z,res=0,pi=1; + //*logptr(contextptr) << "erf z " << z << '\n'; for (long_double n=0;;){ res += pi/(2*n+1); ++n; pi = -pi*z2/n; + // if (n<10) *logptr(contextptr) << "res " << res << "\n pi " << pi << '\n'; if (complex_long_abs(pi)<1e-17) break; } @@ -9211,6 +9218,7 @@ namespace giac { erfc=2-erfc; return -e; } +#ifndef HAVE_LIBMPFR else { // continued fraction // 2*exp(z^2)*int(exp(-t^2),t=z..inf)=1/(z+1/2/(z+1/(z+3/2/(z+...)))) @@ -9225,12 +9233,17 @@ namespace giac { #endif res=std::exp(-z*z)*res/complex_long_double(std::sqrt(M_PI)); erfc=gen(double(res.real()),double(res.imag())); + if (std::abs(z.real())<=1e-2*std::abs(z.imag())){ + *logptr(contextptr) << "Low accuracy\n"; + return -erfc; + } gen e=1-erfc; if (!neg) return e; erfc=2-erfc; return -e; } +#endif // HAVE_LIBMPFR } // end low precision // take account of loss of accuracy int prec=decimal_digits(contextptr); @@ -11211,6 +11224,63 @@ namespace giac { #endif } +#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS +#else + // additions by L. Marohnić: + string to_unix_path(const string &path) { + string ret; + ret.reserve(path.size()); + string::const_iterator it=path.begin(),itend=path.end(); + for (;it!=itend;++it) { + switch (*it) { + case '\\': + ret.push_back('/'); + break; + default: + ret.push_back(*it); + break; + } + } + return ret; + } + /* Create a temporary file name (using the fallback filename if tmpnam fails). + * Optionally, extension EXT may be specified, without the leading dot.*/ + string temp_file_name(const char *fallback_name,const char *ext) { + char buf[L_tmpnam]; + bool has_temp_file=(tmpnam(buf)!=NULL); + string tmpname(has_temp_file?buf:fallback_name); +#ifdef _WIN32 + string tmpdir=getenv("TEMP")?getenv("TEMP"):"c:\\Users\\Public\\"; + tmpname=tmpdir+tmpname; + if (tmpname[tmpname.size()-1]=='.') + tmpname.erase(tmpname.begin()+tmpname.size()-1); +#endif + if (ext!=NULL) + tmpname+="."+string(ext); + return tmpname; + } + /* Return true iff the file FNAME exists. */ + bool ckfileexists(const char *fname) { + if (FILE *f=fopen(fname,"r")) { + fclose(f); + return true; + } + return false; + } + temp_file::temp_file(const char *fallback_name,const char *ext) { + _fname=temp_file_name(fallback_name,ext); + handle=fopen(_fname.c_str(),"wb+"); + } + temp_file::~temp_file() { + if (ckfileexists(_fname.c_str())) { + if (handle!=NULL) + fclose(handle); + if (remove(_fname.c_str())!=0 && debug_infolevel) + cerr << gettext("Failed to remove temporary file") << " '" << _fname << "'\n"; + } + } +#endif + #ifndef NO_NAMESPACE_GIAC } // namespace giac #endif // ndef NO_NAMESPACE_GIAC diff --git a/apps/KhiCAS/src/giac-1.6.0/src/usual.h b/apps/KhiCAS/src/giac-1.6.0/src/usual.h index 2c29b692b..7e49d1cf8 100755 --- a/apps/KhiCAS/src/giac-1.6.0/src/usual.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/usual.h @@ -945,6 +945,25 @@ namespace giac { gen * normal_cos_pi_12_ptr_(); #endif +#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS +#else + // additions by L. Marohnić: + std::string to_unix_path(const std::string &path); + std::string temp_file_name(const char *fallback_name,const char *ext=NULL); + bool ckfileexists(const char *fname); + class temp_file { + // TEMPORARY FILE CLASS + // This is a temporary file object that is accessed through the 'handle' member. + // The file is created and opened by constructor and automatically deleted by destructor. + std::string _fname; + public: + FILE *handle; + temp_file(const char *fallback_name,const char *ext=NULL); + ~temp_file(); + bool fail() const { return handle==NULL; } + }; +#endif + #ifndef NO_NAMESPACE_GIAC } // namespace giac #endif // ndef NO_NAMESPACE_GIAC diff --git a/apps/KhiCAS/src/giac-1.6.0/src/vecteur.cc b/apps/KhiCAS/src/giac-1.6.0/src/vecteur.cc index 290833c76..fbcd46637 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/vecteur.cc +++ b/apps/KhiCAS/src/giac-1.6.0/src/vecteur.cc @@ -48,6 +48,10 @@ using namespace std; #include "modfactor.h" #include "quater.h" #include "giacintl.h" +#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS +#else +#include "signalprocessing.h" +#endif #ifdef HAVE_LIBGSL #include #include @@ -7867,6 +7871,29 @@ namespace giac { y.push_back(x[permutation[i]]); } + /* Addition by L. Marohnić. + * This function permutes the vector V according to the permutation P. + * if COPY_P=true then P is copied first, so that the original is + * unchanged in the end. Otherwise, P is used as a workspace so its + * original content is destroyed. */ + void apply_permutation(vecteur &v,vector &p,bool keep_p) { + vector pc; + if (keep_p) pc=p; + vector &P=keep_p?pc:p; + int n=v.size(),i,curr,next; + for (i=0;i perminv(const vector & p); // solve LU x= b (permutation P) @@ -11493,7 +11520,7 @@ namespace giac { A[i + j * rows].i=0; continue; } - if (g.type==_CPLX && g._CPLXptr->type==_DOUBLE_ && (*g._CPLXptr+1).type==_DOUBLE_){ + if (g.type==_CPLX && g._CPLXptr->type==_DOUBLE_ && (g._CPLXptr+1)->type==_DOUBLE_){ // FIX by L. Marohnić A[i + j * rows].r = g._CPLXptr->_DOUBLE_val; A[i + j * rows].i = (g._CPLXptr+1)->_DOUBLE_val; } @@ -14734,7 +14761,7 @@ namespace giac { char_m=mergematrice(char_m,mtran(*cur_m._VECTptr)); if (is_undef(char_m) || (!jordan && !is_zero(cur_m,contextptr)) ){ #ifndef NO_STDEXCEPT - throw(std::runtime_error("Not diagonalizable at eigenvalue "+x.print())); + gensizeerr("Not diagonalizable at eigenvalue "+x.print()); #endif return false; } @@ -15179,8 +15206,81 @@ namespace giac { return v; } + // adapted by L. Marohnić for image loading and creation gen _image(const gen & a,GIAC_CONTEXT){ +#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS || defined EMCC || defined EMCC2 if ( a.type==_STRNG && a.subtype==-1) return a; +#else + if (a.type==_STRNG) { + if (a.subtype==-1) return a; + if (load_image_ptr) + return load_image_ptr(a._STRNGptr->c_str(),contextptr); + return generr(gettext("FLTK is required for loading images")); + } + if (a.type==_VECT && a.subtype==_SEQ__VECT) { + const vecteur &args=*a._VECTptr; + if (args.size()<2) + return gendimerr(contextptr); + if (!args.front().is_integer()) + return gentypeerr(contextptr); + int d=args.front().val,w=0,h=0; + if (d<1 || d>4) + return generr(gettext("Invalid color type")); + if (args.back().type==_STRNG) { + if (args.size()!=3) + return gendimerr(contextptr); + if (!args[1].is_integer()) + return gentypeerr(contextptr); + w=args[1].val; + try { + return rgba_image(d,w,*args.back()._STRNGptr,contextptr); + } catch (const std::runtime_error &e) { + return generr(e.what()); + } + } + if (args.size()-1>d) + return gendimerr(contextptr); + vector data; + switch (d) { + case 1: + data.push_back(&args[1]); + break; + case 2: + data.push_back(&args[1]); + if (args.size()>2) + data.push_back(&args[2]); + else data.push_back(NULL); + break; + case 3: + if (args.size()==2) + data=vector(3,&args[1]); + else if (args.size()==4) { + data.push_back(&args[1]); + data.push_back(&args[2]); + data.push_back(&args[3]); + } else return gendimerr(contextptr); + break; + case 4: + if (args.size()<4) { + data=vector(3,&args[1]); + data.push_back(args.size()==2?NULL:&args[2]); + } else { + data.push_back(&args[1]); + data.push_back(&args[2]); + data.push_back(&args[3]); + if (args.size()>4) + data.push_back(&args[4]); + else data.push_back(NULL); + } + break; + } + try { + return rgba_image(data,contextptr); + } catch (const std::runtime_error &e) { + return generr(e.what()); + } + } +#endif if (!ckmatrix(a)) return symb_image(a); vecteur v; @@ -15309,6 +15409,17 @@ namespace giac { } gen _size(const gen &args,GIAC_CONTEXT){ if (args.type==_STRNG && args.subtype==-1) return args; +#if defined GIAC_HAS_STO_38 || defined NSPIRE || defined NSPIRE_NEWLIB || defined FXCG || defined GIAC_GGB || defined USE_GMP_REPLACEMENTS || defined KHICAS || defined EMCC || defined EMCC2 +#else + /* size of image or audio clip, addition by L. Marohnić */ + audio_clip *clip=audio_clip::from_gen(args); + rgba_image *img=rgba_image::from_gen(args); + if (clip!=NULL) + return clip->length(); + if (img!=NULL) + return makevecteur(img->width(),img->height()); + /* end audio clip or image size */ +#endif if (args.type==_STRNG) return (int) args._STRNGptr->size(); if (args.type==_SYMB){ @@ -15349,7 +15460,7 @@ namespace giac { gen g; int res=GSL_SUCCESS; for (int i = 0; it!=itend; ++i,++it){ - g=it->evalf(1,contextptr); + g=it->evalf_double(1,contextptr); if (g.type==_DOUBLE_) gsl_vector_set (w, i, g._DOUBLE_val); else { @@ -15383,6 +15494,32 @@ namespace giac { return res; } + // Added by L. Marohnić + // Copies the submatrix of m starting at (i0,j0) with n1 rows and n2 columns to GSL matrix w. + // If transp=true, then w contains the transposed submatrix. + int matrice2gsl_matrix(const matrice & m,int i0,int j0,int n1,int n2,bool transp,gsl_matrix * w,GIAC_CONTEXT) { + gen g; + const_iterateur it=m.begin()+i0,jt; + int res=GSL_SUCCESS,i,j,rc=n1>0?n1:(mrows(m)-i0),cc=n2>0?n2:(mcols(m)-j0); + if (w->size1<(transp?cc:rc) || w->size2<(transp?rc:cc)) + return !GSL_SUCCESS; + for (i=0; itype!=_VECT) + return !GSL_SUCCESS; + vecteur & v =*it->_VECTptr; + for (j=0,jt=v.begin()+j0;jsize1,s2=w->size2; #ifdef DEBUG_SUPPORT @@ -15390,6 +15527,7 @@ namespace giac { if (mrows(m)!=s1 || mcols(m)!=s2) setdimerr(); #endif + return matrice2gsl_matrix(m,0,0,0,0,false,w,contextptr); // change by L. Marohnić gen g; const_iterateur it=m.begin(),itend=m.end(); int res=GSL_SUCCESS; @@ -15421,7 +15559,8 @@ namespace giac { // this function does not deallocate the gsl vector // call gsl_matrix_free(v) for this - matrice gsl_matrix2matrice(const gsl_matrix * v){ + // Addition by L. Marohnić: if transp=true, then the result is transposed (sub)matrix v. + matrice gsl_matrix2matrice(const gsl_matrix * v,bool transp){ matrice res; int s1=v->size1,s2=v->size2; res.reserve(s1); @@ -15429,7 +15568,7 @@ namespace giac { vecteur tmp; tmp.reserve(s2); for (int j=0;j=0) for (i=0;i0) { + if (A[i+i*N]==0) ++(*z); + else if (A[i+i*N]>0) ++(*p); + else ++(*n); + } else { + ++(*p); + ++(*n); + ++i; + } + } + } + return INFO>=0; + } +#endif + bool solve_indef(matrice &A,const vecteur *b,vecteur &x,int *p,int *n,int *z,GIAC_CONTEXT) { + int N=A.size(),i,j; + if (b!=NULL) { // solve A*x=b, A must be factorized, X contains the permutation + if (int(x.size())!=N || !ckmatrix(*b) || mcols(*b)!=N) + return false; + if (N==1) { + x=divvecteur(*b,A[0][0]); + return true; + } + vector perm=vecteur_2_vector_int(x); + x.clear(); + x.reserve(b->size()); + vecteur z(N),u(N),y(N),xi(N); + for (const_iterateur it=b->begin();it!=b->end();++it) { + const vecteur &bi=*it->_VECTptr,&dlow=*A[0]._VECTptr; + for (i=0;i0;) { + y[i]=u[i]; + for (j=i+1;j0) ++(*p); + else if (A[0][0]<0) ++(*n); + else ++(*z); + return true; + } + vector perm; + bool sing; + if (!ldl(A,perm,0,sing,0,contextptr) || sing) + return false; + x=vector_int_2_vecteur(perm); + const vecteur &dlow=*A[0]._VECTptr; + for (i=0;i &p,bool h,GIAC_CONTEXT) { + int I=kat(I)=conj(tmp,contextptr); + } else for (i=I+1;iat(I)); + for (i=0;iat(I),a[i]._VECTptr->at(J)); + if (h) rJ[I]=conj(rJ[I],contextptr); + swapgen(rI[I],rJ[J]); + std::swap(p[k],p[l]); + } + + /* Bunch & Kaufman LDL factorization of an indefinite symmetric/Hermitian matrix A. + * Factorization is performed in-place. PERM defines the permutation matrix. + * The lower sub-diagonal is stored to A[0,1:N-1]. SING is true iff A is singular. + * MAT_TYPE should be set to 1 for real numeric, 2 for complex numeric, 3 for + * complex Hermitian and 0 for general (symbolic) matrix A. */ + bool ldl(matrice &a,vector &perm,int mat_type,bool &sing,double time_limit,GIAC_CONTEXT) { + int N=a.size(),i,j,k,p,r,s,ip; + if (int(perm.size())!=N) perm.resize(N); + for (vector::iterator it=perm.begin();it!=perm.end();++it) + *it=int(it-perm.begin()); + sing=false; + #ifdef HAVE_LIBLAPACK + /* + * DSYTRF/ZSYTRF computes the factorization of a real/complex + * symmetric/Hermitian matrix A using Bunch-Kaufman diagonal + * pivoting method. The form of the factorization is + * + * A = L*D*L**T + * + * where L is a product of permutation and unit lower triangular + * matrices, and D is symmetric and block diagonal with 1-by-1 and + * 2-by-2 diagonal blocks. + * + * This is the blocked version of the algorithm, calling Level 3 BLAS. + */ + if (mat_type>1 && N>1) { // numeric matrix, use LAPACK + char UPLO='L'; // operate on the lower triangle of A + int LDA=N,INFO,*IPIV=new int[N],LWORK=-1; + gen elem; + double *A_DBL=NULL,*WORK_DBL=NULL; + doublef2c_complex *A_CPLX=NULL,*WORK_CPLX=NULL; + if (mat_type==2) A_DBL=new double[N*N]; + else A_CPLX=new doublef2c_complex[N*N]; + iterateur it=a.begin(),itend=a.end(),jt,jtend,rt1,rt2,rtend; + for (i=0;it!=itend;++it,++i) { + if (it->type!=_VECT) + return false; // A is not a matrix + jt=it->_VECTptr->begin(); + jtend=jt+i+1; + for (j=0;jt!=jtend;++jt,++j) { + elem=evalf_double(*jt,1,contextptr); + if (elem.type==_DOUBLE_) { + if (mat_type==2) A_DBL[i+j*N]=elem._DOUBLE_val; + else { + A_CPLX[i+j*N].r=elem._DOUBLE_val; + A_CPLX[i+j*N].i=0; + } + } else if (mat_type>2 && elem.type==_CPLX && elem._CPLXptr->type==_DOUBLE_ && (elem._CPLXptr+1)->type==_DOUBLE_) { + A_CPLX[i+j*N].r=elem._CPLXptr->_DOUBLE_val; + A_CPLX[i+j*N].i=(elem._CPLXptr+1)->_DOUBLE_val; + } else return false; + } + } + if (LWORK==-1) { // get WORK array size + if (mat_type==2) { + double TMP_WORK; + dsytrf_(&UPLO,&N,A_DBL,&LDA,IPIV,&TMP_WORK,&LWORK,&INFO); + if (INFO!=0) + return false; + LWORK=(int)TMP_WORK; + } else { + doublef2c_complex TMP_WORK; + if (mat_type==3) + zsytrf_(&UPLO,&N,A_CPLX,&LDA,IPIV,&TMP_WORK,&LWORK,&INFO); + else + zhetrf_(&UPLO,&N,A_CPLX,&LDA,IPIV,&TMP_WORK,&LWORK,&INFO); + if (INFO!=0) + return false; + LWORK=(int)TMP_WORK.r; + } + } + if (LWORK>0) { + if (mat_type==2) WORK_DBL=new double[LWORK]; + else WORK_CPLX=new doublef2c_complex[LWORK]; + } + if (mat_type==2) + dsytrf_(&UPLO,&N,A_DBL,&LDA,IPIV,WORK_DBL,&LWORK,&INFO); + else if (mat_type==3) + zsytrf_(&UPLO,&N,A_CPLX,&LDA,IPIV,WORK_CPLX,&LWORK,&INFO); + else + zhetrf_(&UPLO,&N,A_CPLX,&LDA,IPIV,WORK_CPLX,&LWORK,&INFO); + if (INFO<0) { // illegal argument value + delete[] IPIV; + if (mat_type==2) { + delete[] A_DBL; + if (WORK_DBL!=NULL) delete[] WORK_DBL; + } else { + delete[] A_CPLX; + if (WORK_CPLX!=NULL) delete[] WORK_CPLX; + } + return false; // LAPACK error + } + if (INFO>0) + sing=true; // there is at least one zero at the diagonal of D + vecteur &dlow=*a[0]._VECTptr; // the lower sub-diagonal + std::fill(dlow.begin()+1,dlow.end(),0); + vector base_perm(perm),col_perm(N); + for (j=0;j0) { + k=j+j*N; + a[j]._VECTptr->at(j)=mat_type==2?gen(A_DBL[k]):gen(A_CPLX[k].r,A_CPLX[k].i); + if (--ip!=j) std::swap(perm[j],perm[ip]); + std::copy(base_perm.begin(),base_perm.end(),col_perm.begin()); + bool skip=false; + for (i=j+1;i0) { + if (--ip!=i) std::swap(col_perm[i],col_perm[ip]); + } else { + if (++ip!=-i-1) std::swap(col_perm[i+1],col_perm[-ip]); + skip=true; + } + } else skip=false; + k=col_perm[i]+j*N; + a[i]._VECTptr->at(j)=mat_type==2?gen(A_DBL[k]):gen(A_CPLX[k].r,A_CPLX[k].i); + } + } else { + k=j+j*N; + a[j]._VECTptr->at(j)=mat_type==2?gen(A_DBL[k]):gen(A_CPLX[k].r,A_CPLX[k].i); + k+=N+1; + a[j+1]._VECTptr->at(j+1)=mat_type==2?gen(A_DBL[k]):gen(A_CPLX[k].r,A_CPLX[k].i); + if (++ip!=-j-1) std::swap(perm[j+1],perm[-ip]); + k-=N; + dlow[j+1]=mat_type==2?gen(A_DBL[k]):gen(A_CPLX[k].r,A_CPLX[k].i); + a[j+1]._VECTptr->at(j)=0; + std::copy(base_perm.begin(),base_perm.end(),col_perm.begin()); + bool skip=false; + for (i=j+2;i0) { + if (--ip!=i) std::swap(col_perm[i],col_perm[ip]); + } else { + if (++ip!=-i-1) std::swap(col_perm[i+1],col_perm[-ip]); + skip=true; + } + } else skip=false; + k=col_perm[i]+j*N; + a[i]._VECTptr->at(j)=mat_type==2?gen(A_DBL[k]):gen(A_CPLX[k].r,A_CPLX[k].i); + k+=N; + a[i]._VECTptr->at(j+1)=mat_type==2?gen(A_DBL[k]):gen(A_CPLX[k].r,A_CPLX[k].i); + } + ++j; + } + } + delete[] IPIV; + if (mat_type==2) { + delete[] A_DBL; + if (WORK_DBL!=NULL) WORK_DBL; + } else { + delete[] A_CPLX; + if (WORK_CPLX!=NULL) delete[] WORK_CPLX; + } + return true; + } + #endif + clock_t time0=clock(); + gen alpha=(1+sqrt(17,contextptr))/8; + if (N==1) return true; // nothing to do + bool h=mat_type==1 || mat_type==4; // matrix A is Hermitian + vecteur &ws1=*a[0]._VECTptr,&ws2=*a[1]._VECTptr; // workspace + int t0,t1; + for (k=0;k0 && double(clock()-time0)/CLOCKS_PER_SEC>time_limit) return false; + const gen &aik=a[i][k]; + e=symb_abs(aik); + if (aik.type==_SYMB) { + if (is_strictly_positive(lambda,contextptr)) + continue; + if ((t1=taille(aik,1000))0 && double(clock()-time0)/CLOCKS_PER_SEC>time_limit) return false; + const gen &air=ir) { + s=r; + r=p; + p=s; + } + s=2; + } + } + // pivot + iterateur it; + if (s==1) { // 1x1 pivot + if (r!=k) ldl_swap_rc(a,r,k,perm,h,contextptr); + const gen &akk=a[k][k]; + for (i=k+1;i0 && double(clock()-time0)/CLOCKS_PER_SEC>time_limit) return false; + it=a[i]._VECTptr->begin()+k; + ws1[i]=*it/akk; + for (j=k+1;j<=i;++j) { + *(++it)-=ws1[i]*(h?conj(a[j][k],contextptr):a[j][k]); + } + } + // update L + for (i=k+1;iat(k)=ws1[i]; + } + if (k+1k+1) { + ldl_swap_rc(a,r,k,perm,h,contextptr); + ldl_swap_rc(a,p,k+1,perm,h,contextptr); + } + const gen &e11=a[k][k],&e21=a[k+1][k],&e22=a[k+1][k+1]; + gen e12=h?conj(e21,contextptr):e21,D=e11*e22-e12*e21; + for (i=k+2;ibegin()+k; + const gen &aik=*it,&aik1=*(++it); + ws1[i]=(aik*e22-aik1*e21)/D; + ws2[i]=(aik1*e11-aik*e12)/D; + for (j=k+2;j<=i;++j) { + if (time_limit>0 && double(clock()-time0)/CLOCKS_PER_SEC>time_limit) return false; + *(++it)-=(h?conj(a[j][k],contextptr):a[j][k])*ws1[i]+(h?conj(a[j][k+1],contextptr):a[j][k+1])*ws2[i]; + } + } + // update L + for (i=k+2;i0 && double(clock()-time0)/CLOCKS_PER_SEC>time_limit) return false; + it=a[i]._VECTptr->begin()+k; + *it=ws1[i]; + *(it+1)=ws2[i]; + } + ws1[k+1]=e21; // store the lower sub-diagonal + a[k+1]._VECTptr->at(k)=0; + if (k+2empty()) + return gendimerr(contextptr); + bool has_opts=g.subtype==_SEQ__VECT,h=false,packed=false; + const gen &first=has_opts?g._VECTptr->front():g; + if (!is_squarematrix(first)) + return gensizeerr(gettext("Expected a square matrix")); + if (has_opts) for (const_iterateur opt=g._VECTptr->begin()+1;opt!=g._VECTptr->end();++opt) { + if (*opt==at_hermite) + h=true; + else if (*opt==at_zip) + packed=true; + } + matrice a; + vecteur p,d,dlow; + int N=first._VECTptr->size(),i,as=array_start(contextptr); + a=*_matrix(makesequence(N,N,0),contextptr)._VECTptr; + for (i=0;iat(i)._VECTptr->begin(); + std::copy(rt,rt+i+1,a[i]._VECTptr->begin()); + } + vector perm; + int mat_type=h?1:0; // general (symbolic) matrix + if (is_fully_numeric(g)) { + mat_type=h?4:3; // complex (Hermitian) numeric + if (is_zero(im(g,contextptr),contextptr)) + mat_type=2; // real numeric + } + bool sing; +#if !defined KHICAS && !defined GIAC_HAS_STO_38 + log_output_redirect lor(contextptr); +#endif + if (!ldl(a,perm,mat_type,sing,0,contextptr)) + return gensizeerr(gettext("LAPACK LDL error")); + if (sing) + //*logptr(contextptr) << gettext("Warning") << ": " << gettext("matrix is singular") << "\n" + ; + vecteur &row1=*a[0]._VECTptr; + dlow=vecteur(row1.begin()+1,row1.end()); + std::fill(row1.begin()+1,row1.end(),0); + p.resize(N); + if (packed) { + for (i=0;iat(i+1)=dlow[i]; + } + } else { + d.resize(N); + iterateur dt=d.begin(),pt=p.begin(); + for (i=0;iat(i); + *dt=aii; + aii=1; + *pt=perm[i]+as; + } + } + if (N>=2) { // clear workspace + vecteur &row2=*a[1]._VECTptr; + std::fill(row2.begin()+2,row2.end(),0); + } + if (packed) + return makesequence(p,a); + return makesequence(p,a,ratnormal(_diag(makesequence(dlow,d,h?conj(dlow,contextptr):dlow),contextptr),contextptr)); + } + static const char _ldl_s []="ldl"; + static define_unary_function_eval (__ldl,&_ldl,_ldl_s); + define_unary_function_ptr5(at_ldl,alias_at_ldl,&__ldl,0,true) + + gen _inertia(const gen &g,GIAC_CONTEXT) { + if (g.type==_STRNG && g.subtype==-1) return g; + if (g.type!=_VECT) + return gentypeerr(contextptr); + if (g._VECTptr->empty()) + return gendimerr(contextptr); + bool do_solve=g.subtype==_SEQ__VECT,is_b_matrix=false; + int pos=-1; + if (do_solve) { + if (g._VECTptr->size()<2 || g._VECTptr->size()>3) + return gendimerr(contextptr); + if (!is_squarematrix(g._VECTptr->front()) || g._VECTptr->at(1).type!=_VECT) + return gentypeerr(contextptr); + if (g._VECTptr->size()==3) { + if (!is_integer(g._VECTptr->back())) + return gentypeerr(contextptr); + pos=g._VECTptr->back().val; + if (pos<0 || pos>int(g._VECTptr->front()._VECTptr->size())) + return gensizeerr(contextptr); + } + } else if (!is_squarematrix(g)) + return gentypeerr(contextptr); + const matrice &mat=do_solve?*g._VECTptr->front()._VECTptr:*g._VECTptr; + int N=mat.size(),M,p,n,z,i,j; + vecteur sol; + matrice bmat; + if (do_solve) { + if (ckmatrix(g._VECTptr->at(1))) { + bmat=*g._VECTptr->at(1)._VECTptr; + is_b_matrix=true; + } else bmat=vecteur(1,g._VECTptr->at(1)); + if (mcols(bmat)!=N) + return gendimerr(contextptr); + M=mrows(bmat); + } +#ifdef HAVE_LIBLAPACK + if (is_fully_numeric(mat)) { + double *A=new double[N*N],*WORK=NULL; + int *IPIV=new int[N]; + const_iterateur it=mat.begin(),itend=mat.end(),jt,jtend; + gen e; + bool ok=true; + for (i=0;ok&&it!=itend;++it,++i) { + for (jt=it->_VECTptr->begin(),jtend=jt+i+1,j=0;jt!=jtend;++jt,++j) { + e=evalf_double(*jt,1,contextptr); + if (e.type!=_DOUBLE_) { + ok=false; + break; + } + A[i+j*N]=e._DOUBLE_val; + } + } + if (ok) { + if ((ok=solve_indef(A,&WORK,IPIV,NULL,N,M,&p,&n,&z)) && do_solve && z==0 && (pos<0 || p==pos)) { + double *B=new double[N*M]; + matrice2lapack(mtran(bmat),B,contextptr); + if (ok=solve_indef(A,&WORK,IPIV,B,N,M,NULL,NULL,NULL)) { + lapack2matrice(B,N,M,sol); + sol=mtran(sol); + } + delete[] B; + } + } + delete[] A; + delete[] IPIV; + if (WORK!=NULL) delete[] WORK; + if (!ok) return gensizeerr(contextptr); + vecteur res=makevecteur(p,n,z); + return do_solve?makesequence(res,!is_b_matrix&&sol.size()==1?sol[0]:sol):res; + } +#endif + matrice A=*_matrix(makesequence(N,N),contextptr)._VECTptr; + const_iterateur rt=mat.begin(),rtend=mat.end(),ct,ctend; + for (i=0;rt!=rtend;++rt,++i) { + for (j=0,ct=rt->_VECTptr->begin(),ctend=rt->_VECTptr->end();ct!=ctend;++ct,++j) + A[i]._VECTptr->at(j)=*ct; + } + if (!solve_indef(A,NULL,sol,&p,&n,&z,contextptr)) + return gensizeerr(contextptr); + if (do_solve && z==0 && (pos<0 || p==pos)) { + if (!solve_indef(A,&bmat,sol,NULL,NULL,NULL,contextptr)) + return gensizeerr(contextptr); + } else sol.clear(); + vecteur res=makevecteur(p,n,z); + return do_solve?makesequence(res,!is_b_matrix&&sol.size()==1?sol[0]:sol):res; + } + static const char _inertia_s []="inertia"; + static define_unary_function_eval (__inertia,&_inertia,_inertia_s); + define_unary_function_ptr5(at_inertia,alias_at_inertia,&__inertia,0,true) + bool matrice2lapack(const matrice & m,double * A,GIAC_CONTEXT){ const_iterateur it=m.begin(),itend=m.end(); gen g; diff --git a/apps/KhiCAS/src/giac-1.6.0/src/vecteur.h b/apps/KhiCAS/src/giac-1.6.0/src/vecteur.h index 1f2ed8bec..b82a8a901 100644 --- a/apps/KhiCAS/src/giac-1.6.0/src/vecteur.h +++ b/apps/KhiCAS/src/giac-1.6.0/src/vecteur.h @@ -260,6 +260,7 @@ namespace giac { bool multvectvector_int_vector_int(const std::vector< std::vector > & M,const std::vector & v,int modulo,std::vector & Mv); void tran_vect_vector_int(const std::vector< std::vector > & N,std::vector< std::vector > & tN); void apply_permutation(const std::vector & permutation,const std::vector &x,std::vector & y); + void apply_permutation(vecteur &v,std::vector &p,bool keep_p=false); // efficient sorting of v w.r.t. p, added by L. Marohnic void vecteur2vector_int(const vecteur & v,int modulo,std::vector & res); enum matrix_algorithms { @@ -465,9 +466,10 @@ namespace giac { int vecteur2gsl_vector(const vecteur & v,gsl_vector * w,GIAC_CONTEXT); // no alloc int vecteur2gsl_vector(const_iterateur it,const_iterateur itend,gsl_vector * w,GIAC_CONTEXT); vecteur gsl_vector2vecteur(const gsl_vector * v); + int matrice2gsl_matrix(const matrice & m,int i0,int j0,int n1,int n2,bool transp,gsl_matrix * w,GIAC_CONTEXT); int matrice2gsl_matrix(const matrice & m,gsl_matrix * w,GIAC_CONTEXT); gsl_matrix * matrice2gsl_matrix(const matrice & m,GIAC_CONTEXT); - matrice gsl_matrix2matrice(const gsl_matrix * v); + matrice gsl_matrix2matrice(const gsl_matrix * v,bool transp=false); vecteur gsl_permutation2vecteur(const gsl_permutation * p,GIAC_CONTEXT); #endif // HAVE_LIBGSL @@ -483,6 +485,29 @@ namespace giac { gen _cholesky(const gen & a,GIAC_CONTEXT); extern const unary_function_ptr * const at_cholesky ; +#if !defined KHICAS && !defined GIAC_HAS_STO_38 + // additions by L. Marohnić: + struct log_output_redirect { // redirecting log output to string + log_output_redirect(GIAC_CONTEXT) { old=logptr(ctx=contextptr)->rdbuf(buffer.rdbuf()); } + ~log_output_redirect() { logptr(ctx)->rdbuf(old); } + std::string get_buffer_string() const { return buffer.str(); } + private: + const context *ctx; + std::stringstream buffer; + std::streambuf *old; + }; +#endif + // LDL decomposition, inertia computation and solve_indef for fast system solving using the factorization + bool ldl(matrice & a,std::vector & perm,int mat_type,bool &sing,double time_limit,GIAC_CONTEXT); +#ifdef HAVE_LIBLAPACK + bool solve_indef(double *A,double **WORK,int *IPIV,double *b,int N,int NRHS,int *p,int *n,int *z); +#endif + bool solve_indef(matrice &A,const vecteur *b,vecteur &x,int *p,int *n,int *z,GIAC_CONTEXT); + gen _ldl(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_ldl ; + gen _inertia(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_inertia ; + // end additions by L. Marohnić gen _svd(const gen & a,GIAC_CONTEXT); extern const unary_function_ptr * const at_svd ; gen _basis(const gen & a,GIAC_CONTEXT); diff --git a/apps/KhiCAS/src/giac-1.6.0/src/vecteur.h~ b/apps/KhiCAS/src/giac-1.6.0/src/vecteur.h~ new file mode 100644 index 000000000..a4bb62d39 --- /dev/null +++ b/apps/KhiCAS/src/giac-1.6.0/src/vecteur.h~ @@ -0,0 +1,560 @@ +// -*- mode:C++ ; compile-command: "g++ -I.. -g -c vecteur.cc" -*- +/* + * Copyright (C) 2000,2014 B. Parisse, Institut Fourier, 38402 St Martin d'Heres + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef _GIAC_VECTEUR_H +#define _GIAC_VECTEUR_H +#include "first.h" +#include "index.h" +#include +#include +#ifdef HAVE_LIBGSL +#include +#include +#include +#endif // HAVE_LIBGSL + +#ifndef NO_NAMESPACE_GIAC +namespace giac { +#endif // ndef NO_NAMESPACE_GIAC + + const double randrange = 100.0; + + struct unary_function_ptr; + struct ref_vecteur; + typedef vecteur matrice; // same type but different name + typedef vecteur::const_iterator const_iterateur; + typedef vecteur::iterator iterateur; + typedef std::complex complex_double; +#if defined(HAVE_LONG_DOUBLE) && !defined(PNACL) + typedef long double long_double; +#else + typedef double long_double; +#endif + typedef std::complex complex_long_double; + double complex_abs(const complex_double & c); + double complex_long_abs(const complex_long_double & c); + + // make a matrix with free rows + // (i.e. it is possible to modify the answer in place) + matrice makefreematrice(const matrice & m); + gen freecopy(const gen & g); // this one makes a free copy of a vector, not of a matrix + // vecteur related functions + vecteur makevecteur(const gen & a); + vecteur makevecteur(const gen & a,const gen & b); + vecteur makevecteur(const gen & a,const gen & b,const gen & c); + vecteur makevecteur(const gen & a,const gen & b,const gen & c,const gen & d); + vecteur makevecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e); + vecteur makevecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f); + vecteur makevecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g); + vecteur makevecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g,const gen & h); + vecteur makevecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g,const gen & h,const gen & i); + vecteur makevecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g,const gen & h,const gen & i,const gen &j); + vecteur makevecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g,const gen & h,const gen & i,const gen &j,const gen & k); + vecteur makevecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g,const gen & h,const gen & i,const gen &j,const gen & k,const gen & l); + vecteur makevecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g,const gen & h,const gen & i,const gen &j,const gen & k,const gen & l,const gen & m); + vecteur makevecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g,const gen & h,const gen & i,const gen &j,const gen & k,const gen & l,const gen & m,const gen &n); + + gen makesequence(const gen & a); + gen makesequence(const gen & a,const gen & b); + gen makesequence(const gen & a,const gen & b,const gen & c); + gen makesequence(const gen & a,const gen & b,const gen & c,const gen & d); + gen makesequence(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e); + gen makesequence(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f); + gen makesequence(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g); + gen makesequence(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g,const gen & h); + gen makesequence(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g,const gen & h,const gen & i); + + ref_vecteur * makenewvecteur(const gen & a); + ref_vecteur * makenewvecteur(const gen & a,const gen & b); + ref_vecteur * makenewvecteur(const gen & a,const gen & b,const gen & c); + ref_vecteur * makenewvecteur(const gen & a,const gen & b,const gen & c,const gen & d); + ref_vecteur * makenewvecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e); + ref_vecteur * makenewvecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f); + ref_vecteur * makenewvecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g); + ref_vecteur * makenewvecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g,const gen & h); + ref_vecteur * makenewvecteur(const gen & a,const gen & b,const gen & c,const gen & d,const gen & e,const gen & f,const gen & g,const gen & h,const gen & i); + + // numeric root utilities + bool francis_schur(std_matrix & H,int n1,int n2,std_matrix & P,int maxiter,double eps,bool is_hessenberg,bool complex_schur,bool compute_P,bool no_lapack,GIAC_CONTEXT); + + class matrix_double:public std::vector< std::vector >{ + public: + // inherited constructors + matrix_double() : std::vector< std::vector >() { }; + matrix_double(int i) : std::vector< std::vector >(i) { }; + matrix_double(int i,const std::vector v) : std::vector< std::vector >(i,v) { }; + matrix_double(const matrix_double::const_iterator b,const matrix_double::const_iterator e) : std::vector< std::vector >(b,e) { }; + void dbgprint() const ; + }; + + class matrix_complex_double:public std::vector< std::vector >{ + public: + // inherited constructors + matrix_complex_double() : std::vector< std::vector >() { }; + matrix_complex_double(int i) : std::vector< std::vector >(i) { }; + matrix_complex_double(int i,const std::vector v) : std::vector< std::vector >(i,v) { }; + void dbgprint() const ; + }; + + bool balanced_eigenvalues(matrix_double & H,vecteur & res,int maxiter,double eps,bool is_hessenberg,GIAC_CONTEXT); + bool francis_schur(matrix_double & H,int n1,int n2,matrix_double & P,int maxiter,double eps,bool is_hessenberg,bool compute_P); + bool francis_schur(matrix_complex_double & H,int n1,int n2,matrix_complex_double & P,int maxiter,double eps,bool is_hessenberg,bool compute_P); + + bool matrice2lapack(const matrice & m,double * A,GIAC_CONTEXT); + void lapack2matrice(double * A,unsigned rows,unsigned cols,matrice & R); + bool lapack_schur(std_matrix & H,std_matrix & P,bool compute_P,vecteur & eigenvalues,GIAC_CONTEXT); + bool lapack_schur(matrix_double & H,matrix_double & P,bool compute_P,vecteur & eigenvalues); + bool eigenval2(matrix_double & H,int n2,giac_double & l1, giac_double & l2); + bool std_matrix_gen2std_matrix_giac_double(const std_matrix & H,matrix_double & H1,bool crunch); + bool std_matrix_giac_double2std_matrix_gen(const matrix_double & H,std_matrix & H1); + + matrice companion(const vecteur & w); + gen a_root(const vecteur & v,const std::complex & c0,double eps); + vecteur proot(const vecteur & v); + vecteur proot(const vecteur & v,double eps); + vecteur proot(const vecteur & v,double & eps,int & rprec); + vecteur real_proot(const vecteur & v,double eps,GIAC_CONTEXT); + gen symb_proot(const gen & e) ; + gen _proot(const gen & e,GIAC_CONTEXT); + extern const unary_function_ptr * const at_proot ; + gen symb_pcoeff(const gen & e) ; + gen _pcoeff(const gen & e,GIAC_CONTEXT); + vecteur pcoeff(const vecteur & v); + extern const unary_function_ptr * const at_pcoeff ; + gen symb_peval(const gen & arg1,const gen & arg2) ; + extern const unary_function_ptr * const at_peval; + gen _peval(const gen & e,GIAC_CONTEXT); + + gen spread_convert(const gen & g,int g_row,int g_col,GIAC_CONTEXT); + vecteur lcell(const gen & g); + // these int are used to translate relative cells to spreadsheet names + bool iscell(const gen & g,int & r,int & c,GIAC_CONTEXT); + std::string printcell(const vecteur & v,GIAC_CONTEXT); + // given g=cell() or its argument at row i, column j + // return 0 if not a cell, 1 if a cell, then compute r and c s.t. g refers to (r,c), + // return 2 if g is e.g. A1:B4 compute ref of A1 and B4 + int cell2pos(const gen & g,int i,int j,int & r,int & c,int & r2,int & c2); + // return cell(r,c) argument at (i,j) with same absolute/relative addressing + // as g + gen pos2cell(const gen & g,int i,int j,int r,int c,int r2,int c2); + // insert nrows/ncols of fill in m, e.g. fill= [0,0,2] for a spreadsheet + // or ["","",2] or 0 for a matrix + matrice matrice_insert(const matrice & m,int insert_row,int insert_col,int nrows,int ncols,const gen & fill,GIAC_CONTEXT); + // erase nrows/ncols + matrice matrice_erase(const matrice & m,int insert_row,int insert_col,int nrows,int ncols,GIAC_CONTEXT); + // extract submatrix + matrice matrice_extract(const matrice & m,int insert_row,int insert_col,int nrows,int ncols); + void makespreadsheetmatrice(matrice & m,GIAC_CONTEXT); + matrice extractmatricefromsheet(const matrice & m,bool value=true); + // eval spreadsheet, compute list of dependances in lc + void spread_eval(matrice & m,GIAC_CONTEXT); + + gen makesuite(const gen & a); + gen makesuite(const gen & a,const gen & b); + gen makesuite_inplace(const gen & a,const gen & b); + vecteur mergevecteur(const vecteur & v,const vecteur & w); + vecteur mergeset(const vecteur & v,const vecteur & w); + int vrows(const vecteur & a); + void addvecteur(const vecteur & a,const vecteur & b,vecteur & res); + vecteur addvecteur(const vecteur & a,const vecteur & b); + void subvecteur(const vecteur & a,const vecteur & b,vecteur & res); + vecteur subvecteur(const vecteur & a,const vecteur & b); + vecteur negvecteur(const vecteur & a); // calls negmodpoly + // Multiplication by a scalar + void multvecteur(const gen & a,const vecteur & b,vecteur & res); + vecteur multvecteur(const gen & a,const vecteur & b); + void divvecteur(const vecteur & b,const gen & a,vecteur & res); + vecteur divvecteur(const vecteur & b,const gen & a); + // Matrix times vecteur + void multmatvecteur(const matrice & a,const vecteur & b,vecteur & res); + vecteur multmatvecteur(const matrice & a,const vecteur & b); + void multvecteurmat(const vecteur & a,const matrice & b,vecteur & res); + vecteur multvecteurmat(const vecteur & a,const matrice & b); + // Scalar product (does not conjugate, see scalarproduct in misc.h) + gen dotvecteur(const vecteur & a,const vecteur & b); + giac_double dotvecteur_double(const std::vector & a,const std::vector & c); + giac_double dotvecteur(const std::vector & a,const std::vector & c); + gen dotvecteur(const gen & a,const gen & b); + gen generalized_dotvecteur(const vecteur & a,const vecteur & b,int pos); + vecteur generalized_multmatvecteur(const matrice & a,const vecteur & b); + // Vect product (3-d) + gen complex2vecteur(const gen & g,GIAC_CONTEXT); + vecteur cross(const vecteur & v,const vecteur & w,GIAC_CONTEXT); + gen cross(const gen & g1,const gen & g2,GIAC_CONTEXT); + // ckmvmult check a and b + // if a and b are matrices returns matrix product + // if a is a matrix and b a vecteur return matr*vect + // otherwise returns the dot product of a and b + gen ckmultmatvecteur(const vecteur & a,const vecteur & b,GIAC_CONTEXT); + void multmatvecteur(const matrix_double & H,const std::vector & w,std::vector & v); + + void vecteur2vector_int(const vecteur & v,int modulo,std::vector & res); + bool vecteur2vectvector_int(const vecteur & v,int modulo,std::vector< std::vector > & res); + void vector_int2vecteur(const std::vector & v,vecteur & res); + void vectvector_int2vecteur(const std::vector< std::vector > & v,vecteur & res); + bool iszero(const std::vector & p); + + // matrice related functions + bool ckmatrix(const matrice & a,bool allow_embedded_vect,bool ckundef=true); + bool ckmatrix(const matrice & a); + bool ckmatrix(const gen & a); + bool ckmatrix(const gen & a,bool); + bool is_squarematrix(const matrice & a); + bool is_squarematrix(const gen & a); + bool is_fully_numeric(const vecteur & v, int withfracint = 0); + bool is_fully_numeric(const gen & a, int withfracint = 0); + bool is_exact(const vecteur & v); + bool is_exact(const gen & g); + // the following functions do not check that a is indeed a matrix + int mrows(const matrice & a); + int mcols(const matrice & a); + void mdims(const matrice &m,int & r,int & c); + void mtran(const matrice & a,matrice & res,int ncolres=0,bool ckundef=true); + matrice mtran(const matrice & a); + gen _tran(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_tran ; + void transpose_double(const matrix_double & a,int r0,int r1,int c0,int c1,matrix_double & at); + + // mmult assumes dimensions are correct + void mmult(const matrice & a,const matrice & b,matrice &res); + void mmult_atranb(const matrice & a,const matrice & btran,matrice & res); + matrice mmult(const matrice & a,const matrice & b); + bool mmultck(const matrice & a,const matrice & b,matrice & res); + matrice mmultck(const matrice & a,const matrice & b); + + extern int strassen_limit; + void strassen_mod(bool skip_reduce,bool add,const std::vector< std::vector > & A,const std::vector< std::vector > & Btran,std::vector< std::vector > & C,int p,int arbeg=0,int arend=0,int acbeg=0,int acend=0,int brbeg=0,int brend=0,int bcbeg=0); + void mmult_mod(const std::vector< std::vector > & A,const std::vector< std::vector > & Btran,std::vector< std::vector > & C,int p,int Ar0=0,int Ar1=0,int Ac0=0,int Ac1=0,int Brbeg=0,int Brend=0,int Bcbeg=0,int Crbeg=0,int Ccbeg=0,bool add=false); + + gen mtrace(const matrice & a); + gen ckmtrace(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_trace ; + + gen common_deno(const vecteur & v); + + bool convert(const vecteur & v,std::vector & v1,bool crunch); + bool convert(const vecteur & v,std::vector< complex_double > & v1,bool crunch); + bool convert(const std::vector & v,vecteur & v1); + void matrice2std_matrix_gen(const matrice & m,std_matrix & M); + void std_matrix_gen2matrice(const std_matrix & M,matrice & m); + bool vecteur2index(const vecteur & v,index_t & i); + void vect_vector_int_2_vect_vecteur(const std::vector< std::vector > & N,std_matrix & M); + void vect_vecteur_2_vect_vector_int(const std_matrix & M,int modulo,std::vector< std::vector > & N); + bool vecteur2vectvector_int(const vecteur & v,int modulo,std::vector< std::vector > & res); + void vectvector_int2vecteur(const std::vector< std::vector > & v,vecteur & res); + int dotvector_int(const std::vector & v,const std::vector & w,int modulo); + bool multvectvector_int_vector_int(const std::vector< std::vector > & M,const std::vector & v,int modulo,std::vector & Mv); + void tran_vect_vector_int(const std::vector< std::vector > & N,std::vector< std::vector > & tN); + void apply_permutation(const std::vector & permutation,const std::vector &x,std::vector & y); + void apply_permutation(vecteur &v,std::vector &p,bool keep_p=false); // efficient sorting of v w.r.t. p, added by L. Marohnic + void vecteur2vector_int(const vecteur & v,int modulo,std::vector & res); + + enum matrix_algorithms { + RREF_GAUSS_JORDAN=0, + RREF_GUESS=1, + RREF_BAREISS=2, + RREF_MODULAR=3, + RREF_PADIC=4, + RREF_LAGRANGE=5 + }; + // For approx linear combination, anything || > Ainvtran,Ainv,CAinv; + std::vector permblock,maxrankblock; + vecteur pivblock; + std::vector y,y1,y2,y3; + std::vector z,z1,z2,z3; + }; + bool in_modrref(const matrice & a, std::vector< std::vector > & N,matrice & res, vecteur & pivots, gen & det,int l, int lmax, int c,int cmax,int fullreduction,int dont_swap_below,int modulo,int carac,int rref_or_det_or_lu,const gen & mult_by_det_mod_p,bool inverting,bool no_initial_mod,smallmodrref_temp_t * workptr); + bool modrref(const matrice & a, matrice & res, vecteur & pivots, gen & det,int l, int lmax, int c,int cmax, + int fullreduction,int dont_swap_below,const gen & modulo,bool ckprime,int rref_or_det_or_lu); + bool mrref(const matrice & a, matrice & res, vecteur & pivots, gen & det,GIAC_CONTEXT); + bool modrref(const matrice & a, matrice & res, vecteur & pivots, gen & det,const gen& modulo); + + + // finish full row reduction to echelon form if N is upper triangular + // this is done from lmax-1 to l + void smallmodrref_upper(std::vector< std::vector > & N,int l,int lmax,int c,int cmax,int modulo); + // finish row reduction for matrices with much more columns than rows + // version adapted for threads parallelization + // assumes that all columns are reduced in parallel, pivots are searched + // starting at column 0 + void in_thread_smallmodrref_upper(std::vector< std::vector > & N,int l,int lpivot,int lmax,int c,int cmax,int modulo,int parallel); + void thread_smallmodrref_upper(std::vector< std::vector > & N,int l,int lmax,int c,int cmax,int modulo,int parallel); + void free_null_lines(std::vector< std::vector > & N,int l,int lmax,int c,int cmax); + int smallmodrref_lastpivotcol(const std::vector< std::vector > & K,int lmax); + + void smallmodrref(int nthreads,std::vector< std::vector > & N,vecteur & pivots,std::vector & permutation,std::vector & maxrankcols,longlong & idet,int l, int lmax, int c,int cmax,int fullreduction,int dont_swap_below,int modulo,int rref_or_det_or_lu,bool reset,smallmodrref_temp_t * workptr,bool allow_block,int carac); + void doublerref(matrix_double & N,vecteur & pivots,std::vector & permutation,std::vector & maxrankcols,double & idet,int l, int lmax, int c,int cmax,int fullreduction,int dont_swap_below,int rref_or_det_or_lu,double eps); + void modlinear_combination(vecteur & v1,const gen & c2,const vecteur & v2,const gen & modulo,int cstart,int cend=0); + void modlinear_combination(std::vector & v1,int c2,const std::vector & v2,int modulo,int cstart,int cend,bool pseudo); + vecteur fracmod(const vecteur & v,const gen & modulo,gen * den=0,int prealloc=128); + gen modproduct(const vecteur & v, const gen & modulo); + matrice mrref(const matrice & a,GIAC_CONTEXT); + gen _rref(const gen & a,GIAC_CONTEXT); // first non 0 elem in row is 1 + extern const unary_function_ptr * const at_rref ; + void add_identity(matrice & arref); + void add_identity(std::vector< std::vector > & arref); + bool remove_identity(matrice & res); + bool remove_identity(std::vector< std::vector > & res,int modulo); + + void mdividebypivot(matrice & a,int lastcol,GIAC_CONTEXT); // in-place div by pivots + void mdividebypivot(matrice & a,int lastcol=-1); // in-place div by pivots + // if lastcol==-1, divide last col, if lastcol==-2 do not divide last col + // if lastcol>=0 stop dividing at lastcol + void midn(int n,matrice & res); + matrice midn(int n); + gen _idn(const gen & e,GIAC_CONTEXT); + extern const unary_function_ptr * const at_idn ; + + gen fieldcoeff(const gen &F); + vecteur vranm(int n,const gen & f,GIAC_CONTEXT); + matrice mranm(int n,int m,const gen & f,GIAC_CONTEXT); // random matrix using f + gen _ranm(const gen & e,GIAC_CONTEXT); + extern const unary_function_ptr * const at_ranm ; + gen _randvector(const gen & e,GIAC_CONTEXT); + + bool read_reduction_options(const gen & a_orig,matrice & a,bool & convert_internal,int & algorithm,bool & minor_det,bool & keep_pivot,int & last_col); + bool minv(const matrice & a,matrice & res,bool convert_internal,int algorithm,GIAC_CONTEXT); /* if unsure, use true for convert_internal and 1 for algorithm */ + bool smallmodinv(const std::vector< std::vector > & a,std::vector< std::vector > & res,int modulo,longlong & det_mod_p); + bool modinv(const matrice & a,matrice & res,const gen & modulo,gen & det_mod_p); + // solve a*x=b where a and b have integer coeffs + // using a p-adic algorithm, n is the precision required + // c must be the inverse of a mod p + vecteur padic_linsolve_c(const matrice & a,const vecteur & b,const matrice & c,unsigned n,const gen & p,unsigned reconstruct=0); + // solve a*x=b where a and b have integer coeffs using a p-adic algorithm + // lcmdeno of the answer may be used to give an estimate of the + // least divisor element of a if b is random + // returns 0 if no invertible found, -1 if det==0, 1 otherwise + int padic_linsolve(const matrice & a,const vecteur & b,vecteur & res,gen & p,gen & det_mod_p,gen & h2,unsigned reconstruct=0,int maxtry=4); + // a is a matrix with integer coeffs + // find p such that a mod p has the same rank + // rankline and rankcols are the lines/cols used for the submatrix + // asub of max rank, ainv is the inverse of asub mod p + // return -1 or the rank + int padic_linsolve_prepare(const matrice & a,gen & p,std::vector & ranklines, std::vector & rankcols,matrice & asub,matrice & ainv,vecteur & compat,vecteur & kernel); + // solve a prepared non Cramer linear system + bool padic_linsolve_solve(const matrice & a,const gen & p,const std::vector & ranklines,const std::vector & rankcols,const matrice & asub,const matrice & ainv,const vecteur & compat,const vecteur & b,vecteur & sol); + gen _padic_linsolve(const gen & g,GIAC_CONTEXT); + + matrice minv(const matrice & a,GIAC_CONTEXT); + gen mdet(const matrice & a,GIAC_CONTEXT); + gen _det(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_det ; + gen _det_minor(const gen & g,bool convert_internal,GIAC_CONTEXT); + extern const unary_function_ptr * const at_det_minor ; + gen det_minor(const matrice & a,vecteur lv,bool convert_internal,GIAC_CONTEXT); + void sylvester(const vecteur & v1,const vecteur & v2,matrice & res); + matrice sylvester(const vecteur & v1,const vecteur & v2); + gen _sylvester(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_sylvester ; + + gen _hessenberg(const gen & g,GIAC_CONTEXT); + extern const unary_function_ptr * const at_hessenberg ; + + bool balance_krylov(const matrix_double & H,std::vector & d,int niter=5,double cutoff=1e-8); + bool probabilistic_pmin(const matrice & m,vecteur & w,bool check,GIAC_CONTEXT); + vecteur mpcar_int(const matrice & A,bool krylov,GIAC_CONTEXT,bool compute_pmin); + + void mod_pcar(std_matrix & N,vecteur & res,bool compute_pmin); + bool mod_pcar(const matrice & A,std::vector< std::vector > & N,int modulo,bool & krylov,std::vector & res,GIAC_CONTEXT,bool compute_pmin); + bool mod_pcar(std::vector< std::vector > & N,int modulo,bool & krylov,std::vector & res,GIAC_CONTEXT,bool compute_pmin); + vecteur mpcar_hessenberg(const matrice & A,int modulo,GIAC_CONTEXT); + gen _pcar_hessenberg(const gen & g,GIAC_CONTEXT); + extern const unary_function_ptr * const at_pcar_hessenberg ; + void mhessenberg(std::vector< std::vector > & H,std::vector< std::vector > & P,int modulo,bool compute_P); + void hessenberg(std_matrix & H,std_matrix & P,GIAC_CONTEXT); + void hessenberg_ortho(std_matrix & H,std_matrix & P,GIAC_CONTEXT); + void hessenberg_ortho(std_matrix & H,std_matrix & P,int firstrow,int n,bool compute_P,int already_zero,double eps,GIAC_CONTEXT); + void qr_ortho(std_matrix & H,std_matrix & P,bool computeP,GIAC_CONTEXT); + void hessenberg_schur(std_matrix & H,std_matrix & P,int maxiter,double eps,GIAC_CONTEXT); + gen _hessenberg(const gen & g0,GIAC_CONTEXT); + + vecteur mpcar(const matrice & a,vecteur & B,bool compute_B,GIAC_CONTEXT); + vecteur mpcar(const matrice & a,vecteur & Bv,bool compute_Bv,bool convert_internal,GIAC_CONTEXT); + gen _pcar(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_pcar ; + + // if jordan is false, errors for non diagonalizable matrices + // if jordan is true, d is a matrix, not a vecteur + bool egv(const matrice & m,matrice & p,vecteur & d, GIAC_CONTEXT, bool jordan,bool rational_jordan_form,bool eigenvalues_only); + gen symb_egv(const gen & a); + matrice megv(const matrice & a,GIAC_CONTEXT); + gen _egv(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_egv ; + gen _svd(const gen & a,GIAC_CONTEXT); + + gen symb_egvl(const gen & a); + vecteur megvl(const matrice & a,GIAC_CONTEXT); + gen _egvl(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_egvl ; + + gen symb_jordan(const gen & a); + vecteur mjordan(const matrice & a,bool rational_jordan,GIAC_CONTEXT); + gen _jordan(const gen & a,GIAC_CONTEXT); + gen jordan(const gen & a,bool rational_jordan,GIAC_CONTEXT); + gen _rat_jordan(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_jordan ; + matrice rat_jordan_block(const vecteur & v,int n,bool pseudo); + gen _rat_jordan_block(const gen &args,GIAC_CONTEXT); + matrice pseudo_rat_to_rat(const vecteur & v,int n); + + // if g is an expression, replace x by m in g (m assumed to be diagonal) + matrice diagonal_apply(const gen & g,const gen & x,const matrice & m,GIAC_CONTEXT); + // apply an analytic function to a square matrix + matrice analytic_apply(const unary_function_ptr * u,const matrice & m,GIAC_CONTEXT); + matrice analytic_apply(const gen &ux,const gen & x,const matrice & m,GIAC_CONTEXT); + matrice matpow(const matrice & m,const gen & n,GIAC_CONTEXT); + gen _matpow(const gen & a,GIAC_CONTEXT); + + bool mker(std::vector< std::vector > & a,std::vector< std::vector > & v,int modulo); + bool mker(const matrice & a,vecteur & v,int algorithm,GIAC_CONTEXT); + bool mker(const matrice & a,vecteur & v,GIAC_CONTEXT); // algorithm=0 + vecteur mker(const matrice & a,GIAC_CONTEXT); + gen _ker(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_ker ; + + bool mimage(const matrice & a, vecteur & v,GIAC_CONTEXT); + vecteur mimage(const matrice & a,GIAC_CONTEXT); + gen _image(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_image ; + + gen symb_cross(const gen & arg1,const gen & arg2); + gen symb_cross(const gen & a); + gen _cross(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_cross ; + + gen symb_size(const gen & a); + gen _size(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_size ; + bool vecteur2index(const vecteur & v,index_t & i); +#ifdef HAVE_LIBGSL + gsl_vector * vecteur2gsl_vector(const vecteur & v,GIAC_CONTEXT); // allocate + int vecteur2gsl_vector(const vecteur & v,gsl_vector * w,GIAC_CONTEXT); // no alloc + int vecteur2gsl_vector(const_iterateur it,const_iterateur itend,gsl_vector * w,GIAC_CONTEXT); + vecteur gsl_vector2vecteur(const gsl_vector * v); + int matrice2gsl_matrix(const matrice & m,gsl_matrix * w,GIAC_CONTEXT); + gsl_matrix * matrice2gsl_matrix(const matrice & m,GIAC_CONTEXT); + matrice gsl_matrix2matrice(const gsl_matrix * v); + vecteur gsl_permutation2vecteur(const gsl_permutation * p,GIAC_CONTEXT); +#endif // HAVE_LIBGSL + + bool mlu(const matrice & a0,vecteur & P,matrice & L,matrice & U,GIAC_CONTEXT); + gen lu(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_lu ; + gen qr(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_qr ; + matrice thrownulllines(const matrice & res); + + extern const unary_function_ptr * const at_lll_reduce ; + extern const unary_function_ptr * const at_lll ; + + gen _cholesky(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_cholesky ; + // additions by L. Marohnić: + struct log_output_redirect { // redirecting log output to string + log_output_redirect(GIAC_CONTEXT) { old=logptr(ctx=contextptr)->rdbuf(buffer.rdbuf()); } + ~log_output_redirect() { logptr(ctx)->rdbuf(old); } + std::string get_buffer_string() const { return buffer.str(); } + private: + const context *ctx; + std::stringstream buffer; + std::streambuf *old; + }; + // LDL decomposition, inertia computation and solve_indef for fast system solving using the factorization + bool ldl(matrice & a,std::vector & perm,int mat_type,bool &sing,double time_limit,GIAC_CONTEXT); +#ifdef HAVE_LIBLAPACK + bool solve_indef(double *A,double *WORK,int *IPIV,double *b,int N,int NRHS,int *p,int *n,int *z,GIAC_CONTEXT); +#endif + bool solve_indef(matrice &A,const vecteur *b,vecteur &x,int *p,int *n,int *z,GIAC_CONTEXT); + gen _ldl(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_ldl ; + gen _inertia(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_inertia ; + // end additions by L. Marohnić + gen _svd(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_svd ; + gen _basis(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_basis ; + gen _ibasis(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_ibasis ; + + // inert function used for internal representation in spreadsheets + gen _cell(const gen & a,GIAC_CONTEXT); + extern const unary_function_ptr * const at_cell ; + + int alphaposcell(const std::string & s,int & r); + gen l2norm(const vecteur & v,GIAC_CONTEXT); + matrice gramschmidt(const matrice & m,bool normalize,GIAC_CONTEXT); + matrice gramschmidt(const matrice & m,matrice & r,bool normalize,GIAC_CONTEXT); + // lll decomposition of m + matrice lll(const matrice & M,matrice & L,matrice & O,matrice &A,GIAC_CONTEXT); + matrice lll(const matrice & m,GIAC_CONTEXT); + gen _lll(const gen & g,GIAC_CONTEXT); + + + void matrice2std_matrix_gen(const matrice & m,std_matrix & M); + void std_matrix_gen2matrice(const std_matrix & M,matrice & m); + void std_matrix_gen2matrice_destroy(std_matrix & M,matrice & m); + + bool is_integer_vecteur(const vecteur & m,bool intonly=false); + bool is_integer_matrice(const matrice & m,bool intonly=false); + bool is_mod_vecteur(const vecteur & m,std::vector & v,int & p); + bool is_mod_matrice(const matrice & m,std::vector< std::vector > & M,int & p); + + typedef void (*bezout_fonction)(const gen & a,const gen & b,gen & u,gen &v,gen &d); + + struct environment; + bool ismith(const matrice & Aorig, matrice & U,matrice & A,matrice & V,GIAC_CONTEXT); + bool smith(const std_matrix & Aorig,std_matrix & U,std_matrix & A,std_matrix & V,environment * env,GIAC_CONTEXT); + bool ihermite(const matrice & Aorig, matrice & U,matrice & A,GIAC_CONTEXT); + bool hermite(const std_matrix & Aorig,std_matrix & U,std_matrix & A,environment * env,GIAC_CONTEXT); + gen _ihermite(const gen & g,GIAC_CONTEXT); + gen _ismith(const gen & g,GIAC_CONTEXT); +#if !defined NSPIRE && !defined FXCG + gen _csv2gen(const gen & g,GIAC_CONTEXT); + matrice csv2gen(std::istream & i,char sep,char nl,char decsep,char eof,GIAC_CONTEXT); +#endif + + // find index i of x in v that is i such that v[i] <= x < v[i+1] + // where v[-1]=-inf, and v[v.size()]=+inf + int dichotomy(const std::vector & v,double x); + +#ifndef NO_NAMESPACE_GIAC +} // namespace giac +#endif // ndef NO_NAMESPACE_GIAC + +#endif // _GIAC_VECTEUR_H diff --git a/apps/KhiCAS/src/gmp-6.2.1/aclocal.m4 b/apps/KhiCAS/src/gmp-6.2.1/aclocal.m4 deleted file mode 100644 index 32cc8eef8..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/aclocal.m4 +++ /dev/null @@ -1,9921 +0,0 @@ -# generated automatically by aclocal 1.15 -*- Autoconf -*- - -# Copyright (C) 1996-2014 Free Software Foundation, Inc. - -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, -[m4_warning([this file was generated for autoconf 2.69. -You have another version of autoconf. It may work, but is not guaranteed to. -If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically 'autoreconf'.])]) - -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- -# -# Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -m4_define([_LT_COPYING], [dnl -# Copyright (C) 2014 Free Software Foundation, Inc. -# This is free software; see the source for copying conditions. There is NO -# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -# GNU Libtool is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of of the License, or -# (at your option) any later version. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program or library that is built -# using GNU Libtool, you may include this file under the same -# distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -]) - -# serial 58 LT_INIT - - -# LT_PREREQ(VERSION) -# ------------------ -# Complain and exit if this libtool version is less that VERSION. -m4_defun([LT_PREREQ], -[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, - [m4_default([$3], - [m4_fatal([Libtool version $1 or higher is required], - 63)])], - [$2])]) - - -# _LT_CHECK_BUILDDIR -# ------------------ -# Complain if the absolute build directory name contains unusual characters -m4_defun([_LT_CHECK_BUILDDIR], -[case `pwd` in - *\ * | *\ *) - AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; -esac -]) - - -# LT_INIT([OPTIONS]) -# ------------------ -AC_DEFUN([LT_INIT], -[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK -AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl -AC_BEFORE([$0], [LT_LANG])dnl -AC_BEFORE([$0], [LT_OUTPUT])dnl -AC_BEFORE([$0], [LTDL_INIT])dnl -m4_require([_LT_CHECK_BUILDDIR])dnl - -dnl Autoconf doesn't catch unexpanded LT_ macros by default: -m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl -m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl -dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 -dnl unless we require an AC_DEFUNed macro: -AC_REQUIRE([LTOPTIONS_VERSION])dnl -AC_REQUIRE([LTSUGAR_VERSION])dnl -AC_REQUIRE([LTVERSION_VERSION])dnl -AC_REQUIRE([LTOBSOLETE_VERSION])dnl -m4_require([_LT_PROG_LTMAIN])dnl - -_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) - -dnl Parse OPTIONS -_LT_SET_OPTIONS([$0], [$1]) - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS=$ltmain - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl - -_LT_SETUP - -# Only expand once: -m4_define([LT_INIT]) -])# LT_INIT - -# Old names: -AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) -AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PROG_LIBTOOL], []) -dnl AC_DEFUN([AM_PROG_LIBTOOL], []) - - -# _LT_PREPARE_CC_BASENAME -# ----------------------- -m4_defun([_LT_PREPARE_CC_BASENAME], [ -# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. -func_cc_basename () -{ - for cc_temp in @S|@*""; do - case $cc_temp in - compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; - distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; - \-*) ;; - *) break;; - esac - done - func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` -} -])# _LT_PREPARE_CC_BASENAME - - -# _LT_CC_BASENAME(CC) -# ------------------- -# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME, -# but that macro is also expanded into generated libtool script, which -# arranges for $SED and $ECHO to be set by different means. -m4_defun([_LT_CC_BASENAME], -[m4_require([_LT_PREPARE_CC_BASENAME])dnl -AC_REQUIRE([_LT_DECL_SED])dnl -AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl -func_cc_basename $1 -cc_basename=$func_cc_basename_result -]) - - -# _LT_FILEUTILS_DEFAULTS -# ---------------------- -# It is okay to use these file commands and assume they have been set -# sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'. -m4_defun([_LT_FILEUTILS_DEFAULTS], -[: ${CP="cp -f"} -: ${MV="mv -f"} -: ${RM="rm -f"} -])# _LT_FILEUTILS_DEFAULTS - - -# _LT_SETUP -# --------- -m4_defun([_LT_SETUP], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl -AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl - -_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl -dnl -_LT_DECL([], [host_alias], [0], [The host system])dnl -_LT_DECL([], [host], [0])dnl -_LT_DECL([], [host_os], [0])dnl -dnl -_LT_DECL([], [build_alias], [0], [The build system])dnl -_LT_DECL([], [build], [0])dnl -_LT_DECL([], [build_os], [0])dnl -dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -dnl -AC_REQUIRE([AC_PROG_LN_S])dnl -test -z "$LN_S" && LN_S="ln -s" -_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl -dnl -AC_REQUIRE([LT_CMD_MAX_LEN])dnl -_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl -_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl -dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_CHECK_SHELL_FEATURES])dnl -m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl -m4_require([_LT_CMD_RELOAD])dnl -m4_require([_LT_CHECK_MAGIC_METHOD])dnl -m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl -m4_require([_LT_CMD_OLD_ARCHIVE])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -m4_require([_LT_WITH_SYSROOT])dnl -m4_require([_LT_CMD_TRUNCATE])dnl - -_LT_CONFIG_LIBTOOL_INIT([ -# See if we are running on zsh, and set the options that allow our -# commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}"; then - setopt NO_GLOB_SUBST -fi -]) -if test -n "${ZSH_VERSION+set}"; then - setopt NO_GLOB_SUBST -fi - -_LT_CHECK_OBJDIR - -m4_require([_LT_TAG_COMPILER])dnl - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test set != "${COLLECT_NAMES+set}"; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Global variables: -ofile=libtool -can_build_shared=yes - -# All known linkers require a '.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a - -with_gnu_ld=$lt_cv_prog_gnu_ld - -old_CC=$CC -old_CFLAGS=$CFLAGS - -# Set sane defaults for various variables -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$LD" && LD=ld -test -z "$ac_objext" && ac_objext=o - -_LT_CC_BASENAME([$compiler]) - -# Only perform the check for file, if the check method requires it -test -z "$MAGIC_CMD" && MAGIC_CMD=file -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - _LT_PATH_MAGIC - fi - ;; -esac - -# Use C for the default configuration in the libtool script -LT_SUPPORTED_TAG([CC]) -_LT_LANG_C_CONFIG -_LT_LANG_DEFAULT_CONFIG -_LT_CONFIG_COMMANDS -])# _LT_SETUP - - -# _LT_PREPARE_SED_QUOTE_VARS -# -------------------------- -# Define a few sed substitution that help us do robust quoting. -m4_defun([_LT_PREPARE_SED_QUOTE_VARS], -[# Backslashify metacharacters that are still active within -# double-quoted strings. -sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\([["`\\]]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' -]) - -# _LT_PROG_LTMAIN -# --------------- -# Note that this code is called both from 'configure', and 'config.status' -# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, -# 'config.status' has no value for ac_aux_dir unless we are using Automake, -# so we pass a copy along to make sure it has a sensible value anyway. -m4_defun([_LT_PROG_LTMAIN], -[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl -_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) -ltmain=$ac_aux_dir/ltmain.sh -])# _LT_PROG_LTMAIN - - - -# So that we can recreate a full libtool script including additional -# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS -# in macros and then make a single call at the end using the 'libtool' -# label. - - -# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) -# ---------------------------------------- -# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL_INIT], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_INIT], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_INIT]) - - -# _LT_CONFIG_LIBTOOL([COMMANDS]) -# ------------------------------ -# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) - - -# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) -# ----------------------------------------------------- -m4_defun([_LT_CONFIG_SAVE_COMMANDS], -[_LT_CONFIG_LIBTOOL([$1]) -_LT_CONFIG_LIBTOOL_INIT([$2]) -]) - - -# _LT_FORMAT_COMMENT([COMMENT]) -# ----------------------------- -# Add leading comment marks to the start of each line, and a trailing -# full-stop to the whole comment if one is not present already. -m4_define([_LT_FORMAT_COMMENT], -[m4_ifval([$1], [ -m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], - [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) -)]) - - - - - -# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) -# ------------------------------------------------------------------- -# CONFIGNAME is the name given to the value in the libtool script. -# VARNAME is the (base) name used in the configure script. -# VALUE may be 0, 1 or 2 for a computed quote escaped value based on -# VARNAME. Any other value will be used directly. -m4_define([_LT_DECL], -[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], - [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], - [m4_ifval([$1], [$1], [$2])]) - lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) - m4_ifval([$4], - [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) - lt_dict_add_subkey([lt_decl_dict], [$2], - [tagged?], [m4_ifval([$5], [yes], [no])])]) -]) - - -# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) -# -------------------------------------------------------- -m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) - - -# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_tag_varnames], -[_lt_decl_filter([tagged?], [yes], $@)]) - - -# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) -# --------------------------------------------------------- -m4_define([_lt_decl_filter], -[m4_case([$#], - [0], [m4_fatal([$0: too few arguments: $#])], - [1], [m4_fatal([$0: too few arguments: $#: $1])], - [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], - [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], - [lt_dict_filter([lt_decl_dict], $@)])[]dnl -]) - - -# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) -# -------------------------------------------------- -m4_define([lt_decl_quote_varnames], -[_lt_decl_filter([value], [1], $@)]) - - -# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_dquote_varnames], -[_lt_decl_filter([value], [2], $@)]) - - -# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_varnames_tagged], -[m4_assert([$# <= 2])dnl -_$0(m4_quote(m4_default([$1], [[, ]])), - m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), - m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) -m4_define([_lt_decl_varnames_tagged], -[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) - - -# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_all_varnames], -[_$0(m4_quote(m4_default([$1], [[, ]])), - m4_if([$2], [], - m4_quote(lt_decl_varnames), - m4_quote(m4_shift($@))))[]dnl -]) -m4_define([_lt_decl_all_varnames], -[lt_join($@, lt_decl_varnames_tagged([$1], - lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl -]) - - -# _LT_CONFIG_STATUS_DECLARE([VARNAME]) -# ------------------------------------ -# Quote a variable value, and forward it to 'config.status' so that its -# declaration there will have the same value as in 'configure'. VARNAME -# must have a single quote delimited value for this to work. -m4_define([_LT_CONFIG_STATUS_DECLARE], -[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) - - -# _LT_CONFIG_STATUS_DECLARATIONS -# ------------------------------ -# We delimit libtool config variables with single quotes, so when -# we write them to config.status, we have to be sure to quote all -# embedded single quotes properly. In configure, this macro expands -# each variable declared with _LT_DECL (and _LT_TAGDECL) into: -# -# ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' -m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], -[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), - [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAGS -# ---------------- -# Output comment and list of tags supported by the script -m4_defun([_LT_LIBTOOL_TAGS], -[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl -available_tags='_LT_TAGS'dnl -]) - - -# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) -# ----------------------------------- -# Extract the dictionary values for VARNAME (optionally with TAG) and -# expand to a commented shell variable setting: -# -# # Some comment about what VAR is for. -# visible_name=$lt_internal_name -m4_define([_LT_LIBTOOL_DECLARE], -[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], - [description])))[]dnl -m4_pushdef([_libtool_name], - m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl -m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), - [0], [_libtool_name=[$]$1], - [1], [_libtool_name=$lt_[]$1], - [2], [_libtool_name=$lt_[]$1], - [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl -m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl -]) - - -# _LT_LIBTOOL_CONFIG_VARS -# ----------------------- -# Produce commented declarations of non-tagged libtool config variables -# suitable for insertion in the LIBTOOL CONFIG section of the 'libtool' -# script. Tagged libtool config variables (even for the LIBTOOL CONFIG -# section) are produced by _LT_LIBTOOL_TAG_VARS. -m4_defun([_LT_LIBTOOL_CONFIG_VARS], -[m4_foreach([_lt_var], - m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAG_VARS(TAG) -# ------------------------- -m4_define([_LT_LIBTOOL_TAG_VARS], -[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) - - -# _LT_TAGVAR(VARNAME, [TAGNAME]) -# ------------------------------ -m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) - - -# _LT_CONFIG_COMMANDS -# ------------------- -# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of -# variables for single and double quote escaping we saved from calls -# to _LT_DECL, we can put quote escaped variables declarations -# into 'config.status', and then the shell code to quote escape them in -# for loops in 'config.status'. Finally, any additional code accumulated -# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. -m4_defun([_LT_CONFIG_COMMANDS], -[AC_PROVIDE_IFELSE([LT_OUTPUT], - dnl If the libtool generation code has been placed in $CONFIG_LT, - dnl instead of duplicating it all over again into config.status, - dnl then we will have config.status run $CONFIG_LT later, so it - dnl needs to know what name is stored there: - [AC_CONFIG_COMMANDS([libtool], - [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], - dnl If the libtool generation code is destined for config.status, - dnl expand the accumulated commands and init code now: - [AC_CONFIG_COMMANDS([libtool], - [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) -])#_LT_CONFIG_COMMANDS - - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], -[ - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -sed_quote_subst='$sed_quote_subst' -double_quote_subst='$double_quote_subst' -delay_variable_subst='$delay_variable_subst' -_LT_CONFIG_STATUS_DECLARATIONS -LTCC='$LTCC' -LTCFLAGS='$LTCFLAGS' -compiler='$compiler_DEFAULT' - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$[]1 -_LTECHO_EOF' -} - -# Quote evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_quote_varnames); do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Double-quote double-evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_dquote_varnames); do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -_LT_OUTPUT_LIBTOOL_INIT -]) - -# _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) -# ------------------------------------ -# Generate a child script FILE with all initialization necessary to -# reuse the environment learned by the parent script, and make the -# file executable. If COMMENT is supplied, it is inserted after the -# '#!' sequence but before initialization text begins. After this -# macro, additional text can be appended to FILE to form the body of -# the child script. The macro ends with non-zero status if the -# file could not be fully written (such as if the disk is full). -m4_ifdef([AS_INIT_GENERATED], -[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], -[m4_defun([_LT_GENERATED_FILE_INIT], -[m4_require([AS_PREPARE])]dnl -[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl -[lt_write_fail=0 -cat >$1 <<_ASEOF || lt_write_fail=1 -#! $SHELL -# Generated by $as_me. -$2 -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$1 <<\_ASEOF || lt_write_fail=1 -AS_SHELL_SANITIZE -_AS_PREPARE -exec AS_MESSAGE_FD>&1 -_ASEOF -test 0 = "$lt_write_fail" && chmod +x $1[]dnl -m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT - -# LT_OUTPUT -# --------- -# This macro allows early generation of the libtool script (before -# AC_OUTPUT is called), incase it is used in configure for compilation -# tests. -AC_DEFUN([LT_OUTPUT], -[: ${CONFIG_LT=./config.lt} -AC_MSG_NOTICE([creating $CONFIG_LT]) -_LT_GENERATED_FILE_INIT(["$CONFIG_LT"], -[# Run this file to recreate a libtool stub with the current configuration.]) - -cat >>"$CONFIG_LT" <<\_LTEOF -lt_cl_silent=false -exec AS_MESSAGE_LOG_FD>>config.log -{ - echo - AS_BOX([Running $as_me.]) -} >&AS_MESSAGE_LOG_FD - -lt_cl_help="\ -'$as_me' creates a local libtool stub from the current configuration, -for use in further configure time tests before the real libtool is -generated. - -Usage: $[0] [[OPTIONS]] - - -h, --help print this help, then exit - -V, --version print version number, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - -Report bugs to ." - -lt_cl_version="\ -m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl -m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) -configured by $[0], generated by m4_PACKAGE_STRING. - -Copyright (C) 2011 Free Software Foundation, Inc. -This config.lt script is free software; the Free Software Foundation -gives unlimited permision to copy, distribute and modify it." - -while test 0 != $[#] -do - case $[1] in - --version | --v* | -V ) - echo "$lt_cl_version"; exit 0 ;; - --help | --h* | -h ) - echo "$lt_cl_help"; exit 0 ;; - --debug | --d* | -d ) - debug=: ;; - --quiet | --q* | --silent | --s* | -q ) - lt_cl_silent=: ;; - - -*) AC_MSG_ERROR([unrecognized option: $[1] -Try '$[0] --help' for more information.]) ;; - - *) AC_MSG_ERROR([unrecognized argument: $[1] -Try '$[0] --help' for more information.]) ;; - esac - shift -done - -if $lt_cl_silent; then - exec AS_MESSAGE_FD>/dev/null -fi -_LTEOF - -cat >>"$CONFIG_LT" <<_LTEOF -_LT_OUTPUT_LIBTOOL_COMMANDS_INIT -_LTEOF - -cat >>"$CONFIG_LT" <<\_LTEOF -AC_MSG_NOTICE([creating $ofile]) -_LT_OUTPUT_LIBTOOL_COMMANDS -AS_EXIT(0) -_LTEOF -chmod +x "$CONFIG_LT" - -# configure is writing to config.log, but config.lt does its own redirection, -# appending to config.log, which fails on DOS, as config.log is still kept -# open by configure. Here we exec the FD to /dev/null, effectively closing -# config.log, so it can be properly (re)opened and appended to by config.lt. -lt_cl_success=: -test yes = "$silent" && - lt_config_lt_args="$lt_config_lt_args --quiet" -exec AS_MESSAGE_LOG_FD>/dev/null -$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false -exec AS_MESSAGE_LOG_FD>>config.log -$lt_cl_success || AS_EXIT(1) -])# LT_OUTPUT - - -# _LT_CONFIG(TAG) -# --------------- -# If TAG is the built-in tag, create an initial libtool script with a -# default configuration from the untagged config vars. Otherwise add code -# to config.status for appending the configuration named by TAG from the -# matching tagged config vars. -m4_defun([_LT_CONFIG], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_CONFIG_SAVE_COMMANDS([ - m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl - m4_if(_LT_TAG, [C], [ - # See if we are running on zsh, and set the options that allow our - # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}"; then - setopt NO_GLOB_SUBST - fi - - cfgfile=${ofile}T - trap "$RM \"$cfgfile\"; exit 1" 1 2 15 - $RM "$cfgfile" - - cat <<_LT_EOF >> "$cfgfile" -#! $SHELL -# Generated automatically by $as_me ($PACKAGE) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# NOTE: Changes made to this file will be lost: look at ltmain.sh. - -# Provide generalized library-building support services. -# Written by Gordon Matzigkeit, 1996 - -_LT_COPYING -_LT_LIBTOOL_TAGS - -# Configured defaults for sys_lib_dlsearch_path munging. -: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} - -# ### BEGIN LIBTOOL CONFIG -_LT_LIBTOOL_CONFIG_VARS -_LT_LIBTOOL_TAG_VARS -# ### END LIBTOOL CONFIG - -_LT_EOF - - cat <<'_LT_EOF' >> "$cfgfile" - -# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE - -_LT_PREPARE_MUNGE_PATH_LIST -_LT_PREPARE_CC_BASENAME - -# ### END FUNCTIONS SHARED WITH CONFIGURE - -_LT_EOF - - case $host_os in - aix3*) - cat <<\_LT_EOF >> "$cfgfile" -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test set != "${COLLECT_NAMES+set}"; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -_LT_EOF - ;; - esac - - _LT_PROG_LTMAIN - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" -], -[cat <<_LT_EOF >> "$ofile" - -dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded -dnl in a comment (ie after a #). -# ### BEGIN LIBTOOL TAG CONFIG: $1 -_LT_LIBTOOL_TAG_VARS(_LT_TAG) -# ### END LIBTOOL TAG CONFIG: $1 -_LT_EOF -])dnl /m4_if -], -[m4_if([$1], [], [ - PACKAGE='$PACKAGE' - VERSION='$VERSION' - RM='$RM' - ofile='$ofile'], []) -])dnl /_LT_CONFIG_SAVE_COMMANDS -])# _LT_CONFIG - - -# LT_SUPPORTED_TAG(TAG) -# --------------------- -# Trace this macro to discover what tags are supported by the libtool -# --tag option, using: -# autoconf --trace 'LT_SUPPORTED_TAG:$1' -AC_DEFUN([LT_SUPPORTED_TAG], []) - - -# C support is built-in for now -m4_define([_LT_LANG_C_enabled], []) -m4_define([_LT_TAGS], []) - - -# LT_LANG(LANG) -# ------------- -# Enable libtool support for the given language if not already enabled. -AC_DEFUN([LT_LANG], -[AC_BEFORE([$0], [LT_OUTPUT])dnl -m4_case([$1], - [C], [_LT_LANG(C)], - [C++], [_LT_LANG(CXX)], - [Go], [_LT_LANG(GO)], - [Java], [_LT_LANG(GCJ)], - [Fortran 77], [_LT_LANG(F77)], - [Fortran], [_LT_LANG(FC)], - [Windows Resource], [_LT_LANG(RC)], - [m4_ifdef([_LT_LANG_]$1[_CONFIG], - [_LT_LANG($1)], - [m4_fatal([$0: unsupported language: "$1"])])])dnl -])# LT_LANG - - -# _LT_LANG(LANGNAME) -# ------------------ -m4_defun([_LT_LANG], -[m4_ifdef([_LT_LANG_]$1[_enabled], [], - [LT_SUPPORTED_TAG([$1])dnl - m4_append([_LT_TAGS], [$1 ])dnl - m4_define([_LT_LANG_]$1[_enabled], [])dnl - _LT_LANG_$1_CONFIG($1)])dnl -])# _LT_LANG - - -m4_ifndef([AC_PROG_GO], [ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_GO. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # -m4_defun([AC_PROG_GO], -[AC_LANG_PUSH(Go)dnl -AC_ARG_VAR([GOC], [Go compiler command])dnl -AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl -_AC_ARG_VAR_LDFLAGS()dnl -AC_CHECK_TOOL(GOC, gccgo) -if test -z "$GOC"; then - if test -n "$ac_tool_prefix"; then - AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) - fi -fi -if test -z "$GOC"; then - AC_CHECK_PROG(GOC, gccgo, gccgo, false) -fi -])#m4_defun -])#m4_ifndef - - -# _LT_LANG_DEFAULT_CONFIG -# ----------------------- -m4_defun([_LT_LANG_DEFAULT_CONFIG], -[AC_PROVIDE_IFELSE([AC_PROG_CXX], - [LT_LANG(CXX)], - [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) - -AC_PROVIDE_IFELSE([AC_PROG_F77], - [LT_LANG(F77)], - [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) - -AC_PROVIDE_IFELSE([AC_PROG_FC], - [LT_LANG(FC)], - [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) - -dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal -dnl pulling things in needlessly. -AC_PROVIDE_IFELSE([AC_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([LT_PROG_GCJ], - [LT_LANG(GCJ)], - [m4_ifdef([AC_PROG_GCJ], - [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([A][M_PROG_GCJ], - [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([LT_PROG_GCJ], - [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) - -AC_PROVIDE_IFELSE([AC_PROG_GO], - [LT_LANG(GO)], - [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) - -AC_PROVIDE_IFELSE([LT_PROG_RC], - [LT_LANG(RC)], - [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) -])# _LT_LANG_DEFAULT_CONFIG - -# Obsolete macros: -AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) -AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) -AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) -AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) -AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_CXX], []) -dnl AC_DEFUN([AC_LIBTOOL_F77], []) -dnl AC_DEFUN([AC_LIBTOOL_FC], []) -dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) -dnl AC_DEFUN([AC_LIBTOOL_RC], []) - - -# _LT_TAG_COMPILER -# ---------------- -m4_defun([_LT_TAG_COMPILER], -[AC_REQUIRE([AC_PROG_CC])dnl - -_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl -_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl -_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl -_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC -])# _LT_TAG_COMPILER - - -# _LT_COMPILER_BOILERPLATE -# ------------------------ -# Check for compiler boilerplate output or warnings with -# the simple compiler test code. -m4_defun([_LT_COMPILER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$RM conftest* -])# _LT_COMPILER_BOILERPLATE - - -# _LT_LINKER_BOILERPLATE -# ---------------------- -# Check for linker boilerplate output or warnings with -# the simple link test code. -m4_defun([_LT_LINKER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$RM -r conftest* -])# _LT_LINKER_BOILERPLATE - -# _LT_REQUIRED_DARWIN_CHECKS -# ------------------------- -m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ - case $host_os in - rhapsody* | darwin*) - AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) - AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) - AC_CHECK_TOOL([LIPO], [lipo], [:]) - AC_CHECK_TOOL([OTOOL], [otool], [:]) - AC_CHECK_TOOL([OTOOL64], [otool64], [:]) - _LT_DECL([], [DSYMUTIL], [1], - [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) - _LT_DECL([], [NMEDIT], [1], - [Tool to change global to local symbols on Mac OS X]) - _LT_DECL([], [LIPO], [1], - [Tool to manipulate fat objects and archives on Mac OS X]) - _LT_DECL([], [OTOOL], [1], - [ldd/readelf like tool for Mach-O binaries on Mac OS X]) - _LT_DECL([], [OTOOL64], [1], - [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) - - AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], - [lt_cv_apple_cc_single_mod=no - if test -z "$LT_MULTI_MODULE"; then - # By default we will add the -single_module flag. You can override - # by either setting the environment variable LT_MULTI_MODULE - # non-empty at configure time, or by adding -multi_module to the - # link flags. - rm -rf libconftest.dylib* - echo "int foo(void){return 1;}" > conftest.c - echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ --dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ - -dynamiclib -Wl,-single_module conftest.c 2>conftest.err - _lt_result=$? - # If there is a non-empty error log, and "single_module" - # appears in it, assume the flag caused a linker warning - if test -s conftest.err && $GREP single_module conftest.err; then - cat conftest.err >&AS_MESSAGE_LOG_FD - # Otherwise, if the output was created with a 0 exit code from - # the compiler, it worked. - elif test -f libconftest.dylib && test 0 = "$_lt_result"; then - lt_cv_apple_cc_single_mod=yes - else - cat conftest.err >&AS_MESSAGE_LOG_FD - fi - rm -rf libconftest.dylib* - rm -f conftest.* - fi]) - - AC_CACHE_CHECK([for -exported_symbols_list linker flag], - [lt_cv_ld_exported_symbols_list], - [lt_cv_ld_exported_symbols_list=no - save_LDFLAGS=$LDFLAGS - echo "_main" > conftest.sym - LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [lt_cv_ld_exported_symbols_list=yes], - [lt_cv_ld_exported_symbols_list=no]) - LDFLAGS=$save_LDFLAGS - ]) - - AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], - [lt_cv_ld_force_load=no - cat > conftest.c << _LT_EOF -int forced_loaded() { return 2;} -_LT_EOF - echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD - echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD - $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD - echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD - $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD - cat > conftest.c << _LT_EOF -int main() { return 0;} -_LT_EOF - echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err - _lt_result=$? - if test -s conftest.err && $GREP force_load conftest.err; then - cat conftest.err >&AS_MESSAGE_LOG_FD - elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then - lt_cv_ld_force_load=yes - else - cat conftest.err >&AS_MESSAGE_LOG_FD - fi - rm -f conftest.err libconftest.a conftest conftest.c - rm -rf conftest.dSYM - ]) - case $host_os in - rhapsody* | darwin1.[[012]]) - _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; - darwin1.*) - _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) - _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; - 10.[[012]][[,.]]*) - _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; - esac - ;; - esac - if test yes = "$lt_cv_apple_cc_single_mod"; then - _lt_dar_single_mod='$single_module' - fi - if test yes = "$lt_cv_ld_exported_symbols_list"; then - _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' - else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' - fi - if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then - _lt_dsymutil='~$DSYMUTIL $lib || :' - else - _lt_dsymutil= - fi - ;; - esac -]) - - -# _LT_DARWIN_LINKER_FEATURES([TAG]) -# --------------------------------- -# Checks for linker and compiler features on darwin -m4_defun([_LT_DARWIN_LINKER_FEATURES], -[ - m4_require([_LT_REQUIRED_DARWIN_CHECKS]) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_automatic, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - if test yes = "$lt_cv_ld_force_load"; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' - m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], - [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) - else - _LT_TAGVAR(whole_archive_flag_spec, $1)='' - fi - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined - case $cc_basename in - ifort*|nagfor*) _lt_dar_can_shared=yes ;; - *) _lt_dar_can_shared=$GCC ;; - esac - if test yes = "$_lt_dar_can_shared"; then - output_verbose_link_cmd=func_echo_all - _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" - _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" - _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" - m4_if([$1], [CXX], -[ if test yes != "$lt_cv_apple_cc_single_mod"; then - _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" - fi -],[]) - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi -]) - -# _LT_SYS_MODULE_PATH_AIX([TAGNAME]) -# ---------------------------------- -# Links a minimal program and checks the executable -# for the system default hardcoded library path. In most cases, -# this is /usr/lib:/lib, but when the MPI compilers are used -# the location of the communication and MPI libs are included too. -# If we don't find anything, use the default library path according -# to the aix ld manual. -# Store the results from the different compilers for each TAGNAME. -# Allow to override them for all tags through lt_cv_aix_libpath. -m4_defun([_LT_SYS_MODULE_PATH_AIX], -[m4_require([_LT_DECL_SED])dnl -if test set = "${lt_cv_aix_libpath+set}"; then - aix_libpath=$lt_cv_aix_libpath -else - AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], - [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ - lt_aix_libpath_sed='[ - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }]' - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi],[]) - if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib - fi - ]) - aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) -fi -])# _LT_SYS_MODULE_PATH_AIX - - -# _LT_SHELL_INIT(ARG) -# ------------------- -m4_define([_LT_SHELL_INIT], -[m4_divert_text([M4SH-INIT], [$1 -])])# _LT_SHELL_INIT - - - -# _LT_PROG_ECHO_BACKSLASH -# ----------------------- -# Find how we can fake an echo command that does not interpret backslash. -# In particular, with Autoconf 2.60 or later we add some code to the start -# of the generated configure script that will find a shell with a builtin -# printf (that we can use as an echo command). -m4_defun([_LT_PROG_ECHO_BACKSLASH], -[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - -AC_MSG_CHECKING([how to print strings]) -# Test print first, because it will be a builtin if present. -if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ - test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='print -r --' -elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='printf %s\n' -else - # Use this function as a fallback that always works. - func_fallback_echo () - { - eval 'cat <<_LTECHO_EOF -$[]1 -_LTECHO_EOF' - } - ECHO='func_fallback_echo' -fi - -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "$*" -} - -case $ECHO in - printf*) AC_MSG_RESULT([printf]) ;; - print*) AC_MSG_RESULT([print -r]) ;; - *) AC_MSG_RESULT([cat]) ;; -esac - -m4_ifdef([_AS_DETECT_SUGGESTED], -[_AS_DETECT_SUGGESTED([ - test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( - ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' - ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO - ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - PATH=/empty FPATH=/empty; export PATH FPATH - test "X`printf %s $ECHO`" = "X$ECHO" \ - || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) - -_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) -_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) -])# _LT_PROG_ECHO_BACKSLASH - - -# _LT_WITH_SYSROOT -# ---------------- -AC_DEFUN([_LT_WITH_SYSROOT], -[AC_MSG_CHECKING([for sysroot]) -AC_ARG_WITH([sysroot], -[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], - [Search for dependent libraries within DIR (or the compiler's sysroot - if not specified).])], -[], [with_sysroot=no]) - -dnl lt_sysroot will always be passed unquoted. We quote it here -dnl in case the user passed a directory name. -lt_sysroot= -case $with_sysroot in #( - yes) - if test yes = "$GCC"; then - lt_sysroot=`$CC --print-sysroot 2>/dev/null` - fi - ;; #( - /*) - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` - ;; #( - no|'') - ;; #( - *) - AC_MSG_RESULT([$with_sysroot]) - AC_MSG_ERROR([The sysroot must be an absolute path.]) - ;; -esac - - AC_MSG_RESULT([${lt_sysroot:-no}]) -_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl -[dependent libraries, and where our libraries should be installed.])]) - -# _LT_ENABLE_LOCK -# --------------- -m4_defun([_LT_ENABLE_LOCK], -[AC_ARG_ENABLE([libtool-lock], - [AS_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test no = "$enable_libtool_lock" || enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out what ABI is being produced by ac_compile, and set mode - # options accordingly. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE=32 - ;; - *ELF-64*) - HPUX_IA64_MODE=64 - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out what ABI is being produced by ac_compile, and set linker - # options accordingly. - echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - if test yes = "$lt_cv_prog_gnu_ld"; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -mips64*-*linux*) - # Find out what ABI is being produced by ac_compile, and set linker - # options accordingly. - echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - emul=elf - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - emul="${emul}32" - ;; - *64-bit*) - emul="${emul}64" - ;; - esac - case `/usr/bin/file conftest.$ac_objext` in - *MSB*) - emul="${emul}btsmip" - ;; - *LSB*) - emul="${emul}ltsmip" - ;; - esac - case `/usr/bin/file conftest.$ac_objext` in - *N32*) - emul="${emul}n32" - ;; - esac - LD="${LD-ld} -m $emul" - fi - rm -rf conftest* - ;; - -x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out what ABI is being produced by ac_compile, and set linker - # options accordingly. Note that the listed cases only cover the - # situations where additional linker options are needed (such as when - # doing 32-bit compilation for a host where ld defaults to 64-bit, or - # vice versa); the common cases where no linker options are needed do - # not appear in the list. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_i386_fbsd" - ;; - x86_64-*linux*) - case `/usr/bin/file conftest.o` in - *x86-64*) - LD="${LD-ld} -m elf32_x86_64" - ;; - *) - LD="${LD-ld} -m elf_i386" - ;; - esac - ;; - powerpc64le-*linux*) - LD="${LD-ld} -m elf32lppclinux" - ;; - powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_x86_64_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - powerpcle-*linux*) - LD="${LD-ld} -m elf64lppc" - ;; - powerpc-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*|s390*-*tpf*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS -belf" - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_LANG_PUSH(C) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) - AC_LANG_POP]) - if test yes != "$lt_cv_cc_needs_belf"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS=$SAVE_CFLAGS - fi - ;; -*-*solaris*) - # Find out what ABI is being produced by ac_compile, and set linker - # options accordingly. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) - case $host in - i?86-*-solaris*|x86_64-*-solaris*) - LD="${LD-ld} -m elf_x86_64" - ;; - sparc*-*-solaris*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - # GNU ld 2.21 introduced _sol2 emulations. Use them if available. - if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then - LD=${LD-ld}_sol2 - fi - ;; - *) - if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then - LD="${LD-ld} -64" - fi - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; -esac - -need_locks=$enable_libtool_lock -])# _LT_ENABLE_LOCK - - -# _LT_PROG_AR -# ----------- -m4_defun([_LT_PROG_AR], -[AC_CHECK_TOOLS(AR, [ar], false) -: ${AR=ar} -: ${AR_FLAGS=cru} -_LT_DECL([], [AR], [1], [The archiver]) -_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) - -AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], - [lt_cv_ar_at_file=no - AC_COMPILE_IFELSE([AC_LANG_PROGRAM], - [echo conftest.$ac_objext > conftest.lst - lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' - AC_TRY_EVAL([lt_ar_try]) - if test 0 -eq "$ac_status"; then - # Ensure the archiver fails upon bogus file names. - rm -f conftest.$ac_objext libconftest.a - AC_TRY_EVAL([lt_ar_try]) - if test 0 -ne "$ac_status"; then - lt_cv_ar_at_file=@ - fi - fi - rm -f conftest.* libconftest.a - ]) - ]) - -if test no = "$lt_cv_ar_at_file"; then - archiver_list_spec= -else - archiver_list_spec=$lt_cv_ar_at_file -fi -_LT_DECL([], [archiver_list_spec], [1], - [How to feed a file listing to the archiver]) -])# _LT_PROG_AR - - -# _LT_CMD_OLD_ARCHIVE -# ------------------- -m4_defun([_LT_CMD_OLD_ARCHIVE], -[_LT_PROG_AR - -AC_CHECK_TOOL(STRIP, strip, :) -test -z "$STRIP" && STRIP=: -_LT_DECL([], [STRIP], [1], [A symbol stripping program]) - -AC_CHECK_TOOL(RANLIB, ranlib, :) -test -z "$RANLIB" && RANLIB=: -_LT_DECL([], [RANLIB], [1], - [Commands used to install an old-style archive]) - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - bitrig* | openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" -fi - -case $host_os in - darwin*) - lock_old_archive_extraction=yes ;; - *) - lock_old_archive_extraction=no ;; -esac -_LT_DECL([], [old_postinstall_cmds], [2]) -_LT_DECL([], [old_postuninstall_cmds], [2]) -_LT_TAGDECL([], [old_archive_cmds], [2], - [Commands used to build an old-style archive]) -_LT_DECL([], [lock_old_archive_extraction], [0], - [Whether to use a lock for old archive extraction]) -])# _LT_CMD_OLD_ARCHIVE - - -# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------------------- -# Check whether the given compiler option works -AC_DEFUN([_LT_COMPILER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$3" ## exclude from sc_useless_quotes_in_assignment - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - fi - $RM conftest* -]) - -if test yes = "[$]$2"; then - m4_if([$5], , :, [$5]) -else - m4_if([$6], , :, [$6]) -fi -])# _LT_COMPILER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) - - -# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------- -# Check whether the given linker option works -AC_DEFUN([_LT_LINKER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - save_LDFLAGS=$LDFLAGS - LDFLAGS="$LDFLAGS $3" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&AS_MESSAGE_LOG_FD - $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - else - $2=yes - fi - fi - $RM -r conftest* - LDFLAGS=$save_LDFLAGS -]) - -if test yes = "[$]$2"; then - m4_if([$4], , :, [$4]) -else - m4_if([$5], , :, [$5]) -fi -])# _LT_LINKER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) - - -# LT_CMD_MAX_LEN -#--------------- -AC_DEFUN([LT_CMD_MAX_LEN], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -# find the maximum length of command line arguments -AC_MSG_CHECKING([the maximum length of command line arguments]) -AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl - i=0 - teststring=ABCD - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw* | cegcc*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - mint*) - # On MiNT this can take a long time and run out of memory. - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - os2*) - # The test takes a long time on OS/2. - lt_cv_sys_max_cmd_len=8192 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len" && \ - test undefined != "$lt_cv_sys_max_cmd_len"; then - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - else - # Make teststring a little bigger before we do anything with it. - # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8; do - teststring=$teststring$teststring - done - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - while { test X`env echo "$teststring$teststring" 2>/dev/null` \ - = "X$teststring$teststring"; } >/dev/null 2>&1 && - test 17 != "$i" # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - # Only check the string length outside the loop. - lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` - teststring= - # Add a significant safety factor because C++ compilers can tack on - # massive amounts of additional arguments before passing them to the - # linker. It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - fi - ;; - esac -]) -if test -n "$lt_cv_sys_max_cmd_len"; then - AC_MSG_RESULT($lt_cv_sys_max_cmd_len) -else - AC_MSG_RESULT(none) -fi -max_cmd_len=$lt_cv_sys_max_cmd_len -_LT_DECL([], [max_cmd_len], [0], - [What is the maximum length of a command?]) -])# LT_CMD_MAX_LEN - -# Old name: -AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) - - -# _LT_HEADER_DLFCN -# ---------------- -m4_defun([_LT_HEADER_DLFCN], -[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl -])# _LT_HEADER_DLFCN - - -# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# ---------------------------------------------------------------- -m4_defun([_LT_TRY_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test yes = "$cross_compiling"; then : - [$4] -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -[#line $LINENO "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -/* When -fvisibility=hidden is used, assume the code has been annotated - correspondingly for the symbols needed. */ -#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); -#endif - -int fnord () { return 42; } -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else - { - if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - else puts (dlerror ()); - } - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -}] -_LT_EOF - if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then - (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) $1 ;; - x$lt_dlneed_uscore) $2 ;; - x$lt_dlunknown|x*) $3 ;; - esac - else : - # compilation failed - $3 - fi -fi -rm -fr conftest* -])# _LT_TRY_DLOPEN_SELF - - -# LT_SYS_DLOPEN_SELF -# ------------------ -AC_DEFUN([LT_SYS_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test yes != "$enable_dlopen"; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen=load_add_on - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32* | cegcc*) - lt_cv_dlopen=LoadLibrary - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen=dlopen - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[ - lt_cv_dlopen=dyld - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ]) - ;; - - tpf*) - # Don't try to run any link tests for TPF. We know it's impossible - # because TPF is a cross-compiler, and we know how we open DSOs. - lt_cv_dlopen=dlopen - lt_cv_dlopen_libs= - lt_cv_dlopen_self=no - ;; - - *) - AC_CHECK_FUNC([shl_load], - [lt_cv_dlopen=shl_load], - [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld], - [AC_CHECK_FUNC([dlopen], - [lt_cv_dlopen=dlopen], - [AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl], - [AC_CHECK_LIB([svld], [dlopen], - [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld], - [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld]) - ]) - ]) - ]) - ]) - ]) - ;; - esac - - if test no = "$lt_cv_dlopen"; then - enable_dlopen=no - else - enable_dlopen=yes - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS=$CPPFLAGS - test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS=$LDFLAGS - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS=$LIBS - LIBS="$lt_cv_dlopen_libs $LIBS" - - AC_CACHE_CHECK([whether a program can dlopen itself], - lt_cv_dlopen_self, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, - lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) - ]) - - if test yes = "$lt_cv_dlopen_self"; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], - lt_cv_dlopen_self_static, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, - lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) - ]) - fi - - CPPFLAGS=$save_CPPFLAGS - LDFLAGS=$save_LDFLAGS - LIBS=$save_LIBS - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi -_LT_DECL([dlopen_support], [enable_dlopen], [0], - [Whether dlopen is supported]) -_LT_DECL([dlopen_self], [enable_dlopen_self], [0], - [Whether dlopen of programs is supported]) -_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], - [Whether dlopen of statically linked programs is supported]) -])# LT_SYS_DLOPEN_SELF - -# Old name: -AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) - - -# _LT_COMPILER_C_O([TAGNAME]) -# --------------------------- -# Check to see if options -c and -o are simultaneously supported by compiler. -# This macro does not hard code the compiler like AC_PROG_CC_C_O. -m4_defun([_LT_COMPILER_C_O], -[m4_require([_LT_DECL_SED])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - fi - fi - chmod u+w . 2>&AS_MESSAGE_LOG_FD - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* -]) -_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], - [Does compiler simultaneously support -c and -o options?]) -])# _LT_COMPILER_C_O - - -# _LT_COMPILER_FILE_LOCKS([TAGNAME]) -# ---------------------------------- -# Check to see if we can do hard links to lock some files if needed -m4_defun([_LT_COMPILER_FILE_LOCKS], -[m4_require([_LT_ENABLE_LOCK])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_COMPILER_C_O([$1]) - -hard_links=nottested -if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then - # do not overwrite the value of need_locks provided by the user - AC_MSG_CHECKING([if we can lock with hard links]) - hard_links=yes - $RM conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - AC_MSG_RESULT([$hard_links]) - if test no = "$hard_links"; then - AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe]) - need_locks=warn - fi -else - need_locks=no -fi -_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) -])# _LT_COMPILER_FILE_LOCKS - - -# _LT_CHECK_OBJDIR -# ---------------- -m4_defun([_LT_CHECK_OBJDIR], -[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], -[rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null]) -objdir=$lt_cv_objdir -_LT_DECL([], [objdir], [0], - [The name of the directory that contains temporary libtool files])dnl -m4_pattern_allow([LT_OBJDIR])dnl -AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/", - [Define to the sub-directory where libtool stores uninstalled libraries.]) -])# _LT_CHECK_OBJDIR - - -# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) -# -------------------------------------- -# Check hardcoding attributes. -m4_defun([_LT_LINKER_HARDCODE_LIBPATH], -[AC_MSG_CHECKING([how to hardcode library paths into programs]) -_LT_TAGVAR(hardcode_action, $1)= -if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || - test -n "$_LT_TAGVAR(runpath_var, $1)" || - test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then - - # We can hardcode non-existent directories. - if test no != "$_LT_TAGVAR(hardcode_direct, $1)" && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" && - test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then - # Linking always hardcodes the temporary library directory. - _LT_TAGVAR(hardcode_action, $1)=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - _LT_TAGVAR(hardcode_action, $1)=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - _LT_TAGVAR(hardcode_action, $1)=unsupported -fi -AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) - -if test relink = "$_LT_TAGVAR(hardcode_action, $1)" || - test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then - # Fast installation is not supported - enable_fast_install=no -elif test yes = "$shlibpath_overrides_runpath" || - test no = "$enable_shared"; then - # Fast installation is not necessary - enable_fast_install=needless -fi -_LT_TAGDECL([], [hardcode_action], [0], - [How to hardcode a shared library path into an executable]) -])# _LT_LINKER_HARDCODE_LIBPATH - - -# _LT_CMD_STRIPLIB -# ---------------- -m4_defun([_LT_CMD_STRIPLIB], -[m4_require([_LT_DECL_EGREP]) -striplib= -old_striplib= -AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP"; then - striplib="$STRIP -x" - old_striplib="$STRIP -S" - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac -fi -_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) -_LT_DECL([], [striplib], [1]) -])# _LT_CMD_STRIPLIB - - -# _LT_PREPARE_MUNGE_PATH_LIST -# --------------------------- -# Make sure func_munge_path_list() is defined correctly. -m4_defun([_LT_PREPARE_MUNGE_PATH_LIST], -[[# func_munge_path_list VARIABLE PATH -# ----------------------------------- -# VARIABLE is name of variable containing _space_ separated list of -# directories to be munged by the contents of PATH, which is string -# having a format: -# "DIR[:DIR]:" -# string "DIR[ DIR]" will be prepended to VARIABLE -# ":DIR[:DIR]" -# string "DIR[ DIR]" will be appended to VARIABLE -# "DIRP[:DIRP]::[DIRA:]DIRA" -# string "DIRP[ DIRP]" will be prepended to VARIABLE and string -# "DIRA[ DIRA]" will be appended to VARIABLE -# "DIR[:DIR]" -# VARIABLE will be replaced by "DIR[ DIR]" -func_munge_path_list () -{ - case x@S|@2 in - x) - ;; - *:) - eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\" - ;; - x:*) - eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\" - ;; - *::*) - eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" - eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\" - ;; - *) - eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\" - ;; - esac -} -]])# _LT_PREPARE_PATH_LIST - - -# _LT_SYS_DYNAMIC_LINKER([TAG]) -# ----------------------------- -# PORTME Fill in your ld.so characteristics -m4_defun([_LT_SYS_DYNAMIC_LINKER], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_OBJDUMP])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_CHECK_SHELL_FEATURES])dnl -m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl -AC_MSG_CHECKING([dynamic linker characteristics]) -m4_if([$1], - [], [ -if test yes = "$GCC"; then - case $host_os in - darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; - *) lt_awk_arg='/^libraries:/' ;; - esac - case $host_os in - mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; - *) lt_sed_strip_eq='s|=/|/|g' ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` - case $lt_search_path_spec in - *\;*) - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` - ;; - *) - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` - ;; - esac - # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary... - lt_tmp_lt_search_path_spec= - lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` - # ...but if some path component already ends with the multilib dir we assume - # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). - case "$lt_multi_os_dir; $lt_search_path_spec " in - "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) - lt_multi_os_dir= - ;; - esac - for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" - elif test -n "$lt_multi_os_dir"; then - test -d "$lt_sys_path" && \ - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" - fi - done - lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' -BEGIN {RS = " "; FS = "/|\n";} { - lt_foo = ""; - lt_count = 0; - for (lt_i = NF; lt_i > 0; lt_i--) { - if ($lt_i != "" && $lt_i != ".") { - if ($lt_i == "..") { - lt_count++; - } else { - if (lt_count == 0) { - lt_foo = "/" $lt_i lt_foo; - } else { - lt_count--; - } - } - } - } - if (lt_foo != "") { lt_freq[[lt_foo]]++; } - if (lt_freq[[lt_foo]] == 1) { print lt_foo; } -}'` - # AWK program above erroneously prepends '/' to C:/dos/paths - # for these hosts. - case $host_os in - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ - $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;; - esac - sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi]) -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=.so -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -AC_ARG_VAR([LT_SYS_LIBRARY_PATH], -[User-defined run-time library search path.]) - -case $host_os in -aix3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname$release$shared_ext$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='$libname$release$shared_ext$major' - ;; - -aix[[4-9]]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test ia64 = "$host_cpu"; then - # AIX 5 supports IA64 - library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line '#! .'. This would cause the generated library to - # depend on '.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[[01]] | aix4.[[01]].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # Using Import Files as archive members, it is possible to support - # filename-based versioning of shared library archives on AIX. While - # this would work for both with and without runtime linking, it will - # prevent static linking of such archives. So we do filename-based - # shared library versioning with .so extension only, which is used - # when both runtime linking and shared linking is enabled. - # Unfortunately, runtime linking may impact performance, so we do - # not want this to be the default eventually. Also, we use the - # versioned .so libs for executables only if there is the -brtl - # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. - # To allow for filename-based versioning support, we need to create - # libNAME.so.V as an archive file, containing: - # *) an Import File, referring to the versioned filename of the - # archive as well as the shared archive member, telling the - # bitwidth (32 or 64) of that shared object, and providing the - # list of exported symbols of that shared object, eventually - # decorated with the 'weak' keyword - # *) the shared object with the F_LOADONLY flag set, to really avoid - # it being seen by the linker. - # At run time we better use the real file rather than another symlink, - # but for link time we create the symlink libNAME.so -> libNAME.so.V - - case $with_aix_soname,$aix_use_runtimelinking in - # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - aix,yes) # traditional libtool - dynamic_linker='AIX unversionable lib.so' - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - ;; - aix,no) # traditional AIX only - dynamic_linker='AIX lib.a[(]lib.so.V[)]' - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='$libname$release.a $libname.a' - soname_spec='$libname$release$shared_ext$major' - ;; - svr4,*) # full svr4 only - dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]" - library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' - # We do not specify a path in Import Files, so LIBPATH fires. - shlibpath_overrides_runpath=yes - ;; - *,yes) # both, prefer svr4 - dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]" - library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' - # unpreferred sharedlib libNAME.a needs extra handling - postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' - postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' - # We do not specify a path in Import Files, so LIBPATH fires. - shlibpath_overrides_runpath=yes - ;; - *,no) # both, prefer aix - dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]" - library_names_spec='$libname$release.a $libname.a' - soname_spec='$libname$release$shared_ext$major' - # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling - postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' - postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' - ;; - esac - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - case $host_cpu in - powerpc) - # Since July 2007 AmigaOS4 officially supports .so libraries. - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - ;; - m68k) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - esac - ;; - -beos*) - library_names_spec='$libname$shared_ext' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[[45]]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_version=no - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32* | cegcc*) - version_type=windows - shrext_cmds=.dll - need_version=no - need_lib_prefix=no - - case $GCC,$cc_basename in - yes,*) - # gcc - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \$file`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' -m4_if([$1], [],[ - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' - ;; - esac - dynamic_linker='Win32 ld.exe' - ;; - - *,cl*) - # Native MSVC - libname_spec='$name' - soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' - library_names_spec='$libname.dll.lib' - - case $build_os in - mingw*) - sys_lib_search_path_spec= - lt_save_ifs=$IFS - IFS=';' - for lt_path in $LIB - do - IFS=$lt_save_ifs - # Let DOS variable expansion print the short 8.3 style file name. - lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` - sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" - done - IFS=$lt_save_ifs - # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` - ;; - cygwin*) - # Convert to unix form, then to dos form, then back to unix form - # but this time dos style (no spaces!) so that the unix form looks - # like /cygdrive/c/PROGRA~1:/cygdr... - sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` - sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` - sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - ;; - *) - sys_lib_search_path_spec=$LIB - if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then - # It is most probably a Windows format PATH. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # FIXME: find the short name or the path components, as spaces are - # common. (e.g. "Program Files" -> "PROGRA~1") - ;; - esac - - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \$file`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - dynamic_linker='Win32 link.exe' - ;; - - *) - # Assume MSVC wrapper - library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib' - dynamic_linker='Win32 ld.exe' - ;; - esac - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' - soname_spec='$libname$release$major$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' -m4_if([$1], [],[ - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[[23]].*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2.*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[[01]]* | freebsdelf3.[[01]]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ - freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - *) # from 4.6 on, and DragonFly - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -haiku*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - dynamic_linker="$host_os runtime_loader" - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - shlibpath_var=LIBRARY_PATH - shlibpath_overrides_runpath=no - sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - if test 32 = "$HPUX_IA64_MODE"; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - sys_lib_dlsearch_path_spec=/usr/lib/hpux32 - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - sys_lib_dlsearch_path_spec=/usr/lib/hpux64 - fi - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555, ... - postinstall_cmds='chmod 555 $lib' - # or fails outright, so override atomically: - install_override_mode=555 - ;; - -interix[[3-9]]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test yes = "$lt_cv_prog_gnu_ld"; then - version_type=linux # correct to gnu/linux during the next big refactor - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='$libname$release$shared_ext$major' - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" - sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -linux*android*) - version_type=none # Android doesn't support versioned libraries. - need_lib_prefix=no - need_version=no - library_names_spec='$libname$release$shared_ext' - soname_spec='$libname$release$shared_ext' - finish_cmds= - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - dynamic_linker='Android linker' - # Don't embed -rpath directories since the linker doesn't support them. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - ;; - -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - - # Some binutils ld are patched to set DT_RUNPATH - AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], - [lt_cv_shlibpath_overrides_runpath=no - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ - LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], - [lt_cv_shlibpath_overrides_runpath=yes])]) - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - ]) - shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Ideally, we could use ldconfig to report *all* directores which are - # searched for libraries, however this is still not possible. Aside from not - # being certain /sbin/ldconfig is available, command - # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, - # even though it is searched at run-time. Try to do the best guess by - # appending ld.so.conf contents (and includes) to the search path. - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -*nto* | *qnx*) - version_type=qnx - need_lib_prefix=no - need_version=no - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='ldqnx.so' - ;; - -openbsd* | bitrig*) - version_type=sunos - sys_lib_dlsearch_path_spec=/usr/lib - need_lib_prefix=no - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then - need_version=no - else - need_version=yes - fi - library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -os2*) - libname_spec='$name' - version_type=windows - shrext_cmds=.dll - need_version=no - need_lib_prefix=no - # OS/2 can only load a DLL with a base name of 8 characters or less. - soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; - v=$($ECHO $release$versuffix | tr -d .-); - n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); - $ECHO $n$v`$shared_ext' - library_names_spec='${libname}_dll.$libext' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=BEGINLIBPATH - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - postinstall_cmds='base_file=`basename \$file`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='$libname$release$shared_ext$major' - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - -rdos*) - dynamic_linker=no - ;; - -solaris*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test yes = "$with_gnu_ld"; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec; then - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' - soname_spec='$libname$shared_ext.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=sco - need_lib_prefix=no - need_version=no - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - if test yes = "$with_gnu_ld"; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -tpf*) - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -uts4*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' - soname_spec='$libname$release$shared_ext$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -AC_MSG_RESULT([$dynamic_linker]) -test no = "$dynamic_linker" && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test yes = "$GCC"; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then - sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec -fi - -if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then - sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec -fi - -# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... -configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec - -# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code -func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" - -# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool -configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH - -_LT_DECL([], [variables_saved_for_relink], [1], - [Variables whose values should be saved in libtool wrapper scripts and - restored at link time]) -_LT_DECL([], [need_lib_prefix], [0], - [Do we need the "lib" prefix for modules?]) -_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) -_LT_DECL([], [version_type], [0], [Library versioning type]) -_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) -_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) -_LT_DECL([], [shlibpath_overrides_runpath], [0], - [Is shlibpath searched before the hard-coded library search path?]) -_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) -_LT_DECL([], [library_names_spec], [1], - [[List of archive names. First name is the real one, the rest are links. - The last name is the one that the linker finds with -lNAME]]) -_LT_DECL([], [soname_spec], [1], - [[The coded name of the library, if different from the real name]]) -_LT_DECL([], [install_override_mode], [1], - [Permission mode override for installation of shared libraries]) -_LT_DECL([], [postinstall_cmds], [2], - [Command to use after installation of a shared archive]) -_LT_DECL([], [postuninstall_cmds], [2], - [Command to use after uninstallation of a shared archive]) -_LT_DECL([], [finish_cmds], [2], - [Commands used to finish a libtool library installation in a directory]) -_LT_DECL([], [finish_eval], [1], - [[As "finish_cmds", except a single script fragment to be evaled but - not shown]]) -_LT_DECL([], [hardcode_into_libs], [0], - [Whether we should hardcode library paths into libraries]) -_LT_DECL([], [sys_lib_search_path_spec], [2], - [Compile-time system search path for libraries]) -_LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2], - [Detected run-time system search path for libraries]) -_LT_DECL([], [configure_time_lt_sys_library_path], [2], - [Explicit LT_SYS_LIBRARY_PATH set during ./configure time]) -])# _LT_SYS_DYNAMIC_LINKER - - -# _LT_PATH_TOOL_PREFIX(TOOL) -# -------------------------- -# find a file program that can recognize shared library -AC_DEFUN([_LT_PATH_TOOL_PREFIX], -[m4_require([_LT_DECL_EGREP])dnl -AC_MSG_CHECKING([for $1]) -AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, -[case $MAGIC_CMD in -[[\\/*] | ?:[\\/]*]) - lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD=$MAGIC_CMD - lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR -dnl $ac_dummy forces splitting on constant user-supplied paths. -dnl POSIX.2 word splitting is done only on the output of word expansions, -dnl not every word. This closes a longstanding sh security hole. - ac_dummy="m4_if([$2], , $PATH, [$2])" - for ac_dir in $ac_dummy; do - IFS=$lt_save_ifs - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$1"; then - lt_cv_path_MAGIC_CMD=$ac_dir/"$1" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD=$lt_cv_path_MAGIC_CMD - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS=$lt_save_ifs - MAGIC_CMD=$lt_save_MAGIC_CMD - ;; -esac]) -MAGIC_CMD=$lt_cv_path_MAGIC_CMD -if test -n "$MAGIC_CMD"; then - AC_MSG_RESULT($MAGIC_CMD) -else - AC_MSG_RESULT(no) -fi -_LT_DECL([], [MAGIC_CMD], [0], - [Used to examine libraries when file_magic_cmd begins with "file"])dnl -])# _LT_PATH_TOOL_PREFIX - -# Old name: -AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) - - -# _LT_PATH_MAGIC -# -------------- -# find a file program that can recognize a shared library -m4_defun([_LT_PATH_MAGIC], -[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) - else - MAGIC_CMD=: - fi -fi -])# _LT_PATH_MAGIC - - -# LT_PATH_LD -# ---------- -# find the pathname to the GNU or non-GNU linker -AC_DEFUN([LT_PATH_LD], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_PROG_ECHO_BACKSLASH])dnl - -AC_ARG_WITH([gnu-ld], - [AS_HELP_STRING([--with-gnu-ld], - [assume the C compiler uses GNU ld @<:@default=no@:>@])], - [test no = "$withval" || with_gnu_ld=yes], - [with_gnu_ld=no])dnl - -ac_prog=ld -if test yes = "$GCC"; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by $CC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return, which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]]* | ?:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD=$ac_prog - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test yes = "$with_gnu_ld"; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL(lt_cv_path_LD, -[if test -z "$LD"; then - lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS=$lt_save_ifs - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD=$ac_dir/$ac_prog - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &1 conftest.i -cat conftest.i conftest.i >conftest2.i -: ${lt_DD:=$DD} -AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd], -[if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then - cmp -s conftest.i conftest.out \ - && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: -fi]) -rm -f conftest.i conftest2.i conftest.out]) -])# _LT_PATH_DD - - -# _LT_CMD_TRUNCATE -# ---------------- -# find command to truncate a binary pipe -m4_defun([_LT_CMD_TRUNCATE], -[m4_require([_LT_PATH_DD]) -AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin], -[printf 0123456789abcdef0123456789abcdef >conftest.i -cat conftest.i conftest.i >conftest2.i -lt_cv_truncate_bin= -if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then - cmp -s conftest.i conftest.out \ - && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" -fi -rm -f conftest.i conftest2.i conftest.out -test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"]) -_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1], - [Command to truncate a binary pipe]) -])# _LT_CMD_TRUNCATE - - -# _LT_CHECK_MAGIC_METHOD -# ---------------------- -# how to check for library dependencies -# -- PORTME fill in with the dynamic library characteristics -m4_defun([_LT_CHECK_MAGIC_METHOD], -[m4_require([_LT_DECL_EGREP]) -m4_require([_LT_DECL_OBJDUMP]) -AC_CACHE_CHECK([how to recognize dependent libraries], -lt_cv_deplibs_check_method, -[lt_cv_file_magic_cmd='$MAGIC_CMD' -lt_cv_file_magic_test_file= -lt_cv_deplibs_check_method='unknown' -# Need to set the preceding variable on all platforms that support -# interlibrary dependencies. -# 'none' -- dependencies not supported. -# 'unknown' -- same as none, but documents that we really don't know. -# 'pass_all' -- all dependencies passed with no checks. -# 'test_compile' -- check by making test program. -# 'file_magic [[regex]]' -- check by looking for files in library path -# that responds to the $file_magic_cmd with a given extended regex. -# If you have 'file' or equivalent on your system and you're not sure -# whether 'pass_all' will *always* work, you probably want this one. - -case $host_os in -aix[[4-9]]*) - lt_cv_deplibs_check_method=pass_all - ;; - -beos*) - lt_cv_deplibs_check_method=pass_all - ;; - -bsdi[[45]]*) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' - lt_cv_file_magic_test_file=/shlib/libc.so - ;; - -cygwin*) - # func_win32_libid is a shell function defined in ltmain.sh - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - ;; - -mingw* | pw32*) - # Base MSYS/MinGW do not provide the 'file' command needed by - # func_win32_libid shell function, so use a weaker test based on 'objdump', - # unless we find 'file', for example because we are cross-compiling. - if ( file / ) >/dev/null 2>&1; then - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - else - # Keep this pattern in sync with the one in func_win32_libid. - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' - lt_cv_file_magic_cmd='$OBJDUMP -f' - fi - ;; - -cegcc*) - # use the weaker test based on 'objdump'. See mingw*. - lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method=pass_all - ;; - -freebsd* | dragonfly*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -haiku*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix[[3-9]]*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -*nto* | *qnx*) - lt_cv_deplibs_check_method=pass_all - ;; - -openbsd* | bitrig*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -rdos*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -tpf*) - lt_cv_deplibs_check_method=pass_all - ;; -os2*) - lt_cv_deplibs_check_method=pass_all - ;; -esac -]) - -file_magic_glob= -want_nocaseglob=no -if test "$build" = "$host"; then - case $host_os in - mingw* | pw32*) - if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then - want_nocaseglob=yes - else - file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` - fi - ;; - esac -fi - -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown - -_LT_DECL([], [deplibs_check_method], [1], - [Method to check whether dependent libraries are shared objects]) -_LT_DECL([], [file_magic_cmd], [1], - [Command to use when deplibs_check_method = "file_magic"]) -_LT_DECL([], [file_magic_glob], [1], - [How to find potential files when deplibs_check_method = "file_magic"]) -_LT_DECL([], [want_nocaseglob], [1], - [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) -])# _LT_CHECK_MAGIC_METHOD - - -# LT_PATH_NM -# ---------- -# find the pathname to a BSD- or MS-compatible name lister -AC_DEFUN([LT_PATH_NM], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, -[if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM=$NM -else - lt_nm_to_check=${ac_tool_prefix}nm - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS=$lt_save_ifs - test -z "$ac_dir" && ac_dir=. - tmp_nm=$ac_dir/$lt_tmp_nm - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the 'sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty - case $build_os in - mingw*) lt_bad_file=conftest.nm/nofile ;; - *) lt_bad_file=/dev/null ;; - esac - case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in - *$lt_bad_file* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break 2 - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break 2 - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS=$lt_save_ifs - done - : ${lt_cv_path_NM=no} -fi]) -if test no != "$lt_cv_path_NM"; then - NM=$lt_cv_path_NM -else - # Didn't find any BSD compatible name lister, look for dumpbin. - if test -n "$DUMPBIN"; then : - # Let the user override the test. - else - AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) - case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in - *COFF*) - DUMPBIN="$DUMPBIN -symbols -headers" - ;; - *) - DUMPBIN=: - ;; - esac - fi - AC_SUBST([DUMPBIN]) - if test : != "$DUMPBIN"; then - NM=$DUMPBIN - fi -fi -test -z "$NM" && NM=nm -AC_SUBST([NM]) -_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl - -AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], - [lt_cv_nm_interface="BSD nm" - echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) - cat conftest.out >&AS_MESSAGE_LOG_FD - if $GREP 'External.*some_variable' conftest.out > /dev/null; then - lt_cv_nm_interface="MS dumpbin" - fi - rm -f conftest*]) -])# LT_PATH_NM - -# Old names: -AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) -AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_PROG_NM], []) -dnl AC_DEFUN([AC_PROG_NM], []) - -# _LT_CHECK_SHAREDLIB_FROM_LINKLIB -# -------------------------------- -# how to determine the name of the shared library -# associated with a specific link library. -# -- PORTME fill in with the dynamic library characteristics -m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], -[m4_require([_LT_DECL_EGREP]) -m4_require([_LT_DECL_OBJDUMP]) -m4_require([_LT_DECL_DLLTOOL]) -AC_CACHE_CHECK([how to associate runtime and link libraries], -lt_cv_sharedlib_from_linklib_cmd, -[lt_cv_sharedlib_from_linklib_cmd='unknown' - -case $host_os in -cygwin* | mingw* | pw32* | cegcc*) - # two different shell functions defined in ltmain.sh; - # decide which one to use based on capabilities of $DLLTOOL - case `$DLLTOOL --help 2>&1` in - *--identify-strict*) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib - ;; - *) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback - ;; - esac - ;; -*) - # fallback: assume linklib IS sharedlib - lt_cv_sharedlib_from_linklib_cmd=$ECHO - ;; -esac -]) -sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd -test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO - -_LT_DECL([], [sharedlib_from_linklib_cmd], [1], - [Command to associate shared and link libraries]) -])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB - - -# _LT_PATH_MANIFEST_TOOL -# ---------------------- -# locate the manifest tool -m4_defun([_LT_PATH_MANIFEST_TOOL], -[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) -test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt -AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], - [lt_cv_path_mainfest_tool=no - echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD - $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out - cat conftest.err >&AS_MESSAGE_LOG_FD - if $GREP 'Manifest Tool' conftest.out > /dev/null; then - lt_cv_path_mainfest_tool=yes - fi - rm -f conftest*]) -if test yes != "$lt_cv_path_mainfest_tool"; then - MANIFEST_TOOL=: -fi -_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl -])# _LT_PATH_MANIFEST_TOOL - - -# _LT_DLL_DEF_P([FILE]) -# --------------------- -# True iff FILE is a Windows DLL '.def' file. -# Keep in sync with func_dll_def_p in the libtool script -AC_DEFUN([_LT_DLL_DEF_P], -[dnl - test DEF = "`$SED -n dnl - -e '\''s/^[[ ]]*//'\'' dnl Strip leading whitespace - -e '\''/^\(;.*\)*$/d'\'' dnl Delete empty lines and comments - -e '\''s/^\(EXPORTS\|LIBRARY\)\([[ ]].*\)*$/DEF/p'\'' dnl - -e q dnl Only consider the first "real" line - $1`" dnl -])# _LT_DLL_DEF_P - - -# LT_LIB_M -# -------- -# check for math library -AC_DEFUN([LT_LIB_M], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -LIBM= -case $host in -*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) - # These system don't have libm, or don't need it - ;; -*-ncr-sysv4.3*) - AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw) - AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") - ;; -*) - AC_CHECK_LIB(m, cos, LIBM=-lm) - ;; -esac -AC_SUBST([LIBM]) -])# LT_LIB_M - -# Old name: -AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_CHECK_LIBM], []) - - -# _LT_COMPILER_NO_RTTI([TAGNAME]) -# ------------------------------- -m4_defun([_LT_COMPILER_NO_RTTI], -[m4_require([_LT_TAG_COMPILER])dnl - -_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - -if test yes = "$GCC"; then - case $cc_basename in - nvcc*) - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; - *) - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; - esac - - _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], - lt_cv_prog_compiler_rtti_exceptions, - [-fno-rtti -fno-exceptions], [], - [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) -fi -_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], - [Compiler flag to turn off builtin functions]) -])# _LT_COMPILER_NO_RTTI - - -# _LT_CMD_GLOBAL_SYMBOLS -# ---------------------- -m4_defun([_LT_CMD_GLOBAL_SYMBOLS], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_PROG_AWK])dnl -AC_REQUIRE([LT_PATH_NM])dnl -AC_REQUIRE([LT_PATH_LD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_TAG_COMPILER])dnl - -# Check for command to grab the raw symbol name followed by C symbol from nm. -AC_MSG_CHECKING([command to parse $NM output from $compiler object]) -AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], -[ -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[[BCDEGRST]]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[[BCDT]]' - ;; -cygwin* | mingw* | pw32* | cegcc*) - symcode='[[ABCDGISTW]]' - ;; -hpux*) - if test ia64 = "$host_cpu"; then - symcode='[[ABCDEGRST]]' - fi - ;; -irix* | nonstopux*) - symcode='[[BCDEGRST]]' - ;; -osf*) - symcode='[[BCDEGQRST]]' - ;; -solaris*) - symcode='[[BDRT]]' - ;; -sco3.2v5*) - symcode='[[DT]]' - ;; -sysv4.2uw2*) - symcode='[[DT]]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[[ABDT]]' - ;; -sysv4) - symcode='[[DFNSTU]]' - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[[ABCDGIRSTW]]' ;; -esac - -if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Gets list of data symbols to import. - lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" - # Adjust the below global symbol transforms to fixup imported variables. - lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" - lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" - lt_c_name_lib_hook="\ - -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ - -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" -else - # Disable hooks by default. - lt_cv_sys_global_symbol_to_import= - lt_cdecl_hook= - lt_c_name_hook= - lt_c_name_lib_hook= -fi - -# Transform an extracted symbol line into a proper C declaration. -# Some systems (esp. on ia64) link data and code symbols differently, -# so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n"\ -$lt_cdecl_hook\ -" -e 's/^T .* \(.*\)$/extern int \1();/p'"\ -" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ -$lt_c_name_hook\ -" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ -" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" - -# Transform an extracted symbol line into symbol name with lib prefix and -# symbol address. -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ -$lt_c_name_lib_hook\ -" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ -" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ -" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# Try without a prefix underscore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function, - # D for any global variable and I for any imported variable. - # Also find C++ and __fastcall symbols from MSVC++, - # which start with @ or ?. - lt_cv_sys_global_symbol_pipe="$AWK ['"\ -" {last_section=section; section=\$ 3};"\ -" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ -" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ -" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ -" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ -" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ -" \$ 0!~/External *\|/{next};"\ -" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ -" {if(hide[section]) next};"\ -" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ -" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ -" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ -" ' prfx=^$ac_symprfx]" - else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - fi - lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext <<_LT_EOF -#ifdef __cplusplus -extern "C" { -#endif -char nm_test_var; -void nm_test_func(void); -void nm_test_func(void){} -#ifdef __cplusplus -} -#endif -int main(){nm_test_var='a';nm_test_func();return(0);} -_LT_EOF - - if AC_TRY_EVAL(ac_compile); then - # Now try to grab the symbols. - nlist=conftest.nm - if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if $GREP ' nm_test_var$' "$nlist" >/dev/null; then - if $GREP ' nm_test_func$' "$nlist" >/dev/null; then - cat <<_LT_EOF > conftest.$ac_ext -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE -/* DATA imports from DLLs on WIN32 can't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT@&t@_DLSYM_CONST -#elif defined __osf__ -/* This system does not cope well with relocations in const data. */ -# define LT@&t@_DLSYM_CONST -#else -# define LT@&t@_DLSYM_CONST const -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -_LT_EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' - - cat <<_LT_EOF >> conftest.$ac_ext - -/* The mapping between symbol names and symbols. */ -LT@&t@_DLSYM_CONST struct { - const char *name; - void *address; -} -lt__PROGRAM__LTX_preloaded_symbols[[]] = -{ - { "@PROGRAM@", (void *) 0 }, -_LT_EOF - $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext - cat <<\_LT_EOF >> conftest.$ac_ext - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt__PROGRAM__LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif -_LT_EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_globsym_save_LIBS=$LIBS - lt_globsym_save_CFLAGS=$CFLAGS - LIBS=conftstm.$ac_objext - CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" - if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then - pipe_works=yes - fi - LIBS=$lt_globsym_save_LIBS - CFLAGS=$lt_globsym_save_CFLAGS - else - echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD - fi - else - echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD - cat conftest.$ac_ext >&5 - fi - rm -rf conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test yes = "$pipe_works"; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done -]) -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - AC_MSG_RESULT(failed) -else - AC_MSG_RESULT(ok) -fi - -# Response file support. -if test "$lt_cv_nm_interface" = "MS dumpbin"; then - nm_file_list_spec='@' -elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then - nm_file_list_spec='@' -fi - -_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], - [Take the output of nm and produce a listing of raw symbols and C names]) -_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], - [Transform the output of nm in a proper C declaration]) -_LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1], - [Transform the output of nm into a list of symbols to manually relocate]) -_LT_DECL([global_symbol_to_c_name_address], - [lt_cv_sys_global_symbol_to_c_name_address], [1], - [Transform the output of nm in a C name address pair]) -_LT_DECL([global_symbol_to_c_name_address_lib_prefix], - [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], - [Transform the output of nm in a C name address pair when lib prefix is needed]) -_LT_DECL([nm_interface], [lt_cv_nm_interface], [1], - [The name lister interface]) -_LT_DECL([], [nm_file_list_spec], [1], - [Specify filename containing input files for $NM]) -]) # _LT_CMD_GLOBAL_SYMBOLS - - -# _LT_COMPILER_PIC([TAGNAME]) -# --------------------------- -m4_defun([_LT_COMPILER_PIC], -[m4_require([_LT_TAG_COMPILER])dnl -_LT_TAGVAR(lt_prog_compiler_wl, $1)= -_LT_TAGVAR(lt_prog_compiler_pic, $1)= -_LT_TAGVAR(lt_prog_compiler_static, $1)= - -m4_if([$1], [CXX], [ - # C++ specific cases for pic, static, wl, etc. - if test yes = "$GXX"; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test ia64 = "$host_cpu"; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the '-m68020' flag to GCC prevents building anything better, - # like '-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - case $host_os in - os2*) - _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' - ;; - esac - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - _LT_TAGVAR(lt_prog_compiler_static, $1)= - ;; - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - case $host_os in - aix[[4-9]]*) - # All AIX code is PIC. - if test ia64 = "$host_cpu"; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68*) - # Green Hills C++ Compiler - # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" - ;; - esac - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - dgux*) - case $cc_basename in - ec++*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - ghcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | dragonfly*) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' - if test ia64 != "$host_cpu"; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - fi - ;; - aCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - interix*) - # This is c89, which is MS Visual C++ (no shared libs) - # Anyone wants to do a port? - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) - case $cc_basename in - KCC*) - # KAI C++ Compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - ecpc* ) - # old Intel C++ for x86_64, which still supported -KPIC. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - icpc* ) - # Intel C++, used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - cxx*) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) - # IBM XL 8.0, 9.0 on PPC and BlueGene - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - esac - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd*) - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - ;; - RCC*) - # Rational C++ 2.4.1 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - cxx*) - # Digital/Compaq C++ - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - solaris*) - case $cc_basename in - CC* | sunCC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - lcc*) - # Lucid - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - *) - ;; - esac - ;; - vxworks*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -], -[ - if test yes = "$GCC"; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test ia64 = "$host_cpu"; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the '-m68020' flag to GCC prevents building anything better, - # like '-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - case $host_os in - os2*) - _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' - ;; - esac - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - _LT_TAGVAR(lt_prog_compiler_static, $1)= - ;; - - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - enable_shared=no - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - - case $cc_basename in - nvcc*) # Cuda Compiler Driver 2.2 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' - if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" - fi - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - if test ia64 = "$host_cpu"; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - case $cc_basename in - nagfor*) - # NAG Fortran compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - esac - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - case $host_os in - os2*) - _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' - ;; - esac - ;; - - hpux9* | hpux10* | hpux11*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC (with -KPIC) is the default. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) - case $cc_basename in - # old Intel for x86_64, which still supported -KPIC. - ecc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # icc used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - icc* | ifort*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # Lahey Fortran 8.1. - lf95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' - _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' - ;; - nagfor*) - # NAG Fortran compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - tcc*) - # Fabrice Bellard et al's Tiny C Compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - ccc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All Alpha code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xl* | bgxl* | bgf* | mpixl*) - # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='' - ;; - *Sun\ F* | *Sun*Fortran*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - *Sun\ C*) - # Sun C 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - ;; - *Intel*\ [[CF]]*Compiler*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - *Portland\ Group*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - esac - ;; - esac - ;; - - newsos6) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - osf3* | osf4* | osf5*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All OSF/1 code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - rdos*) - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - solaris*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - case $cc_basename in - f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; - *) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; - esac - ;; - - sunos4*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - unicos*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - - uts4*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -]) -case $host_os in - # For platforms that do not support PIC, -DPIC is meaningless: - *djgpp*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" - ;; -esac - -AC_CACHE_CHECK([for $compiler option to produce PIC], - [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], - [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) -_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then - _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], - [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], - [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], - [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in - "" | " "*) ;; - *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; - esac], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) -fi -_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], - [Additional compiler flags for building library objects]) - -_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], - [How to pass a linker flag through the compiler]) -# -# Check to make sure the static flag actually works. -# -wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" -_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], - _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), - $lt_tmp_static_flag, - [], - [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) -_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], - [Compiler flag to prevent dynamic linking]) -])# _LT_COMPILER_PIC - - -# _LT_LINKER_SHLIBS([TAGNAME]) -# ---------------------------- -# See if the linker supports building shared libraries. -m4_defun([_LT_LINKER_SHLIBS], -[AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -m4_require([_LT_PATH_MANIFEST_TOOL])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -m4_if([$1], [CXX], [ - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] - case $host_os in - aix[[4-9]]*) - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to GNU nm, but means don't demangle to AIX nm. - # Without the "-l" option, or with the "-B" option, AIX nm treats - # weak defined symbols like other global defined symbols, whereas - # GNU nm marks them as "W". - # While the 'weak' keyword is ignored in the Export File, we need - # it in the Import File for the 'aix-soname' feature, so we have - # to replace the "-B" option with "-P" for AIX nm. - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' - fi - ;; - pw32*) - _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds - ;; - cygwin* | mingw* | cegcc*) - case $cc_basename in - cl*) - _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - ;; - *) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] - ;; - esac - ;; - *) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac -], [ - runpath_var= - _LT_TAGVAR(allow_undefined_flag, $1)= - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(archive_cmds, $1)= - _LT_TAGVAR(archive_expsym_cmds, $1)= - _LT_TAGVAR(compiler_needs_object, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(hardcode_automatic, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_separator, $1)= - _LT_TAGVAR(hardcode_minus_L, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_TAGVAR(inherit_rpath, $1)=no - _LT_TAGVAR(link_all_deplibs, $1)=unknown - _LT_TAGVAR(module_cmds, $1)= - _LT_TAGVAR(module_expsym_cmds, $1)= - _LT_TAGVAR(old_archive_from_new_cmds, $1)= - _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= - _LT_TAGVAR(thread_safe_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - _LT_TAGVAR(include_expsyms, $1)= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ' (' and ')$', so one must not match beginning or - # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', - # as well as any symbol that contains 'd'. - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - # Exclude shared library initialization/finalization symbols. -dnl Note also adjust exclude_expsyms for C++ above. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test yes != "$GCC"; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd* | bitrig*) - with_gnu_ld=no - ;; - esac - - _LT_TAGVAR(ld_shlibs, $1)=yes - - # On some targets, GNU ld is compatible enough with the native linker - # that we're better off using the native interface for both. - lt_use_gnu_ld_interface=no - if test yes = "$with_gnu_ld"; then - case $host_os in - aix*) - # The AIX port of GNU ld has always aspired to compatibility - # with the native linker. However, as the warning in the GNU ld - # block says, versions before 2.19.5* couldn't really create working - # shared libraries, regardless of the interface used. - case `$LD -v 2>&1` in - *\ \(GNU\ Binutils\)\ 2.19.5*) ;; - *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; - *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - fi - - if test yes = "$lt_use_gnu_ld_interface"; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='$wl' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - supports_anon_versioning=no - case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in - *GNU\ gold*) supports_anon_versioning=yes ;; - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix[[3-9]]*) - # On AIX/PPC, the GNU linker is very broken - if test ia64 != "$host_cpu"; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: the GNU linker, at least up to release 2.19, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to install binutils -*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. -*** You will then need to restart the configuration process. - -_LT_EOF - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file, use it as - # is; otherwise, prepend EXPORTS... - _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - haiku*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - os2*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - shrext_cmds=.dll - _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ - $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ - $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ - $ECHO EXPORTS >> $output_objdir/$libname.def~ - emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ - $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ - emximp -o $lib $output_objdir/$libname.def' - _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ - $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ - $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ - $ECHO EXPORTS >> $output_objdir/$libname.def~ - prefix_cmds="$SED"~ - if test EXPORTS = "`$SED 1q $export_symbols`"; then - prefix_cmds="$prefix_cmds -e 1d"; - fi~ - prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ - cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ - $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ - emximp -o $lib $output_objdir/$libname.def' - _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) - tmp_diet=no - if test linux-dietlibc = "$host_os"; then - case $cc_basename in - diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) - esac - fi - if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test no = "$tmp_diet" - then - tmp_addflag=' $pic_flag' - tmp_sharedflag='-shared' - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95* | pgfortran*) - # Portland Group f77 and f90 compilers - _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - lf95*) # Lahey Fortran 8.1 - _LT_TAGVAR(whole_archive_flag_spec, $1)= - tmp_sharedflag='--shared' ;; - nagfor*) # NAGFOR 5.3 - tmp_sharedflag='-Wl,-shared' ;; - xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; - nvcc*) # Cuda Compiler Driver 2.2 - _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - ;; - esac - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) # Sun C 5.9 - _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - tmp_sharedflag='-G' ;; - *Sun\ F*) # Sun Fortran 8.3 - tmp_sharedflag='-G' ;; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - - if test yes = "$supports_anon_versioning"; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' - fi - - case $cc_basename in - tcc*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic' - ;; - xlf* | bgf* | bgxlf* | mpixlf*) - # IBM XL Fortran 10.1 on PPC cannot create shared libs itself - _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' - _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' - if test yes = "$supports_anon_versioning"; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' - fi - ;; - esac - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - sunos4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - - if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then - runpath_var= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - _LT_TAGVAR(hardcode_direct, $1)=unsupported - fi - ;; - - aix[[4-9]]*) - if test ia64 = "$host_cpu"; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag= - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to GNU nm, but means don't demangle to AIX nm. - # Without the "-l" option, or with the "-B" option, AIX nm treats - # weak defined symbols like other global defined symbols, whereas - # GNU nm marks them as "W". - # While the 'weak' keyword is ignored in the Export File, we need - # it in the Import File for the 'aix-soname' feature, so we have - # to replace the "-B" option with "-P" for AIX nm. - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # have runtime linking enabled, and use it for executables. - # For shared libraries, we enable/disable runtime linking - # depending on the kind of the shared library created - - # when "with_aix_soname,aix_use_runtimelinking" is: - # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables - # "aix,yes" lib.so shared, rtl:yes, for executables - # lib.a static archive - # "both,no" lib.so.V(shr.o) shared, rtl:yes - # lib.a(lib.so.V) shared, rtl:no, for executables - # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables - # lib.a(lib.so.V) shared, rtl:no - # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables - # lib.a static archive - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then - aix_use_runtimelinking=yes - break - fi - done - if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then - # With aix-soname=svr4, we create the lib.so.V shared archives only, - # so we don't have lib.a shared libs to link our executables. - # We have to force runtime linking in this case. - aix_use_runtimelinking=yes - LDFLAGS="$LDFLAGS -Wl,-brtl" - fi - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='$wl-f,' - case $with_aix_soname,$aix_use_runtimelinking in - aix,*) ;; # traditional, no import file - svr4,* | *,yes) # use import file - # The Import File defines what to hardcode. - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=no - ;; - esac - - if test yes = "$GCC"; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`$CC -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - ;; - esac - shared_flag='-shared' - if test yes = "$aix_use_runtimelinking"; then - shared_flag="$shared_flag "'$wl-G' - fi - # Need to ensure runtime linking is disabled for the traditional - # shared library, or the linker may eventually find shared libraries - # /with/ Import File - we do not want to mix them. - shared_flag_aix='-shared' - shared_flag_svr4='-shared $wl-G' - else - # not using gcc - if test ia64 = "$host_cpu"; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test yes = "$aix_use_runtimelinking"; then - shared_flag='$wl-G' - else - shared_flag='$wl-bM:SRE' - fi - shared_flag_aix='$wl-bM:SRE' - shared_flag_svr4='$wl-G' - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag - else - if test ia64 = "$host_cpu"; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' - if test yes = "$with_gnu_ld"; then - # We only use this code for GNU lds that support --whole-archive. - _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' - # -brtl affects multiple linker settings, -berok does not and is overridden later - compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' - if test svr4 != "$with_aix_soname"; then - # This is similar to how AIX traditionally builds its shared libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' - fi - if test aix != "$with_aix_soname"; then - _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' - else - # used by -dlpreopen to get the symbols - _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' - fi - _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' - fi - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - bsdi[[45]]*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - case $cc_basename in - cl*) - # Native MSVC - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='@' - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=.dll - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then - cp "$export_symbols" "$output_objdir/$soname.def"; - echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; - else - $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' - # Don't use ranlib - _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' - _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile=$lt_outputfile.exe - lt_tool_outputfile=$lt_tool_outputfile.exe - ;; - esac~ - if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # Assume MSVC wrapper - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=.dll - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - # FIXME: Should let the user specify the lib program. - _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - esac - ;; - - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - dgux*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2.*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - hpux9*) - if test yes = "$GCC"; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' - ;; - - hpux10*) - if test yes,no = "$GCC,$with_gnu_ld"; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test no = "$with_gnu_ld"; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - fi - ;; - - hpux11*) - if test yes,no = "$GCC,$with_gnu_ld"; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - m4_if($1, [], [ - # Older versions of the 11.00 compiler do not understand -b yet - # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) - _LT_LINKER_OPTION([if $CC understands -b], - _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], - [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], - [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], - [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) - ;; - esac - fi - if test no = "$with_gnu_ld"; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test yes = "$GCC"; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' - # Try to use the -exported_symbol ld option, if it does not - # work, assume that -exports_file does not work either and - # implicitly export all symbols. - # This should be the same for all languages, so no per-tag cache variable. - AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], - [lt_cv_irix_exported_symbol], - [save_LDFLAGS=$LDFLAGS - LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" - AC_LINK_IFELSE( - [AC_LANG_SOURCE( - [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], - [C++], [[int foo (void) { return 0; }]], - [Fortran 77], [[ - subroutine foo - end]], - [Fortran], [[ - subroutine foo - end]])])], - [lt_cv_irix_exported_symbol=yes], - [lt_cv_irix_exported_symbol=no]) - LDFLAGS=$save_LDFLAGS]) - if test yes = "$lt_cv_irix_exported_symbol"; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' - fi - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - linux*) - case $cc_basename in - tcc*) - # Fabrice Bellard et al's Tiny C Compiler - _LT_TAGVAR(ld_shlibs, $1)=yes - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - newsos6) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *nto* | *qnx*) - ;; - - openbsd* | bitrig*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' - fi - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - os2*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - shrext_cmds=.dll - _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ - $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ - $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ - $ECHO EXPORTS >> $output_objdir/$libname.def~ - emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ - $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ - emximp -o $lib $output_objdir/$libname.def' - _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ - $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ - $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ - $ECHO EXPORTS >> $output_objdir/$libname.def~ - prefix_cmds="$SED"~ - if test EXPORTS = "`$SED 1q $export_symbols`"; then - prefix_cmds="$prefix_cmds -e 1d"; - fi~ - prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ - cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ - $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ - emximp -o $lib $output_objdir/$libname.def' - _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - - osf3*) - if test yes = "$GCC"; then - _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test yes = "$GCC"; then - _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' - - # Both c and cxx compiler support -rpath directly - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - solaris*) - _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' - if test yes = "$GCC"; then - wlarc='$wl' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - else - case `$CC -V 2>&1` in - *"Compilers 5.0"*) - wlarc='' - _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' - ;; - *) - wlarc='$wl' - _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - ;; - esac - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands '-z linker_flag'. GCC discards it without '$wl', - # but is careful enough not to reorder. - # Supported since Solaris 2.6 (maybe 2.5.1?) - if test yes = "$GCC"; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - fi - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - sunos4*) - if test sequent = "$host_vendor"; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4) - case $host_vendor in - sni) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' - _LT_TAGVAR(hardcode_direct, $1)=no - ;; - motorola) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4.3*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - _LT_TAGVAR(ld_shlibs, $1)=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - if test yes = "$GCC"; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We CANNOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' - runpath_var='LD_RUN_PATH' - - if test yes = "$GCC"; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - if test sni = "$host_vendor"; then - case $host in - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym' - ;; - esac - fi - fi -]) -AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) -test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no - -_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld - -_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl -_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl -_LT_DECL([], [extract_expsyms_cmds], [2], - [The commands to extract the exported symbol list from a shared archive]) - -# -# Do we need to explicitly link libc? -# -case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in -x|xyes) - # Assume -lc should be added - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - - if test yes,yes = "$GCC,$enable_shared"; then - case $_LT_TAGVAR(archive_cmds, $1) in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - AC_CACHE_CHECK([whether -lc should be explicitly linked in], - [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), - [$RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if AC_TRY_EVAL(ac_compile) 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) - pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) - _LT_TAGVAR(allow_undefined_flag, $1)= - if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) - then - lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no - else - lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes - fi - _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - ]) - _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) - ;; - esac - fi - ;; -esac - -_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], - [Whether or not to add -lc for building shared libraries]) -_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], - [enable_shared_with_static_runtimes], [0], - [Whether or not to disallow shared libs when runtime libs are static]) -_LT_TAGDECL([], [export_dynamic_flag_spec], [1], - [Compiler flag to allow reflexive dlopens]) -_LT_TAGDECL([], [whole_archive_flag_spec], [1], - [Compiler flag to generate shared objects directly from archives]) -_LT_TAGDECL([], [compiler_needs_object], [1], - [Whether the compiler copes with passing no objects directly]) -_LT_TAGDECL([], [old_archive_from_new_cmds], [2], - [Create an old-style archive from a shared archive]) -_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], - [Create a temporary old-style archive to link instead of a shared archive]) -_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) -_LT_TAGDECL([], [archive_expsym_cmds], [2]) -_LT_TAGDECL([], [module_cmds], [2], - [Commands used to build a loadable module if different from building - a shared archive.]) -_LT_TAGDECL([], [module_expsym_cmds], [2]) -_LT_TAGDECL([], [with_gnu_ld], [1], - [Whether we are building with GNU ld or not]) -_LT_TAGDECL([], [allow_undefined_flag], [1], - [Flag that allows shared libraries with undefined symbols to be built]) -_LT_TAGDECL([], [no_undefined_flag], [1], - [Flag that enforces no undefined symbols]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], - [Flag to hardcode $libdir into a binary during linking. - This must work even if $libdir does not exist]) -_LT_TAGDECL([], [hardcode_libdir_separator], [1], - [Whether we need a single "-rpath" flag with a separated argument]) -_LT_TAGDECL([], [hardcode_direct], [0], - [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes - DIR into the resulting binary]) -_LT_TAGDECL([], [hardcode_direct_absolute], [0], - [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes - DIR into the resulting binary and the resulting library dependency is - "absolute", i.e impossible to change by setting $shlibpath_var if the - library is relocated]) -_LT_TAGDECL([], [hardcode_minus_L], [0], - [Set to "yes" if using the -LDIR flag during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_shlibpath_var], [0], - [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_automatic], [0], - [Set to "yes" if building a shared library automatically hardcodes DIR - into the library and all subsequent libraries and executables linked - against it]) -_LT_TAGDECL([], [inherit_rpath], [0], - [Set to yes if linker adds runtime paths of dependent libraries - to runtime path list]) -_LT_TAGDECL([], [link_all_deplibs], [0], - [Whether libtool must link a program against all its dependency libraries]) -_LT_TAGDECL([], [always_export_symbols], [0], - [Set to "yes" if exported symbols are required]) -_LT_TAGDECL([], [export_symbols_cmds], [2], - [The commands to list exported symbols]) -_LT_TAGDECL([], [exclude_expsyms], [1], - [Symbols that should not be listed in the preloaded symbols]) -_LT_TAGDECL([], [include_expsyms], [1], - [Symbols that must always be exported]) -_LT_TAGDECL([], [prelink_cmds], [2], - [Commands necessary for linking programs (against libraries) with templates]) -_LT_TAGDECL([], [postlink_cmds], [2], - [Commands necessary for finishing linking programs]) -_LT_TAGDECL([], [file_list_spec], [1], - [Specify filename containing input files]) -dnl FIXME: Not yet implemented -dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], -dnl [Compiler flag to generate thread safe objects]) -])# _LT_LINKER_SHLIBS - - -# _LT_LANG_C_CONFIG([TAG]) -# ------------------------ -# Ensure that the configuration variables for a C compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to 'libtool'. -m4_defun([_LT_LANG_C_CONFIG], -[m4_require([_LT_DECL_EGREP])dnl -lt_save_CC=$CC -AC_LANG_PUSH(C) - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}' - -_LT_TAG_COMPILER -# Save the default compiler, since it gets overwritten when the other -# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. -compiler_DEFAULT=$CC - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - LT_SYS_DLOPEN_SELF - _LT_CMD_STRIPLIB - - # Report what library types will actually be built - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test no = "$can_build_shared" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test yes = "$enable_shared" && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - - aix[[4-9]]*) - if test ia64 != "$host_cpu"; then - case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in - yes,aix,yes) ;; # shared object as lib.so file only - yes,svr4,*) ;; # shared object as lib.so archive member only - yes,*) enable_static=no ;; # shared object in lib.a archive as well - esac - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test yes = "$enable_shared" || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_CONFIG($1) -fi -AC_LANG_POP -CC=$lt_save_CC -])# _LT_LANG_C_CONFIG - - -# _LT_LANG_CXX_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a C++ compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to 'libtool'. -m4_defun([_LT_LANG_CXX_CONFIG], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_PATH_MANIFEST_TOOL])dnl -if test -n "$CXX" && ( test no != "$CXX" && - ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || - (test g++ != "$CXX"))); then - AC_PROG_CXXCPP -else - _lt_caught_CXX_error=yes -fi - -AC_LANG_PUSH(C++) -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(compiler_needs_object, $1)=no -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for C++ test sources. -ac_ext=cpp - -# Object file extension for compiled C++ test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the CXX compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test yes != "$_lt_caught_CXX_error"; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="int some_variable = 0;" - - # Code to be used in simple link tests - lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC=$CC - lt_save_CFLAGS=$CFLAGS - lt_save_LD=$LD - lt_save_GCC=$GCC - GCC=$GXX - lt_save_with_gnu_ld=$with_gnu_ld - lt_save_path_LD=$lt_cv_path_LD - if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then - lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx - else - $as_unset lt_cv_prog_gnu_ld - fi - if test -n "${lt_cv_path_LDCXX+set}"; then - lt_cv_path_LD=$lt_cv_path_LDCXX - else - $as_unset lt_cv_path_LD - fi - test -z "${LDCXX+set}" || LD=$LDCXX - CC=${CXX-"c++"} - CFLAGS=$CXXFLAGS - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - # We don't want -fno-exception when compiling C++ code, so set the - # no_builtin_flag separately - if test yes = "$GXX"; then - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - else - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - fi - - if test yes = "$GXX"; then - # Set up default GNU C++ configuration - - LT_PATH_LD - - # Check if GNU C++ uses GNU ld as the underlying linker, since the - # archiving commands below assume that GNU ld is being used. - if test yes = "$with_gnu_ld"; then - _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' - - # If archive_cmds runs LD, not CC, wlarc should be empty - # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to - # investigate it a little bit more. (MM) - wlarc='$wl' - - # ancient GNU ld didn't support --whole-archive et. al. - if eval "`$CC -print-prog-name=ld` --help 2>&1" | - $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - with_gnu_ld=no - wlarc= - - # A generic and very simple default shared library creation - # command for GNU C++ for the case where it uses the native - # linker, instead of GNU ld. If possible, this setting should - # overridden to take advantage of the native linker features on - # the platform it is being used on. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - fi - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - - else - GXX=no - with_gnu_ld=no - wlarc= - fi - - # PORTME: fill in a description of your system's C++ link characteristics - AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) - _LT_TAGVAR(ld_shlibs, $1)=yes - case $host_os in - aix3*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aix[[4-9]]*) - if test ia64 = "$host_cpu"; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag= - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # have runtime linking enabled, and use it for executables. - # For shared libraries, we enable/disable runtime linking - # depending on the kind of the shared library created - - # when "with_aix_soname,aix_use_runtimelinking" is: - # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables - # "aix,yes" lib.so shared, rtl:yes, for executables - # lib.a static archive - # "both,no" lib.so.V(shr.o) shared, rtl:yes - # lib.a(lib.so.V) shared, rtl:no, for executables - # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables - # lib.a(lib.so.V) shared, rtl:no - # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables - # lib.a static archive - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - case $ld_flag in - *-brtl*) - aix_use_runtimelinking=yes - break - ;; - esac - done - if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then - # With aix-soname=svr4, we create the lib.so.V shared archives only, - # so we don't have lib.a shared libs to link our executables. - # We have to force runtime linking in this case. - aix_use_runtimelinking=yes - LDFLAGS="$LDFLAGS -Wl,-brtl" - fi - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='$wl-f,' - case $with_aix_soname,$aix_use_runtimelinking in - aix,*) ;; # no import file - svr4,* | *,yes) # use import file - # The Import File defines what to hardcode. - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=no - ;; - esac - - if test yes = "$GXX"; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`$CC -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - esac - shared_flag='-shared' - if test yes = "$aix_use_runtimelinking"; then - shared_flag=$shared_flag' $wl-G' - fi - # Need to ensure runtime linking is disabled for the traditional - # shared library, or the linker may eventually find shared libraries - # /with/ Import File - we do not want to mix them. - shared_flag_aix='-shared' - shared_flag_svr4='-shared $wl-G' - else - # not using gcc - if test ia64 = "$host_cpu"; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test yes = "$aix_use_runtimelinking"; then - shared_flag='$wl-G' - else - shared_flag='$wl-bM:SRE' - fi - shared_flag_aix='$wl-bM:SRE' - shared_flag_svr4='$wl-G' - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to - # export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - # The "-G" linker flag allows undefined symbols. - _LT_TAGVAR(no_undefined_flag, $1)='-bernotok' - # Determine the default libpath from the value encoded in an empty - # executable. - _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" - - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag - else - if test ia64 = "$host_cpu"; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' - if test yes = "$with_gnu_ld"; then - # We only use this code for GNU lds that support --whole-archive. - _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' - # -brtl affects multiple linker settings, -berok does not and is overridden later - compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' - if test svr4 != "$with_aix_soname"; then - # This is similar to how AIX traditionally builds its shared - # libraries. Need -bnortl late, we may have -brtl in LDFLAGS. - _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' - fi - if test aix != "$with_aix_soname"; then - _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' - else - # used by -dlpreopen to get the symbols - _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' - fi - _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' - fi - fi - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - cygwin* | mingw* | pw32* | cegcc*) - case $GXX,$cc_basename in - ,cl* | no,cl*) - # Native MSVC - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='@' - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=.dll - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then - cp "$export_symbols" "$output_objdir/$soname.def"; - echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; - else - $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - # Don't use ranlib - _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' - _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile=$lt_outputfile.exe - lt_tool_outputfile=$lt_tool_outputfile.exe - ;; - esac~ - func_to_tool_file "$lt_outputfile"~ - if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # g++ - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file, use it as - # is; otherwise, prepend EXPORTS... - _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - os2*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - shrext_cmds=.dll - _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ - $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ - $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ - $ECHO EXPORTS >> $output_objdir/$libname.def~ - emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ - $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ - emximp -o $lib $output_objdir/$libname.def' - _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ - $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ - $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ - $ECHO EXPORTS >> $output_objdir/$libname.def~ - prefix_cmds="$SED"~ - if test EXPORTS = "`$SED 1q $export_symbols`"; then - prefix_cmds="$prefix_cmds -e 1d"; - fi~ - prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ - cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ - $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ - emximp -o $lib $output_objdir/$libname.def' - _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - - dgux*) - case $cc_basename in - ec++*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - ghcx*) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - freebsd2.*) - # C++ shared libraries reported to be fairly broken before - # switch to ELF - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - freebsd-elf*) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - ;; - - freebsd* | dragonfly*) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - haiku*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - hpux9*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test yes = "$GXX"; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - hpux10*|hpux11*) - if test no = "$with_gnu_ld"; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - ;; - *) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' - ;; - esac - fi - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - esac - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test yes = "$GXX"; then - if test no = "$with_gnu_ld"; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - fi - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - irix5* | irix6*) - case $cc_basename in - CC*) - # SGI C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' - - # Archives containing C++ object files must be created using - # "CC -ar", where "CC" is the IRIX C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' - ;; - *) - if test yes = "$GXX"; then - if test no = "$with_gnu_ld"; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' - fi - fi - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - esac - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - ;; - - linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc* | ecpc* ) - # Intel C++ - with_gnu_ld=yes - # version 8.0 and above of icpc choke on multiply defined symbols - # if we add $predep_objects and $postdep_objects, however 7.1 and - # earlier do not add the objects themselves. - case `$CC -V 2>&1` in - *"Version 7."*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' - ;; - *) # Version 8.0 or newer - tmp_idyn= - case $host_cpu in - ia64*) tmp_idyn=' -i_dynamic';; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' - ;; - esac - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - case `$CC -V` in - *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) - _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ - compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' - _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ - $RANLIB $oldlib' - _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' - ;; - *) # Version 6 and above use weak symbols - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' - ;; - cxx*) - # Compaq C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' - - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' - ;; - xl* | mpixl* | bgxl*) - # IBM XL 8.0 on PPC, with GNU ld - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' - _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - if test yes = "$supports_anon_versioning"; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' - fi - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - - # Not sure whether something based on - # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 - # would be better. - output_verbose_link_cmd='func_echo_all' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - esac - ;; - esac - ;; - - lynxos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - m88k*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - mvs*) - case $cc_basename in - cxx*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - fi - # Workaround some broken pre-1.5 toolchains - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' - ;; - - *nto* | *qnx*) - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - openbsd* | bitrig*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' - _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' - fi - output_verbose_link_cmd=func_echo_all - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - case $host in - osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; - *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; - esac - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - cxx*) - case $host in - osf3*) - _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' - ;; - *) - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ - $RM $lib.exp' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test yes,no = "$GXX,$with_gnu_ld"; then - _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' - case $host in - osf3*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - psos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - lcc*) - # Lucid - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - solaris*) - case $cc_basename in - CC* | sunCC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(archive_cmds_need_lc,$1)=yes - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands '-z linker_flag'. - # Supported since Solaris 2.6 (maybe 2.5.1?) - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - - output_verbose_link_cmd='func_echo_all' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' - - # The C++ compiler must be used to create the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' - ;; - *) - # GNU C++ compiler with Solaris linker - if test yes,no = "$GXX,$with_gnu_ld"; then - _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs' - if $CC --version | $GREP -v '^2\.7' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - else - # g++ 2.7 appears to require '-G' NOT '-shared' on this - # platform. - _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - fi - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' - ;; - esac - fi - ;; - esac - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We CANNOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ - '"$_LT_TAGVAR(old_archive_cmds, $1)" - _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ - '"$_LT_TAGVAR(reload_cmds, $1)" - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - vxworks*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) - test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no - - _LT_TAGVAR(GCC, $1)=$GXX - _LT_TAGVAR(LD, $1)=$LD - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - CC=$lt_save_CC - CFLAGS=$lt_save_CFLAGS - LDCXX=$LD - LD=$lt_save_LD - GCC=$lt_save_GCC - with_gnu_ld=$lt_save_with_gnu_ld - lt_cv_path_LDCXX=$lt_cv_path_LD - lt_cv_path_LD=$lt_save_path_LD - lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld - lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -fi # test yes != "$_lt_caught_CXX_error" - -AC_LANG_POP -])# _LT_LANG_CXX_CONFIG - - -# _LT_FUNC_STRIPNAME_CNF -# ---------------------- -# func_stripname_cnf prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# -# This function is identical to the (non-XSI) version of func_stripname, -# except this one can be used by m4 code that may be executed by configure, -# rather than the libtool script. -m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl -AC_REQUIRE([_LT_DECL_SED]) -AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) -func_stripname_cnf () -{ - case @S|@2 in - .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;; - *) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;; - esac -} # func_stripname_cnf -])# _LT_FUNC_STRIPNAME_CNF - - -# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) -# --------------------------------- -# Figure out "hidden" library dependencies from verbose -# compiler output when linking a shared library. -# Parse the compiler output and extract the necessary -# objects, libraries and library flags. -m4_defun([_LT_SYS_HIDDEN_LIBDEPS], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl -# Dependencies to place before and after the object being linked: -_LT_TAGVAR(predep_objects, $1)= -_LT_TAGVAR(postdep_objects, $1)= -_LT_TAGVAR(predeps, $1)= -_LT_TAGVAR(postdeps, $1)= -_LT_TAGVAR(compiler_lib_search_path, $1)= - -dnl we can't use the lt_simple_compile_test_code here, -dnl because it contains code intended for an executable, -dnl not a library. It's possible we should let each -dnl tag define a new lt_????_link_test_code variable, -dnl but it's only used here... -m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF -int a; -void foo (void) { a = 0; } -_LT_EOF -], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF -class Foo -{ -public: - Foo (void) { a = 0; } -private: - int a; -}; -_LT_EOF -], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer*4 a - a=0 - return - end -_LT_EOF -], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer a - a=0 - return - end -_LT_EOF -], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF -public class foo { - private int a; - public void bar (void) { - a = 0; - } -}; -_LT_EOF -], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF -package foo -func foo() { -} -_LT_EOF -]) - -_lt_libdeps_save_CFLAGS=$CFLAGS -case "$CC $CFLAGS " in #( -*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; -*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; -*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; -esac - -dnl Parse the compiler output and extract the necessary -dnl objects, libraries and library flags. -if AC_TRY_EVAL(ac_compile); then - # Parse the compiler output and extract the necessary - # objects, libraries and library flags. - - # Sentinel used to keep track of whether or not we are before - # the conftest object file. - pre_test_object_deps_done=no - - for p in `eval "$output_verbose_link_cmd"`; do - case $prev$p in - - -L* | -R* | -l*) - # Some compilers place space between "-{L,R}" and the path. - # Remove the space. - if test x-L = "$p" || - test x-R = "$p"; then - prev=$p - continue - fi - - # Expand the sysroot to ease extracting the directories later. - if test -z "$prev"; then - case $p in - -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; - -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; - -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; - esac - fi - case $p in - =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; - esac - if test no = "$pre_test_object_deps_done"; then - case $prev in - -L | -R) - # Internal compiler library paths should come after those - # provided the user. The postdeps already come after the - # user supplied libs so there is no need to process them. - if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then - _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p - else - _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p" - fi - ;; - # The "-l" case would never come before the object being - # linked, so don't bother handling this case. - esac - else - if test -z "$_LT_TAGVAR(postdeps, $1)"; then - _LT_TAGVAR(postdeps, $1)=$prev$p - else - _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p" - fi - fi - prev= - ;; - - *.lto.$objext) ;; # Ignore GCC LTO objects - *.$objext) - # This assumes that the test object file only shows up - # once in the compiler output. - if test "$p" = "conftest.$objext"; then - pre_test_object_deps_done=yes - continue - fi - - if test no = "$pre_test_object_deps_done"; then - if test -z "$_LT_TAGVAR(predep_objects, $1)"; then - _LT_TAGVAR(predep_objects, $1)=$p - else - _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" - fi - else - if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then - _LT_TAGVAR(postdep_objects, $1)=$p - else - _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" - fi - fi - ;; - - *) ;; # Ignore the rest. - - esac - done - - # Clean up. - rm -f a.out a.exe -else - echo "libtool.m4: error: problem compiling $1 test program" -fi - -$RM -f confest.$objext -CFLAGS=$_lt_libdeps_save_CFLAGS - -# PORTME: override above test on systems where it is broken -m4_if([$1], [CXX], -[case $host_os in -interix[[3-9]]*) - # Interix 3.5 installs completely hosed .la files for C++, so rather than - # hack all around it, let's just trust "g++" to DTRT. - _LT_TAGVAR(predep_objects,$1)= - _LT_TAGVAR(postdep_objects,$1)= - _LT_TAGVAR(postdeps,$1)= - ;; -esac -]) - -case " $_LT_TAGVAR(postdeps, $1) " in -*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; -esac - _LT_TAGVAR(compiler_lib_search_dirs, $1)= -if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then - _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'` -fi -_LT_TAGDECL([], [compiler_lib_search_dirs], [1], - [The directories searched by this compiler when creating a shared library]) -_LT_TAGDECL([], [predep_objects], [1], - [Dependencies to place before and after the objects being linked to - create a shared library]) -_LT_TAGDECL([], [postdep_objects], [1]) -_LT_TAGDECL([], [predeps], [1]) -_LT_TAGDECL([], [postdeps], [1]) -_LT_TAGDECL([], [compiler_lib_search_path], [1], - [The library search path used internally by the compiler when linking - a shared library]) -])# _LT_SYS_HIDDEN_LIBDEPS - - -# _LT_LANG_F77_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a Fortran 77 compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to 'libtool'. -m4_defun([_LT_LANG_F77_CONFIG], -[AC_LANG_PUSH(Fortran 77) -if test -z "$F77" || test no = "$F77"; then - _lt_disable_F77=yes -fi - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for f77 test sources. -ac_ext=f - -# Object file extension for compiled f77 test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the F77 compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test yes != "$_lt_disable_F77"; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC=$CC - lt_save_GCC=$GCC - lt_save_CFLAGS=$CFLAGS - CC=${F77-"f77"} - CFLAGS=$FFLAGS - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - GCC=$G77 - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test no = "$can_build_shared" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test yes = "$enable_shared" && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test ia64 != "$host_cpu"; then - case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in - yes,aix,yes) ;; # shared object as lib.so file only - yes,svr4,*) ;; # shared object as lib.so archive member only - yes,*) enable_static=no ;; # shared object in lib.a archive as well - esac - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test yes = "$enable_shared" || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)=$G77 - _LT_TAGVAR(LD, $1)=$LD - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC=$lt_save_CC - CFLAGS=$lt_save_CFLAGS -fi # test yes != "$_lt_disable_F77" - -AC_LANG_POP -])# _LT_LANG_F77_CONFIG - - -# _LT_LANG_FC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for a Fortran compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to 'libtool'. -m4_defun([_LT_LANG_FC_CONFIG], -[AC_LANG_PUSH(Fortran) - -if test -z "$FC" || test no = "$FC"; then - _lt_disable_FC=yes -fi - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for fc test sources. -ac_ext=${ac_fc_srcext-f} - -# Object file extension for compiled fc test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the FC compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test yes != "$_lt_disable_FC"; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC=$CC - lt_save_GCC=$GCC - lt_save_CFLAGS=$CFLAGS - CC=${FC-"f95"} - CFLAGS=$FCFLAGS - compiler=$CC - GCC=$ac_cv_fc_compiler_gnu - - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test no = "$can_build_shared" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test yes = "$enable_shared" && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test ia64 != "$host_cpu"; then - case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in - yes,aix,yes) ;; # shared object as lib.so file only - yes,svr4,*) ;; # shared object as lib.so archive member only - yes,*) enable_static=no ;; # shared object in lib.a archive as well - esac - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test yes = "$enable_shared" || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu - _LT_TAGVAR(LD, $1)=$LD - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC=$lt_save_CC - CFLAGS=$lt_save_CFLAGS -fi # test yes != "$_lt_disable_FC" - -AC_LANG_POP -])# _LT_LANG_FC_CONFIG - - -# _LT_LANG_GCJ_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Java Compiler compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to 'libtool'. -m4_defun([_LT_LANG_GCJ_CONFIG], -[AC_REQUIRE([LT_PROG_GCJ])dnl -AC_LANG_SAVE - -# Source file extension for Java test sources. -ac_ext=java - -# Object file extension for compiled Java test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="class foo {}" - -# Code to be used in simple link tests -lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC=$CC -lt_save_CFLAGS=$CFLAGS -lt_save_GCC=$GCC -GCC=yes -CC=${GCJ-"gcj"} -CFLAGS=$GCJFLAGS -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)=$LD -_LT_CC_BASENAME([$compiler]) - -# GCJ did not exist at the time GCC didn't implicitly link libc in. -_LT_TAGVAR(archive_cmds_need_lc, $1)=no - -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds - -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) -fi - -AC_LANG_RESTORE - -GCC=$lt_save_GCC -CC=$lt_save_CC -CFLAGS=$lt_save_CFLAGS -])# _LT_LANG_GCJ_CONFIG - - -# _LT_LANG_GO_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Go compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to 'libtool'. -m4_defun([_LT_LANG_GO_CONFIG], -[AC_REQUIRE([LT_PROG_GO])dnl -AC_LANG_SAVE - -# Source file extension for Go test sources. -ac_ext=go - -# Object file extension for compiled Go test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="package main; func main() { }" - -# Code to be used in simple link tests -lt_simple_link_test_code='package main; func main() { }' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC=$CC -lt_save_CFLAGS=$CFLAGS -lt_save_GCC=$GCC -GCC=yes -CC=${GOC-"gccgo"} -CFLAGS=$GOFLAGS -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)=$LD -_LT_CC_BASENAME([$compiler]) - -# Go did not exist at the time GCC didn't implicitly link libc in. -_LT_TAGVAR(archive_cmds_need_lc, $1)=no - -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds - -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) -fi - -AC_LANG_RESTORE - -GCC=$lt_save_GCC -CC=$lt_save_CC -CFLAGS=$lt_save_CFLAGS -])# _LT_LANG_GO_CONFIG - - -# _LT_LANG_RC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for the Windows resource compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to 'libtool'. -m4_defun([_LT_LANG_RC_CONFIG], -[AC_REQUIRE([LT_PROG_RC])dnl -AC_LANG_SAVE - -# Source file extension for RC test sources. -ac_ext=rc - -# Object file extension for compiled RC test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' - -# Code to be used in simple link tests -lt_simple_link_test_code=$lt_simple_compile_test_code - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC=$CC -lt_save_CFLAGS=$CFLAGS -lt_save_GCC=$GCC -GCC= -CC=${RC-"windres"} -CFLAGS= -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_CC_BASENAME([$compiler]) -_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - -if test -n "$compiler"; then - : - _LT_CONFIG($1) -fi - -GCC=$lt_save_GCC -AC_LANG_RESTORE -CC=$lt_save_CC -CFLAGS=$lt_save_CFLAGS -])# _LT_LANG_RC_CONFIG - - -# LT_PROG_GCJ -# ----------- -AC_DEFUN([LT_PROG_GCJ], -[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], - [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], - [AC_CHECK_TOOL(GCJ, gcj,) - test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2" - AC_SUBST(GCJFLAGS)])])[]dnl -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_GCJ], []) - - -# LT_PROG_GO -# ---------- -AC_DEFUN([LT_PROG_GO], -[AC_CHECK_TOOL(GOC, gccgo,) -]) - - -# LT_PROG_RC -# ---------- -AC_DEFUN([LT_PROG_RC], -[AC_CHECK_TOOL(RC, windres,) -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_RC], []) - - -# _LT_DECL_EGREP -# -------------- -# If we don't have a new enough Autoconf to choose the best grep -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_EGREP], -[AC_REQUIRE([AC_PROG_EGREP])dnl -AC_REQUIRE([AC_PROG_FGREP])dnl -test -z "$GREP" && GREP=grep -_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) -_LT_DECL([], [EGREP], [1], [An ERE matcher]) -_LT_DECL([], [FGREP], [1], [A literal string matcher]) -dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too -AC_SUBST([GREP]) -]) - - -# _LT_DECL_OBJDUMP -# -------------- -# If we don't have a new enough Autoconf to choose the best objdump -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_OBJDUMP], -[AC_CHECK_TOOL(OBJDUMP, objdump, false) -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) -AC_SUBST([OBJDUMP]) -]) - -# _LT_DECL_DLLTOOL -# ---------------- -# Ensure DLLTOOL variable is set. -m4_defun([_LT_DECL_DLLTOOL], -[AC_CHECK_TOOL(DLLTOOL, dlltool, false) -test -z "$DLLTOOL" && DLLTOOL=dlltool -_LT_DECL([], [DLLTOOL], [1], [DLL creation program]) -AC_SUBST([DLLTOOL]) -]) - -# _LT_DECL_SED -# ------------ -# Check for a fully-functional sed program, that truncates -# as few characters as possible. Prefer GNU sed if found. -m4_defun([_LT_DECL_SED], -[AC_PROG_SED -test -z "$SED" && SED=sed -Xsed="$SED -e 1s/^X//" -_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) -_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], - [Sed that helps us avoid accidentally triggering echo(1) options like -n]) -])# _LT_DECL_SED - -m4_ifndef([AC_PROG_SED], [ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_SED. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # - -m4_defun([AC_PROG_SED], -[AC_MSG_CHECKING([for a sed that does not truncate output]) -AC_CACHE_VAL(lt_cv_path_SED, -[# Loop through the user's path and test for sed and gsed. -# Then use that list of sed's as ones to test for truncation. -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for lt_ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then - lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" - fi - done - done -done -IFS=$as_save_IFS -lt_ac_max=0 -lt_ac_count=0 -# Add /usr/xpg4/bin/sed as it is typically found on Solaris -# along with /bin/sed that truncates output. -for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do - test ! -f "$lt_ac_sed" && continue - cat /dev/null > conftest.in - lt_ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >conftest.in - # Check for GNU sed and select it if it is found. - if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then - lt_cv_path_SED=$lt_ac_sed - break - fi - while true; do - cat conftest.in conftest.in >conftest.tmp - mv conftest.tmp conftest.in - cp conftest.in conftest.nl - echo >>conftest.nl - $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break - cmp -s conftest.out conftest.nl || break - # 10000 chars as input seems more than enough - test 10 -lt "$lt_ac_count" && break - lt_ac_count=`expr $lt_ac_count + 1` - if test "$lt_ac_count" -gt "$lt_ac_max"; then - lt_ac_max=$lt_ac_count - lt_cv_path_SED=$lt_ac_sed - fi - done -done -]) -SED=$lt_cv_path_SED -AC_SUBST([SED]) -AC_MSG_RESULT([$SED]) -])#AC_PROG_SED -])#m4_ifndef - -# Old name: -AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_SED], []) - - -# _LT_CHECK_SHELL_FEATURES -# ------------------------ -# Find out whether the shell is Bourne or XSI compatible, -# or has some other useful features. -m4_defun([_LT_CHECK_SHELL_FEATURES], -[if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - lt_unset=unset -else - lt_unset=false -fi -_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl - -# test EBCDIC or ASCII -case `echo X|tr X '\101'` in - A) # ASCII based system - # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr - lt_SP2NL='tr \040 \012' - lt_NL2SP='tr \015\012 \040\040' - ;; - *) # EBCDIC based system - lt_SP2NL='tr \100 \n' - lt_NL2SP='tr \r\n \100\100' - ;; -esac -_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl -_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl -])# _LT_CHECK_SHELL_FEATURES - - -# _LT_PATH_CONVERSION_FUNCTIONS -# ----------------------------- -# Determine what file name conversion functions should be used by -# func_to_host_file (and, implicitly, by func_to_host_path). These are needed -# for certain cross-compile configurations and native mingw. -m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_MSG_CHECKING([how to convert $build file names to $host format]) -AC_CACHE_VAL(lt_cv_to_host_file_cmd, -[case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 - ;; - esac - ;; - *-*-cygwin* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin - ;; - esac - ;; - * ) # unhandled hosts (and "normal" native builds) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; -esac -]) -to_host_file_cmd=$lt_cv_to_host_file_cmd -AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) -_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], - [0], [convert $build file names to $host format])dnl - -AC_MSG_CHECKING([how to convert $build file names to toolchain format]) -AC_CACHE_VAL(lt_cv_to_tool_file_cmd, -[#assume ordinary cross tools, or native build. -lt_cv_to_tool_file_cmd=func_convert_file_noop -case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 - ;; - esac - ;; -esac -]) -to_tool_file_cmd=$lt_cv_to_tool_file_cmd -AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) -_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], - [0], [convert $build files to toolchain format])dnl -])# _LT_PATH_CONVERSION_FUNCTIONS - -# Helper functions for option handling. -*- Autoconf -*- -# -# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software -# Foundation, Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 8 ltoptions.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) - - -# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) -# ------------------------------------------ -m4_define([_LT_MANGLE_OPTION], -[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) - - -# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) -# --------------------------------------- -# Set option OPTION-NAME for macro MACRO-NAME, and if there is a -# matching handler defined, dispatch to it. Other OPTION-NAMEs are -# saved as a flag. -m4_define([_LT_SET_OPTION], -[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl -m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), - _LT_MANGLE_DEFUN([$1], [$2]), - [m4_warning([Unknown $1 option '$2'])])[]dnl -]) - - -# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) -# ------------------------------------------------------------ -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -m4_define([_LT_IF_OPTION], -[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) - - -# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) -# ------------------------------------------------------- -# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME -# are set. -m4_define([_LT_UNLESS_OPTIONS], -[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), - [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), - [m4_define([$0_found])])])[]dnl -m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 -])[]dnl -]) - - -# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) -# ---------------------------------------- -# OPTION-LIST is a space-separated list of Libtool options associated -# with MACRO-NAME. If any OPTION has a matching handler declared with -# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about -# the unknown option and exit. -m4_defun([_LT_SET_OPTIONS], -[# Set options -m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), - [_LT_SET_OPTION([$1], _LT_Option)]) - -m4_if([$1],[LT_INIT],[ - dnl - dnl Simply set some default values (i.e off) if boolean options were not - dnl specified: - _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no - ]) - _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no - ]) - dnl - dnl If no reference was made to various pairs of opposing options, then - dnl we run the default mode handler for the pair. For example, if neither - dnl 'shared' nor 'disable-shared' was passed, we enable building of shared - dnl archives by default: - _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) - _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) - _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) - _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], - [_LT_ENABLE_FAST_INSTALL]) - _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4], - [_LT_WITH_AIX_SONAME([aix])]) - ]) -])# _LT_SET_OPTIONS - - - -# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) -# ----------------------------------------- -m4_define([_LT_MANGLE_DEFUN], -[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) - - -# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) -# ----------------------------------------------- -m4_define([LT_OPTION_DEFINE], -[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl -])# LT_OPTION_DEFINE - - -# dlopen -# ------ -LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes -]) - -AU_DEFUN([AC_LIBTOOL_DLOPEN], -[_LT_SET_OPTION([LT_INIT], [dlopen]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the 'dlopen' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) - - -# win32-dll -# --------- -# Declare package support for building win32 dll's. -LT_OPTION_DEFINE([LT_INIT], [win32-dll], -[enable_win32_dll=yes - -case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) - AC_CHECK_TOOL(AS, as, false) - AC_CHECK_TOOL(DLLTOOL, dlltool, false) - AC_CHECK_TOOL(OBJDUMP, objdump, false) - ;; -esac - -test -z "$AS" && AS=as -_LT_DECL([], [AS], [1], [Assembler program])dnl - -test -z "$DLLTOOL" && DLLTOOL=dlltool -_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl - -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl -])# win32-dll - -AU_DEFUN([AC_LIBTOOL_WIN32_DLL], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -_LT_SET_OPTION([LT_INIT], [win32-dll]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the 'win32-dll' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) - - -# _LT_ENABLE_SHARED([DEFAULT]) -# ---------------------------- -# implement the --enable-shared flag, and supports the 'shared' and -# 'disable-shared' LT_INIT options. -# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. -m4_define([_LT_ENABLE_SHARED], -[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([shared], - [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], - [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, - for pkg in $enableval; do - IFS=$lt_save_ifs - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS=$lt_save_ifs - ;; - esac], - [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) - - _LT_DECL([build_libtool_libs], [enable_shared], [0], - [Whether or not to build shared libraries]) -])# _LT_ENABLE_SHARED - -LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) - -# Old names: -AC_DEFUN([AC_ENABLE_SHARED], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) -]) - -AC_DEFUN([AC_DISABLE_SHARED], -[_LT_SET_OPTION([LT_INIT], [disable-shared]) -]) - -AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) -AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_ENABLE_SHARED], []) -dnl AC_DEFUN([AM_DISABLE_SHARED], []) - - - -# _LT_ENABLE_STATIC([DEFAULT]) -# ---------------------------- -# implement the --enable-static flag, and support the 'static' and -# 'disable-static' LT_INIT options. -# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. -m4_define([_LT_ENABLE_STATIC], -[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([static], - [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], - [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, - for pkg in $enableval; do - IFS=$lt_save_ifs - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS=$lt_save_ifs - ;; - esac], - [enable_static=]_LT_ENABLE_STATIC_DEFAULT) - - _LT_DECL([build_old_libs], [enable_static], [0], - [Whether or not to build static libraries]) -])# _LT_ENABLE_STATIC - -LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) - -# Old names: -AC_DEFUN([AC_ENABLE_STATIC], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) -]) - -AC_DEFUN([AC_DISABLE_STATIC], -[_LT_SET_OPTION([LT_INIT], [disable-static]) -]) - -AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) -AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_ENABLE_STATIC], []) -dnl AC_DEFUN([AM_DISABLE_STATIC], []) - - - -# _LT_ENABLE_FAST_INSTALL([DEFAULT]) -# ---------------------------------- -# implement the --enable-fast-install flag, and support the 'fast-install' -# and 'disable-fast-install' LT_INIT options. -# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. -m4_define([_LT_ENABLE_FAST_INSTALL], -[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([fast-install], - [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], - [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, - for pkg in $enableval; do - IFS=$lt_save_ifs - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS=$lt_save_ifs - ;; - esac], - [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) - -_LT_DECL([fast_install], [enable_fast_install], [0], - [Whether or not to optimize for fast installation])dnl -])# _LT_ENABLE_FAST_INSTALL - -LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) - -# Old names: -AU_DEFUN([AC_ENABLE_FAST_INSTALL], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you put -the 'fast-install' option into LT_INIT's first parameter.]) -]) - -AU_DEFUN([AC_DISABLE_FAST_INSTALL], -[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you put -the 'disable-fast-install' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) -dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) - - -# _LT_WITH_AIX_SONAME([DEFAULT]) -# ---------------------------------- -# implement the --with-aix-soname flag, and support the `aix-soname=aix' -# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT -# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'. -m4_define([_LT_WITH_AIX_SONAME], -[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl -shared_archive_member_spec= -case $host,$enable_shared in -power*-*-aix[[5-9]]*,yes) - AC_MSG_CHECKING([which variant of shared library versioning to provide]) - AC_ARG_WITH([aix-soname], - [AS_HELP_STRING([--with-aix-soname=aix|svr4|both], - [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])], - [case $withval in - aix|svr4|both) - ;; - *) - AC_MSG_ERROR([Unknown argument to --with-aix-soname]) - ;; - esac - lt_cv_with_aix_soname=$with_aix_soname], - [AC_CACHE_VAL([lt_cv_with_aix_soname], - [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT) - with_aix_soname=$lt_cv_with_aix_soname]) - AC_MSG_RESULT([$with_aix_soname]) - if test aix != "$with_aix_soname"; then - # For the AIX way of multilib, we name the shared archive member - # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', - # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. - # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, - # the AIX toolchain works better with OBJECT_MODE set (default 32). - if test 64 = "${OBJECT_MODE-32}"; then - shared_archive_member_spec=shr_64 - else - shared_archive_member_spec=shr - fi - fi - ;; -*) - with_aix_soname=aix - ;; -esac - -_LT_DECL([], [shared_archive_member_spec], [0], - [Shared archive member basename, for filename based shared library versioning on AIX])dnl -])# _LT_WITH_AIX_SONAME - -LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])]) -LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])]) -LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])]) - - -# _LT_WITH_PIC([MODE]) -# -------------------- -# implement the --with-pic flag, and support the 'pic-only' and 'no-pic' -# LT_INIT options. -# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'. -m4_define([_LT_WITH_PIC], -[AC_ARG_WITH([pic], - [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], - [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [lt_p=${PACKAGE-default} - case $withval in - yes|no) pic_mode=$withval ;; - *) - pic_mode=default - # Look at the argument we got. We use all the common list separators. - lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, - for lt_pkg in $withval; do - IFS=$lt_save_ifs - if test "X$lt_pkg" = "X$lt_p"; then - pic_mode=yes - fi - done - IFS=$lt_save_ifs - ;; - esac], - [pic_mode=m4_default([$1], [default])]) - -_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl -])# _LT_WITH_PIC - -LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) -LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) - -# Old name: -AU_DEFUN([AC_LIBTOOL_PICMODE], -[_LT_SET_OPTION([LT_INIT], [pic-only]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the 'pic-only' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) - - -m4_define([_LTDL_MODE], []) -LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], - [m4_define([_LTDL_MODE], [nonrecursive])]) -LT_OPTION_DEFINE([LTDL_INIT], [recursive], - [m4_define([_LTDL_MODE], [recursive])]) -LT_OPTION_DEFINE([LTDL_INIT], [subproject], - [m4_define([_LTDL_MODE], [subproject])]) - -m4_define([_LTDL_TYPE], []) -LT_OPTION_DEFINE([LTDL_INIT], [installable], - [m4_define([_LTDL_TYPE], [installable])]) -LT_OPTION_DEFINE([LTDL_INIT], [convenience], - [m4_define([_LTDL_TYPE], [convenience])]) - -# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- -# -# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software -# Foundation, Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 6 ltsugar.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) - - -# lt_join(SEP, ARG1, [ARG2...]) -# ----------------------------- -# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their -# associated separator. -# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier -# versions in m4sugar had bugs. -m4_define([lt_join], -[m4_if([$#], [1], [], - [$#], [2], [[$2]], - [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) -m4_define([_lt_join], -[m4_if([$#$2], [2], [], - [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) - - -# lt_car(LIST) -# lt_cdr(LIST) -# ------------ -# Manipulate m4 lists. -# These macros are necessary as long as will still need to support -# Autoconf-2.59, which quotes differently. -m4_define([lt_car], [[$1]]) -m4_define([lt_cdr], -[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], - [$#], 1, [], - [m4_dquote(m4_shift($@))])]) -m4_define([lt_unquote], $1) - - -# lt_append(MACRO-NAME, STRING, [SEPARATOR]) -# ------------------------------------------ -# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. -# Note that neither SEPARATOR nor STRING are expanded; they are appended -# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). -# No SEPARATOR is output if MACRO-NAME was previously undefined (different -# than defined and empty). -# -# This macro is needed until we can rely on Autoconf 2.62, since earlier -# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. -m4_define([lt_append], -[m4_define([$1], - m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) - - - -# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) -# ---------------------------------------------------------- -# Produce a SEP delimited list of all paired combinations of elements of -# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list -# has the form PREFIXmINFIXSUFFIXn. -# Needed until we can rely on m4_combine added in Autoconf 2.62. -m4_define([lt_combine], -[m4_if(m4_eval([$# > 3]), [1], - [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl -[[m4_foreach([_Lt_prefix], [$2], - [m4_foreach([_Lt_suffix], - ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, - [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) - - -# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) -# ----------------------------------------------------------------------- -# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited -# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. -m4_define([lt_if_append_uniq], -[m4_ifdef([$1], - [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], - [lt_append([$1], [$2], [$3])$4], - [$5])], - [lt_append([$1], [$2], [$3])$4])]) - - -# lt_dict_add(DICT, KEY, VALUE) -# ----------------------------- -m4_define([lt_dict_add], -[m4_define([$1($2)], [$3])]) - - -# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) -# -------------------------------------------- -m4_define([lt_dict_add_subkey], -[m4_define([$1($2:$3)], [$4])]) - - -# lt_dict_fetch(DICT, KEY, [SUBKEY]) -# ---------------------------------- -m4_define([lt_dict_fetch], -[m4_ifval([$3], - m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), - m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) - - -# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) -# ----------------------------------------------------------------- -m4_define([lt_if_dict_fetch], -[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], - [$5], - [$6])]) - - -# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) -# -------------------------------------------------------------- -m4_define([lt_dict_filter], -[m4_if([$5], [], [], - [lt_join(m4_quote(m4_default([$4], [[, ]])), - lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), - [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl -]) - -# ltversion.m4 -- version numbers -*- Autoconf -*- -# -# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. -# Written by Scott James Remnant, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# @configure_input@ - -# serial 4179 ltversion.m4 -# This file is part of GNU Libtool - -m4_define([LT_PACKAGE_VERSION], [2.4.6]) -m4_define([LT_PACKAGE_REVISION], [2.4.6]) - -AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.4.6' -macro_revision='2.4.6' -_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) -_LT_DECL(, macro_revision, 0) -]) - -# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- -# -# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software -# Foundation, Inc. -# Written by Scott James Remnant, 2004. -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 5 lt~obsolete.m4 - -# These exist entirely to fool aclocal when bootstrapping libtool. -# -# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN), -# which have later been changed to m4_define as they aren't part of the -# exported API, or moved to Autoconf or Automake where they belong. -# -# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN -# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us -# using a macro with the same name in our local m4/libtool.m4 it'll -# pull the old libtool.m4 in (it doesn't see our shiny new m4_define -# and doesn't know about Autoconf macros at all.) -# -# So we provide this file, which has a silly filename so it's always -# included after everything else. This provides aclocal with the -# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything -# because those macros already exist, or will be overwritten later. -# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. -# -# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. -# Yes, that means every name once taken will need to remain here until -# we give up compatibility with versions before 1.7, at which point -# we need to keep only those names which we still refer to. - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) - -m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) -m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) -m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) -m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) -m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) -m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) -m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) -m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) -m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) -m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) -m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) -m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) -m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) -m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) -m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) -m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) -m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) -m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) -m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) -m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) -m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) -m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) -m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) -m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) -m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) -m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) -m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) -m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) -m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) -m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) -m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) -m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) -m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) -m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) -m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) -m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) -m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) -m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) -m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) -m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) -m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) -m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) -m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) -m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) -m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) -m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) -m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) -m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) -m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) -m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) -m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) -m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) -m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) -m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) -m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) - -# Copyright (C) 2002-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_AUTOMAKE_VERSION(VERSION) -# ---------------------------- -# Automake X.Y traces this macro to ensure aclocal.m4 has been -# generated from the m4 files accompanying Automake X.Y. -# (This private macro should not be called outside this file.) -AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.15' -dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to -dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.15], [], - [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl -]) - -# _AM_AUTOCONF_VERSION(VERSION) -# ----------------------------- -# aclocal traces this macro to find the Autoconf version. -# This is a private macro too. Using m4_define simplifies -# the logic in aclocal, which can simply ignore this definition. -m4_define([_AM_AUTOCONF_VERSION], []) - -# AM_SET_CURRENT_AUTOMAKE_VERSION -# ------------------------------- -# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. -# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.15])dnl -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) - -# AM_AUX_DIR_EXPAND -*- Autoconf -*- - -# Copyright (C) 2001-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to -# '$srcdir', '$srcdir/..', or '$srcdir/../..'. -# -# Of course, Automake must honor this variable whenever it calls a -# tool from the auxiliary directory. The problem is that $srcdir (and -# therefore $ac_aux_dir as well) can be either absolute or relative, -# depending on how configure is run. This is pretty annoying, since -# it makes $ac_aux_dir quite unusable in subdirectories: in the top -# source directory, any form will work fine, but in subdirectories a -# relative path needs to be adjusted first. -# -# $ac_aux_dir/missing -# fails when called from a subdirectory if $ac_aux_dir is relative -# $top_srcdir/$ac_aux_dir/missing -# fails if $ac_aux_dir is absolute, -# fails when called from a subdirectory in a VPATH build with -# a relative $ac_aux_dir -# -# The reason of the latter failure is that $top_srcdir and $ac_aux_dir -# are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is '.', but things will broke when you -# start a VPATH build or use an absolute $srcdir. -# -# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, -# iff we strip the leading $srcdir from $ac_aux_dir. That would be: -# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` -# and then we would define $MISSING as -# MISSING="\${SHELL} $am_aux_dir/missing" -# This will work as long as MISSING is not called from configure, because -# unfortunately $(top_srcdir) has no meaning in configure. -# However there are other variables, like CC, which are often used in -# configure, and could therefore not use this "fixed" $ac_aux_dir. -# -# Another solution, used here, is to always expand $ac_aux_dir to an -# absolute PATH. The drawback is that using absolute paths prevent a -# configured tree to be moved without reconfiguration. - -AC_DEFUN([AM_AUX_DIR_EXPAND], -[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl -# Expand $ac_aux_dir to an absolute path. -am_aux_dir=`cd "$ac_aux_dir" && pwd` -]) - -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright (C) 1997-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ([2.52])dnl - m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE])dnl -AC_SUBST([$1_FALSE])dnl -_AM_SUBST_NOTMAKE([$1_TRUE])dnl -_AM_SUBST_NOTMAKE([$1_FALSE])dnl -m4_define([_AM_COND_VALUE_$1], [$2])dnl -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([[conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]]) -fi])]) - -# Do all the work for Automake. -*- Autoconf -*- - -# Copyright (C) 1996-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This macro actually does too much. Some checks are only needed if -# your package does certain things. But this isn't really a big deal. - -dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. -m4_define([AC_PROG_CC], -m4_defn([AC_PROG_CC]) -[_AM_PROG_CC_C_O -]) - -# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) -# AM_INIT_AUTOMAKE([OPTIONS]) -# ----------------------------------------------- -# The call with PACKAGE and VERSION arguments is the old style -# call (pre autoconf-2.50), which is being phased out. PACKAGE -# and VERSION should now be passed to AC_INIT and removed from -# the call to AM_INIT_AUTOMAKE. -# We support both call styles for the transition. After -# the next Automake release, Autoconf can make the AC_INIT -# arguments mandatory, and then we can depend on a new Autoconf -# release and drop the old call support. -AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.65])dnl -dnl Autoconf wants to disallow AM_ names. We explicitly allow -dnl the ones we care about. -m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl -AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -AC_REQUIRE([AC_PROG_INSTALL])dnl -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi -AC_SUBST([CYGPATH_W]) - -# Define the identity of the package. -dnl Distinguish between old-style and new-style calls. -m4_ifval([$2], -[AC_DIAGNOSE([obsolete], - [$0: two- and three-arguments forms are deprecated.]) -m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl - AC_SUBST([PACKAGE], [$1])dnl - AC_SUBST([VERSION], [$2])], -[_AM_SET_OPTIONS([$1])dnl -dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if( - m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), - [ok:ok],, - [m4_fatal([AC_INIT should be called with package and version arguments])])dnl - AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl - AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl - -_AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) - AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl - -# Some tools Automake needs. -AC_REQUIRE([AM_SANITY_CHECK])dnl -AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) -AM_MISSING_PROG([AUTOCONF], [autoconf]) -AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) -AM_MISSING_PROG([AUTOHEADER], [autoheader]) -AM_MISSING_PROG([MAKEINFO], [makeinfo]) -AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -AC_SUBST([mkdir_p], ['$(MKDIR_P)']) -# We need awk for the "check" target (and possibly the TAP driver). The -# system "awk" is bad on some platforms. -AC_REQUIRE([AC_PROG_AWK])dnl -AC_REQUIRE([AC_PROG_MAKE_SET])dnl -AC_REQUIRE([AM_SET_LEADING_DOT])dnl -_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], - [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], - [_AM_PROG_TAR([v7])])]) -_AM_IF_OPTION([no-dependencies],, -[AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES([CC])], - [m4_define([AC_PROG_CC], - m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES([CXX])], - [m4_define([AC_PROG_CXX], - m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES([OBJC])], - [m4_define([AC_PROG_OBJC], - m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], - [_AM_DEPENDENCIES([OBJCXX])], - [m4_define([AC_PROG_OBJCXX], - m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl -]) -AC_REQUIRE([AM_SILENT_RULES])dnl -dnl The testsuite driver may need to know about EXEEXT, so add the -dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This -dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. -AC_CONFIG_COMMANDS_PRE(dnl -[m4_provide_if([_AM_COMPILER_EXEEXT], - [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl - -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! - -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: - -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. - -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. - -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . - -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) - fi -fi -dnl The trailing newline in this macro's definition is deliberate, for -dnl backward compatibility and to allow trailing 'dnl'-style comments -dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. -]) - -dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not -dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further -dnl mangled by Autoconf and run in a shell conditional statement. -m4_define([_AC_COMPILER_EXEEXT], -m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) - -# When config.status generates a header, we must update the stamp-h file. -# This file resides in the same directory as the config header -# that is generated. The stamp files are numbered to have different names. - -# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the -# loop where config.status creates the headers, so we can generate -# our stamp files there. -AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], -[# Compute $1's index in $config_headers. -_am_arg=$1 -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $_am_arg | $_am_arg:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) - -# Copyright (C) 2001-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_SH -# ------------------ -# Define $install_sh. -AC_DEFUN([AM_PROG_INSTALL_SH], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac -fi -AC_SUBST([install_sh])]) - -# Copyright (C) 2003-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# Check whether the underlying file-system supports filenames -# with a leading dot. For instance MS-DOS doesn't. -AC_DEFUN([AM_SET_LEADING_DOT], -[rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null -AC_SUBST([am__leading_dot])]) - -# Copyright (C) 1998-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_LEX -# ----------- -# Autoconf leaves LEX=: if lex or flex can't be found. Change that to a -# "missing" invocation, for better error output. -AC_DEFUN([AM_PROG_LEX], -[AC_PREREQ([2.50])dnl -AC_REQUIRE([AM_MISSING_HAS_RUN])dnl -AC_REQUIRE([AC_PROG_LEX])dnl -if test "$LEX" = :; then - LEX=${am_missing_run}flex -fi]) - -# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- -# From Jim Meyering - -# Copyright (C) 1996-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_MAINTAINER_MODE([DEFAULT-MODE]) -# ---------------------------------- -# Control maintainer-specific portions of Makefiles. -# Default is to disable them, unless 'enable' is passed literally. -# For symmetry, 'disable' may be passed as well. Anyway, the user -# can override the default with the --enable/--disable switch. -AC_DEFUN([AM_MAINTAINER_MODE], -[m4_case(m4_default([$1], [disable]), - [enable], [m4_define([am_maintainer_other], [disable])], - [disable], [m4_define([am_maintainer_other], [enable])], - [m4_define([am_maintainer_other], [enable]) - m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) -AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) - dnl maintainer-mode's default is 'disable' unless 'enable' is passed - AC_ARG_ENABLE([maintainer-mode], - [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], - am_maintainer_other[ make rules and dependencies not useful - (and sometimes confusing) to the casual installer])], - [USE_MAINTAINER_MODE=$enableval], - [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) - AC_MSG_RESULT([$USE_MAINTAINER_MODE]) - AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) - MAINT=$MAINTAINER_MODE_TRUE - AC_SUBST([MAINT])dnl -] -) - -# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- - -# Copyright (C) 1997-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_MISSING_PROG(NAME, PROGRAM) -# ------------------------------ -AC_DEFUN([AM_MISSING_PROG], -[AC_REQUIRE([AM_MISSING_HAS_RUN]) -$1=${$1-"${am_missing_run}$2"} -AC_SUBST($1)]) - -# AM_MISSING_HAS_RUN -# ------------------ -# Define MISSING if not defined so far and test if it is modern enough. -# If it is, set am_missing_run to use it, otherwise, to nothing. -AC_DEFUN([AM_MISSING_HAS_RUN], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([missing])dnl -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --is-lightweight"; then - am_missing_run="$MISSING " -else - am_missing_run= - AC_MSG_WARN(['missing' script is too old or missing]) -fi -]) - -# Helper functions for option handling. -*- Autoconf -*- - -# Copyright (C) 2001-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_MANGLE_OPTION(NAME) -# ----------------------- -AC_DEFUN([_AM_MANGLE_OPTION], -[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) - -# _AM_SET_OPTION(NAME) -# -------------------- -# Set option NAME. Presently that only means defining a flag for this option. -AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) - -# _AM_SET_OPTIONS(OPTIONS) -# ------------------------ -# OPTIONS is a space-separated list of Automake options. -AC_DEFUN([_AM_SET_OPTIONS], -[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) - -# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) -# ------------------------------------------- -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -AC_DEFUN([_AM_IF_OPTION], -[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) - -# Copyright (C) 1999-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_PROG_CC_C_O -# --------------- -# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC -# to automatically call this. -AC_DEFUN([_AM_PROG_CC_C_O], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([compile])dnl -AC_LANG_PUSH([C])dnl -AC_CACHE_CHECK( - [whether $CC understands -c and -o together], - [am_cv_prog_cc_c_o], - [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) - # Make sure it works both with $CC and with simple cc. - # Following AC_PROG_CC_C_O, we do the test twice because some - # compilers refuse to overwrite an existing .o file with -o, - # though they will create one. - am_cv_prog_cc_c_o=yes - for am_i in 1 2; do - if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ - && test -f conftest2.$ac_objext; then - : OK - else - am_cv_prog_cc_c_o=no - break - fi - done - rm -f core conftest* - unset am_i]) -if test "$am_cv_prog_cc_c_o" != yes; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" -fi -AC_LANG_POP([C])]) - -# For backward compatibility. -AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) - -# Copyright (C) 2001-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_RUN_LOG(COMMAND) -# ------------------- -# Run COMMAND, save the exit status in ac_status, and log it. -# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) -AC_DEFUN([AM_RUN_LOG], -[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD - ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - (exit $ac_status); }]) - -# Check to make sure that the build environment is sane. -*- Autoconf -*- - -# Copyright (C) 1996-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_SANITY_CHECK -# --------------- -AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[[\\\"\#\$\&\'\`$am_lf]]*) - AC_MSG_ERROR([unsafe absolute working directory name]);; -esac -case $srcdir in - *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; -esac - -# Do 'set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken - alias in your environment]) - fi - if test "$[2]" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done - test "$[2]" = conftest.file - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! -Check your system clock]) -fi -AC_MSG_RESULT([yes]) -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi -AC_CONFIG_COMMANDS_PRE( - [AC_MSG_CHECKING([that generated files are newer than configure]) - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - AC_MSG_RESULT([done])]) -rm -f conftest.file -]) - -# Copyright (C) 2009-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_SILENT_RULES([DEFAULT]) -# -------------------------- -# Enable less verbose build rules; with the default set to DEFAULT -# ("yes" being less verbose, "no" or empty being verbose). -AC_DEFUN([AM_SILENT_RULES], -[AC_ARG_ENABLE([silent-rules], [dnl -AS_HELP_STRING( - [--enable-silent-rules], - [less verbose build output (undo: "make V=1")]) -AS_HELP_STRING( - [--disable-silent-rules], - [verbose build output (undo: "make V=0")])dnl -]) -case $enable_silent_rules in @%:@ ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; -esac -dnl -dnl A few 'make' implementations (e.g., NonStop OS and NextStep) -dnl do not support nested variable expansions. -dnl See automake bug#9928 and bug#10237. -am_make=${MAKE-make} -AC_CACHE_CHECK([whether $am_make supports nested variables], - [am_cv_make_support_nested_variables], - [if AS_ECHO([['TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi]) -if test $am_cv_make_support_nested_variables = yes; then - dnl Using '$V' instead of '$(V)' breaks IRIX make. - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AC_SUBST([AM_V])dnl -AM_SUBST_NOTMAKE([AM_V])dnl -AC_SUBST([AM_DEFAULT_V])dnl -AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl -AC_SUBST([AM_DEFAULT_VERBOSITY])dnl -AM_BACKSLASH='\' -AC_SUBST([AM_BACKSLASH])dnl -_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl -]) - -# Copyright (C) 2001-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_INSTALL_STRIP -# --------------------- -# One issue with vendor 'install' (even GNU) is that you can't -# specify the program used to strip binaries. This is especially -# annoying in cross-compiling environments, where the build's strip -# is unlikely to handle the host's binaries. -# Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in "make install-strip", and initialize -# STRIPPROG with the value of the STRIP variable (set by the user). -AC_DEFUN([AM_PROG_INSTALL_STRIP], -[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using 'strip' when the user -# run "make install-strip". However 'strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the 'STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. -if test "$cross_compiling" != no; then - AC_CHECK_TOOL([STRIP], [strip], :) -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" -AC_SUBST([INSTALL_STRIP_PROGRAM])]) - -# Copyright (C) 2006-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- -# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. -# This macro is traced by Automake. -AC_DEFUN([_AM_SUBST_NOTMAKE]) - -# AM_SUBST_NOTMAKE(VARIABLE) -# -------------------------- -# Public sister of _AM_SUBST_NOTMAKE. -AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) - -# Check how to create a tarball. -*- Autoconf -*- - -# Copyright (C) 2004-2014 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_PROG_TAR(FORMAT) -# -------------------- -# Check how to create a tarball in format FORMAT. -# FORMAT should be one of 'v7', 'ustar', or 'pax'. -# -# Substitute a variable $(am__tar) that is a command -# writing to stdout a FORMAT-tarball containing the directory -# $tardir. -# tardir=directory && $(am__tar) > result.tar -# -# Substitute a variable $(am__untar) that extract such -# a tarball read from stdin. -# $(am__untar) < result.tar -# -AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AC_SUBST([AMTAR], ['$${TAR-tar}']) - -# We'll loop over all known methods to create a tar archive until one works. -_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' - -m4_if([$1], [v7], - [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], - - [m4_case([$1], - [ustar], - [# The POSIX 1988 'ustar' format is defined with fixed-size fields. - # There is notably a 21 bits limit for the UID and the GID. In fact, - # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 - # and bug#13588). - am_max_uid=2097151 # 2^21 - 1 - am_max_gid=$am_max_uid - # The $UID and $GID variables are not portable, so we need to resort - # to the POSIX-mandated id(1) utility. Errors in the 'id' calls - # below are definitely unexpected, so allow the users to see them - # (that is, avoid stderr redirection). - am_uid=`id -u || echo unknown` - am_gid=`id -g || echo unknown` - AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) - if test $am_uid -le $am_max_uid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi - AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) - if test $am_gid -le $am_max_gid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi], - - [pax], - [], - - [m4_fatal([Unknown tar format])]) - - AC_MSG_CHECKING([how to create a $1 tar archive]) - - # Go ahead even if we have the value already cached. We do so because we - # need to set the values for the 'am__tar' and 'am__untar' variables. - _am_tools=${am_cv_prog_tar_$1-$_am_tools} - - for _am_tool in $_am_tools; do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break - - # tar/untar a dummy directory, and stop if the command works. - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi - done - rm -rf conftest.dir - - AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) - AC_MSG_RESULT([$am_cv_prog_tar_$1])]) - -AC_SUBST([am__tar]) -AC_SUBST([am__untar]) -]) # _AM_PROG_TAR - -m4_include([acinclude.m4]) diff --git a/apps/KhiCAS/src/gmp-6.2.1/doc/gmp.info b/apps/KhiCAS/src/gmp-6.2.1/doc/gmp.info index c997affd6..449c156ba 100644 --- a/apps/KhiCAS/src/gmp-6.2.1/doc/gmp.info +++ b/apps/KhiCAS/src/gmp-6.2.1/doc/gmp.info @@ -1,4 +1,4 @@ -This is gmp.info, produced by makeinfo version 6.8 from gmp.texi. +This is gmp.info, produced by makeinfo version 6.7 from gmp.texi. This manual describes how to install and use the GNU multiple precision arithmetic library, version 6.2.1. diff --git a/apps/KhiCAS/src/gmp-6.2.1/doc/gmp.info-1 b/apps/KhiCAS/src/gmp-6.2.1/doc/gmp.info-1 index f19f482c0..0616dbb62 100644 --- a/apps/KhiCAS/src/gmp-6.2.1/doc/gmp.info-1 +++ b/apps/KhiCAS/src/gmp-6.2.1/doc/gmp.info-1 @@ -1,4 +1,4 @@ -This is gmp.info, produced by makeinfo version 6.8 from gmp.texi. +This is gmp.info, produced by makeinfo version 6.7 from gmp.texi. This manual describes how to install and use the GNU multiple precision arithmetic library, version 6.2.1. diff --git a/apps/KhiCAS/src/gmp-6.2.1/doc/gmp.info-2 b/apps/KhiCAS/src/gmp-6.2.1/doc/gmp.info-2 index d142f4b1c..893194953 100644 --- a/apps/KhiCAS/src/gmp-6.2.1/doc/gmp.info-2 +++ b/apps/KhiCAS/src/gmp-6.2.1/doc/gmp.info-2 @@ -1,4 +1,4 @@ -This is gmp.info, produced by makeinfo version 6.8 from gmp.texi. +This is gmp.info, produced by makeinfo version 6.7 from gmp.texi. This manual describes how to install and use the GNU multiple precision arithmetic library, version 6.2.1. @@ -2580,7 +2580,7 @@ Concept Index * Bit scanning functions: Integer Logic and Bit Fiddling. (line 39) * Bit shift left: Integer Arithmetic. (line 38) -* Bit shift right: Integer Division. (line 68) +* Bit shift right: Integer Division. (line 74) * Bits per limb: Useful Macros and Constants. (line 7) * Bug reporting: Reporting Bugs. (line 6) @@ -2621,7 +2621,7 @@ Concept Index * Conditions for copying GNU MP: Copying. (line 6) * Configuring GMP: Installing GMP. (line 6) * Congruence algorithm: Exact Remainder. (line 30) -* Congruence functions: Integer Division. (line 144) +* Congruence functions: Integer Division. (line 150) * Constants: Useful Macros and Constants. (line 6) * Contributors: Contributors. (line 6) @@ -2638,7 +2638,7 @@ Concept Index * CPU types: Introduction to GMP. (line 24) * CPU types <1>: Build Options. (line 107) * Cross compiling: Build Options. (line 65) -* Cryptography functions, low-level: Low-level Functions. (line 506) +* Cryptography functions, low-level: Low-level Functions. (line 507) * Custom allocation: Custom Allocation. (line 6) * CXX: Build Options. (line 249) * CXXFLAGS: Build Options. (line 249) @@ -2652,8 +2652,8 @@ Concept Index * Digits in an integer: Miscellaneous Integer Functions. (line 23) * Divisibility algorithm: Exact Remainder. (line 30) -* Divisibility functions: Integer Division. (line 130) -* Divisibility functions <1>: Integer Division. (line 144) +* Divisibility functions: Integer Division. (line 136) +* Divisibility functions <1>: Integer Division. (line 150) * Divisibility testing: Efficiency. (line 91) * Division algorithms: Division Algorithms. (line 6) * Division functions: Integer Division. (line 6) @@ -2672,7 +2672,7 @@ Concept Index * DVI: Build Options. (line 336) * Efficiency: Efficiency. (line 6) * Emacs: Emacs. (line 6) -* Exact division functions: Integer Division. (line 119) +* Exact division functions: Integer Division. (line 125) * Exact remainder: Exact Remainder. (line 6) * Example programs: Demonstration Programs. (line 6) @@ -2905,7 +2905,7 @@ Concept Index * Logical functions: Integer Logic and Bit Fiddling. (line 6) * Low-level functions: Low-level Functions. (line 6) -* Low-level functions for cryptography: Low-level Functions. (line 506) +* Low-level functions for cryptography: Low-level Functions. (line 507) * Lucas number algorithm: Lucas Numbers Algorithm. (line 6) * Lucas number functions: Number Theoretic Functions. @@ -2944,7 +2944,7 @@ Concept Index * Multi-threading: Reentrancy. (line 6) * Multiplication algorithms: Multiplication Algorithms. (line 6) -* Nails: Low-level Functions. (line 685) +* Nails: Low-level Functions. (line 686) * Native compilation: Build Options. (line 51) * NetBSD: Notes for Particular Systems. (line 100) @@ -3221,21 +3221,21 @@ Function and Type Index * gmp_asprintf: Formatted Output Functions. (line 63) * gmp_errno: Random State Initialization. - (line 55) + (line 56) * GMP_ERROR_INVALID_ARGUMENT: Random State Initialization. - (line 55) + (line 56) * GMP_ERROR_UNSUPPORTED_ARGUMENT: Random State Initialization. - (line 55) + (line 56) * gmp_fprintf: Formatted Output Functions. (line 28) * gmp_fscanf: Formatted Input Functions. (line 24) -* GMP_LIMB_BITS: Low-level Functions. (line 713) -* GMP_NAIL_BITS: Low-level Functions. (line 711) -* GMP_NAIL_MASK: Low-level Functions. (line 721) -* GMP_NUMB_BITS: Low-level Functions. (line 712) -* GMP_NUMB_MASK: Low-level Functions. (line 722) -* GMP_NUMB_MAX: Low-level Functions. (line 730) +* GMP_LIMB_BITS: Low-level Functions. (line 714) +* GMP_NAIL_BITS: Low-level Functions. (line 712) +* GMP_NAIL_MASK: Low-level Functions. (line 722) +* GMP_NUMB_BITS: Low-level Functions. (line 713) +* GMP_NUMB_MASK: Low-level Functions. (line 723) +* GMP_NUMB_MAX: Low-level Functions. (line 731) * gmp_obstack_printf: Formatted Output Functions. (line 75) * gmp_obstack_vprintf: Formatted Output Functions. @@ -3263,7 +3263,7 @@ Function and Type Index * gmp_randclass::seed <1>: C++ Interface Random Numbers. (line 33) * gmp_randclear: Random State Initialization. - (line 61) + (line 62) * gmp_randinit: Random State Initialization. (line 45) * gmp_randinit_default: Random State Initialization. @@ -3283,9 +3283,9 @@ Function and Type Index * gmp_randstate_t: Nomenclature and Types. (line 46) * GMP_RAND_ALG_DEFAULT: Random State Initialization. - (line 49) + (line 50) * GMP_RAND_ALG_LC: Random State Initialization. - (line 49) + (line 50) * gmp_scanf: Formatted Input Functions. (line 20) * gmp_snprintf: Formatted Output Functions. @@ -3464,15 +3464,15 @@ Function and Type Index * mpn_addmul_1: Low-level Functions. (line 148) * mpn_add_1: Low-level Functions. (line 62) * mpn_add_n: Low-level Functions. (line 52) -* mpn_andn_n: Low-level Functions. (line 461) -* mpn_and_n: Low-level Functions. (line 446) -* mpn_cmp: Low-level Functions. (line 292) -* mpn_cnd_add_n: Low-level Functions. (line 539) -* mpn_cnd_sub_n: Low-level Functions. (line 541) -* mpn_cnd_swap: Low-level Functions. (line 566) -* mpn_com: Low-level Functions. (line 486) -* mpn_copyd: Low-level Functions. (line 495) -* mpn_copyi: Low-level Functions. (line 491) +* mpn_andn_n: Low-level Functions. (line 462) +* mpn_and_n: Low-level Functions. (line 447) +* mpn_cmp: Low-level Functions. (line 293) +* mpn_cnd_add_n: Low-level Functions. (line 540) +* mpn_cnd_sub_n: Low-level Functions. (line 542) +* mpn_cnd_swap: Low-level Functions. (line 567) +* mpn_com: Low-level Functions. (line 487) +* mpn_copyd: Low-level Functions. (line 496) +* mpn_copyi: Low-level Functions. (line 492) * mpn_divexact_1: Low-level Functions. (line 231) * mpn_divexact_by3: Low-level Functions. (line 238) * mpn_divexact_by3c: Low-level Functions. (line 240) @@ -3480,56 +3480,56 @@ Function and Type Index * mpn_divmod_1: Low-level Functions. (line 210) * mpn_divrem: Low-level Functions. (line 183) * mpn_divrem_1: Low-level Functions. (line 208) -* mpn_gcd: Low-level Functions. (line 300) -* mpn_gcdext: Low-level Functions. (line 315) -* mpn_gcd_1: Low-level Functions. (line 310) -* mpn_get_str: Low-level Functions. (line 370) -* mpn_hamdist: Low-level Functions. (line 435) -* mpn_iorn_n: Low-level Functions. (line 466) -* mpn_ior_n: Low-level Functions. (line 451) -* mpn_lshift: Low-level Functions. (line 268) -* mpn_mod_1: Low-level Functions. (line 263) +* mpn_gcd: Low-level Functions. (line 301) +* mpn_gcdext: Low-level Functions. (line 316) +* mpn_gcd_1: Low-level Functions. (line 311) +* mpn_get_str: Low-level Functions. (line 371) +* mpn_hamdist: Low-level Functions. (line 436) +* mpn_iorn_n: Low-level Functions. (line 467) +* mpn_ior_n: Low-level Functions. (line 452) +* mpn_lshift: Low-level Functions. (line 269) +* mpn_mod_1: Low-level Functions. (line 264) * mpn_mul: Low-level Functions. (line 114) * mpn_mul_1: Low-level Functions. (line 133) * mpn_mul_n: Low-level Functions. (line 103) -* mpn_nand_n: Low-level Functions. (line 471) +* mpn_nand_n: Low-level Functions. (line 472) * mpn_neg: Low-level Functions. (line 96) -* mpn_nior_n: Low-level Functions. (line 476) -* mpn_perfect_square_p: Low-level Functions. (line 441) -* mpn_popcount: Low-level Functions. (line 431) -* mpn_random: Low-level Functions. (line 421) -* mpn_random2: Low-level Functions. (line 422) -* mpn_rshift: Low-level Functions. (line 280) -* mpn_scan0: Low-level Functions. (line 405) -* mpn_scan1: Low-level Functions. (line 413) -* mpn_sec_add_1: Low-level Functions. (line 552) -* mpn_sec_div_qr: Low-level Functions. (line 629) -* mpn_sec_div_qr_itch: Low-level Functions. (line 632) -* mpn_sec_div_r: Low-level Functions. (line 648) -* mpn_sec_div_r_itch: Low-level Functions. (line 650) -* mpn_sec_invert: Low-level Functions. (line 664) -* mpn_sec_invert_itch: Low-level Functions. (line 666) -* mpn_sec_mul: Low-level Functions. (line 573) -* mpn_sec_mul_itch: Low-level Functions. (line 576) -* mpn_sec_powm: Low-level Functions. (line 603) -* mpn_sec_powm_itch: Low-level Functions. (line 606) -* mpn_sec_sqr: Low-level Functions. (line 589) -* mpn_sec_sqr_itch: Low-level Functions. (line 591) -* mpn_sec_sub_1: Low-level Functions. (line 554) -* mpn_sec_tabselect: Low-level Functions. (line 621) -* mpn_set_str: Low-level Functions. (line 385) -* mpn_sizeinbase: Low-level Functions. (line 363) +* mpn_nior_n: Low-level Functions. (line 477) +* mpn_perfect_square_p: Low-level Functions. (line 442) +* mpn_popcount: Low-level Functions. (line 432) +* mpn_random: Low-level Functions. (line 422) +* mpn_random2: Low-level Functions. (line 423) +* mpn_rshift: Low-level Functions. (line 281) +* mpn_scan0: Low-level Functions. (line 406) +* mpn_scan1: Low-level Functions. (line 414) +* mpn_sec_add_1: Low-level Functions. (line 553) +* mpn_sec_div_qr: Low-level Functions. (line 630) +* mpn_sec_div_qr_itch: Low-level Functions. (line 633) +* mpn_sec_div_r: Low-level Functions. (line 649) +* mpn_sec_div_r_itch: Low-level Functions. (line 651) +* mpn_sec_invert: Low-level Functions. (line 665) +* mpn_sec_invert_itch: Low-level Functions. (line 667) +* mpn_sec_mul: Low-level Functions. (line 574) +* mpn_sec_mul_itch: Low-level Functions. (line 577) +* mpn_sec_powm: Low-level Functions. (line 604) +* mpn_sec_powm_itch: Low-level Functions. (line 607) +* mpn_sec_sqr: Low-level Functions. (line 590) +* mpn_sec_sqr_itch: Low-level Functions. (line 592) +* mpn_sec_sub_1: Low-level Functions. (line 555) +* mpn_sec_tabselect: Low-level Functions. (line 622) +* mpn_set_str: Low-level Functions. (line 386) +* mpn_sizeinbase: Low-level Functions. (line 364) * mpn_sqr: Low-level Functions. (line 125) -* mpn_sqrtrem: Low-level Functions. (line 345) +* mpn_sqrtrem: Low-level Functions. (line 346) * mpn_sub: Low-level Functions. (line 88) * mpn_submul_1: Low-level Functions. (line 160) * mpn_sub_1: Low-level Functions. (line 83) * mpn_sub_n: Low-level Functions. (line 74) * mpn_tdiv_qr: Low-level Functions. (line 172) -* mpn_xnor_n: Low-level Functions. (line 481) -* mpn_xor_n: Low-level Functions. (line 456) -* mpn_zero: Low-level Functions. (line 499) -* mpn_zero_p: Low-level Functions. (line 297) +* mpn_xnor_n: Low-level Functions. (line 482) +* mpn_xor_n: Low-level Functions. (line 457) +* mpn_zero: Low-level Functions. (line 500) +* mpn_zero_p: Low-level Functions. (line 298) * mpq_abs: Rational Arithmetic. (line 33) * mpq_add: Rational Arithmetic. (line 6) * mpq_canonicalize: Rational Number Functions. @@ -3646,7 +3646,7 @@ Function and Type Index * mpz_cdiv_q_2exp: Integer Division. (line 26) * mpz_cdiv_q_ui: Integer Division. (line 17) * mpz_cdiv_r: Integer Division. (line 13) -* mpz_cdiv_r_2exp: Integer Division. (line 28) +* mpz_cdiv_r_2exp: Integer Division. (line 29) * mpz_cdiv_r_ui: Integer Division. (line 19) * mpz_cdiv_ui: Integer Division. (line 23) * mpz_class: C++ Interface General. @@ -3710,29 +3710,29 @@ Function and Type Index (line 19) * mpz_combit: Integer Logic and Bit Fiddling. (line 57) -* mpz_congruent_2exp_p: Integer Division. (line 142) -* mpz_congruent_p: Integer Division. (line 138) -* mpz_congruent_ui_p: Integer Division. (line 140) -* mpz_divexact: Integer Division. (line 116) -* mpz_divexact_ui: Integer Division. (line 117) -* mpz_divisible_2exp_p: Integer Division. (line 129) -* mpz_divisible_p: Integer Division. (line 126) -* mpz_divisible_ui_p: Integer Division. (line 127) +* mpz_congruent_2exp_p: Integer Division. (line 148) +* mpz_congruent_p: Integer Division. (line 144) +* mpz_congruent_ui_p: Integer Division. (line 146) +* mpz_divexact: Integer Division. (line 122) +* mpz_divexact_ui: Integer Division. (line 123) +* mpz_divisible_2exp_p: Integer Division. (line 135) +* mpz_divisible_p: Integer Division. (line 132) +* mpz_divisible_ui_p: Integer Division. (line 133) * mpz_even_p: Miscellaneous Integer Functions. (line 17) * mpz_export: Integer Import and Export. (line 43) * mpz_fac_ui: Number Theoretic Functions. (line 112) -* mpz_fdiv_q: Integer Division. (line 31) -* mpz_fdiv_qr: Integer Division. (line 33) -* mpz_fdiv_qr_ui: Integer Division. (line 40) -* mpz_fdiv_q_2exp: Integer Division. (line 45) -* mpz_fdiv_q_ui: Integer Division. (line 36) -* mpz_fdiv_r: Integer Division. (line 32) -* mpz_fdiv_r_2exp: Integer Division. (line 47) -* mpz_fdiv_r_ui: Integer Division. (line 38) -* mpz_fdiv_ui: Integer Division. (line 42) +* mpz_fdiv_q: Integer Division. (line 33) +* mpz_fdiv_qr: Integer Division. (line 35) +* mpz_fdiv_qr_ui: Integer Division. (line 42) +* mpz_fdiv_q_2exp: Integer Division. (line 47) +* mpz_fdiv_q_ui: Integer Division. (line 38) +* mpz_fdiv_r: Integer Division. (line 34) +* mpz_fdiv_r_2exp: Integer Division. (line 50) +* mpz_fdiv_r_ui: Integer Division. (line 40) +* mpz_fdiv_ui: Integer Division. (line 44) * mpz_fib2_ui: Number Theoretic Functions. (line 134) * mpz_fib_ui: Number Theoretic Functions. @@ -3816,8 +3816,8 @@ Function and Type Index (line 144) * mpz_mfac_uiui: Number Theoretic Functions. (line 114) -* mpz_mod: Integer Division. (line 106) -* mpz_mod_ui: Integer Division. (line 107) +* mpz_mod: Integer Division. (line 112) +* mpz_mod_ui: Integer Division. (line 113) * mpz_mul: Integer Arithmetic. (line 18) * mpz_mul_2exp: Integer Arithmetic. (line 36) * mpz_mul_si: Integer Arithmetic. (line 19) @@ -3890,15 +3890,15 @@ Function and Type Index * mpz_swap: Assigning Integers. (line 36) * mpz_t: Nomenclature and Types. (line 6) -* mpz_tdiv_q: Integer Division. (line 50) -* mpz_tdiv_qr: Integer Division. (line 52) -* mpz_tdiv_qr_ui: Integer Division. (line 59) -* mpz_tdiv_q_2exp: Integer Division. (line 64) -* mpz_tdiv_q_ui: Integer Division. (line 55) -* mpz_tdiv_r: Integer Division. (line 51) -* mpz_tdiv_r_2exp: Integer Division. (line 66) -* mpz_tdiv_r_ui: Integer Division. (line 57) -* mpz_tdiv_ui: Integer Division. (line 61) +* mpz_tdiv_q: Integer Division. (line 54) +* mpz_tdiv_qr: Integer Division. (line 56) +* mpz_tdiv_qr_ui: Integer Division. (line 63) +* mpz_tdiv_q_2exp: Integer Division. (line 68) +* mpz_tdiv_q_ui: Integer Division. (line 59) +* mpz_tdiv_r: Integer Division. (line 55) +* mpz_tdiv_r_2exp: Integer Division. (line 71) +* mpz_tdiv_r_ui: Integer Division. (line 61) +* mpz_tdiv_ui: Integer Division. (line 65) * mpz_tstbit: Integer Logic and Bit Fiddling. (line 60) * mpz_ui_kronecker: Number Theoretic Functions. diff --git a/apps/KhiCAS/src/gmp-6.2.1/mini-gmp/tests/Makefile b/apps/KhiCAS/src/gmp-6.2.1/mini-gmp/tests/Makefile deleted file mode 100644 index 7cc4485de..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mini-gmp/tests/Makefile +++ /dev/null @@ -1,65 +0,0 @@ -# Note: Requires GNU make - -# Copyright 2011, 2012, 2014, 2016, 2018 Free Software Foundation, Inc. -# -# This file is part of the GNU MP Library test suite. -# -# The GNU MP Library test suite is free software; you can redistribute it -# and/or modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 3 of the License, -# or (at your option) any later version. -# -# The GNU MP Library test suite is distributed in the hope that it will be -# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. - -srcdir=. -MINI_GMP_DIR=.. - -CC = gcc -CFLAGS = -O -Wall -g -CPPFLAGS = -LDFLAGS = - -LIBS = -lgmp -lm -lmcheck - -CHECK_PROGRAMS = t-add t-sub t-mul t-invert t-div t-div_2exp \ - t-double t-cmp_d t-gcd t-lcm t-import t-comb t-signed \ - t-sqrt t-root t-powm t-logops t-bitops t-scan t-str \ - t-reuse t-aorsmul t-limbs t-cong t-pprime_p t-lucm \ - t-mpq_addsub t-mpq_muldiv t-mpq_muldiv_2exp t-mpq_str \ - t-mpq_double -# Default TESTS to all tests, allowing overriding TESTS for building tests -# without running them. -TESTS = $(CHECK_PROGRAMS) - -MISC_OBJS = hex-random.o mini-random.o testutils.o - -all: - -clean: - rm -f *.o $(CHECK_PROGRAMS) - -%: %.c -.c: - -# Keep object files -.PRECIOUS: %.o - -%.o: %.c $(MINI_GMP_DIR)/mini-gmp.h $(MINI_GMP_DIR)/mini-mpq.h hex-random.h mini-random.h - $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ - -testutils.o: $(MINI_GMP_DIR)/mini-gmp.c $(MINI_GMP_DIR)/mini-mpq.c - -%: %.o $(MISC_OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ - -# Missing tests include: -# mpz_cmp_d, mpz_popcount, mpz_hamdist, mpz_ui_pow_ui - -check: $(CHECK_PROGRAMS) - $(srcdir)/run-tests $(TESTS) diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/gcdext.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/gcdext.c deleted file mode 120000 index a6a558c00..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/gcdext.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/gcdext.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/gcdext_1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/gcdext_1.c deleted file mode 120000 index d713bc948..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/gcdext_1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/gcdext_1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/gcdext_lehmer.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/gcdext_lehmer.c deleted file mode 120000 index fcc85306e..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/gcdext_lehmer.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/gcdext_lehmer.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/get_d.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/get_d.c deleted file mode 120000 index 5db509edf..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/get_d.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/get_d.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/get_str.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/get_str.c deleted file mode 120000 index 3c7d15ec9..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/get_str.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/get_str.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/hamdist.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/hamdist.c deleted file mode 120000 index 4729a18b9..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/hamdist.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/popham.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd.c deleted file mode 120000 index 575f4591e..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/hgcd.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd2.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd2.c deleted file mode 120000 index 02e007e30..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd2.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/hgcd2.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd2_jacobi.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd2_jacobi.c deleted file mode 120000 index 4b6dfcab5..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd2_jacobi.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/hgcd2_jacobi.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_appr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_appr.c deleted file mode 120000 index 02afc6662..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_appr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/hgcd_appr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_jacobi.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_jacobi.c deleted file mode 120000 index c9dadcffa..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_jacobi.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/hgcd_jacobi.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_matrix.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_matrix.c deleted file mode 120000 index 2e422f1f7..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_matrix.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/hgcd_matrix.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_reduce.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_reduce.c deleted file mode 120000 index 3a34d2997..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_reduce.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/hgcd_reduce.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_step.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_step.c deleted file mode 120000 index 36b9af36c..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/hgcd_step.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/hgcd_step.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/invert.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/invert.c deleted file mode 120000 index c3c7bc428..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/invert.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/invert.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/invertappr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/invertappr.c deleted file mode 120000 index baebc1b17..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/invertappr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/invertappr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/ior_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/ior_n.c deleted file mode 120000 index 0a553d94d..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/ior_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/logops_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/iorn_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/iorn_n.c deleted file mode 120000 index 0a553d94d..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/iorn_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/logops_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/jacbase.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/jacbase.c deleted file mode 120000 index e05b9eadc..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/jacbase.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/jacbase.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/jacobi.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/jacobi.c deleted file mode 120000 index 293d08ae4..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/jacobi.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/jacobi.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/jacobi_2.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/jacobi_2.c deleted file mode 120000 index 5a39ad84f..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/jacobi_2.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/jacobi_2.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/lshift.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/lshift.c deleted file mode 120000 index 555b621ed..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/lshift.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/lshift.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/lshiftc.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/lshiftc.c deleted file mode 120000 index 8ed4a6dfe..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/lshiftc.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/lshiftc.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/matrix22_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/matrix22_mul.c deleted file mode 120000 index df363039e..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/matrix22_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/matrix22_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/matrix22_mul1_inverse_vector.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/matrix22_mul1_inverse_vector.c deleted file mode 120000 index 225610be5..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/matrix22_mul1_inverse_vector.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/matrix22_mul1_inverse_vector.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1.c deleted file mode 120000 index de3e5a1a4..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mod_1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1_1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1_1.c deleted file mode 120000 index 79427766d..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1_1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mod_1_1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1_2.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1_2.c deleted file mode 120000 index 2c5b8c4fa..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1_2.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mod_1_2.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1_3.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1_3.c deleted file mode 120000 index c742d14bc..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1_3.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mod_1_3.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1_4.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1_4.c deleted file mode 120000 index 2ded97371..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_1_4.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mod_1_4.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_34lsub1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_34lsub1.c deleted file mode 120000 index 8d5eecb6b..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mod_34lsub1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mod_34lsub1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mode1o.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mode1o.c deleted file mode 120000 index b7b75c5e7..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mode1o.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mode1o.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mp_bases.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mp_bases.c deleted file mode 100644 index ad1279a8d..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mp_bases.c +++ /dev/null @@ -1,268 +0,0 @@ -/* This file generated by gen-bases.c - DO NOT EDIT. */ - -#include "gmp-impl.h" - -#if GMP_NUMB_BITS != 32 -Error, error, this data is for 32 bits -#endif - -const struct bases mp_bases[257] = -{ - /* 0 */ { 0, 0, 0, 0, 0 }, - /* 1 */ { 0, 0, 0, 0, 0 }, - /* 2 */ { 32, CNST_LIMB(0xffffffff), CNST_LIMB(0x1fffffff), CNST_LIMB(0x1), CNST_LIMB(0x0) }, - /* 3 */ { 20, CNST_LIMB(0xa1849cc1), CNST_LIMB(0x32b80347), CNST_LIMB(0xcfd41b91), CNST_LIMB(0x3b563c24) }, - /* 4 */ { 16, CNST_LIMB(0x7fffffff), CNST_LIMB(0x3fffffff), CNST_LIMB(0x2), CNST_LIMB(0x0) }, - /* 5 */ { 13, CNST_LIMB(0x6e40d1a4), CNST_LIMB(0x4a4d3c25), CNST_LIMB(0x48c27395), CNST_LIMB(0xc25c2684) }, - /* 6 */ { 12, CNST_LIMB(0x6308c91b), CNST_LIMB(0x52b80347), CNST_LIMB(0x81bf1000), CNST_LIMB(0xf91bd1b6) }, - /* 7 */ { 11, CNST_LIMB(0x5b3064eb), CNST_LIMB(0x59d5d9fd), CNST_LIMB(0x75db9c97), CNST_LIMB(0x1607a2cb) }, - /* 8 */ { 10, CNST_LIMB(0x55555555), CNST_LIMB(0x5fffffff), CNST_LIMB(0x3), CNST_LIMB(0x0) }, - /* 9 */ { 10, CNST_LIMB(0x50c24e60), CNST_LIMB(0x6570068e), CNST_LIMB(0xcfd41b91), CNST_LIMB(0x3b563c24) }, - /* 10 */ { 9, CNST_LIMB(0x4d104d42), CNST_LIMB(0x6a4d3c25), CNST_LIMB(0x3b9aca00), CNST_LIMB(0x12e0be82) }, - /* 11 */ { 9, CNST_LIMB(0x4a002707), CNST_LIMB(0x6eb3a9f0), CNST_LIMB(0x8c8b6d2b), CNST_LIMB(0xd24cde04) }, - /* 12 */ { 8, CNST_LIMB(0x4768ce0d), CNST_LIMB(0x72b80347), CNST_LIMB(0x19a10000), CNST_LIMB(0x3fa39ab5) }, - /* 13 */ { 8, CNST_LIMB(0x452e53e3), CNST_LIMB(0x766a008e), CNST_LIMB(0x309f1021), CNST_LIMB(0x50f8ac5f) }, - /* 14 */ { 8, CNST_LIMB(0x433cfffb), CNST_LIMB(0x79d5d9fd), CNST_LIMB(0x57f6c100), CNST_LIMB(0x74843b1e) }, - /* 15 */ { 8, CNST_LIMB(0x41867711), CNST_LIMB(0x7d053f6d), CNST_LIMB(0x98c29b81), CNST_LIMB(0xad0326c2) }, - /* 16 */ { 8, CNST_LIMB(0x3fffffff), CNST_LIMB(0x7fffffff), CNST_LIMB(0x4), CNST_LIMB(0x0) }, - /* 17 */ { 7, CNST_LIMB(0x3ea16afd), CNST_LIMB(0x82cc7edf), CNST_LIMB(0x18754571), CNST_LIMB(0x4ef0b6bd) }, - /* 18 */ { 7, CNST_LIMB(0x3d64598d), CNST_LIMB(0x8570068e), CNST_LIMB(0x247dbc80), CNST_LIMB(0xc0fc48a1) }, - /* 19 */ { 7, CNST_LIMB(0x3c43c230), CNST_LIMB(0x87ef05ae), CNST_LIMB(0x3547667b), CNST_LIMB(0x33838942) }, - /* 20 */ { 7, CNST_LIMB(0x3b3b9a42), CNST_LIMB(0x8a4d3c25), CNST_LIMB(0x4c4b4000), CNST_LIMB(0xad7f29ab) }, - /* 21 */ { 7, CNST_LIMB(0x3a4898f0), CNST_LIMB(0x8c8ddd44), CNST_LIMB(0x6b5a6e1d), CNST_LIMB(0x313c3d15) }, - /* 22 */ { 7, CNST_LIMB(0x39680b13), CNST_LIMB(0x8eb3a9f0), CNST_LIMB(0x94ace180), CNST_LIMB(0xb8cca9e0) }, - /* 23 */ { 7, CNST_LIMB(0x3897b2b7), CNST_LIMB(0x90c10500), CNST_LIMB(0xcaf18367), CNST_LIMB(0x42ed6de9) }, - /* 24 */ { 6, CNST_LIMB(0x37d5aed1), CNST_LIMB(0x92b80347), CNST_LIMB(0xb640000), CNST_LIMB(0x67980e0b) }, - /* 25 */ { 6, CNST_LIMB(0x372068d2), CNST_LIMB(0x949a784b), CNST_LIMB(0xe8d4a51), CNST_LIMB(0x19799812) }, - /* 26 */ { 6, CNST_LIMB(0x3676867e), CNST_LIMB(0x966a008e), CNST_LIMB(0x1269ae40), CNST_LIMB(0xbce85396) }, - /* 27 */ { 6, CNST_LIMB(0x35d6deeb), CNST_LIMB(0x982809d5), CNST_LIMB(0x17179149), CNST_LIMB(0x62c103a9) }, - /* 28 */ { 6, CNST_LIMB(0x354071d6), CNST_LIMB(0x99d5d9fd), CNST_LIMB(0x1cb91000), CNST_LIMB(0x1d353d43) }, - /* 29 */ { 6, CNST_LIMB(0x34b260c5), CNST_LIMB(0x9b74948f), CNST_LIMB(0x23744899), CNST_LIMB(0xce1decea) }, - /* 30 */ { 6, CNST_LIMB(0x342be986), CNST_LIMB(0x9d053f6d), CNST_LIMB(0x2b73a840), CNST_LIMB(0x790fc511) }, - /* 31 */ { 6, CNST_LIMB(0x33ac61b9), CNST_LIMB(0x9e88c6b3), CNST_LIMB(0x34e63b41), CNST_LIMB(0x35b865a0) }, - /* 32 */ { 6, CNST_LIMB(0x33333333), CNST_LIMB(0x9fffffff), CNST_LIMB(0x5), CNST_LIMB(0x0) }, - /* 33 */ { 6, CNST_LIMB(0x32bfd901), CNST_LIMB(0xa16bad37), CNST_LIMB(0x4cfa3cc1), CNST_LIMB(0xa9aed1b3) }, - /* 34 */ { 6, CNST_LIMB(0x3251dcf6), CNST_LIMB(0xa2cc7edf), CNST_LIMB(0x5c13d840), CNST_LIMB(0x63dfc229) }, - /* 35 */ { 6, CNST_LIMB(0x31e8d59f), CNST_LIMB(0xa4231623), CNST_LIMB(0x6d91b519), CNST_LIMB(0x2b0fee30) }, - /* 36 */ { 6, CNST_LIMB(0x3184648d), CNST_LIMB(0xa570068e), CNST_LIMB(0x81bf1000), CNST_LIMB(0xf91bd1b6) }, - /* 37 */ { 6, CNST_LIMB(0x312434e8), CNST_LIMB(0xa6b3d78b), CNST_LIMB(0x98ede0c9), CNST_LIMB(0xac89c3a9) }, - /* 38 */ { 6, CNST_LIMB(0x30c7fa34), CNST_LIMB(0xa7ef05ae), CNST_LIMB(0xb3773e40), CNST_LIMB(0x6d2c32fe) }, - /* 39 */ { 6, CNST_LIMB(0x306f6f4c), CNST_LIMB(0xa92203d5), CNST_LIMB(0xd1bbc4d1), CNST_LIMB(0x387907c9) }, - /* 40 */ { 6, CNST_LIMB(0x301a557f), CNST_LIMB(0xaa4d3c25), CNST_LIMB(0xf4240000), CNST_LIMB(0xc6f7a0b) }, - /* 41 */ { 5, CNST_LIMB(0x2fc873d1), CNST_LIMB(0xab7110e6), CNST_LIMB(0x6e7d349), CNST_LIMB(0x28928154) }, - /* 42 */ { 5, CNST_LIMB(0x2f799652), CNST_LIMB(0xac8ddd44), CNST_LIMB(0x7ca30a0), CNST_LIMB(0x6e8629d) }, - /* 43 */ { 5, CNST_LIMB(0x2f2d8d8f), CNST_LIMB(0xada3f5fb), CNST_LIMB(0x8c32bbb), CNST_LIMB(0xd373dca0) }, - /* 44 */ { 5, CNST_LIMB(0x2ee42e16), CNST_LIMB(0xaeb3a9f0), CNST_LIMB(0x9d46c00), CNST_LIMB(0xa0b17895) }, - /* 45 */ { 5, CNST_LIMB(0x2e9d5009), CNST_LIMB(0xafbd42b4), CNST_LIMB(0xaffacfd), CNST_LIMB(0x746811a5) }, - /* 46 */ { 5, CNST_LIMB(0x2e58cec0), CNST_LIMB(0xb0c10500), CNST_LIMB(0xc46bee0), CNST_LIMB(0x4da6500f) }, - /* 47 */ { 5, CNST_LIMB(0x2e168874), CNST_LIMB(0xb1bf311e), CNST_LIMB(0xdab86ef), CNST_LIMB(0x2ba23582) }, - /* 48 */ { 5, CNST_LIMB(0x2dd65df7), CNST_LIMB(0xb2b80347), CNST_LIMB(0xf300000), CNST_LIMB(0xdb20a88) }, - /* 49 */ { 5, CNST_LIMB(0x2d983275), CNST_LIMB(0xb3abb3fa), CNST_LIMB(0x10d63af1), CNST_LIMB(0xe68d5ce4) }, - /* 50 */ { 5, CNST_LIMB(0x2d5beb38), CNST_LIMB(0xb49a784b), CNST_LIMB(0x12a05f20), CNST_LIMB(0xb7cdfd9d) }, - /* 51 */ { 5, CNST_LIMB(0x2d216f79), CNST_LIMB(0xb5848226), CNST_LIMB(0x1490aae3), CNST_LIMB(0x8e583933) }, - /* 52 */ { 5, CNST_LIMB(0x2ce8a82e), CNST_LIMB(0xb66a008e), CNST_LIMB(0x16a97400), CNST_LIMB(0x697cc3ea) }, - /* 53 */ { 5, CNST_LIMB(0x2cb17fea), CNST_LIMB(0xb74b1fd6), CNST_LIMB(0x18ed2825), CNST_LIMB(0x48a5ca6c) }, - /* 54 */ { 5, CNST_LIMB(0x2c7be2b0), CNST_LIMB(0xb82809d5), CNST_LIMB(0x1b5e4d60), CNST_LIMB(0x2b52db16) }, - /* 55 */ { 5, CNST_LIMB(0x2c47bddb), CNST_LIMB(0xb900e615), CNST_LIMB(0x1dff8297), CNST_LIMB(0x111586a6) }, - /* 56 */ { 5, CNST_LIMB(0x2c14fffc), CNST_LIMB(0xb9d5d9fd), CNST_LIMB(0x20d38000), CNST_LIMB(0xf31d2b36) }, - /* 57 */ { 5, CNST_LIMB(0x2be398c3), CNST_LIMB(0xbaa708f5), CNST_LIMB(0x23dd1799), CNST_LIMB(0xc8d76d19) }, - /* 58 */ { 5, CNST_LIMB(0x2bb378e7), CNST_LIMB(0xbb74948f), CNST_LIMB(0x271f35a0), CNST_LIMB(0xa2cb1eb4) }, - /* 59 */ { 5, CNST_LIMB(0x2b849210), CNST_LIMB(0xbc3e9ca2), CNST_LIMB(0x2a9ce10b), CNST_LIMB(0x807c3ec3) }, - /* 60 */ { 5, CNST_LIMB(0x2b56d6c7), CNST_LIMB(0xbd053f6d), CNST_LIMB(0x2e593c00), CNST_LIMB(0x617ec8bf) }, - /* 61 */ { 5, CNST_LIMB(0x2b2a3a60), CNST_LIMB(0xbdc899ab), CNST_LIMB(0x3257844d), CNST_LIMB(0x45746cbe) }, - /* 62 */ { 5, CNST_LIMB(0x2afeb0f1), CNST_LIMB(0xbe88c6b3), CNST_LIMB(0x369b13e0), CNST_LIMB(0x2c0aa273) }, - /* 63 */ { 5, CNST_LIMB(0x2ad42f3c), CNST_LIMB(0xbf45e08b), CNST_LIMB(0x3b27613f), CNST_LIMB(0x14f90805) }, - /* 64 */ { 5, CNST_LIMB(0x2aaaaaaa), CNST_LIMB(0xbfffffff), CNST_LIMB(0x6), CNST_LIMB(0x0) }, - /* 65 */ { 5, CNST_LIMB(0x2a82193a), CNST_LIMB(0xc0b73cb4), CNST_LIMB(0x4528a141), CNST_LIMB(0xd9cf0829) }, - /* 66 */ { 5, CNST_LIMB(0x2a5a7176), CNST_LIMB(0xc16bad37), CNST_LIMB(0x4aa51420), CNST_LIMB(0xb6fc4841) }, - /* 67 */ { 5, CNST_LIMB(0x2a33aa6e), CNST_LIMB(0xc21d6713), CNST_LIMB(0x50794633), CNST_LIMB(0x973054cb) }, - /* 68 */ { 5, CNST_LIMB(0x2a0dbbaa), CNST_LIMB(0xc2cc7edf), CNST_LIMB(0x56a94400), CNST_LIMB(0x7a1dbe4b) }, - /* 69 */ { 5, CNST_LIMB(0x29e89d24), CNST_LIMB(0xc3790848), CNST_LIMB(0x5d393975), CNST_LIMB(0x5f7fcd7f) }, - /* 70 */ { 5, CNST_LIMB(0x29c44740), CNST_LIMB(0xc4231623), CNST_LIMB(0x642d7260), CNST_LIMB(0x47196c84) }, - /* 71 */ { 5, CNST_LIMB(0x29a0b2c7), CNST_LIMB(0xc4caba78), CNST_LIMB(0x6b8a5ae7), CNST_LIMB(0x30b43635) }, - /* 72 */ { 5, CNST_LIMB(0x297dd8db), CNST_LIMB(0xc570068e), CNST_LIMB(0x73548000), CNST_LIMB(0x1c1fa5f6) }, - /* 73 */ { 5, CNST_LIMB(0x295bb2f9), CNST_LIMB(0xc6130af4), CNST_LIMB(0x7b908fe9), CNST_LIMB(0x930634a) }, - /* 74 */ { 5, CNST_LIMB(0x293a3aeb), CNST_LIMB(0xc6b3d78b), CNST_LIMB(0x84435aa0), CNST_LIMB(0xef7f4a3c) }, - /* 75 */ { 5, CNST_LIMB(0x29196acc), CNST_LIMB(0xc7527b93), CNST_LIMB(0x8d71d25b), CNST_LIMB(0xcf5552d2) }, - /* 76 */ { 5, CNST_LIMB(0x28f93cfb), CNST_LIMB(0xc7ef05ae), CNST_LIMB(0x97210c00), CNST_LIMB(0xb1a47c8e) }, - /* 77 */ { 5, CNST_LIMB(0x28d9ac1b), CNST_LIMB(0xc88983ed), CNST_LIMB(0xa1563f9d), CNST_LIMB(0x9634b43e) }, - /* 78 */ { 5, CNST_LIMB(0x28bab310), CNST_LIMB(0xc92203d5), CNST_LIMB(0xac16c8e0), CNST_LIMB(0x7cd3817d) }, - /* 79 */ { 5, CNST_LIMB(0x289c4cf8), CNST_LIMB(0xc9b89267), CNST_LIMB(0xb768278f), CNST_LIMB(0x65536761) }, - /* 80 */ { 5, CNST_LIMB(0x287e7529), CNST_LIMB(0xca4d3c25), CNST_LIMB(0xc3500000), CNST_LIMB(0x4f8b588e) }, - /* 81 */ { 5, CNST_LIMB(0x28612730), CNST_LIMB(0xcae00d1c), CNST_LIMB(0xcfd41b91), CNST_LIMB(0x3b563c24) }, - /* 82 */ { 5, CNST_LIMB(0x28445ec9), CNST_LIMB(0xcb7110e6), CNST_LIMB(0xdcfa6920), CNST_LIMB(0x28928154) }, - /* 83 */ { 5, CNST_LIMB(0x282817e1), CNST_LIMB(0xcc0052b1), CNST_LIMB(0xeac8fd83), CNST_LIMB(0x1721bfb0) }, - /* 84 */ { 5, CNST_LIMB(0x280c4e90), CNST_LIMB(0xcc8ddd44), CNST_LIMB(0xf9461400), CNST_LIMB(0x6e8629d) }, - /* 85 */ { 4, CNST_LIMB(0x27f0ff1b), CNST_LIMB(0xcd19bb05), CNST_LIMB(0x31c84b1), CNST_LIMB(0x491cc17c) }, - /* 86 */ { 4, CNST_LIMB(0x27d625ec), CNST_LIMB(0xcda3f5fb), CNST_LIMB(0x342ab10), CNST_LIMB(0x3a11d83b) }, - /* 87 */ { 4, CNST_LIMB(0x27bbbf95), CNST_LIMB(0xce2c97d6), CNST_LIMB(0x36a2c21), CNST_LIMB(0x2be074cd) }, - /* 88 */ { 4, CNST_LIMB(0x27a1c8c8), CNST_LIMB(0xceb3a9f0), CNST_LIMB(0x3931000), CNST_LIMB(0x1e7a02e7) }, - /* 89 */ { 4, CNST_LIMB(0x27883e5e), CNST_LIMB(0xcf393550), CNST_LIMB(0x3bd5ee1), CNST_LIMB(0x11d10edd) }, - /* 90 */ { 4, CNST_LIMB(0x276f1d4c), CNST_LIMB(0xcfbd42b4), CNST_LIMB(0x3e92110), CNST_LIMB(0x5d92c68) }, - /* 91 */ { 4, CNST_LIMB(0x275662a8), CNST_LIMB(0xd03fda8b), CNST_LIMB(0x4165ef1), CNST_LIMB(0xf50dbfb2) }, - /* 92 */ { 4, CNST_LIMB(0x273e0ba3), CNST_LIMB(0xd0c10500), CNST_LIMB(0x4452100), CNST_LIMB(0xdf9f1316) }, - /* 93 */ { 4, CNST_LIMB(0x2726158c), CNST_LIMB(0xd140c9fa), CNST_LIMB(0x4756fd1), CNST_LIMB(0xcb52a684) }, - /* 94 */ { 4, CNST_LIMB(0x270e7dc9), CNST_LIMB(0xd1bf311e), CNST_LIMB(0x4a75410), CNST_LIMB(0xb8163e97) }, - /* 95 */ { 4, CNST_LIMB(0x26f741dd), CNST_LIMB(0xd23c41d4), CNST_LIMB(0x4dad681), CNST_LIMB(0xa5d8f269) }, - /* 96 */ { 4, CNST_LIMB(0x26e05f5f), CNST_LIMB(0xd2b80347), CNST_LIMB(0x5100000), CNST_LIMB(0x948b0fcd) }, - /* 97 */ { 4, CNST_LIMB(0x26c9d3fe), CNST_LIMB(0xd3327c6a), CNST_LIMB(0x546d981), CNST_LIMB(0x841e0215) }, - /* 98 */ { 4, CNST_LIMB(0x26b39d7f), CNST_LIMB(0xd3abb3fa), CNST_LIMB(0x57f6c10), CNST_LIMB(0x74843b1e) }, - /* 99 */ { 4, CNST_LIMB(0x269db9bc), CNST_LIMB(0xd423b07e), CNST_LIMB(0x5b9c0d1), CNST_LIMB(0x65b11e6e) }, - /* 100 */ { 4, CNST_LIMB(0x268826a1), CNST_LIMB(0xd49a784b), CNST_LIMB(0x5f5e100), CNST_LIMB(0x5798ee23) }, - /* 101 */ { 4, CNST_LIMB(0x2672e22d), CNST_LIMB(0xd5101187), CNST_LIMB(0x633d5f1), CNST_LIMB(0x4a30b99b) }, - /* 102 */ { 4, CNST_LIMB(0x265dea72), CNST_LIMB(0xd5848226), CNST_LIMB(0x673a910), CNST_LIMB(0x3d6e4d94) }, - /* 103 */ { 4, CNST_LIMB(0x26493d93), CNST_LIMB(0xd5f7cff4), CNST_LIMB(0x6b563e1), CNST_LIMB(0x314825b0) }, - /* 104 */ { 4, CNST_LIMB(0x2634d9c2), CNST_LIMB(0xd66a008e), CNST_LIMB(0x6f91000), CNST_LIMB(0x25b55f2e) }, - /* 105 */ { 4, CNST_LIMB(0x2620bd41), CNST_LIMB(0xd6db196a), CNST_LIMB(0x73eb721), CNST_LIMB(0x1aadaccb) }, - /* 106 */ { 4, CNST_LIMB(0x260ce662), CNST_LIMB(0xd74b1fd6), CNST_LIMB(0x7866310), CNST_LIMB(0x10294ba2) }, - /* 107 */ { 4, CNST_LIMB(0x25f95385), CNST_LIMB(0xd7ba18f9), CNST_LIMB(0x7d01db1), CNST_LIMB(0x620f8f6) }, - /* 108 */ { 4, CNST_LIMB(0x25e60316), CNST_LIMB(0xd82809d5), CNST_LIMB(0x81bf100), CNST_LIMB(0xf91bd1b6) }, - /* 109 */ { 4, CNST_LIMB(0x25d2f390), CNST_LIMB(0xd894f74b), CNST_LIMB(0x869e711), CNST_LIMB(0xe6d37b2a) }, - /* 110 */ { 4, CNST_LIMB(0x25c02379), CNST_LIMB(0xd900e615), CNST_LIMB(0x8ba0a10), CNST_LIMB(0xd55cff6e) }, - /* 111 */ { 4, CNST_LIMB(0x25ad9165), CNST_LIMB(0xd96bdad2), CNST_LIMB(0x90c6441), CNST_LIMB(0xc4ad2db2) }, - /* 112 */ { 4, CNST_LIMB(0x259b3bf3), CNST_LIMB(0xd9d5d9fd), CNST_LIMB(0x9610000), CNST_LIMB(0xb4b985cf) }, - /* 113 */ { 4, CNST_LIMB(0x258921cb), CNST_LIMB(0xda3ee7f3), CNST_LIMB(0x9b7e7c1), CNST_LIMB(0xa5782bef) }, - /* 114 */ { 4, CNST_LIMB(0x257741a2), CNST_LIMB(0xdaa708f5), CNST_LIMB(0xa112610), CNST_LIMB(0x96dfdd2a) }, - /* 115 */ { 4, CNST_LIMB(0x25659a37), CNST_LIMB(0xdb0e4126), CNST_LIMB(0xa6cc591), CNST_LIMB(0x88e7e509) }, - /* 116 */ { 4, CNST_LIMB(0x25542a50), CNST_LIMB(0xdb74948f), CNST_LIMB(0xacad100), CNST_LIMB(0x7b8813d3) }, - /* 117 */ { 4, CNST_LIMB(0x2542f0c2), CNST_LIMB(0xdbda071c), CNST_LIMB(0xb2b5331), CNST_LIMB(0x6eb8b595) }, - /* 118 */ { 4, CNST_LIMB(0x2531ec64), CNST_LIMB(0xdc3e9ca2), CNST_LIMB(0xb8e5710), CNST_LIMB(0x627289db) }, - /* 119 */ { 4, CNST_LIMB(0x25211c1c), CNST_LIMB(0xdca258dc), CNST_LIMB(0xbf3e7a1), CNST_LIMB(0x56aebc07) }, - /* 120 */ { 4, CNST_LIMB(0x25107ed5), CNST_LIMB(0xdd053f6d), CNST_LIMB(0xc5c1000), CNST_LIMB(0x4b66dc33) }, - /* 121 */ { 4, CNST_LIMB(0x25001383), CNST_LIMB(0xdd6753e0), CNST_LIMB(0xcc6db61), CNST_LIMB(0x4094d8a3) }, - /* 122 */ { 4, CNST_LIMB(0x24efd921), CNST_LIMB(0xddc899ab), CNST_LIMB(0xd345510), CNST_LIMB(0x3632f7a5) }, - /* 123 */ { 4, CNST_LIMB(0x24dfceb3), CNST_LIMB(0xde29142e), CNST_LIMB(0xda48871), CNST_LIMB(0x2c3bd1f0) }, - /* 124 */ { 4, CNST_LIMB(0x24cff343), CNST_LIMB(0xde88c6b3), CNST_LIMB(0xe178100), CNST_LIMB(0x22aa4d5f) }, - /* 125 */ { 4, CNST_LIMB(0x24c045e1), CNST_LIMB(0xdee7b471), CNST_LIMB(0xe8d4a51), CNST_LIMB(0x19799812) }, - /* 126 */ { 4, CNST_LIMB(0x24b0c5a6), CNST_LIMB(0xdf45e08b), CNST_LIMB(0xf05f010), CNST_LIMB(0x10a523e5) }, - /* 127 */ { 4, CNST_LIMB(0x24a171b0), CNST_LIMB(0xdfa34e11), CNST_LIMB(0xf817e01), CNST_LIMB(0x828a237) }, - /* 128 */ { 4, CNST_LIMB(0x24924924), CNST_LIMB(0xdfffffff), CNST_LIMB(0x7), CNST_LIMB(0x0) }, - /* 129 */ { 4, CNST_LIMB(0x24834b2c), CNST_LIMB(0xe05bf942), CNST_LIMB(0x10818201), CNST_LIMB(0xf04ec452) }, - /* 130 */ { 4, CNST_LIMB(0x247476f9), CNST_LIMB(0xe0b73cb4), CNST_LIMB(0x11061010), CNST_LIMB(0xe136444a) }, - /* 131 */ { 4, CNST_LIMB(0x2465cbc0), CNST_LIMB(0xe111cd1d), CNST_LIMB(0x118db651), CNST_LIMB(0xd2af9589) }, - /* 132 */ { 4, CNST_LIMB(0x245748bc), CNST_LIMB(0xe16bad37), CNST_LIMB(0x12188100), CNST_LIMB(0xc4b42a83) }, - /* 133 */ { 4, CNST_LIMB(0x2448ed2f), CNST_LIMB(0xe1c4dfab), CNST_LIMB(0x12a67c71), CNST_LIMB(0xb73dccf5) }, - /* 134 */ { 4, CNST_LIMB(0x243ab85d), CNST_LIMB(0xe21d6713), CNST_LIMB(0x1337b510), CNST_LIMB(0xaa4698c5) }, - /* 135 */ { 4, CNST_LIMB(0x242ca992), CNST_LIMB(0xe27545fb), CNST_LIMB(0x13cc3761), CNST_LIMB(0x9dc8f729) }, - /* 136 */ { 4, CNST_LIMB(0x241ec01b), CNST_LIMB(0xe2cc7edf), CNST_LIMB(0x14641000), CNST_LIMB(0x91bf9a30) }, - /* 137 */ { 4, CNST_LIMB(0x2410fb4d), CNST_LIMB(0xe323142d), CNST_LIMB(0x14ff4ba1), CNST_LIMB(0x86257887) }, - /* 138 */ { 4, CNST_LIMB(0x24035a80), CNST_LIMB(0xe3790848), CNST_LIMB(0x159df710), CNST_LIMB(0x7af5c98c) }, - /* 139 */ { 4, CNST_LIMB(0x23f5dd10), CNST_LIMB(0xe3ce5d82), CNST_LIMB(0x16401f31), CNST_LIMB(0x702c01a0) }, - /* 140 */ { 4, CNST_LIMB(0x23e8825d), CNST_LIMB(0xe4231623), CNST_LIMB(0x16e5d100), CNST_LIMB(0x65c3ceb1) }, - /* 141 */ { 4, CNST_LIMB(0x23db49cc), CNST_LIMB(0xe4773465), CNST_LIMB(0x178f1991), CNST_LIMB(0x5bb91502) }, - /* 142 */ { 4, CNST_LIMB(0x23ce32c4), CNST_LIMB(0xe4caba78), CNST_LIMB(0x183c0610), CNST_LIMB(0x5207ec23) }, - /* 143 */ { 4, CNST_LIMB(0x23c13cb3), CNST_LIMB(0xe51daa7e), CNST_LIMB(0x18eca3c1), CNST_LIMB(0x48ac9c19) }, - /* 144 */ { 4, CNST_LIMB(0x23b46706), CNST_LIMB(0xe570068e), CNST_LIMB(0x19a10000), CNST_LIMB(0x3fa39ab5) }, - /* 145 */ { 4, CNST_LIMB(0x23a7b132), CNST_LIMB(0xe5c1d0b5), CNST_LIMB(0x1a592841), CNST_LIMB(0x36e98912) }, - /* 146 */ { 4, CNST_LIMB(0x239b1aac), CNST_LIMB(0xe6130af4), CNST_LIMB(0x1b152a10), CNST_LIMB(0x2e7b3140) }, - /* 147 */ { 4, CNST_LIMB(0x238ea2ef), CNST_LIMB(0xe663b741), CNST_LIMB(0x1bd51311), CNST_LIMB(0x2655840b) }, - /* 148 */ { 4, CNST_LIMB(0x23824976), CNST_LIMB(0xe6b3d78b), CNST_LIMB(0x1c98f100), CNST_LIMB(0x1e7596ea) }, - /* 149 */ { 4, CNST_LIMB(0x23760dc3), CNST_LIMB(0xe7036db3), CNST_LIMB(0x1d60d1b1), CNST_LIMB(0x16d8a20d) }, - /* 150 */ { 4, CNST_LIMB(0x2369ef58), CNST_LIMB(0xe7527b93), CNST_LIMB(0x1e2cc310), CNST_LIMB(0xf7bfe87) }, - /* 151 */ { 4, CNST_LIMB(0x235dedbb), CNST_LIMB(0xe7a102f9), CNST_LIMB(0x1efcd321), CNST_LIMB(0x85d2492) }, - /* 152 */ { 4, CNST_LIMB(0x23520874), CNST_LIMB(0xe7ef05ae), CNST_LIMB(0x1fd11000), CNST_LIMB(0x179a9f4) }, - /* 153 */ { 4, CNST_LIMB(0x23463f10), CNST_LIMB(0xe83c856d), CNST_LIMB(0x20a987e1), CNST_LIMB(0xf59e80eb) }, - /* 154 */ { 4, CNST_LIMB(0x233a911b), CNST_LIMB(0xe88983ed), CNST_LIMB(0x21864910), CNST_LIMB(0xe8b768db) }, - /* 155 */ { 4, CNST_LIMB(0x232efe26), CNST_LIMB(0xe8d602d9), CNST_LIMB(0x226761f1), CNST_LIMB(0xdc39d6d5) }, - /* 156 */ { 4, CNST_LIMB(0x232385c6), CNST_LIMB(0xe92203d5), CNST_LIMB(0x234ce100), CNST_LIMB(0xd021c5d1) }, - /* 157 */ { 4, CNST_LIMB(0x2318278e), CNST_LIMB(0xe96d887e), CNST_LIMB(0x2436d4d1), CNST_LIMB(0xc46b5e37) }, - /* 158 */ { 4, CNST_LIMB(0x230ce318), CNST_LIMB(0xe9b89267), CNST_LIMB(0x25254c10), CNST_LIMB(0xb912f39c) }, - /* 159 */ { 4, CNST_LIMB(0x2301b7fd), CNST_LIMB(0xea03231d), CNST_LIMB(0x26185581), CNST_LIMB(0xae150294) }, - /* 160 */ { 4, CNST_LIMB(0x22f6a5d9), CNST_LIMB(0xea4d3c25), CNST_LIMB(0x27100000), CNST_LIMB(0xa36e2eb1) }, - /* 161 */ { 4, CNST_LIMB(0x22ebac4c), CNST_LIMB(0xea96defe), CNST_LIMB(0x280c5a81), CNST_LIMB(0x991b4094) }, - /* 162 */ { 4, CNST_LIMB(0x22e0caf6), CNST_LIMB(0xeae00d1c), CNST_LIMB(0x290d7410), CNST_LIMB(0x8f19241e) }, - /* 163 */ { 4, CNST_LIMB(0x22d60179), CNST_LIMB(0xeb28c7f2), CNST_LIMB(0x2a135bd1), CNST_LIMB(0x8564e6b7) }, - /* 164 */ { 4, CNST_LIMB(0x22cb4f7a), CNST_LIMB(0xeb7110e6), CNST_LIMB(0x2b1e2100), CNST_LIMB(0x7bfbb5b4) }, - /* 165 */ { 4, CNST_LIMB(0x22c0b4a1), CNST_LIMB(0xebb8e95d), CNST_LIMB(0x2c2dd2f1), CNST_LIMB(0x72dadcc8) }, - /* 166 */ { 4, CNST_LIMB(0x22b63095), CNST_LIMB(0xec0052b1), CNST_LIMB(0x2d428110), CNST_LIMB(0x69ffc498) }, - /* 167 */ { 4, CNST_LIMB(0x22abc300), CNST_LIMB(0xec474e39), CNST_LIMB(0x2e5c3ae1), CNST_LIMB(0x6167f154) }, - /* 168 */ { 4, CNST_LIMB(0x22a16b90), CNST_LIMB(0xec8ddd44), CNST_LIMB(0x2f7b1000), CNST_LIMB(0x5911016e) }, - /* 169 */ { 4, CNST_LIMB(0x229729f1), CNST_LIMB(0xecd4011c), CNST_LIMB(0x309f1021), CNST_LIMB(0x50f8ac5f) }, - /* 170 */ { 4, CNST_LIMB(0x228cfdd4), CNST_LIMB(0xed19bb05), CNST_LIMB(0x31c84b10), CNST_LIMB(0x491cc17c) }, - /* 171 */ { 4, CNST_LIMB(0x2282e6e9), CNST_LIMB(0xed5f0c3c), CNST_LIMB(0x32f6d0b1), CNST_LIMB(0x417b26d8) }, - /* 172 */ { 4, CNST_LIMB(0x2278e4e3), CNST_LIMB(0xeda3f5fb), CNST_LIMB(0x342ab100), CNST_LIMB(0x3a11d83b) }, - /* 173 */ { 4, CNST_LIMB(0x226ef777), CNST_LIMB(0xede87974), CNST_LIMB(0x3563fc11), CNST_LIMB(0x32dee622) }, - /* 174 */ { 4, CNST_LIMB(0x22651e5a), CNST_LIMB(0xee2c97d6), CNST_LIMB(0x36a2c210), CNST_LIMB(0x2be074cd) }, - /* 175 */ { 4, CNST_LIMB(0x225b5944), CNST_LIMB(0xee705249), CNST_LIMB(0x37e71341), CNST_LIMB(0x2514bb58) }, - /* 176 */ { 4, CNST_LIMB(0x2251a7ee), CNST_LIMB(0xeeb3a9f0), CNST_LIMB(0x39310000), CNST_LIMB(0x1e7a02e7) }, - /* 177 */ { 4, CNST_LIMB(0x22480a11), CNST_LIMB(0xeef69fea), CNST_LIMB(0x3a8098c1), CNST_LIMB(0x180ea5d0) }, - /* 178 */ { 4, CNST_LIMB(0x223e7f69), CNST_LIMB(0xef393550), CNST_LIMB(0x3bd5ee10), CNST_LIMB(0x11d10edd) }, - /* 179 */ { 4, CNST_LIMB(0x223507b4), CNST_LIMB(0xef7b6b39), CNST_LIMB(0x3d311091), CNST_LIMB(0xbbfb88e) }, - /* 180 */ { 4, CNST_LIMB(0x222ba2af), CNST_LIMB(0xefbd42b4), CNST_LIMB(0x3e921100), CNST_LIMB(0x5d92c68) }, - /* 181 */ { 4, CNST_LIMB(0x22225019), CNST_LIMB(0xeffebccd), CNST_LIMB(0x3ff90031), CNST_LIMB(0x1c024c) }, - /* 182 */ { 4, CNST_LIMB(0x22190fb4), CNST_LIMB(0xf03fda8b), CNST_LIMB(0x4165ef10), CNST_LIMB(0xf50dbfb2) }, - /* 183 */ { 4, CNST_LIMB(0x220fe141), CNST_LIMB(0xf0809cf2), CNST_LIMB(0x42d8eea1), CNST_LIMB(0xea30efa3) }, - /* 184 */ { 4, CNST_LIMB(0x2206c483), CNST_LIMB(0xf0c10500), CNST_LIMB(0x44521000), CNST_LIMB(0xdf9f1316) }, - /* 185 */ { 4, CNST_LIMB(0x21fdb93f), CNST_LIMB(0xf10113b1), CNST_LIMB(0x45d16461), CNST_LIMB(0xd555c0c9) }, - /* 186 */ { 4, CNST_LIMB(0x21f4bf3a), CNST_LIMB(0xf140c9fa), CNST_LIMB(0x4756fd10), CNST_LIMB(0xcb52a684) }, - /* 187 */ { 4, CNST_LIMB(0x21ebd639), CNST_LIMB(0xf18028cf), CNST_LIMB(0x48e2eb71), CNST_LIMB(0xc193881f) }, - /* 188 */ { 4, CNST_LIMB(0x21e2fe06), CNST_LIMB(0xf1bf311e), CNST_LIMB(0x4a754100), CNST_LIMB(0xb8163e97) }, - /* 189 */ { 4, CNST_LIMB(0x21da3667), CNST_LIMB(0xf1fde3d3), CNST_LIMB(0x4c0e0f51), CNST_LIMB(0xaed8b724) }, - /* 190 */ { 4, CNST_LIMB(0x21d17f28), CNST_LIMB(0xf23c41d4), CNST_LIMB(0x4dad6810), CNST_LIMB(0xa5d8f269) }, - /* 191 */ { 4, CNST_LIMB(0x21c8d811), CNST_LIMB(0xf27a4c05), CNST_LIMB(0x4f535d01), CNST_LIMB(0x9d15039d) }, - /* 192 */ { 4, CNST_LIMB(0x21c040ef), CNST_LIMB(0xf2b80347), CNST_LIMB(0x51000000), CNST_LIMB(0x948b0fcd) }, - /* 193 */ { 4, CNST_LIMB(0x21b7b98f), CNST_LIMB(0xf2f56875), CNST_LIMB(0x52b36301), CNST_LIMB(0x8c394d1d) }, - /* 194 */ { 4, CNST_LIMB(0x21af41bc), CNST_LIMB(0xf3327c6a), CNST_LIMB(0x546d9810), CNST_LIMB(0x841e0215) }, - /* 195 */ { 4, CNST_LIMB(0x21a6d947), CNST_LIMB(0xf36f3ffb), CNST_LIMB(0x562eb151), CNST_LIMB(0x7c3784f8) }, - /* 196 */ { 4, CNST_LIMB(0x219e7ffd), CNST_LIMB(0xf3abb3fa), CNST_LIMB(0x57f6c100), CNST_LIMB(0x74843b1e) }, - /* 197 */ { 4, CNST_LIMB(0x219635af), CNST_LIMB(0xf3e7d937), CNST_LIMB(0x59c5d971), CNST_LIMB(0x6d02985d) }, - /* 198 */ { 4, CNST_LIMB(0x218dfa2e), CNST_LIMB(0xf423b07e), CNST_LIMB(0x5b9c0d10), CNST_LIMB(0x65b11e6e) }, - /* 199 */ { 4, CNST_LIMB(0x2185cd4c), CNST_LIMB(0xf45f3a98), CNST_LIMB(0x5d796e61), CNST_LIMB(0x5e8e5c64) }, - /* 200 */ { 4, CNST_LIMB(0x217daeda), CNST_LIMB(0xf49a784b), CNST_LIMB(0x5f5e1000), CNST_LIMB(0x5798ee23) }, - /* 201 */ { 4, CNST_LIMB(0x21759eac), CNST_LIMB(0xf4d56a5b), CNST_LIMB(0x614a04a1), CNST_LIMB(0x50cf7bde) }, - /* 202 */ { 4, CNST_LIMB(0x216d9c96), CNST_LIMB(0xf5101187), CNST_LIMB(0x633d5f10), CNST_LIMB(0x4a30b99b) }, - /* 203 */ { 4, CNST_LIMB(0x2165a86e), CNST_LIMB(0xf54a6e8c), CNST_LIMB(0x65383231), CNST_LIMB(0x43bb66bd) }, - /* 204 */ { 4, CNST_LIMB(0x215dc207), CNST_LIMB(0xf5848226), CNST_LIMB(0x673a9100), CNST_LIMB(0x3d6e4d94) }, - /* 205 */ { 4, CNST_LIMB(0x2155e939), CNST_LIMB(0xf5be4d0c), CNST_LIMB(0x69448e91), CNST_LIMB(0x374842ee) }, - /* 206 */ { 4, CNST_LIMB(0x214e1ddb), CNST_LIMB(0xf5f7cff4), CNST_LIMB(0x6b563e10), CNST_LIMB(0x314825b0) }, - /* 207 */ { 4, CNST_LIMB(0x21465fc4), CNST_LIMB(0xf6310b8f), CNST_LIMB(0x6d6fb2c1), CNST_LIMB(0x2b6cde75) }, - /* 208 */ { 4, CNST_LIMB(0x213eaecd), CNST_LIMB(0xf66a008e), CNST_LIMB(0x6f910000), CNST_LIMB(0x25b55f2e) }, - /* 209 */ { 4, CNST_LIMB(0x21370ace), CNST_LIMB(0xf6a2af9e), CNST_LIMB(0x71ba3941), CNST_LIMB(0x2020a2c5) }, - /* 210 */ { 4, CNST_LIMB(0x212f73a0), CNST_LIMB(0xf6db196a), CNST_LIMB(0x73eb7210), CNST_LIMB(0x1aadaccb) }, - /* 211 */ { 4, CNST_LIMB(0x2127e920), CNST_LIMB(0xf7133e9b), CNST_LIMB(0x7624be11), CNST_LIMB(0x155b891f) }, - /* 212 */ { 4, CNST_LIMB(0x21206b26), CNST_LIMB(0xf74b1fd6), CNST_LIMB(0x78663100), CNST_LIMB(0x10294ba2) }, - /* 213 */ { 4, CNST_LIMB(0x2118f98f), CNST_LIMB(0xf782bdbf), CNST_LIMB(0x7aafdeb1), CNST_LIMB(0xb160fe9) }, - /* 214 */ { 4, CNST_LIMB(0x21119436), CNST_LIMB(0xf7ba18f9), CNST_LIMB(0x7d01db10), CNST_LIMB(0x620f8f6) }, - /* 215 */ { 4, CNST_LIMB(0x210a3af8), CNST_LIMB(0xf7f13221), CNST_LIMB(0x7f5c3a21), CNST_LIMB(0x14930ef) }, - /* 216 */ { 4, CNST_LIMB(0x2102edb3), CNST_LIMB(0xf82809d5), CNST_LIMB(0x81bf1000), CNST_LIMB(0xf91bd1b6) }, - /* 217 */ { 4, CNST_LIMB(0x20fbac44), CNST_LIMB(0xf85ea0b0), CNST_LIMB(0x842a70e1), CNST_LIMB(0xefdcb0c7) }, - /* 218 */ { 4, CNST_LIMB(0x20f4768a), CNST_LIMB(0xf894f74b), CNST_LIMB(0x869e7110), CNST_LIMB(0xe6d37b2a) }, - /* 219 */ { 4, CNST_LIMB(0x20ed4c62), CNST_LIMB(0xf8cb0e3b), CNST_LIMB(0x891b24f1), CNST_LIMB(0xddfeb94a) }, - /* 220 */ { 4, CNST_LIMB(0x20e62dae), CNST_LIMB(0xf900e615), CNST_LIMB(0x8ba0a100), CNST_LIMB(0xd55cff6e) }, - /* 221 */ { 4, CNST_LIMB(0x20df1a4b), CNST_LIMB(0xf9367f6d), CNST_LIMB(0x8e2ef9d1), CNST_LIMB(0xcceced50) }, - /* 222 */ { 4, CNST_LIMB(0x20d8121c), CNST_LIMB(0xf96bdad2), CNST_LIMB(0x90c64410), CNST_LIMB(0xc4ad2db2) }, - /* 223 */ { 4, CNST_LIMB(0x20d11500), CNST_LIMB(0xf9a0f8d3), CNST_LIMB(0x93669481), CNST_LIMB(0xbc9c75f9) }, - /* 224 */ { 4, CNST_LIMB(0x20ca22d9), CNST_LIMB(0xf9d5d9fd), CNST_LIMB(0x96100000), CNST_LIMB(0xb4b985cf) }, - /* 225 */ { 4, CNST_LIMB(0x20c33b88), CNST_LIMB(0xfa0a7eda), CNST_LIMB(0x98c29b81), CNST_LIMB(0xad0326c2) }, - /* 226 */ { 4, CNST_LIMB(0x20bc5ef1), CNST_LIMB(0xfa3ee7f3), CNST_LIMB(0x9b7e7c10), CNST_LIMB(0xa5782bef) }, - /* 227 */ { 4, CNST_LIMB(0x20b58cf5), CNST_LIMB(0xfa7315d0), CNST_LIMB(0x9e43b6d1), CNST_LIMB(0x9e1771a9) }, - /* 228 */ { 4, CNST_LIMB(0x20aec579), CNST_LIMB(0xfaa708f5), CNST_LIMB(0xa1126100), CNST_LIMB(0x96dfdd2a) }, - /* 229 */ { 4, CNST_LIMB(0x20a8085e), CNST_LIMB(0xfadac1e7), CNST_LIMB(0xa3ea8ff1), CNST_LIMB(0x8fd05c41) }, - /* 230 */ { 4, CNST_LIMB(0x20a1558b), CNST_LIMB(0xfb0e4126), CNST_LIMB(0xa6cc5910), CNST_LIMB(0x88e7e509) }, - /* 231 */ { 4, CNST_LIMB(0x209aace2), CNST_LIMB(0xfb418734), CNST_LIMB(0xa9b7d1e1), CNST_LIMB(0x8225759d) }, - /* 232 */ { 4, CNST_LIMB(0x20940e49), CNST_LIMB(0xfb74948f), CNST_LIMB(0xacad1000), CNST_LIMB(0x7b8813d3) }, - /* 233 */ { 4, CNST_LIMB(0x208d79a5), CNST_LIMB(0xfba769b3), CNST_LIMB(0xafac2921), CNST_LIMB(0x750eccf9) }, - /* 234 */ { 4, CNST_LIMB(0x2086eedb), CNST_LIMB(0xfbda071c), CNST_LIMB(0xb2b53310), CNST_LIMB(0x6eb8b595) }, - /* 235 */ { 4, CNST_LIMB(0x20806dd2), CNST_LIMB(0xfc0c6d44), CNST_LIMB(0xb5c843b1), CNST_LIMB(0x6884e923) }, - /* 236 */ { 4, CNST_LIMB(0x2079f671), CNST_LIMB(0xfc3e9ca2), CNST_LIMB(0xb8e57100), CNST_LIMB(0x627289db) }, - /* 237 */ { 4, CNST_LIMB(0x2073889d), CNST_LIMB(0xfc7095ae), CNST_LIMB(0xbc0cd111), CNST_LIMB(0x5c80c07b) }, - /* 238 */ { 4, CNST_LIMB(0x206d243e), CNST_LIMB(0xfca258dc), CNST_LIMB(0xbf3e7a10), CNST_LIMB(0x56aebc07) }, - /* 239 */ { 4, CNST_LIMB(0x2066c93c), CNST_LIMB(0xfcd3e6a0), CNST_LIMB(0xc27a8241), CNST_LIMB(0x50fbb19b) }, - /* 240 */ { 4, CNST_LIMB(0x2060777e), CNST_LIMB(0xfd053f6d), CNST_LIMB(0xc5c10000), CNST_LIMB(0x4b66dc33) }, - /* 241 */ { 4, CNST_LIMB(0x205a2eed), CNST_LIMB(0xfd3663b2), CNST_LIMB(0xc91209c1), CNST_LIMB(0x45ef7c7c) }, - /* 242 */ { 4, CNST_LIMB(0x2053ef71), CNST_LIMB(0xfd6753e0), CNST_LIMB(0xcc6db610), CNST_LIMB(0x4094d8a3) }, - /* 243 */ { 4, CNST_LIMB(0x204db8f3), CNST_LIMB(0xfd981064), CNST_LIMB(0xcfd41b91), CNST_LIMB(0x3b563c24) }, - /* 244 */ { 4, CNST_LIMB(0x20478b5c), CNST_LIMB(0xfdc899ab), CNST_LIMB(0xd3455100), CNST_LIMB(0x3632f7a5) }, - /* 245 */ { 4, CNST_LIMB(0x20416696), CNST_LIMB(0xfdf8f020), CNST_LIMB(0xd6c16d31), CNST_LIMB(0x312a60c3) }, - /* 246 */ { 4, CNST_LIMB(0x203b4a8b), CNST_LIMB(0xfe29142e), CNST_LIMB(0xda488710), CNST_LIMB(0x2c3bd1f0) }, - /* 247 */ { 4, CNST_LIMB(0x20353725), CNST_LIMB(0xfe59063c), CNST_LIMB(0xdddab5a1), CNST_LIMB(0x2766aa45) }, - /* 248 */ { 4, CNST_LIMB(0x202f2c4e), CNST_LIMB(0xfe88c6b3), CNST_LIMB(0xe1781000), CNST_LIMB(0x22aa4d5f) }, - /* 249 */ { 4, CNST_LIMB(0x202929f0), CNST_LIMB(0xfeb855f8), CNST_LIMB(0xe520ad61), CNST_LIMB(0x1e06233c) }, - /* 250 */ { 4, CNST_LIMB(0x20232ff8), CNST_LIMB(0xfee7b471), CNST_LIMB(0xe8d4a510), CNST_LIMB(0x19799812) }, - /* 251 */ { 4, CNST_LIMB(0x201d3e50), CNST_LIMB(0xff16e281), CNST_LIMB(0xec940e71), CNST_LIMB(0x15041c33) }, - /* 252 */ { 4, CNST_LIMB(0x201754e5), CNST_LIMB(0xff45e08b), CNST_LIMB(0xf05f0100), CNST_LIMB(0x10a523e5) }, - /* 253 */ { 4, CNST_LIMB(0x201173a1), CNST_LIMB(0xff74aef0), CNST_LIMB(0xf4359451), CNST_LIMB(0xc5c2749) }, - /* 254 */ { 4, CNST_LIMB(0x200b9a71), CNST_LIMB(0xffa34e11), CNST_LIMB(0xf817e010), CNST_LIMB(0x828a237) }, - /* 255 */ { 4, CNST_LIMB(0x2005c942), CNST_LIMB(0xffd1be4c), CNST_LIMB(0xfc05fc01), CNST_LIMB(0x40a1423) }, - /* 256 */ { 4, CNST_LIMB(0x1fffffff), CNST_LIMB(0xffffffff), CNST_LIMB(0x8), CNST_LIMB(0x0) }, -}; diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_bdiv_q.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_bdiv_q.c deleted file mode 120000 index 9b04f38a9..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_bdiv_q.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mu_bdiv_q.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_bdiv_qr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_bdiv_qr.c deleted file mode 120000 index e6f2ed39d..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_bdiv_qr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mu_bdiv_qr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_div_q.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_div_q.c deleted file mode 120000 index 470e70584..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_div_q.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mu_div_q.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_div_qr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_div_qr.c deleted file mode 120000 index 456619627..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_div_qr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mu_div_qr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_divappr_q.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_divappr_q.c deleted file mode 120000 index a06e1cd7b..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mu_divappr_q.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mu_divappr_q.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mul.c deleted file mode 120000 index f7ede4fb9..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mul_1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mul_1.c deleted file mode 120000 index 580ced6fa..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mul_1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mul_1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mul_basecase.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mul_basecase.c deleted file mode 120000 index 0ee2c4b1e..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mul_basecase.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mul_basecase.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mul_fft.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mul_fft.c deleted file mode 120000 index b064cd252..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mul_fft.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mul_fft.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mul_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mul_n.c deleted file mode 120000 index de41b2e08..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mul_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mul_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mullo_basecase.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mullo_basecase.c deleted file mode 120000 index 948d1f3a8..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mullo_basecase.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mullo_basecase.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mullo_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mullo_n.c deleted file mode 120000 index 010baa87a..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mullo_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mullo_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mulmid.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mulmid.c deleted file mode 120000 index d90ce25d3..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mulmid.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mulmid.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mulmid_basecase.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mulmid_basecase.c deleted file mode 120000 index eb3bc955f..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mulmid_basecase.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mulmid_basecase.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mulmid_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mulmid_n.c deleted file mode 120000 index 546526470..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mulmid_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mulmid_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/mulmod_bnm1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/mulmod_bnm1.c deleted file mode 120000 index 397e0ef97..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/mulmod_bnm1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/mulmod_bnm1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/nand_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/nand_n.c deleted file mode 120000 index 0a553d94d..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/nand_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/logops_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/neg.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/neg.c deleted file mode 120000 index 8774bf54f..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/neg.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/neg.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/nior_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/nior_n.c deleted file mode 120000 index 0a553d94d..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/nior_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/logops_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/nussbaumer_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/nussbaumer_mul.c deleted file mode 120000 index 519e30cc4..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/nussbaumer_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/nussbaumer_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/perfpow.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/perfpow.c deleted file mode 120000 index c89604392..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/perfpow.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/perfpow.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/perfsqr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/perfsqr.c deleted file mode 120000 index 447874916..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/perfsqr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/perfsqr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/popcount.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/popcount.c deleted file mode 120000 index 4729a18b9..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/popcount.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/popham.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/pow_1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/pow_1.c deleted file mode 120000 index 55ffecf16..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/pow_1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/pow_1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/powm.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/powm.c deleted file mode 120000 index b1d874487..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/powm.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/powm.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/pre_divrem_1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/pre_divrem_1.c deleted file mode 120000 index 6b2349f4e..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/pre_divrem_1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/pre_divrem_1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/pre_mod_1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/pre_mod_1.c deleted file mode 120000 index ed1e6e2f0..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/pre_mod_1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/pre_mod_1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/random.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/random.c deleted file mode 120000 index b84c7c691..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/random.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/random.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/random2.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/random2.c deleted file mode 120000 index e9bd5b1db..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/random2.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/random2.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/redc_1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/redc_1.c deleted file mode 120000 index 61d4a17a7..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/redc_1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/redc_1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/redc_2.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/redc_2.c deleted file mode 120000 index b2ede580d..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/redc_2.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/redc_2.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/redc_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/redc_n.c deleted file mode 120000 index e9c260f51..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/redc_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/redc_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/remove.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/remove.c deleted file mode 120000 index 057e2caa6..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/remove.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/remove.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/rootrem.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/rootrem.c deleted file mode 120000 index ac052e8d3..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/rootrem.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/rootrem.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/rshift.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/rshift.c deleted file mode 120000 index 484e0e5b5..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/rshift.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/rshift.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_bdiv_q.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_bdiv_q.c deleted file mode 120000 index de362a300..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_bdiv_q.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sbpi1_bdiv_q.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_bdiv_qr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_bdiv_qr.c deleted file mode 120000 index a0d6b8e34..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_bdiv_qr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sbpi1_bdiv_qr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_bdiv_r.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_bdiv_r.c deleted file mode 120000 index 8af23e70b..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_bdiv_r.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sbpi1_bdiv_r.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_div_q.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_div_q.c deleted file mode 120000 index 87ee30422..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_div_q.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sbpi1_div_q.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_div_qr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_div_qr.c deleted file mode 120000 index 0de92a8d1..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_div_qr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sbpi1_div_qr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_divappr_q.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_divappr_q.c deleted file mode 120000 index 49f23463c..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sbpi1_divappr_q.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sbpi1_divappr_q.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/scan0.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/scan0.c deleted file mode 120000 index 4b2f7b13b..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/scan0.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/scan0.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/scan1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/scan1.c deleted file mode 120000 index 3f5189056..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/scan1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/scan1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_add_1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_add_1.c deleted file mode 120000 index 5fde85170..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_add_1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sec_aors_1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_div_qr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_div_qr.c deleted file mode 120000 index 7e1f1b28b..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_div_qr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sec_div.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_div_r.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_div_r.c deleted file mode 120000 index 7e1f1b28b..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_div_r.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sec_div.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_invert.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_invert.c deleted file mode 120000 index 66841bf41..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_invert.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sec_invert.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_mul.c deleted file mode 120000 index 9a72c9342..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sec_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_pi1_div_qr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_pi1_div_qr.c deleted file mode 120000 index 920657aa8..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_pi1_div_qr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sec_pi1_div.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_pi1_div_r.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_pi1_div_r.c deleted file mode 120000 index 920657aa8..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_pi1_div_r.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sec_pi1_div.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_powm.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_powm.c deleted file mode 120000 index e00403c10..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_powm.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sec_powm.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_sqr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_sqr.c deleted file mode 120000 index 4becde2ea..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_sqr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sec_sqr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_sub_1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_sub_1.c deleted file mode 120000 index 5fde85170..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_sub_1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sec_aors_1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_tabselect.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_tabselect.c deleted file mode 120000 index fdde7a413..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sec_tabselect.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sec_tabselect.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/set_str.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/set_str.c deleted file mode 120000 index 93864554d..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/set_str.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/set_str.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sizeinbase.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sizeinbase.c deleted file mode 120000 index c6a7cd877..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sizeinbase.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sizeinbase.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sqr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sqr.c deleted file mode 120000 index 5264cae30..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sqr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sqr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sqr_basecase.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sqr_basecase.c deleted file mode 120000 index fb8a1f80c..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sqr_basecase.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sqr_basecase.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sqrlo.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sqrlo.c deleted file mode 120000 index fd18efe90..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sqrlo.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sqrlo.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sqrlo_basecase.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sqrlo_basecase.c deleted file mode 120000 index 39e518bfb..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sqrlo_basecase.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sqrlo_basecase.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sqrtrem.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sqrtrem.c deleted file mode 120000 index 64e752209..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sqrtrem.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sqrtrem.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/strongfibo.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/strongfibo.c deleted file mode 120000 index 0186e6958..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/strongfibo.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/strongfibo.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sub.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sub.c deleted file mode 120000 index cf4818438..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sub.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sub.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_1.c deleted file mode 120000 index 4efdb594a..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sub_1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_err1_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_err1_n.c deleted file mode 120000 index dde35ce0c..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_err1_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sub_err1_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_err2_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_err2_n.c deleted file mode 120000 index f59bfd667..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_err2_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sub_err2_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_err3_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_err3_n.c deleted file mode 120000 index ea03b12e0..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_err3_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sub_err3_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_n.c deleted file mode 120000 index 1926b4638..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/sub_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/sub_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/submul_1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/submul_1.c deleted file mode 120000 index be9f534f5..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/submul_1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/submul_1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/tdiv_qr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/tdiv_qr.c deleted file mode 120000 index a5b0b25ee..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/tdiv_qr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/tdiv_qr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom22_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom22_mul.c deleted file mode 120000 index d9611f34a..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom22_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom22_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom2_sqr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom2_sqr.c deleted file mode 120000 index 2f4a7199a..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom2_sqr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom2_sqr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom32_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom32_mul.c deleted file mode 120000 index 594557b35..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom32_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom32_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom33_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom33_mul.c deleted file mode 120000 index 35ca5cb21..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom33_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom33_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom3_sqr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom3_sqr.c deleted file mode 120000 index 7a2df4576..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom3_sqr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom3_sqr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom42_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom42_mul.c deleted file mode 120000 index 0e2821b6e..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom42_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom42_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom42_mulmid.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom42_mulmid.c deleted file mode 120000 index d2e26404a..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom42_mulmid.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom42_mulmid.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom43_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom43_mul.c deleted file mode 120000 index 73c999a05..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom43_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom43_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom44_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom44_mul.c deleted file mode 120000 index a470f2976..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom44_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom44_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom4_sqr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom4_sqr.c deleted file mode 120000 index 59eac76ee..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom4_sqr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom4_sqr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom52_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom52_mul.c deleted file mode 120000 index a1621167e..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom52_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom52_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom53_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom53_mul.c deleted file mode 120000 index 043bd74da..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom53_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom53_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom54_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom54_mul.c deleted file mode 120000 index 3ccd1dcd7..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom54_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom54_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom62_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom62_mul.c deleted file mode 120000 index 98039c1ff..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom62_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom62_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom63_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom63_mul.c deleted file mode 120000 index f74dea197..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom63_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom63_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom6_sqr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom6_sqr.c deleted file mode 120000 index f48935020..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom6_sqr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom6_sqr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom6h_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom6h_mul.c deleted file mode 120000 index dca308e78..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom6h_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom6h_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom8_sqr.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom8_sqr.c deleted file mode 120000 index f519bae90..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom8_sqr.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom8_sqr.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom8h_mul.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom8h_mul.c deleted file mode 120000 index d40b0cdd6..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom8h_mul.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom8h_mul.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_couple_handling.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_couple_handling.c deleted file mode 120000 index 2a4eaedae..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_couple_handling.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom_couple_handling.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_dgr3_pm1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_dgr3_pm1.c deleted file mode 120000 index 42819a3f7..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_dgr3_pm1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom_eval_dgr3_pm1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_dgr3_pm2.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_dgr3_pm2.c deleted file mode 120000 index 1decd3458..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_dgr3_pm2.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom_eval_dgr3_pm2.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_pm1.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_pm1.c deleted file mode 120000 index 0f34ff356..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_pm1.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom_eval_pm1.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_pm2.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_pm2.c deleted file mode 120000 index 8b85d5b19..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_pm2.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom_eval_pm2.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_pm2exp.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_pm2exp.c deleted file mode 120000 index c4814a984..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_pm2exp.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom_eval_pm2exp.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_pm2rexp.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_pm2rexp.c deleted file mode 120000 index d151e02e4..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_eval_pm2rexp.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom_eval_pm2rexp.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_12pts.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_12pts.c deleted file mode 120000 index f5999b5d7..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_12pts.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom_interpolate_12pts.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_16pts.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_16pts.c deleted file mode 120000 index 5743b1ee3..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_16pts.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom_interpolate_16pts.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_5pts.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_5pts.c deleted file mode 120000 index 76bc0d13b..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_5pts.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom_interpolate_5pts.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_6pts.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_6pts.c deleted file mode 120000 index cf8c87773..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_6pts.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom_interpolate_6pts.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_7pts.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_7pts.c deleted file mode 120000 index c75a4737e..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_7pts.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom_interpolate_7pts.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_8pts.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_8pts.c deleted file mode 120000 index f23185bb5..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/toom_interpolate_8pts.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/toom_interpolate_8pts.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/trialdiv.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/trialdiv.c deleted file mode 120000 index 169e53aac..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/trialdiv.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/trialdiv.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/xnor_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/xnor_n.c deleted file mode 120000 index 0a553d94d..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/xnor_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/logops_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/xor_n.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/xor_n.c deleted file mode 120000 index 0a553d94d..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/xor_n.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/logops_n.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/zero.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/zero.c deleted file mode 120000 index e0ba5ec42..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/zero.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/zero.c \ No newline at end of file diff --git a/apps/KhiCAS/src/gmp-6.2.1/mpn/zero_p.c b/apps/KhiCAS/src/gmp-6.2.1/mpn/zero_p.c deleted file mode 120000 index 3468aeff0..000000000 --- a/apps/KhiCAS/src/gmp-6.2.1/mpn/zero_p.c +++ /dev/null @@ -1 +0,0 @@ -../mpn/generic/zero_p.c \ No newline at end of file diff --git a/apps/KhiCAS/src/main.cpp b/apps/KhiCAS/src/main.cpp index 1ff6953c9..0c1611b9e 100644 --- a/apps/KhiCAS/src/main.cpp +++ b/apps/KhiCAS/src/main.cpp @@ -26,6 +26,10 @@ void extapp_main() { ext_main(); } +bool iskeydown(int key) { + return extapp_isKeydown(key); +} + uint64_t millis() { return extapp_millis(); } @@ -193,11 +197,6 @@ int getkey(int allow_suspend) { return extapp_getKey(allow_suspend, &alphawasactive_); } - -bool iskeydown(int key) { - return extapp_isKeydown(key); -} - void GetKey(int * key) { *key = getkey(true); } diff --git a/apps/KhiCAS/src/micropython-1.12/numworks/graphic.c b/apps/KhiCAS/src/micropython-1.12/numworks/graphic.c index 15b9a2cd3..c1425cfcc 100644 --- a/apps/KhiCAS/src/micropython-1.12/numworks/graphic.c +++ b/apps/KhiCAS/src/micropython-1.12/numworks/graphic.c @@ -204,7 +204,7 @@ static mp_obj_t graphic_draw_line(size_t n_args, const mp_obj_t *args) { x2 = mp_obj_get_int(args[2]), y2 = mp_obj_get_int(args[3]), color=0; if (n_args==5) - color = mp_obj_get_int(args[4]); + color = mp_get_color(args[4]); c_draw_line(x1,y1,x2,y2,color); return mp_const_none; } @@ -254,7 +254,7 @@ static mp_obj_t graphic_draw_polygon_(size_t n_args, const mp_obj_t *args,bool f ++tab; } if (n_args==2) - color = mp_obj_get_int(args[1]); + color = mp_get_color(args[1]); if (filled) c_draw_filled_polygon(x,y,n,0,LCD_WIDTH,0,LCD_HEIGHT,color); else diff --git a/apps/KhiCAS/src/micropython-1.12/numworks/graphic.c~ b/apps/KhiCAS/src/micropython-1.12/numworks/graphic.c~ index cc79ba545..fca309fa1 100644 --- a/apps/KhiCAS/src/micropython-1.12/numworks/graphic.c~ +++ b/apps/KhiCAS/src/micropython-1.12/numworks/graphic.c~ @@ -22,6 +22,7 @@ #include "parse.h" #include "compile.h" extern const struct _mp_obj_module_t mp_module_graphic; +void py_ck_ctrl_c(); // basic #ifdef NUMWORKS void c_sprint_double(char * s,double d); @@ -203,7 +204,7 @@ static mp_obj_t graphic_draw_line(size_t n_args, const mp_obj_t *args) { x2 = mp_obj_get_int(args[2]), y2 = mp_obj_get_int(args[3]), color=0; if (n_args==5) - color = mp_obj_get_int(args[4]); + color = mp_get_colr(args[4]); c_draw_line(x1,y1,x2,y2,color); return mp_const_none; } @@ -253,7 +254,7 @@ static mp_obj_t graphic_draw_polygon_(size_t n_args, const mp_obj_t *args,bool f ++tab; } if (n_args==2) - color = mp_obj_get_int(args[1]); + color = mp_get_color(args[1]); if (filled) c_draw_filled_polygon(x,y,n,0,LCD_WIDTH,0,LCD_HEIGHT,color); else @@ -2055,7 +2056,6 @@ const mp_obj_module_t mp_module_linalg = { /* TURTLE, using caseval */ void turtle_freeze(); -void py_ck_ctrl_c(); mp_obj_t turtle_ret(const char * val){ py_ck_ctrl_c(); diff --git a/apps/KhiCAS/src/micropython-1.12/numworks/main.c b/apps/KhiCAS/src/micropython-1.12/numworks/main.c index 8ab6f84c3..017da20f0 100644 --- a/apps/KhiCAS/src/micropython-1.12/numworks/main.c +++ b/apps/KhiCAS/src/micropython-1.12/numworks/main.c @@ -308,6 +308,7 @@ void mp_keyboard_interrupt(void) { bool back_key_pressed(); int getkey(int allow_suspend); +double millis(); int micropython_port_vm_hook_loop() { /* This function is called very frequently by the MicroPython engine. We grab @@ -317,12 +318,18 @@ int micropython_port_vm_hook_loop() { /* Doing too many things here slows down Python execution quite a lot. So we * only do things once in a while and return as soon as possible otherwise. */ static int c = 0; - ++c; - if (c & 0x7ff ) { + if (c & 0x7f ) { return 0; } + static double t = 0; + const int delay = 100; + double t2 = millis(); + if (t2-t header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the `dup2' function. */ +#undef HAVE_DUP2 + +/* Define to 1 if you have the header file. */ +#undef HAVE_FLOAT_H + +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `mpfr_q_sub' function. */ +#undef HAVE_MPFR_Q_SUB + +/* Define to 1 if you have the `mpfr_z_div' function. */ +#undef HAVE_MPFR_Z_DIV + +/* Define to 1 if you have the `mpfr_z_sub' function. */ +#undef HAVE_MPFR_Z_SUB + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#undef LT_OBJDIR + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif + + +/* Version number of package */ +#undef VERSION + +/* Define to 1 if it is a development version. */ +#undef WARN_IF_REVERTED_ENDPOINTS + +/* Define to 1 if on MINIX. */ +#undef _MINIX + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#undef _POSIX_1_SOURCE + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#undef _POSIX_SOURCE + +/* Define to `unsigned int' if does not define. */ +#undef size_t diff --git a/apps/KhiCAS/src/mpfr-4.1.0/doc/mpfr.info b/apps/KhiCAS/src/mpfr-4.1.0/doc/mpfr.info index 5f2e3ae82..264896d0b 100644 --- a/apps/KhiCAS/src/mpfr-4.1.0/doc/mpfr.info +++ b/apps/KhiCAS/src/mpfr-4.1.0/doc/mpfr.info @@ -1,4 +1,4 @@ -This is mpfr.info, produced by makeinfo version 6.8 from mpfr.texi. +This is mpfr.info, produced by makeinfo version 6.7 from mpfr.texi. This manual documents how to install and use the Multiple Precision Floating-Point Reliable Library, version 4.1.0. @@ -4381,7 +4381,7 @@ Concept Index * Exception related functions: Exception Related Functions. (line 3) * Exponent: Nomenclature and Types. - (line 39) + (line 41) * Floating-point functions: MPFR Interface. (line 6) * Floating-point number: Nomenclature and Types. (line 6) @@ -4390,7 +4390,7 @@ Concept Index * GNU Free Documentation License <1>: GNU Free Documentation License. (line 6) * Group of flags: Nomenclature and Types. - (line 50) + (line 52) * I/O functions: Input and Output Functions. (line 3) * I/O functions <1>: Formatted Output Functions. @@ -4427,7 +4427,7 @@ Concept Index * Output functions <1>: Formatted Output Functions. (line 3) * Precision: Nomenclature and Types. - (line 25) + (line 27) * Precision <1>: MPFR Interface. (line 17) * Regular number: Nomenclature and Types. (line 6) @@ -4435,7 +4435,7 @@ Concept Index (line 3) * Reporting bugs: Reporting Bugs. (line 6) * Rounding: Nomenclature and Types. - (line 45) + (line 47) * Rounding mode related functions: Rounding-Related Functions. (line 3) * stdarg.h: Headers and Libraries. @@ -4444,7 +4444,7 @@ Concept Index (line 22) * stdio.h: Headers and Libraries. (line 12) -* Ternary value: Rounding. (line 75) +* Ternary value: Rounding. (line 79) * Transcendental functions: Transcendental Functions. (line 3) * uintmax_t: Headers and Libraries. @@ -4460,11 +4460,11 @@ Function and Type Index * Menu: * mpfr_abs: Arithmetic Functions. - (line 142) + (line 144) * mpfr_acos: Transcendental Functions. - (line 118) + (line 120) * mpfr_acosh: Transcendental Functions. - (line 182) + (line 185) * mpfr_add: Arithmetic Functions. (line 6) * mpfr_add_d: Arithmetic Functions. @@ -4478,23 +4478,23 @@ Function and Type Index * mpfr_add_z: Arithmetic Functions. (line 14) * mpfr_agm: Transcendental Functions. - (line 278) + (line 281) * mpfr_ai: Transcendental Functions. - (line 288) + (line 291) * mpfr_asin: Transcendental Functions. - (line 119) + (line 121) * mpfr_asinh: Transcendental Functions. - (line 183) + (line 186) * mpfr_asprintf: Formatted Output Functions. (line 199) * mpfr_atan: Transcendental Functions. - (line 120) + (line 122) * mpfr_atan2: Transcendental Functions. - (line 130) + (line 132) * mpfr_atanh: Transcendental Functions. - (line 184) + (line 187) * mpfr_beta: Transcendental Functions. - (line 240) + (line 243) * mpfr_buildopt_decimal_p: Miscellaneous Functions. (line 185) * mpfr_buildopt_float128_p: Miscellaneous Functions. @@ -4510,7 +4510,7 @@ Function and Type Index * mpfr_can_round: Rounding-Related Functions. (line 40) * mpfr_cbrt: Arithmetic Functions. - (line 115) + (line 116) * mpfr_ceil: Integer and Remainder Related Functions. (line 7) * mpfr_check_range: Exception Related Functions. @@ -4558,27 +4558,27 @@ Function and Type Index * mpfr_cmp_z: Comparison Functions. (line 11) * mpfr_const_catalan: Transcendental Functions. - (line 299) + (line 302) * mpfr_const_euler: Transcendental Functions. - (line 298) + (line 301) * mpfr_const_log2: Transcendental Functions. - (line 296) + (line 299) * mpfr_const_pi: Transcendental Functions. - (line 297) + (line 300) * mpfr_copysign: Miscellaneous Functions. (line 127) * mpfr_cos: Transcendental Functions. - (line 96) + (line 98) * mpfr_cosh: Transcendental Functions. - (line 162) + (line 165) * mpfr_cot: Transcendental Functions. - (line 114) + (line 116) * mpfr_coth: Transcendental Functions. - (line 178) + (line 181) * mpfr_csc: Transcendental Functions. - (line 113) + (line 115) * mpfr_csch: Transcendental Functions. - (line 177) + (line 180) * mpfr_custom_get_exp: Custom Interface. (line 76) * mpfr_custom_get_kind: Custom Interface. (line 66) * mpfr_custom_get_significand: Custom Interface. (line 71) @@ -4589,9 +4589,9 @@ Function and Type Index * MPFR_DECL_INIT: Initialization Functions. (line 77) * mpfr_digamma: Transcendental Functions. - (line 235) + (line 238) * mpfr_dim: Arithmetic Functions. - (line 153) + (line 156) * mpfr_div: Arithmetic Functions. (line 74) * mpfr_divby0_p: Exception Related Functions. @@ -4599,9 +4599,9 @@ Function and Type Index * mpfr_div_2exp: Compatibility with MPF. (line 56) * mpfr_div_2si: Arithmetic Functions. - (line 168) + (line 171) * mpfr_div_2ui: Arithmetic Functions. - (line 166) + (line 169) * mpfr_div_d: Arithmetic Functions. (line 86) * mpfr_div_q: Arithmetic Functions. @@ -4613,7 +4613,7 @@ Function and Type Index * mpfr_div_z: Arithmetic Functions. (line 88) * mpfr_dot: Arithmetic Functions. - (line 224) + (line 228) * mpfr_dump: Input and Output Functions. (line 76) * mpfr_d_div: Arithmetic Functions. @@ -4621,7 +4621,7 @@ Function and Type Index * mpfr_d_sub: Arithmetic Functions. (line 36) * mpfr_eint: Transcendental Functions. - (line 188) + (line 191) * mpfr_eq: Compatibility with MPF. (line 35) * mpfr_equal_p: Comparison Functions. @@ -4631,21 +4631,21 @@ Function and Type Index * mpfr_erangeflag_p: Exception Related Functions. (line 179) * mpfr_erf: Transcendental Functions. - (line 252) + (line 255) * mpfr_erfc: Transcendental Functions. - (line 253) + (line 256) * mpfr_exp: Transcendental Functions. - (line 40) + (line 41) * mpfr_exp10: Transcendental Functions. - (line 42) + (line 43) * mpfr_exp2: Transcendental Functions. - (line 41) + (line 42) * mpfr_expm1: Transcendental Functions. - (line 46) + (line 47) * mpfr_exp_t: Nomenclature and Types. - (line 39) + (line 41) * mpfr_fac_ui: Arithmetic Functions. - (line 174) + (line 177) * mpfr_fits_intmax_p: Conversion Functions. (line 185) * mpfr_fits_sint_p: Conversion Functions. @@ -4671,23 +4671,23 @@ Function and Type Index * mpfr_flags_set: Exception Related Functions. (line 193) * mpfr_flags_t: Nomenclature and Types. - (line 50) + (line 52) * mpfr_flags_test: Exception Related Functions. (line 196) * mpfr_floor: Integer and Remainder Related Functions. (line 8) * mpfr_fma: Arithmetic Functions. - (line 178) + (line 181) * mpfr_fmma: Arithmetic Functions. - (line 188) + (line 191) * mpfr_fmms: Arithmetic Functions. - (line 190) + (line 193) * mpfr_fmod: Integer and Remainder Related Functions. - (line 106) -* mpfr_fmodquo: Integer and Remainder Related Functions. (line 108) +* mpfr_fmodquo: Integer and Remainder Related Functions. + (line 110) * mpfr_fms: Arithmetic Functions. - (line 180) + (line 183) * mpfr_fpif_export: Input and Output Functions. (line 51) * mpfr_fpif_import: Input and Output Functions. @@ -4695,7 +4695,7 @@ Function and Type Index * mpfr_fprintf: Formatted Output Functions. (line 163) * mpfr_frac: Integer and Remainder Related Functions. - (line 89) + (line 91) * mpfr_free_cache: Memory Handling Functions. (line 9) * mpfr_free_cache2: Memory Handling Functions. @@ -4707,9 +4707,9 @@ Function and Type Index * mpfr_frexp: Conversion Functions. (line 52) * mpfr_gamma: Transcendental Functions. - (line 203) + (line 206) * mpfr_gamma_inc: Transcendental Functions. - (line 204) + (line 207) * mpfr_get_d: Conversion Functions. (line 7) * mpfr_get_decimal128: Conversion Functions. @@ -4777,7 +4777,7 @@ Function and Type Index * mpfr_greater_p: Comparison Functions. (line 56) * mpfr_hypot: Arithmetic Functions. - (line 198) + (line 201) * mpfr_inexflag_p: Exception Related Functions. (line 178) * mpfr_inf_p: Comparison Functions. @@ -4811,13 +4811,13 @@ Function and Type Index * mpfr_inp_str: Input and Output Functions. (line 39) * mpfr_integer_p: Integer and Remainder Related Functions. - (line 135) + (line 137) * mpfr_j0: Transcendental Functions. - (line 257) + (line 260) * mpfr_j1: Transcendental Functions. - (line 258) + (line 261) * mpfr_jn: Transcendental Functions. - (line 259) + (line 262) * mpfr_lessequal_p: Comparison Functions. (line 59) * mpfr_lessgreater_p: Comparison Functions. @@ -4825,17 +4825,17 @@ Function and Type Index * mpfr_less_p: Comparison Functions. (line 58) * mpfr_lgamma: Transcendental Functions. - (line 225) + (line 228) * mpfr_li2: Transcendental Functions. - (line 198) + (line 201) * mpfr_lngamma: Transcendental Functions. - (line 217) + (line 220) * mpfr_log: Transcendental Functions. (line 25) * mpfr_log10: Transcendental Functions. (line 29) * mpfr_log1p: Transcendental Functions. - (line 36) + (line 37) * mpfr_log2: Transcendental Functions. (line 28) * mpfr_log_ui: Transcendental Functions. @@ -4847,7 +4847,7 @@ Function and Type Index * mpfr_min_prec: Rounding-Related Functions. (line 85) * mpfr_modf: Integer and Remainder Related Functions. - (line 96) + (line 98) * mpfr_mp_memory_cleanup: Memory Handling Functions. (line 35) * mpfr_mul: Arithmetic Functions. @@ -4855,9 +4855,9 @@ Function and Type Index * mpfr_mul_2exp: Compatibility with MPF. (line 54) * mpfr_mul_2si: Arithmetic Functions. - (line 161) + (line 164) * mpfr_mul_2ui: Arithmetic Functions. - (line 159) + (line 162) * mpfr_mul_d: Arithmetic Functions. (line 59) * mpfr_mul_q: Arithmetic Functions. @@ -4873,7 +4873,7 @@ Function and Type Index * mpfr_nan_p: Comparison Functions. (line 40) * mpfr_neg: Arithmetic Functions. - (line 141) + (line 143) * mpfr_nextabove: Miscellaneous Functions. (line 15) * mpfr_nextbelow: Miscellaneous Functions. @@ -4889,17 +4889,17 @@ Function and Type Index * mpfr_overflow_p: Exception Related Functions. (line 175) * mpfr_pow: Transcendental Functions. - (line 50) + (line 51) * mpfr_pow_si: Transcendental Functions. - (line 54) + (line 55) * mpfr_pow_ui: Transcendental Functions. - (line 52) + (line 53) * mpfr_pow_z: Transcendental Functions. - (line 56) + (line 57) * mpfr_prec_round: Rounding-Related Functions. (line 13) * mpfr_prec_t: Nomenclature and Types. - (line 25) + (line 27) * mpfr_printf: Formatted Output Functions. (line 170) * mpfr_print_rnd_mode: Rounding-Related Functions. @@ -4913,27 +4913,27 @@ Function and Type Index * mpfr_reldiff: Compatibility with MPF. (line 46) * mpfr_remainder: Integer and Remainder Related Functions. - (line 110) -* mpfr_remquo: Integer and Remainder Related Functions. (line 112) +* mpfr_remquo: Integer and Remainder Related Functions. + (line 114) * mpfr_rint: Integer and Remainder Related Functions. (line 6) * mpfr_rint_ceil: Integer and Remainder Related Functions. - (line 52) + (line 54) * mpfr_rint_floor: Integer and Remainder Related Functions. - (line 53) -* mpfr_rint_round: Integer and Remainder Related Functions. (line 55) -* mpfr_rint_roundeven: Integer and Remainder Related Functions. +* mpfr_rint_round: Integer and Remainder Related Functions. (line 57) -* mpfr_rint_trunc: Integer and Remainder Related Functions. +* mpfr_rint_roundeven: Integer and Remainder Related Functions. (line 59) +* mpfr_rint_trunc: Integer and Remainder Related Functions. + (line 61) * mpfr_rnd_t: Nomenclature and Types. - (line 45) + (line 47) * mpfr_root: Arithmetic Functions. - (line 130) + (line 132) * mpfr_rootn_ui: Arithmetic Functions. - (line 116) + (line 117) * mpfr_round: Integer and Remainder Related Functions. (line 9) * mpfr_roundeven: Integer and Remainder Related Functions. @@ -4941,9 +4941,9 @@ Function and Type Index * mpfr_round_nearest_away: Rounding-Related Functions. (line 95) * mpfr_sec: Transcendental Functions. - (line 112) + (line 114) * mpfr_sech: Transcendental Functions. - (line 176) + (line 179) * mpfr_set: Assignment Functions. (line 9) * mpfr_setsign: Miscellaneous Functions. @@ -4977,11 +4977,11 @@ Function and Type Index * mpfr_set_inexflag: Exception Related Functions. (line 169) * mpfr_set_inf: Assignment Functions. - (line 156) + (line 157) * mpfr_set_ld: Assignment Functions. (line 17) * mpfr_set_nan: Assignment Functions. - (line 155) + (line 156) * mpfr_set_nanflag: Exception Related Functions. (line 168) * mpfr_set_overflow: Exception Related Functions. @@ -4995,41 +4995,41 @@ Function and Type Index * mpfr_set_si: Assignment Functions. (line 12) * mpfr_set_si_2exp: Assignment Functions. - (line 63) + (line 64) * mpfr_set_sj: Assignment Functions. (line 14) * mpfr_set_sj_2exp: Assignment Functions. - (line 67) + (line 68) * mpfr_set_str: Assignment Functions. - (line 75) + (line 76) * mpfr_set_ui: Assignment Functions. (line 10) * mpfr_set_ui_2exp: Assignment Functions. - (line 61) + (line 62) * mpfr_set_uj: Assignment Functions. (line 13) * mpfr_set_uj_2exp: Assignment Functions. - (line 65) + (line 66) * mpfr_set_underflow: Exception Related Functions. (line 165) * mpfr_set_z: Assignment Functions. (line 25) * mpfr_set_zero: Assignment Functions. - (line 157) + (line 158) * mpfr_set_z_2exp: Assignment Functions. - (line 69) + (line 70) * mpfr_sgn: Comparison Functions. (line 50) * mpfr_signbit: Miscellaneous Functions. (line 117) * mpfr_sin: Transcendental Functions. - (line 97) + (line 99) * mpfr_sinh: Transcendental Functions. - (line 163) + (line 166) * mpfr_sinh_cosh: Transcendental Functions. - (line 168) + (line 171) * mpfr_sin_cos: Transcendental Functions. - (line 102) + (line 104) * mpfr_si_div: Arithmetic Functions. (line 80) * mpfr_si_sub: Arithmetic Functions. @@ -5045,7 +5045,7 @@ Function and Type Index * mpfr_sqrt_ui: Arithmetic Functions. (line 101) * mpfr_strtofr: Assignment Functions. - (line 93) + (line 94) * mpfr_sub: Arithmetic Functions. (line 26) * mpfr_subnormalize: Exception Related Functions. @@ -5061,15 +5061,15 @@ Function and Type Index * mpfr_sub_z: Arithmetic Functions. (line 42) * mpfr_sum: Arithmetic Functions. - (line 207) + (line 211) * mpfr_swap: Assignment Functions. - (line 163) + (line 164) * mpfr_t: Nomenclature and Types. (line 6) * mpfr_tan: Transcendental Functions. - (line 98) + (line 100) * mpfr_tanh: Transcendental Functions. - (line 164) + (line 167) * mpfr_total_order_p: Comparison Functions. (line 74) * mpfr_trunc: Integer and Remainder Related Functions. @@ -5077,9 +5077,9 @@ Function and Type Index * mpfr_ui_div: Arithmetic Functions. (line 76) * mpfr_ui_pow: Transcendental Functions. - (line 60) + (line 61) * mpfr_ui_pow_ui: Transcendental Functions. - (line 58) + (line 59) * mpfr_ui_sub: Arithmetic Functions. (line 28) * mpfr_underflow_p: Exception Related Functions. @@ -5113,17 +5113,17 @@ Function and Type Index * mpfr_vsprintf: Formatted Output Functions. (line 177) * mpfr_y0: Transcendental Functions. - (line 268) + (line 271) * mpfr_y1: Transcendental Functions. - (line 269) + (line 272) * mpfr_yn: Transcendental Functions. - (line 270) + (line 273) * mpfr_zero_p: Comparison Functions. (line 43) * mpfr_zeta: Transcendental Functions. - (line 246) + (line 249) * mpfr_zeta_ui: Transcendental Functions. - (line 247) + (line 250) * mpfr_z_sub: Arithmetic Functions. (line 40) diff --git a/apps/apps.js b/apps/apps.js index 459018174..31ff5e328 100644 --- a/apps/apps.js +++ b/apps/apps.js @@ -2,11 +2,13 @@ angular.module('nwas').service('apps', function() { return [ + { name: "Golly", description: {en: "Game of Life imagined by John Conway", fr: "Jeu de la vie imaginé par John Conway"} }, + { name: "Fractal", description: {en: "Fractal generator (W/B)", fr: "Générateur de fractales (N/B)"} }, + { name: "Peanut-GB", description: {en: "GameBoy emulator", fr: "Émulateur GameBoy"} }, { name: "KhiCAS", description: {en: "Computer algebra system", fr: "Système de calcul formel"} }, { name: "Periodic", description: {en: "Periodic table of elements", fr: "Tableau périodique des éléments"} }, { name: "Nofrendo", description: {en: "NES emulator", fr: "Émulateur NES"} }, { name: "Peanut-GBC", description: {en: "GameBoy Color emulator", fr: "Émulateur GameBoy Color"} }, - { name: "Peanut-GB", description: {en: "GameBoy emulator", fr: "Émulateur GameBoy"} }, { name: "HexEdit", description: {en: "Hexadecimal editor", fr: "Éditeur hexadécimal"} }, { name: "BadApple", description: {en: "Bad Apple demo", fr: "Démo Bad Apple"} }, { name: "UnitCircle", description: {en: "Unit circle", fr: "Cercle trigonométrique"} },