本文整理匯總了Java中com.google.common.math.IntMath.gcd方法的典型用法代碼示例。如果您正苦於以下問題:Java IntMath.gcd方法的具體用法?Java IntMath.gcd怎麽用?Java IntMath.gcd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.math.IntMath
的用法示例。
在下文中一共展示了IntMath.gcd方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createSlidingUnifier
import com.google.common.math.IntMath; //導入方法依賴的package包/類
public static PTOperator createSlidingUnifier(StreamMeta streamMeta, PhysicalPlan plan, int
operatorApplicationWindowCount, int slidingWindowCount)
{
int gcd = IntMath.gcd(operatorApplicationWindowCount, slidingWindowCount);
OperatorMeta um = streamMeta.getSource()
.getSlidingUnifier(operatorApplicationWindowCount / gcd, gcd, slidingWindowCount / gcd);
PTOperator pu = plan.newOperator(um, um.getName());
Operator unifier = um.getOperator();
PortMappingDescriptor mergeDesc = new PortMappingDescriptor();
Operators.describe(unifier, mergeDesc);
if (mergeDesc.outputPorts.size() != 1) {
throw new AssertionError("Unifier must have a single output port, instead found : " + mergeDesc.outputPorts);
}
pu.unifiedOperatorMeta = streamMeta.getSource().getOperatorMeta();
pu.outputs.add(new PTOutput(mergeDesc.outputPorts.keySet().iterator().next(), streamMeta, pu));
plan.newOpers.put(pu, unifier);
return pu;
}
示例2: RatLitExpr
import com.google.common.math.IntMath; //導入方法依賴的package包/類
RatLitExpr(final int num, final int denom) {
checkArgument(denom != 0);
final int gcd = IntMath.gcd(Math.abs(num), Math.abs(denom));
if (denom >= 0) {
this.num = num / gcd;
this.denom = denom / gcd;
} else {
this.num = -num / gcd;
this.denom = -denom / gcd;
}
}
示例3: gCD
import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Benchmark int gCD(int reps) {
int tmp = 0;
for (int i = 0; i < reps; i++) {
int j = i & ARRAY_MASK;
tmp += IntMath.gcd(nonnegative[j], positive[j]);
}
return tmp;
}
示例4: activate
import com.google.common.math.IntMath; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void activate()
{
alive = true;
APPLICATION_WINDOW_COUNT = context.getValue(OperatorContext.APPLICATION_WINDOW_COUNT);
if (context.getValue(OperatorContext.SLIDE_BY_WINDOW_COUNT) != null) {
int slidingWindowCount = context.getValue(OperatorContext.SLIDE_BY_WINDOW_COUNT);
APPLICATION_WINDOW_COUNT = IntMath.gcd(APPLICATION_WINDOW_COUNT, slidingWindowCount);
}
DAG_CHECKPOINT_WINDOW_COUNT = context.getValue(Context.DAGContext.CHECKPOINT_WINDOW_COUNT);
CHECKPOINT_WINDOW_COUNT = context.getValue(OperatorContext.CHECKPOINT_WINDOW_COUNT);
Collection<StatsListener> statsListeners = context.getValue(OperatorContext.STATS_LISTENERS);
if (CHECKPOINT_WINDOW_COUNT % APPLICATION_WINDOW_COUNT != 0) {
logger.warn("{} is not exact multiple of {} for operator {}. This may cause side effects such as processing to begin without beginWindow preceding it in the first window after activation.",
OperatorContext.CHECKPOINT_WINDOW_COUNT,
OperatorContext.APPLICATION_WINDOW_COUNT,
operator);
}
PROCESSING_MODE = context.getValue(OperatorContext.PROCESSING_MODE);
if (PROCESSING_MODE == ProcessingMode.EXACTLY_ONCE && CHECKPOINT_WINDOW_COUNT != 1) {
logger.warn("Ignoring {} attribute in favor of {} processing mode", OperatorContext.CHECKPOINT_WINDOW_COUNT.getSimpleName(), ProcessingMode.EXACTLY_ONCE.name());
CHECKPOINT_WINDOW_COUNT = 1;
}
activateSinks();
if (operator instanceof Operator.ActivationListener) {
((Operator.ActivationListener<OperatorContext>)operator).activate(context);
}
if (statsListeners != null) {
Iterator<StatsListener> iterator = statsListeners.iterator();
while (iterator.hasNext()) {
DATA_TUPLE_AWARE = iterator.next().getClass().isAnnotationPresent(StatsListener.DataQueueSize.class);
if (DATA_TUPLE_AWARE) {
break;
}
}
}
if (!DATA_TUPLE_AWARE && (operator instanceof StatsListener)) {
DATA_TUPLE_AWARE = operator.getClass().isAnnotationPresent(StatsListener.DataQueueSize.class);
}
/*
* If there were any requests which needed to be executed before the operator started
* its normal execution, execute those requests now - e.g. Restarting the operator
* recording for the operators which failed while recording and being replaced.
*/
handleRequests(currentWindowId);
}
示例5: gcdInt
import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Override
public int gcdInt(int a, int b) {
return IntMath.gcd(a, b);
}
示例6: lcm
import com.google.common.math.IntMath; //導入方法依賴的package包/類
private static int lcm(int a, int b) {
//Divide before multiplying for overflow resistance.
return a / IntMath.gcd(a, b) * b;
}
示例7: gcd
import com.google.common.math.IntMath; //導入方法依賴的package包/類
/**
* 兩個數的最大公約數,必須均為非負數.
*
* 是公約數,別想太多
*/
public static int gcd(int a, int b) {
return IntMath.gcd(a, b);
}