Skip to content

Commit

Permalink
https://github.com/crowlogic/arb4j/issues/480
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlogic committed Sep 15, 2024
1 parent e86ad40 commit c611974
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
Expand Down
12 changes: 11 additions & 1 deletion native/TypesAndStructures.i
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

%{
#include <flint/fmpz.h>
#include <flint/fmpq.h>
#include <flint/qqbar.h>
#include <mpfr.h>
#include <flint/flint.h>
#include <arf.h>
Expand Down Expand Up @@ -45,6 +45,16 @@ typedef long int mp_size_t;

%}

typedef struct
{
fmpz_poly_struct poly;
acb_struct enclosure;
}
qqbar_struct;

typedef qqbar_struct qqbar_t[1];


typedef struct
{
jlong num;
Expand Down
1 change: 1 addition & 0 deletions native/arb.i
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ typedef unsigned long int mp_limb_t;
%rename (numRows) r;
%rename (numCols) c;

%rename (AlgebraicNumber) qqbar_struct;
%rename (RationalFunction) fmpz_poly_q_struct;
%rename (IntegerPolynomial) fmpz_poly_struct;
%rename (denominatorAddress) den;
Expand Down
1 change: 1 addition & 0 deletions native/complex.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <flint/flint.h>
#include <flint/fmpq.h>
#include <flint/fmpq_poly.h>
#include <flint/qqbar.h>
#include <arf.h>
#include <arb.h>
#include <acb.h>
Expand Down
61 changes: 61 additions & 0 deletions src/main/java/arb/AlgebraicNumber.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (https://www.swig.org).
* Version 4.2.0
*
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

package arb;

public class AlgebraicNumber {
protected long swigCPtr;
protected boolean swigCMemOwn;

public AlgebraicNumber(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}

public static long getCPtr(AlgebraicNumber obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

@SuppressWarnings({"deprecation", "removal"})
protected void finalize() {
delete();
}

public synchronized void delete() {
if (swigCPtr != 0) {
if (swigCMemOwn) {
swigCMemOwn = false;
arblibJNI.delete_AlgebraicNumber(swigCPtr);
}
swigCPtr = 0;
}
}

public void setPoly(IntegerPolynomial value) {
arblibJNI.AlgebraicNumber_poly_set(swigCPtr, this, IntegerPolynomial.getCPtr(value), value);
}

public IntegerPolynomial getPoly() {
long cPtr = arblibJNI.AlgebraicNumber_poly_get(swigCPtr, this);
return (cPtr == 0) ? null : new IntegerPolynomial(cPtr, false);
}

public void setEnclosure(Complex value) {
arblibJNI.AlgebraicNumber_enclosure_set(swigCPtr, this, Complex.getCPtr(value), value);
}

public Complex getEnclosure() {
long cPtr = arblibJNI.AlgebraicNumber_enclosure_get(swigCPtr, this);
return (cPtr == 0) ? null : new Complex(cPtr, false);
}

public AlgebraicNumber() {
this(arblibJNI.new_AlgebraicNumber(), true);
}

}
2 changes: 1 addition & 1 deletion src/main/java/arb/Complex.java
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ public String toString()
sb.append("]");
}
return ( name == null ? "" : name + "=" ) + sb.toString();
}
}

public int dim = 1;

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/arb/Real.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ public RationalFunction mul(RationalFunction that, int prec, RationalFunction re
{
return res.set(this).mul(that, prec, res);
}

public Complex sqrt(int prec, Complex res)
{
return res.set(this).sqrt(prec);
}

public Fraction sub(Fraction subtrahend, int bits, Fraction res)
{
Expand Down Expand Up @@ -1538,11 +1543,6 @@ public Real sqrt(int prec, Real res)
return res;
}

public Complex sqrt(int prec, Complex res)
{
return res.set(this).sqrt(prec);
}

/**
* @see arb#arb_addmul(Real, Real, Real, int)
* @param that
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/arb/arblibJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,12 @@ public class arblibJNI {
public final static native void arb_asin(long jarg1, Real jarg1_, long jarg2, Real jarg2_, int jarg3);
public final static native void arb_acos(long jarg1, Real jarg1_, long jarg2, Real jarg2_, int jarg3);
public final static native void arb_atanh(long jarg1, Real jarg1_, long jarg2, Real jarg2_, int jarg3);
public final static native void AlgebraicNumber_poly_set(long jarg1, AlgebraicNumber jarg1_, long jarg2, IntegerPolynomial jarg2_);
public final static native long AlgebraicNumber_poly_get(long jarg1, AlgebraicNumber jarg1_);
public final static native void AlgebraicNumber_enclosure_set(long jarg1, AlgebraicNumber jarg1_, long jarg2, Complex jarg2_);
public final static native long AlgebraicNumber_enclosure_get(long jarg1, AlgebraicNumber jarg1_);
public final static native long new_AlgebraicNumber();
public final static native void delete_AlgebraicNumber(long jarg1);
public final static native void RationalFunction_numeratorAddress_set(long jarg1, RationalFunction jarg1_, long jarg2);
public final static native long RationalFunction_numeratorAddress_get(long jarg1, RationalFunction jarg1_);
public final static native void RationalFunction_denominatorAddress_set(long jarg1, RationalFunction jarg1_, long jarg2);
Expand Down

0 comments on commit c611974

Please sign in to comment.