Commit 23bf1dac authored by ulrich_y's avatar ulrich_y

Added optional GiNaC interface

parent 9174f364
MODE=DEBUG
HAVE_GINAC=1
FC=gfortran
AR=ar rcs
CC=gcc
MCC=mcc
ifeq ($(HAVE_GINAC),1)
LD=g++
LFLAGS=-lgfortran
else
LD=gfortran
endif
FFLAGS=-fdefault-real-8 -cpp -pedantic-errors -std=f2008
FFLAGS+= -Werror -Wall -Wno-maybe-uninitialized -Wno-uninitialized
......@@ -17,6 +23,11 @@ else
FFLAGS += -ffpe-trap=invalid,overflow -fdump-core -fbacktrace
endif
ifeq ($(HAVE_GINAC),1)
FFLAGS += -DHAVE_GINAC
endif
files=globals.o ieps.o utils.o shuffle.o maths_functions.o mpl_module.o gpl_module.o
objects = $(addprefix build/,$(files))
......@@ -31,6 +42,9 @@ build/%.o: src/%.f90
@echo "F90 $@"
@$(FC) $(FFLAGS) -c $< -J build -o $@
build/%.o: src/%.cpp
@echo "C++ $@"
@$(CC) -c $< -o $@
# Mathlink related
......@@ -61,11 +75,18 @@ gpl: build/gpl.o libgpl.a build/mcc.internals
eval: libgpl.a build/eval.o
@echo "LD $@"
@$(LD) -o $@ build/eval.o -L. -lgpl
@$(LD) -o $@ build/eval.o -L. -lgpl $(LFLAGS)
ifeq ($(HAVE_GINAC),1)
test: $(objects) build/ginac.o build/test.o
@echo "LD $@"
@$(LD) -o $@ $^ -lcln -lginac $(LFLAGS)
else
test: $(objects) build/test.o
@echo "LD $@"
@$(LD) -o $@ $^ $(LFLAGS)
$(LD) -o $@ $^ $(LFLAGS)
endif
check: test
./$<
......
#include <ginac/ginac.h>
using namespace GiNaC;
#include <cln/cln.h>
#include <stdio.h>
#include <iostream>
typedef struct {double r,i;} complex_t;
extern "C"{
complex_t geval_(complex_t * z, int* n);
};
complex_t geval_(complex_t * z, int* n) {
cln::cl_inhibit_floating_point_underflow = true;
lst w;
for(long i=0;i<(*n)-1;i++)
{
w.append((z->r)+(z->i)*I);
z++;
}
ex ans = G(w,z->r).evalf();
return {
.r = ex_to<numeric>(evalf(real_part(ans))).to_double(),
.i = ex_to<numeric>(evalf(imag_part(ans))).to_double()
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment