Skip to content

Commit cb3abc5

Browse files
committed
Add ImagConstants, QuatConstants, and OctConstants
1 parent 58c33a3 commit cb3abc5

File tree

14 files changed

+742
-1
lines changed

14 files changed

+742
-1
lines changed

EQUATION_LANGUAGE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ Supported constants:
7575
PI
7676
GAMMA
7777
PHI
78+
I
79+
J
80+
K
81+
L
82+
I0
83+
J0
84+
K0
7885

7986
Supported function calls:
8087

src/main/java/nom/bdezonia/zorbage/procedure/impl/parse/EquationParser.java

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@
6767
import nom.bdezonia.zorbage.type.algebra.RealConstants;
6868
import nom.bdezonia.zorbage.type.algebra.Exponential;
6969
import nom.bdezonia.zorbage.type.algebra.Hyperbolic;
70+
import nom.bdezonia.zorbage.type.algebra.ImaginaryConstants;
7071
import nom.bdezonia.zorbage.type.algebra.InverseHyperbolic;
7172
import nom.bdezonia.zorbage.type.algebra.InverseTrigonometric;
73+
import nom.bdezonia.zorbage.type.algebra.OctonionConstants;
74+
import nom.bdezonia.zorbage.type.algebra.QuaternionConstants;
7275
import nom.bdezonia.zorbage.type.algebra.Random;
7376
import nom.bdezonia.zorbage.type.algebra.Roots;
7477
import nom.bdezonia.zorbage.type.algebra.Trigonometric;
@@ -435,6 +438,92 @@ else if (ch == 'E') {
435438
a.E().call(value);
436439
toks.add(new Numeric(i, value));
437440
}
441+
else if (ch == 'L') {
442+
U value = alg.construct();
443+
if (!(alg instanceof OctonionConstants<?>)) {
444+
result.setA("Lex err near position "+i+": L not defined for given algebra");
445+
return result;
446+
}
447+
@SuppressWarnings("unchecked")
448+
OctonionConstants<U> a = (OctonionConstants<U>) alg;
449+
a.L().call(value);
450+
toks.add(new Numeric(i, value));
451+
}
452+
else if (ch == 'I') {
453+
if (nextFew(str, i, "I0")) {
454+
U value = alg.construct();
455+
if (!(alg instanceof OctonionConstants<?>)) {
456+
result.setA("Lex err near position "+i+": I0 not defined for given algebra");
457+
return result;
458+
}
459+
@SuppressWarnings("unchecked")
460+
OctonionConstants<U> a = (OctonionConstants<U>) alg;
461+
a.I0().call(value);
462+
toks.add(new Numeric(i, value));
463+
i += 1;
464+
}
465+
else {
466+
U value = alg.construct();
467+
if (!(alg instanceof ImaginaryConstants<?>)) {
468+
result.setA("Lex err near position "+i+": I not defined for given algebra");
469+
return result;
470+
}
471+
@SuppressWarnings("unchecked")
472+
ImaginaryConstants<U> a = (ImaginaryConstants<U>) alg;
473+
a.I().call(value);
474+
toks.add(new Numeric(i, value));
475+
}
476+
}
477+
else if (ch == 'J') {
478+
if (nextFew(str, i, "J0")) {
479+
U value = alg.construct();
480+
if (!(alg instanceof OctonionConstants<?>)) {
481+
result.setA("Lex err near position "+i+": J0 not defined for given algebra");
482+
return result;
483+
}
484+
@SuppressWarnings("unchecked")
485+
OctonionConstants<U> a = (OctonionConstants<U>) alg;
486+
a.J0().call(value);
487+
toks.add(new Numeric(i, value));
488+
i += 1;
489+
}
490+
else {
491+
U value = alg.construct();
492+
if (!(alg instanceof QuaternionConstants<?>)) {
493+
result.setA("Lex err near position "+i+": J not defined for given algebra");
494+
return result;
495+
}
496+
@SuppressWarnings("unchecked")
497+
QuaternionConstants<U> a = (QuaternionConstants<U>) alg;
498+
a.J().call(value);
499+
toks.add(new Numeric(i, value));
500+
}
501+
}
502+
else if (ch == 'K') {
503+
if (nextFew(str, i, "K0")) {
504+
U value = alg.construct();
505+
if (!(alg instanceof OctonionConstants<?>)) {
506+
result.setA("Lex err near position "+i+": K0 not defined for given algebra");
507+
return result;
508+
}
509+
@SuppressWarnings("unchecked")
510+
OctonionConstants<U> a = (OctonionConstants<U>) alg;
511+
a.K0().call(value);
512+
toks.add(new Numeric(i, value));
513+
i += 1;
514+
}
515+
else {
516+
U value = alg.construct();
517+
if (!(alg instanceof QuaternionConstants<?>)) {
518+
result.setA("Lex err near position "+i+": K not defined for given algebra");
519+
return result;
520+
}
521+
@SuppressWarnings("unchecked")
522+
QuaternionConstants<U> a = (QuaternionConstants<U>) alg;
523+
a.K().call(value);
524+
toks.add(new Numeric(i, value));
525+
}
526+
}
438527
else if (ch == 'G') {
439528
if (nextFew(str, i, "GAMMA")) {
440529
U value = alg.construct();
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Zorbage: an algebraic data hierarchy for use in numeric processing.
3+
*
4+
* Copyright (C) 2016-2019 Barry DeZonia
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright notice,
10+
* this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation
13+
* and/or other materials provided with the distribution.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
19+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
* POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
package nom.bdezonia.zorbage.type.algebra;
28+
29+
import nom.bdezonia.zorbage.procedure.Procedure1;
30+
31+
/**
32+
*
33+
* @author Barry DeZonia
34+
*
35+
*/
36+
public interface ImaginaryConstants<T> {
37+
Procedure1<T> I();
38+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Zorbage: an algebraic data hierarchy for use in numeric processing.
3+
*
4+
* Copyright (C) 2016-2019 Barry DeZonia
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright notice,
10+
* this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation
13+
* and/or other materials provided with the distribution.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
19+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
* POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
package nom.bdezonia.zorbage.type.algebra;
28+
29+
import nom.bdezonia.zorbage.procedure.Procedure1;
30+
31+
/**
32+
*
33+
* @author Barry DeZonia
34+
*
35+
*/
36+
public interface OctonionConstants<T> {
37+
Procedure1<T> L();
38+
Procedure1<T> I0();
39+
Procedure1<T> J0();
40+
Procedure1<T> K0();
41+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Zorbage: an algebraic data hierarchy for use in numeric processing.
3+
*
4+
* Copyright (C) 2016-2019 Barry DeZonia
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright notice,
10+
* this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation
13+
* and/or other materials provided with the distribution.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
19+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
* POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
package nom.bdezonia.zorbage.type.algebra;
28+
29+
import nom.bdezonia.zorbage.procedure.Procedure1;
30+
31+
/**
32+
*
33+
* @author Barry DeZonia
34+
*
35+
*/
36+
public interface QuaternionConstants<T> {
37+
Procedure1<T> J();
38+
Procedure1<T> K();
39+
}

src/main/java/nom/bdezonia/zorbage/type/data/float16/complex/ComplexFloat16Algebra.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import nom.bdezonia.zorbage.type.algebra.Exponential;
5959
import nom.bdezonia.zorbage.type.algebra.Field;
6060
import nom.bdezonia.zorbage.type.algebra.Hyperbolic;
61+
import nom.bdezonia.zorbage.type.algebra.ImaginaryConstants;
6162
import nom.bdezonia.zorbage.type.algebra.Infinite;
6263
import nom.bdezonia.zorbage.type.algebra.InverseHyperbolic;
6364
import nom.bdezonia.zorbage.type.algebra.InverseTrigonometric;
@@ -82,6 +83,7 @@ public class ComplexFloat16Algebra
8283
Field<ComplexFloat16Algebra, ComplexFloat16Member>,
8384
Norm<ComplexFloat16Member, Float16Member>,
8485
RealConstants<ComplexFloat16Member>,
86+
ImaginaryConstants<ComplexFloat16Member>,
8587
Exponential<ComplexFloat16Member>,
8688
Trigonometric<ComplexFloat16Member>,
8789
InverseTrigonometric<ComplexFloat16Member>,
@@ -390,7 +392,6 @@ public Procedure1<ComplexFloat16Member> GAMMA() {
390392
return GAMMA_;
391393
}
392394

393-
394395
private final Procedure1<ComplexFloat16Member> PHI_ =
395396
new Procedure1<ComplexFloat16Member>()
396397
{
@@ -405,6 +406,20 @@ public Procedure1<ComplexFloat16Member> PHI() {
405406
return PHI_;
406407
}
407408

409+
private final Procedure1<ComplexFloat16Member> I_ =
410+
new Procedure1<ComplexFloat16Member>()
411+
{
412+
@Override
413+
public void call(ComplexFloat16Member a) {
414+
assign().call(I, a);
415+
}
416+
};
417+
418+
@Override
419+
public Procedure1<ComplexFloat16Member> I() {
420+
return I_;
421+
}
422+
408423
private final Procedure2<ComplexFloat16Member,ComplexFloat16Member> ASIN =
409424
new Procedure2<ComplexFloat16Member, ComplexFloat16Member>()
410425
{

0 commit comments

Comments
 (0)