File tree Expand file tree Collapse file tree 5 files changed +189
-0
lines changed
src/main/java/net/imglib2/algorithm/math Expand file tree Collapse file tree 5 files changed +189
-0
lines changed Original file line number Diff line number Diff line change 1+ package net .imglib2 .algorithm .math ;
2+
3+ import java .util .Map ;
4+
5+ import net .imglib2 .algorithm .math .abstractions .AUnaryFunction ;
6+ import net .imglib2 .algorithm .math .abstractions .OFunction ;
7+ import net .imglib2 .algorithm .math .execution .Exponential ;
8+ import net .imglib2 .algorithm .math .execution .LetBinding ;
9+ import net .imglib2 .algorithm .math .execution .Variable ;
10+ import net .imglib2 .converter .Converter ;
11+ import net .imglib2 .type .numeric .RealType ;
12+
13+ public final class Exp extends AUnaryFunction
14+ {
15+ public Exp ( final Object o1 )
16+ {
17+ super ( o1 );
18+ }
19+
20+ @ Override
21+ public < O extends RealType < O > > Exponential < O > reInit (
22+ final O tmp ,
23+ final Map < String , LetBinding < O > > bindings ,
24+ final Converter < RealType < ? >, O > converter ,
25+ final Map < Variable < O >, OFunction < O > > imgSources )
26+ {
27+ return new Exponential < O >( tmp .copy (),
28+ this .a .reInit ( tmp , bindings , converter , imgSources ) );
29+ }
30+ }
Original file line number Diff line number Diff line change @@ -209,6 +209,21 @@ static public final Min minimum( final Object... obs )
209209 return new Min ( obs );
210210 }
211211
212+ static public final Log log ( final Object o1 )
213+ {
214+ return new Log ( o1 );
215+ }
216+
217+ static public final Log logarithm ( final Object o1 )
218+ {
219+ return new Log ( o1 );
220+ }
221+
222+ static public final Exp exp ( final Object o1 )
223+ {
224+ return new Exp ( o1 );
225+ }
226+
212227 static public final Let let ( final String varName , final Object varValue , final Object body )
213228 {
214229 return new Let ( varName , varValue , body );
Original file line number Diff line number Diff line change 1+ package net .imglib2 .algorithm .math ;
2+
3+ import java .util .Map ;
4+
5+ import net .imglib2 .algorithm .math .abstractions .AUnaryFunction ;
6+ import net .imglib2 .algorithm .math .abstractions .OFunction ;
7+ import net .imglib2 .algorithm .math .execution .Logarithm ;
8+ import net .imglib2 .algorithm .math .execution .LetBinding ;
9+ import net .imglib2 .algorithm .math .execution .Variable ;
10+ import net .imglib2 .converter .Converter ;
11+ import net .imglib2 .type .numeric .RealType ;
12+
13+ public final class Log extends AUnaryFunction
14+ {
15+ public Log ( final Object o1 )
16+ {
17+ super ( o1 );
18+ }
19+
20+ @ Override
21+ public < O extends RealType < O > > Logarithm < O > reInit (
22+ final O tmp ,
23+ final Map < String , LetBinding < O > > bindings ,
24+ final Converter < RealType < ? >, O > converter ,
25+ final Map < Variable < O >, OFunction < O > > imgSources )
26+ {
27+ return new Logarithm < O >( tmp .copy (),
28+ this .a .reInit ( tmp , bindings , converter , imgSources ) );
29+ }
30+ }
Original file line number Diff line number Diff line change 1+ package net .imglib2 .algorithm .math .execution ;
2+
3+ import java .util .Arrays ;
4+ import java .util .List ;
5+
6+ import net .imglib2 .Localizable ;
7+ import net .imglib2 .algorithm .math .abstractions .OFunction ;
8+ import net .imglib2 .type .numeric .RealType ;
9+
10+ /**
11+ * Doesn't use {@code NumericType} math because it lacks the log function.
12+ *
13+ * @param <O>
14+ */
15+ public class Exponential < O extends RealType < O > > implements OFunction < O >
16+ {
17+ private final OFunction < O > a ;
18+ private final O scrap ;
19+
20+ public Exponential ( final O scrap , final OFunction < O > a )
21+ {
22+ this .scrap = scrap ;
23+ this .a = a ;
24+ }
25+
26+ @ Override
27+ public final O eval ()
28+ {
29+ this .scrap .setReal ( Math .exp ( this .a .eval ().getRealDouble () ) );
30+ return this .scrap ;
31+ }
32+
33+ @ Override
34+ public final O eval ( final Localizable loc )
35+ {
36+ this .scrap .setReal ( Math .exp ( this .a .eval ( loc ).getRealDouble () ) );
37+ return this .scrap ;
38+ }
39+
40+ @ Override
41+ public List < OFunction < O > > children ()
42+ {
43+ return Arrays .asList ( this .a );
44+ }
45+
46+ @ Override
47+ public final double evalDouble ()
48+ {
49+ return Math .exp ( this .a .evalDouble () );
50+ }
51+
52+ @ Override
53+ public final double evalDouble ( final Localizable loc )
54+ {
55+ return Math .exp ( this .a .evalDouble ( loc ) );
56+ }
57+ }
Original file line number Diff line number Diff line change 1+ package net .imglib2 .algorithm .math .execution ;
2+
3+ import java .util .Arrays ;
4+ import java .util .List ;
5+
6+ import net .imglib2 .Localizable ;
7+ import net .imglib2 .algorithm .math .abstractions .OFunction ;
8+ import net .imglib2 .type .numeric .RealType ;
9+
10+ /**
11+ * Doesn't use {@code NumericType} math because it lacks the log function.
12+ *
13+ * @param <O>
14+ */
15+ public class Logarithm < O extends RealType < O > > implements OFunction < O >
16+ {
17+ private final OFunction < O > a ;
18+ private final O scrap ;
19+
20+ public Logarithm ( final O scrap , final OFunction < O > a )
21+ {
22+ this .scrap = scrap ;
23+ this .a = a ;
24+ }
25+
26+ @ Override
27+ public final O eval ()
28+ {
29+ this .scrap .setReal ( Math .log ( this .a .eval ().getRealDouble () ) );
30+ return this .scrap ;
31+ }
32+
33+ @ Override
34+ public final O eval ( final Localizable loc )
35+ {
36+ this .scrap .setReal ( Math .log ( this .a .eval ( loc ).getRealDouble () ) );
37+ return this .scrap ;
38+ }
39+
40+ @ Override
41+ public List < OFunction < O > > children ()
42+ {
43+ return Arrays .asList ( this .a );
44+ }
45+
46+ @ Override
47+ public final double evalDouble ()
48+ {
49+ return Math .log ( this .a .evalDouble () );
50+ }
51+
52+ @ Override
53+ public final double evalDouble ( final Localizable loc )
54+ {
55+ return Math .log ( this .a .evalDouble ( loc ) );
56+ }
57+ }
You can’t perform that action at this time.
0 commit comments