Skip to content

Commit

Permalink
Merge pull request #791 from chathurawidanage/0.4.0
Browse files Browse the repository at this point in the history
Adding operation classes
  • Loading branch information
supunkamburugamuve authored Dec 3, 2019
2 parents 1773e91 + 9b89563 commit ab2d11d
Show file tree
Hide file tree
Showing 9 changed files with 390 additions and 388 deletions.

This file was deleted.

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);
}
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);
}
}
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;
}
}
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;
}
}
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);
}
}
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);
}
}
Loading

0 comments on commit ab2d11d

Please sign in to comment.