Skip to content

Commit 559033f

Browse files
committed
ParameterConversion: fix integer division
1/9 = 0 in Java.
1 parent dab83f7 commit 559033f

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

docs/ops/doc/ParameterConversion.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ Suppose a user wants to use this Op with a small, fixed kernel, which for ease i
4545
Img<DoubleType> in = ...
4646
// 3x3 averaging kernel
4747
double[][] kernel = { //
48-
{ 1/9, 1/9, 1/9}, //
49-
{ 1/9, 1/9, 1/9}, //
50-
{ 1/9, 1/9, 1/9} //
48+
{ 1/9d, 1/9d, 1/9d}, //
49+
{ 1/9d, 1/9d, 1/9d}, //
50+
{ 1/9d, 1/9d, 1/9d} //
5151
};
5252
// transform double[][] into a RandomAccessibleInterval
5353
Img<DoubleType> kernel = ArrayImgs.doubles(data, 3, 3);
@@ -95,9 +95,9 @@ Using this ``engine.convert`` Op, SciJava Ops can match our ``filter.convolve``
9595
Img<DoubleType> in = ...
9696
// 3x3 averaging kernel
9797
double[][] kernel = { //
98-
{ 1/9, 1/9, 1/9}, //
99-
{ 1/9, 1/9, 1/9}, //
100-
{ 1/9, 1/9, 1/9} //
98+
{ 1/9d, 1/9d, 1/9d}, //
99+
{ 1/9d, 1/9d, 1/9d}, //
100+
{ 1/9d, 1/9d, 1/9d} //
101101
};
102102
103103
// Ideal case - no need to wrap to Img
@@ -165,9 +165,9 @@ Now, imagine that the user wished to execute the Op using **only** ``double[][]`
165165
double[][] in = ...
166166
// 3x3 averaging kernel
167167
double[][] kernel = { //
168-
{ 1/9, 1/9, 1/9}, //
169-
{ 1/9, 1/9, 1/9}, //
170-
{ 1/9, 1/9, 1/9} //
168+
{ 1/9d, 1/9d, 1/9d}, //
169+
{ 1/9d, 1/9d, 1/9d}, //
170+
{ 1/9d, 1/9d, 1/9d} //
171171
};
172172
173173
double[][] result = ops.op("filter.convolve") //
@@ -240,9 +240,9 @@ Suppose that again the user wants to call this Op using *only* ``double[][]``\ s
240240
double[][] in = ...
241241
// 3x3 averaging kernel
242242
double[][] kernel = { //
243-
{ 1/9, 1/9, 1/9}, //
244-
{ 1/9, 1/9, 1/9}, //
245-
{ 1/9, 1/9, 1/9} //
243+
{ 1/9d, 1/9d, 1/9d}, //
244+
{ 1/9d, 1/9d, 1/9d}, //
245+
{ 1/9d, 1/9d, 1/9d} //
246246
};
247247
double[][] result = new double[in.length][in[0].length];
248248
@@ -290,4 +290,4 @@ All in all, you can enable parameter conversion from type ``A`` to type ``B`` by
290290

291291
Note that, in the process of creating your ``engine.convert`` ``Function`` Ops, you'll likely want to write some ``engine.create`` Ops that could produce objects of type ``B``. In addition to making your ``engine.convert`` Ops more granular by using them as Op dependencies, but they'll additionally help enable features like Op adaptation.
292292

293-
Beyond this, it would also be helpful to ensure that an ``engine.copy(converted_output: A, user_buffer: A)`` Op exists, such that users can also call *your* ``Computer`` and ``Inplace`` Ops using objects of type ``A``.
293+
Beyond this, it would also be helpful to ensure that an ``engine.copy(converted_output: A, user_buffer: A)`` Op exists, such that users can also call *your* ``Computer`` and ``Inplace`` Ops using objects of type ``A``.

0 commit comments

Comments
 (0)