Skip to content

Commit

Permalink
Using CladosCalculator to bug hunt and fix
Browse files Browse the repository at this point in the history
Also fixed a few things using the unit tests. Mostly calculator fixes, though
  • Loading branch information
adiffer committed Sep 26, 2020
1 parent acfb6d0 commit fad4956
Show file tree
Hide file tree
Showing 31 changed files with 263 additions and 180 deletions.
128 changes: 79 additions & 49 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,71 +1,101 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project name="Clados" default="dist" basedir=".">
<description>

<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="junit" location="junit"/>
<property name="dist" location="dist"/>
</description>

<property name="appHome" value="https://github.com/InterworldTransport/CladosCalculator" />
<property name="srcDir" value="src"/>
<property name="docDir" value="doc" />
<property name="buildDir" value="build"/>
<property name="junit" value="junit"/>
<property name="distDir" value="dist"/>
<property name="copyleft" value="&lt;p&gt;
--------------------------------------------------------------------------------
&lt;br&gt;
Clados_API_Documentation&lt;br&gt;
--------------------------------------------------------------------------------
&lt;br&gt;
Copyright © 2020 Alfred Differ. All rights reserved.
&lt;p&gt;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License for more details.
&lt;p&gt;
Use of this code or executable objects derived from it by the Licensee
states their willingness to accept the terms of the license.
&lt;p&gt;
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see https://www.gnu.org/licenses/."/>

<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${buildDir}"/>
</target>

<target name="clean"
description="clean up">
<!-- Delete the ${buildDir} and ${distDir} directory trees -->
<delete dir="${buildDir}"/>
<delete dir="${distDir}"/>
<delete dir="${docDir}"/>
</target>

<target name="compile"
depends="init"
description="compile the source">
<target name="compile"
depends="init"
description="compile the source">
<!-- Compile the Java code from ${src} into ${build} -->
<javac includeantruntime="false"
srcdir="${src}"
destdir="${build}" />
<javac includeantruntime="false"
srcdir="${srcDir}"
destdir="${buildDir}">
<exclude name="com/interworldtransport/cladosGTest/**"/>
<exclude name="com/interworldtransport/cladosFTest/**"/>
</javac>
</target>

<target name="dist"
depends="compile"
description="generate the distribution">
<target name="dist"
depends="compile"
description="generate the distribution">
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<mkdir dir="${distDir}/lib"/>

<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${dist}/lib/Clados-${DSTAMP}.jar"
basedir="${build}"/>
<jar jarfile="${distDir}/lib/clados-${DSTAMP}.jar"
basedir="${buildDir}"/>
</target>

<target name="javadoc">
<javadoc access="public"
author="true"
classpath="/Users/alfredwdiffer/.p2/pool/plugins/org.junit.platform.launcher_1.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.platform.suite.api_1.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.jupiter.migrationsupport_5.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.platform.commons_1.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit_4.12.0.v201504281640/junit.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.platform.engine_1.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.jupiter.api_5.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.apiguardian_1.0.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.vintage.engine_5.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.opentest4j_1.0.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.jupiter.engine_5.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.platform.runner_1.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.hamcrest.core_1.3.0.v20180420-1519.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.jupiter.params_5.1.0.v20180327-1502.jar"
destdir="doc"
doctitle="CladosOne"
nodeprecated="false"
nodeprecatedlist="false"
noindex="false"
nonavbar="false"
notree="false"
overview="/Users/alfredwdiffer/eclipse-workspace/CladosOne/src/overview.html"
packagenames="com.interworldtransport.cladosFExceptions,com.interworldtransport.cladosF,com.interworldtransport.cladosGExceptions,com.interworldtransport.cladosG"
source="10"
sourcepath="src"
splitindex="true"
use="true"
version="true">
<javadoc author="true"
bottom="${copyleft}"
classpath="/Users/alfredwdiffer/.p2/pool/plugins/org.junit.platform.launcher_1.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.platform.suite.api_1.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.jupiter.migrationsupport_5.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.platform.commons_1.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit_4.12.0.v201504281640/junit.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.platform.engine_1.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.jupiter.api_5.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.apiguardian_1.0.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.vintage.engine_5.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.opentest4j_1.0.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.jupiter.engine_5.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.platform.runner_1.1.0.v20180327-1502.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.hamcrest.core_1.3.0.v20180420-1519.jar:/Users/alfredwdiffer/.p2/pool/plugins/org.junit.jupiter.params_5.1.0.v20180327-1502.jar"
destdir="${docDir}"
doctitle="CladosOne"
nodeprecated="false"
nodeprecatedlist="false"
noindex="false"
nonavbar="false"
notree="false"
overview="/Users/alfredwdiffer/eclipse-workspace/CladosOne/src/overview.html"
packagenames="com.interworldtransport.cladosFExceptions,com.interworldtransport.cladosF,com.interworldtransport.cladosGExceptions,com.interworldtransport.cladosG"
source="10"
sourcepath="src"
splitindex="true"
use="true"
version="true">
<link href="http://hamcrest.org/JavaHamcrest/javadoc/1.3/"/>
<link href="http://ota4j-team.github.io/opentest4j/docs/current/api/"/>
<link href="https://apiguardian-team.github.io/apiguardian/docs/current/api/"/>
<link href="http://junit.org/junit5/docs/current/api/"/>
<link href="http://junit.org/junit4/javadoc/latest/"/>
</javadoc>
</target>

<target name="clean"
description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>

</project>
Binary file modified src/.DS_Store
Binary file not shown.
7 changes: 3 additions & 4 deletions src/com/interworldtransport/cladosF/ComplexD.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static ComplexD copyFromSQModuliSum(ComplexD[] pL) throws FieldBinaryExce

for (int j = 1; j < pL.length; j++)
if (isTypeMatch(pL[j], tR))
tR.add(ComplexD.copyONE(pL[j]).scale(pL[j].getSQModulus()));
tR.add((ComplexD.copyONE(pL[j])).scale(pL[j].getSQModulus()));
else
throw new FieldBinaryException(pL[j], "Field Type mistach during addition", tR);

Expand Down Expand Up @@ -675,9 +675,8 @@ public ComplexD multiply(DivisableD pF) throws FieldBinaryException
@Override
public ComplexD scale(double pS)
{
double tempS = Math.sqrt(Math.abs(pS));
setReal(Math.signum(pS) * tempS * getReal());
setImg(Math.signum(pS) * tempS * getImg());
setReal(pS * getReal());
setImg(pS * getImg());
return this;
}

Expand Down
27 changes: 16 additions & 11 deletions src/com/interworldtransport/cladosF/ComplexF.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,15 @@ public static ComplexF conjugate(ComplexF pF)
*/
public static ComplexF copyFromModuliSum(ComplexF[] pL) throws FieldBinaryException
{
ComplexF tR = ComplexF.copyFromSQModuliSum(pL);
// now figure out how to do the SQRT of this complex object.
float tM = (float) Math.sqrt(tR.getModulus());
float tA = tR.getArgument() / 2;
tR.setReal((float) (tM * Math.cos(tA)));
tR.setImg((float) (tM * Math.sin(tA)));
ComplexF tR = (ComplexF.copyONE(pL[0])).scale(pL[0].getModulus());

for (int j = 1; j < pL.length; j++)
if (isTypeMatch(pL[j], tR))
{
tR.add((ComplexF.copyONE(pL[j]).scale(pL[j].getModulus())));
}
else
throw new FieldBinaryException(pL[j], "Field Type mistach during addition", tR);
return tR;
}

Expand All @@ -141,11 +144,11 @@ public static ComplexF copyFromModuliSum(ComplexF[] pL) throws FieldBinaryExcept
*/
public static ComplexF copyFromSQModuliSum(ComplexF[] pL) throws FieldBinaryException
{
ComplexF tR = ComplexF.copyONE(pL[0]).scale(pL[0].getSQModulus());
ComplexF tR = (ComplexF.copyONE(pL[0])).scale(pL[0].getSQModulus());

for (int j = 1; j < pL.length; j++)
if (isTypeMatch(pL[j], tR))
tR.add(ComplexF.copyONE(pL[j]).scale(pL[j].getSQModulus()));
tR.add((ComplexF.copyONE(pL[j])).scale(pL[j].getSQModulus()));
else
throw new FieldBinaryException(pL[j], "Field Type mistach during addition", tR);

Expand Down Expand Up @@ -675,9 +678,11 @@ public ComplexF multiply(DivisableF pF) throws FieldBinaryException
@Override
public ComplexF scale(float pS)
{
float tempS = (float) Math.sqrt(Math.abs(pS));
setReal(Math.signum(pS) * tempS * getReal());
setImg(Math.signum(pS) * tempS * getImg());
//float tempS = Math.abs(pS);
setReal(pS * getReal());
setImg(pS * getImg());
//setReal(Math.signum(pS) * tempS * getReal());
//setImg(Math.signum(pS) * tempS * getImg());
return this;
}

Expand Down
4 changes: 4 additions & 0 deletions src/com/interworldtransport/cladosF/DivField.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
*/
public abstract class DivField
{
public static final String COMPLEXD="ComplexD";
public static final String COMPLEXF="ComplexF";
public static final String REALD="RealD";
public static final String REALF="RealF";
/**
* Check to see if the two argument are of the same field type.
*
Expand Down
4 changes: 2 additions & 2 deletions src/com/interworldtransport/cladosF/RealD.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ public static RealD conjugate(RealD pF)
*/
public static RealD copyFromModuliSum(RealD[] pL) throws FieldBinaryException
{
RealD tR = RealD.copyONE(pL[0]).scale(pL[0].getModulus());
RealD tR = (RealD.copyONE(pL[0])).scale(pL[0].getModulus());
for (int j = 1; j < pL.length; j++)
if (isTypeMatch(pL[j], tR))
tR.add(RealD.copyONE(pL[j].scale(pL[j].getModulus())));
tR.add((RealD.copyONE(pL[j]).scale(pL[j].getModulus())));
else
throw new FieldBinaryException(pL[j], "Field Type mistach during addition", tR);
return tR;
Expand Down
8 changes: 4 additions & 4 deletions src/com/interworldtransport/cladosF/RealF.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ public static RealF conjugate(RealF pF)
*/
public static RealF copyFromModuliSum(RealF[] pL) throws FieldBinaryException
{
RealF tR = RealF.copyONE(pL[0]).scale(pL[0].getModulus());
RealF tR = (RealF.copyONE(pL[0])).scale(pL[0].getModulus());
for (int j = 1; j < pL.length; j++)
if (isTypeMatch(pL[j], tR))
tR.add(RealF.copyONE(pL[j].scale(pL[j].getModulus())));
tR.add((RealF.copyONE(pL[j]).scale(pL[j].getModulus())));
else
throw new FieldBinaryException(pL[j], "Field Type mistach during addition", tR);
return tR;
Expand All @@ -141,11 +141,11 @@ public static RealF copyFromModuliSum(RealF[] pL) throws FieldBinaryException
*/
public static RealF copyFromSQModuliSum(RealF[] pL) throws FieldBinaryException
{
RealF tR = RealF.copyONE(pL[0]).scale(pL[0].getSQModulus());
RealF tR = (RealF.copyONE(pL[0])).scale(pL[0].getSQModulus());

for (int j = 1; j < pL.length; j++)
if (isTypeMatch(pL[j], tR))
tR.add(RealF.copyONE(pL[j].scale(pL[j].getSQModulus())));
tR.add((RealF.copyONE(pL[j]).scale(pL[j].getSQModulus())));
else
throw new FieldBinaryException(pL[j], "Field Type mistach during addition", tR);

Expand Down
Loading

0 comments on commit fad4956

Please sign in to comment.