-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #791 from chathurawidanage/0.4.0
Adding operation classes
- Loading branch information
Showing
9 changed files
with
390 additions
and
388 deletions.
There are no files selected for viewing
45 changes: 0 additions & 45 deletions
45
twister2/comms/src/java/edu/iu/dsc/tws/comms/functions/ReduceSumFunction.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
twister2/comms/src/java/edu/iu/dsc/tws/comms/functions/reduction/AbstractOp.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,26 @@ | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package edu.iu.dsc.tws.comms.functions.reduction; | ||
|
||
public interface AbstractOp { | ||
int doInt(int o1, int o2); | ||
|
||
long doLong(long o1, long o2); | ||
|
||
short doShort(short o1, short o2); | ||
|
||
float doFloat(float o1, float o2); | ||
|
||
double doDouble(double o1, double o2); | ||
|
||
byte doByte(byte o1, byte o2); | ||
} |
51 changes: 51 additions & 0 deletions
51
twister2/comms/src/java/edu/iu/dsc/tws/comms/functions/reduction/OpDivision.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,51 @@ | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package edu.iu.dsc.tws.comms.functions.reduction; | ||
|
||
public class OpDivision implements AbstractOp { | ||
|
||
private static final OpDivision INSTANCE = new OpDivision(); | ||
|
||
public static AbstractOp getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
public int doInt(int o1, int o2) { | ||
return o1 / o2; | ||
} | ||
|
||
@Override | ||
public long doLong(long o1, long o2) { | ||
return o1 / o2; | ||
} | ||
|
||
@Override | ||
public short doShort(short o1, short o2) { | ||
return (short) (o1 / o2); | ||
} | ||
|
||
@Override | ||
public float doFloat(float o1, float o2) { | ||
return o1 / o2; | ||
} | ||
|
||
@Override | ||
public double doDouble(double o1, double o2) { | ||
return o1 / o2; | ||
} | ||
|
||
@Override | ||
public byte doByte(byte o1, byte o2) { | ||
return (byte) (o1 / o2); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
twister2/comms/src/java/edu/iu/dsc/tws/comms/functions/reduction/OpMax.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,51 @@ | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package edu.iu.dsc.tws.comms.functions.reduction; | ||
|
||
public class OpMax implements AbstractOp { | ||
|
||
private static final OpMax INSTANCE = new OpMax(); | ||
|
||
public static AbstractOp getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
public int doInt(int o1, int o2) { | ||
return o1 > o2 ? o1 : o2; | ||
} | ||
|
||
@Override | ||
public long doLong(long o1, long o2) { | ||
return o1 > o2 ? o1 : o2; | ||
} | ||
|
||
@Override | ||
public short doShort(short o1, short o2) { | ||
return o1 > o2 ? o1 : o2; | ||
} | ||
|
||
@Override | ||
public float doFloat(float o1, float o2) { | ||
return o1 > o2 ? o1 : o2; | ||
} | ||
|
||
@Override | ||
public double doDouble(double o1, double o2) { | ||
return o1 > o2 ? o1 : o2; | ||
} | ||
|
||
@Override | ||
public byte doByte(byte o1, byte o2) { | ||
return o1 > o2 ? o1 : o2; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
twister2/comms/src/java/edu/iu/dsc/tws/comms/functions/reduction/OpMin.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,51 @@ | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package edu.iu.dsc.tws.comms.functions.reduction; | ||
|
||
public class OpMin implements AbstractOp { | ||
|
||
private static final OpMin INSTANCE = new OpMin(); | ||
|
||
public static AbstractOp getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
public int doInt(int o1, int o2) { | ||
return o1 < o2 ? o1 : o2; | ||
} | ||
|
||
@Override | ||
public long doLong(long o1, long o2) { | ||
return o1 < o2 ? o1 : o2; | ||
} | ||
|
||
@Override | ||
public short doShort(short o1, short o2) { | ||
return o1 < o2 ? o1 : o2; | ||
} | ||
|
||
@Override | ||
public float doFloat(float o1, float o2) { | ||
return o1 < o2 ? o1 : o2; | ||
} | ||
|
||
@Override | ||
public double doDouble(double o1, double o2) { | ||
return o1 < o2 ? o1 : o2; | ||
} | ||
|
||
@Override | ||
public byte doByte(byte o1, byte o2) { | ||
return o1 < o2 ? o1 : o2; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
twister2/comms/src/java/edu/iu/dsc/tws/comms/functions/reduction/OpProduct.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,51 @@ | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package edu.iu.dsc.tws.comms.functions.reduction; | ||
|
||
public class OpProduct implements AbstractOp { | ||
|
||
private static final OpProduct INSTANCE = new OpProduct(); | ||
|
||
public static AbstractOp getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
public int doInt(int o1, int o2) { | ||
return o1 * o2; | ||
} | ||
|
||
@Override | ||
public long doLong(long o1, long o2) { | ||
return o1 * o2; | ||
} | ||
|
||
@Override | ||
public short doShort(short o1, short o2) { | ||
return (short) (o1 * o2); | ||
} | ||
|
||
@Override | ||
public float doFloat(float o1, float o2) { | ||
return o1 * o2; | ||
} | ||
|
||
@Override | ||
public double doDouble(double o1, double o2) { | ||
return o1 * o2; | ||
} | ||
|
||
@Override | ||
public byte doByte(byte o1, byte o2) { | ||
return (byte) (o1 * o2); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
twister2/comms/src/java/edu/iu/dsc/tws/comms/functions/reduction/OpSum.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,51 @@ | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package edu.iu.dsc.tws.comms.functions.reduction; | ||
|
||
public class OpSum implements AbstractOp { | ||
|
||
private static final OpSum INSTANCE = new OpSum(); | ||
|
||
public static AbstractOp getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
public int doInt(int o1, int o2) { | ||
return o1 + o2; | ||
} | ||
|
||
@Override | ||
public long doLong(long o1, long o2) { | ||
return o1 + o2; | ||
} | ||
|
||
@Override | ||
public short doShort(short o1, short o2) { | ||
return (short) (o1 + o2); | ||
} | ||
|
||
@Override | ||
public float doFloat(float o1, float o2) { | ||
return o1 + o2; | ||
} | ||
|
||
@Override | ||
public double doDouble(double o1, double o2) { | ||
return o1 + o2; | ||
} | ||
|
||
@Override | ||
public byte doByte(byte o1, byte o2) { | ||
return (byte) (o1 + o2); | ||
} | ||
} |
Oops, something went wrong.