-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
271 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/test/java/nom/bdezonia/zorbage/algorithm/TestSplatComplex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Zorbage: an algebraic data hierarchy for use in numeric processing. | ||
* | ||
* Copyright (C) 2016-2019 Barry DeZonia | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package nom.bdezonia.zorbage.algorithm; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
import nom.bdezonia.zorbage.algebras.G; | ||
import nom.bdezonia.zorbage.tuple.Tuple2; | ||
import nom.bdezonia.zorbage.type.data.float32.complex.ComplexFloat32Member; | ||
import nom.bdezonia.zorbage.type.data.float32.real.Float32Member; | ||
|
||
/** | ||
* | ||
* @author Barry DeZonia | ||
* | ||
*/ | ||
public class TestSplatComplex { | ||
|
||
@Test | ||
public void test1() { | ||
ComplexFloat32Member value = G.CFLT.construct("{1.2,2.4}"); | ||
Tuple2<Float32Member,Float32Member> tuple = new Tuple2<>(G.FLT.construct(),G.FLT.construct()); | ||
SplatComplex.toTuple(value, tuple); | ||
assertEquals(1.2f, tuple.a().v(), 0); | ||
assertEquals(2.4f, tuple.b().v(), 0); | ||
} | ||
|
||
@Test | ||
public void test2() { | ||
Tuple2<Float32Member,Float32Member> tuple = new Tuple2<>(G.FLT.construct("1.2"),G.FLT.construct("2.4")); | ||
ComplexFloat32Member value = G.CFLT.construct(); | ||
SplatComplex.toValue(tuple, value); | ||
assertEquals(1.2f, value.r(), 0); | ||
assertEquals(2.4f, value.i(), 0); | ||
} | ||
|
||
} |
79 changes: 79 additions & 0 deletions
79
src/test/java/nom/bdezonia/zorbage/algorithm/TestSplatOctonion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Zorbage: an algebraic data hierarchy for use in numeric processing. | ||
* | ||
* Copyright (C) 2016-2019 Barry DeZonia | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package nom.bdezonia.zorbage.algorithm; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
import nom.bdezonia.zorbage.algebras.G; | ||
import nom.bdezonia.zorbage.tuple.Tuple8; | ||
import nom.bdezonia.zorbage.type.data.float32.octonion.OctonionFloat32Member; | ||
import nom.bdezonia.zorbage.type.data.float32.real.Float32Member; | ||
|
||
/** | ||
* | ||
* @author Barry DeZonia | ||
* | ||
*/ | ||
public class TestSplatOctonion { | ||
|
||
@Test | ||
public void test1() { | ||
OctonionFloat32Member value = G.OFLT.construct("{1,2,3,4,5,6,7,8}"); | ||
Tuple8<Float32Member,Float32Member,Float32Member,Float32Member,Float32Member,Float32Member,Float32Member,Float32Member> | ||
tuple = | ||
new Tuple8<>(G.FLT.construct(),G.FLT.construct(),G.FLT.construct(),G.FLT.construct(),G.FLT.construct(),G.FLT.construct(),G.FLT.construct(),G.FLT.construct()); | ||
SplatOctonion.toTuple(value, tuple); | ||
assertEquals(1, tuple.a().v(), 0); | ||
assertEquals(2, tuple.b().v(), 0); | ||
assertEquals(3, tuple.c().v(), 0); | ||
assertEquals(4, tuple.d().v(), 0); | ||
assertEquals(5, tuple.e().v(), 0); | ||
assertEquals(6, tuple.f().v(), 0); | ||
assertEquals(7, tuple.g().v(), 0); | ||
assertEquals(8, tuple.h().v(), 0); | ||
} | ||
|
||
@Test | ||
public void test2() { | ||
Tuple8<Float32Member,Float32Member,Float32Member,Float32Member,Float32Member,Float32Member,Float32Member,Float32Member> | ||
tuple = | ||
new Tuple8<>(G.FLT.construct("1"),G.FLT.construct("2"),G.FLT.construct("3"),G.FLT.construct("4"),G.FLT.construct("5"),G.FLT.construct("6"),G.FLT.construct("7"),G.FLT.construct("8")); | ||
OctonionFloat32Member value = G.OFLT.construct(); | ||
SplatOctonion.toValue(tuple, value); | ||
assertEquals(1, value.r(), 0); | ||
assertEquals(2, value.i(), 0); | ||
assertEquals(3, value.j(), 0); | ||
assertEquals(4, value.k(), 0); | ||
assertEquals(5, value.l(), 0); | ||
assertEquals(6, value.i0(), 0); | ||
assertEquals(7, value.j0(), 0); | ||
assertEquals(8, value.k0(), 0); | ||
} | ||
|
||
} |
69 changes: 69 additions & 0 deletions
69
src/test/java/nom/bdezonia/zorbage/algorithm/TestSplatQuaternion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Zorbage: an algebraic data hierarchy for use in numeric processing. | ||
* | ||
* Copyright (C) 2016-2019 Barry DeZonia | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package nom.bdezonia.zorbage.algorithm; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
import nom.bdezonia.zorbage.algebras.G; | ||
import nom.bdezonia.zorbage.tuple.Tuple4; | ||
import nom.bdezonia.zorbage.type.data.float32.quaternion.QuaternionFloat32Member; | ||
import nom.bdezonia.zorbage.type.data.float32.real.Float32Member; | ||
|
||
/** | ||
* | ||
* @author Barry DeZonia | ||
* | ||
*/ | ||
public class TestSplatQuaternion { | ||
|
||
@Test | ||
public void test1() { | ||
QuaternionFloat32Member value = G.QFLT.construct("{1,2,3,4}"); | ||
Tuple4<Float32Member,Float32Member,Float32Member,Float32Member> tuple = | ||
new Tuple4<>(G.FLT.construct(),G.FLT.construct(),G.FLT.construct(),G.FLT.construct()); | ||
SplatQuaternion.toTuple(value, tuple); | ||
assertEquals(1, tuple.a().v(), 0); | ||
assertEquals(2, tuple.b().v(), 0); | ||
assertEquals(3, tuple.c().v(), 0); | ||
assertEquals(4, tuple.d().v(), 0); | ||
} | ||
|
||
@Test | ||
public void test2() { | ||
Tuple4<Float32Member,Float32Member,Float32Member,Float32Member> tuple = | ||
new Tuple4<>(G.FLT.construct("1"),G.FLT.construct("2"),G.FLT.construct("3"),G.FLT.construct("4")); | ||
QuaternionFloat32Member value = G.QFLT.construct(); | ||
SplatQuaternion.toValue(tuple, value); | ||
assertEquals(1, value.r(), 0); | ||
assertEquals(2, value.i(), 0); | ||
assertEquals(3, value.j(), 0); | ||
assertEquals(4, value.k(), 0); | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
src/test/java/nom/bdezonia/zorbage/algorithm/TestSplatReal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Zorbage: an algebraic data hierarchy for use in numeric processing. | ||
* | ||
* Copyright (C) 2016-2019 Barry DeZonia | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package nom.bdezonia.zorbage.algorithm; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
import nom.bdezonia.zorbage.algebras.G; | ||
import nom.bdezonia.zorbage.tuple.Tuple1; | ||
import nom.bdezonia.zorbage.type.data.float32.real.Float32Member; | ||
|
||
/** | ||
* | ||
* @author Barry DeZonia | ||
* | ||
*/ | ||
public class TestSplatReal { | ||
|
||
@Test | ||
public void test1() { | ||
Float32Member value = G.FLT.construct("1.5"); | ||
Tuple1<Float32Member> tuple = new Tuple1<>(G.FLT.construct()); | ||
SplatReal.toTuple(value, tuple); | ||
assertEquals(1.5f, tuple.a().v(), 0); | ||
} | ||
|
||
@Test | ||
public void test2() { | ||
Tuple1<Float32Member> tuple = new Tuple1<>(G.FLT.construct("4.2")); | ||
Float32Member value = G.FLT.construct(); | ||
SplatReal.toValue(tuple, value); | ||
assertEquals(4.2f, value.v(), 0); | ||
} | ||
|
||
} |