|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.score.dependence.omega.omegaLib.Equation
public final class Equation
A representation of a linear equation.
$Id: Equation.java,v 1.15 2005-02-07 21:28:39 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
This version of the Omega Libray is a translation from C++ to Java of the Omega Library developed at the University of Maryland.
Copyright (C) 1994-1996 by the Omega ProjectAn equation represents a linear equation of the formAll rights reserved.
NOTICE: This software is provided ``as is'', without any warranty, including any implied warranty for merchantability or fitness for a particular purpose. Under no circumstances shall the Omega Project or its agents be liable for any use of, misuse of, or inability to use this software, including incidental and consequential damages.
License is hereby given to use, modify, and redistribute this software, in whole or in part, for any purpose, commercial or non-commercial, provided that the user agrees to the terms of this copyright notice, including disclaimer of warranty, and provided that this copyright notice, including disclaimer of warranty, is preserved in the source code and documentation of anything derived from this software. Any redistributor of this software or anything derived from this software assumes responsibility for ensuring that any parties to whom such a redistribution is made are fully aware of the terms of this license and disclaimer.
The Omega project can be contacted at omega@cs.umd.edu or http://www.cs.umd.edu/projects/omega
Field Summary | |
---|---|
int |
v1
|
int |
v2
|
Constructor Summary | |
---|---|
Equation(int key,
int color,
int nVars,
int constant)
Create a new Equation. |
Method Summary | |
---|---|
void |
addToCoef(int var,
int value)
Add the value to the specified coefficient. |
boolean |
anyNZCoef(int last,
int first)
Return true if any coefficient's value is 1 or -1. |
void |
checkMultCoefs(Equation f1,
int nVars,
int mult)
Set the coefficients to the product of a scalar and the coefficients of another Equation. |
void |
checkMultCoefs(int nVars,
int mult)
Multiply the coefficients by a scalar value. |
java.lang.String |
coefsToString(int last,
int first)
Return a String representing the coefficients. |
void |
combineColumns(int src,
int dest)
Add the sorce column coefficient to the destination column coefficient. |
int |
computeHashcode(int topVar,
int[] packing)
|
Equation |
copy()
Create a new Equation that is a duplicate of this Equation. |
void |
copyCoef(Equation from,
int src,
int dest)
Set the destination coefficient to the same value as the soure coefficient. |
void |
copyCoef(int src,
int dest)
Set the destination coefficient to the same value as the soure coefficient. |
void |
copyCoef(int src,
int dest,
int number)
Set the destination coefficients to the same value as the soure coefficients. |
void |
copyCoefs(Equation from,
int num)
Copy the coefficients from one Equation to another. |
void |
copyCoefs(Equation from,
int last,
int first)
Copy the coefficients from one Equation to another. |
void |
copyCoefsIndexed(Equation from,
int nVars,
int[] index)
Copy the coefficients from the specified Equation to this Equation. |
void |
copyColumn(Equation fp,
int src,
int dest)
|
static int |
created()
|
int |
crossProduct(int last,
int first)
|
void |
divideCoef(int var,
int value)
Divide the specified coefficient by the value. |
void |
divideCoefs(int nVars,
int value)
Divide the coefficients by the value. |
void |
divideCoefsEven(int nVars,
int value)
Divide the coefficients by the value. |
void |
eqncpy(Equation eq)
Make this Equation the duplicate of the specified Equation. |
boolean |
findDifference(int nVars)
Return true if equation is of form (v1 - coef >= v2) . |
int |
findLargestNZ(int last,
int first)
Return the index of the last coefficient with the largest non-zero value. |
int |
findSmallestNZ(int last,
int first)
Return the index of the last coefficient with the smallest non-zero value. |
int |
gcdCoefs(int last,
int first)
Return the greates common denominator of the specified coefficients. |
int |
gcdSumOfProd(Equation eq2,
int mult1,
int mult2,
int last,
int first)
|
int |
getCoefficient(int i)
Return the specified coefficient. |
int |
getColor()
Return the color of the Equation. |
int |
getConstant()
Return the coefficient of the constant term. |
int |
getKey()
Return the key. |
int |
getVarCount()
Return the varCount. |
void |
incVarCount()
Increment the varCount value by 1. |
void |
intModHat(int var,
int b)
|
boolean |
intModHat(int first,
int last,
int b)
|
void |
intModHatI(int i,
int nVars)
|
boolean |
isBlack()
Return true if the Equation is BLACK. |
boolean |
isEssential()
Return true if this Equation is essential. |
boolean |
isGoodEquation(Equation eq2,
int mult,
int last,
int first)
|
boolean |
isNotBlack()
Return true if the Equation is not BLACK. |
boolean |
isNotRed()
Return true if the Equation is not red. |
boolean |
isNotZero(int var)
Return true if specified coefficient is not zero. |
boolean |
isTouched()
Return true if this Equation is touched. |
boolean |
isZero(int var)
Return true if specified coefficient is zero. |
int |
lastCoefGt1(int last,
int first)
Return the index of the last coefficient whose absolute value is greater than 1. |
int |
lastDiffModZero(Equation eq2,
int g,
int i,
int last,
int first)
|
int |
lastNZCoef(int last,
int first)
Return the index of the last non-zero coefficient. |
int |
lastNZCoef(int v1,
int v2,
int last,
int first)
Return the index of the last non-zero coefficient whose index is not specified. |
int |
lastOneCoef(int last,
int first)
Return the index of the last coefficient whose value is 1 or -1. |
void |
multAndSub(Equation f1,
int mult,
int nVars)
Subtract the product of a scalar and the coefficients of another Equation from these coefficients. |
void |
multCoefs(Equation f1,
int nVars,
int mult)
Set the coefficients to the product of a scalar and the coefficients of another Equation. |
void |
multCoefs(int nVars,
int mult)
Multiply all of the coefficients by the scalar specified. |
void |
negate(int nVars)
Negate all of the coefficients. |
void |
negateCoefficients(int nVars)
Negate all of the coefficients and set touched to true. |
void |
negateCoefs(Equation from,
int last,
int first)
Negate the of the specified Equation to get this Equation's coefficients. |
void |
negateCoefs(int last,
int first)
Negate the specified coefficients. |
int |
numNZCoefs(int last,
int first)
Return count of coefficients that are not zero. |
int |
numOneCoefs(int last,
int first)
Return count of coefficients whose value is 1 or -1. |
int |
numVars()
Return the number of variable slots that exist. |
int |
packNZIndexes(int[] indexes,
int last,
int first)
|
void |
reset(int color,
int nVars,
int constant)
Reset the Equation for resuse. |
void |
set(int color,
int key,
boolean touched)
Set the color, key, and touched values. |
void |
setCoef(int i,
int value)
Set the value of the specified coefficient. |
void |
setColor(Equation f1)
Set the color of the Equation. |
void |
setColor(Equation f1,
Equation f2)
Set the color of this Equation to the union of the colors of the two Equations. |
void |
setColor(Equation f1,
Equation f2,
Equation f3)
Set the color of this Equation to the union of the colors of the three Equations. |
void |
setColor(int color)
Set the color of the Equation. |
void |
setConstant(int value)
Set the value of the constant term. |
void |
setEssential(boolean flg)
Set the essential flag. |
void |
setKey(int key)
Set the key value. |
void |
setTouched(boolean flg)
Set the touched flag. |
void |
setTrueIfNotZero(boolean[] res,
int last,
int first)
Set the array element true if the corresponding coefficient is not zero. |
void |
setVarCount(int varCount)
Set the varCount value. |
void |
sumAndDivide(Equation f1,
Equation f2,
int divisor,
int nVars)
Set the coefficients to the (c1 + c2) / divisor where n1 and n2 are the coressponding coefficients from two Equations. |
void |
sumOfCoefs(Equation f1,
Equation f2,
int nVars)
Set the coefficients to the sum of the coefficients from two Equations. |
void |
sumOfMult(Equation f1,
int mult1,
Equation f2,
int mult2,
int nVars)
Set the coefficients to (coef[i] = mult1 * f1.coef[i] + mult2 * f2.coef[i];) . |
void |
swapVars(int v1,
int v2)
Swap the values of the specified coefficients and set touched true. |
java.lang.String |
toString()
Return a String representation of this Equation. |
void |
turnBlack()
Turn the Equation BLACK. |
void |
turnRed()
Turn the Equation red. |
void |
weirdCopyCoefs(Equation from,
int last,
int first,
int g)
Copy the coefficients from the specified Equation to this Equation. |
void |
zeroColumn(int col)
Set the specified coefficient to zero. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public int v1
public int v2
Constructor Detail |
---|
public Equation(int key, int color, int nVars, int constant)
key
- is the key valuecolor
- is the color of the EquationnVars
- is the number of variablesconstant
- is the value of the constant term coefficientMethod Detail |
---|
public static int created()
public Equation copy()
public void reset(int color, int nVars, int constant)
nVars
- is the number of variables in the equation.public void set(int color, int key, boolean touched)
public void eqncpy(Equation eq)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String coefsToString(int last, int first)
last
- is the index of the last coefficient copiedfirst
- is the index of the first coefficient copiedpublic int getVarCount()
public void setVarCount(int varCount)
public void incVarCount()
public int getKey()
public void setKey(int key)
public boolean isTouched()
public void setTouched(boolean flg)
public boolean isEssential()
public void setEssential(boolean flg)
public boolean isZero(int var)
public boolean isNotZero(int var)
public void turnBlack()
public void turnRed()
public int getColor()
public void setColor(int color)
public void setColor(Equation f1)
public void setColor(Equation f1, Equation f2)
public void setColor(Equation f1, Equation f2, Equation f3)
public boolean isBlack()
public boolean isNotBlack()
public boolean isNotRed()
public int numVars()
public int getCoefficient(int i)
public int getConstant()
public void setCoef(int i, int value)
public void setConstant(int value)
public void addToCoef(int var, int value)
public void sumOfCoefs(Equation f1, Equation f2, int nVars)
public void divideCoef(int var, int value)
public void divideCoefs(int nVars, int value)
public void divideCoefsEven(int nVars, int value)
public void sumAndDivide(Equation f1, Equation f2, int divisor, int nVars)
public void copyCoef(int src, int dest)
public void copyCoef(Equation from, int src, int dest)
public void copyCoef(int src, int dest, int number)
public void copyCoefs(Equation from, int num)
from
- is the source of the coefficientspublic void copyCoefs(Equation from, int last, int first)
from
- is the source of the coefficientslast
- is the index of the last coefficient copiedfirst
- is the index of the first coefficient copiedpublic void copyCoefsIndexed(Equation from, int nVars, int[] index)
coef[index[i]] = from.coef[i]
from
- is the source of the coefficientsindex
- specifies the mappingpublic void weirdCopyCoefs(Equation from, int last, int first, int g)
coef[i] = (6 * from.coef[i] + g / 2) / g;
from
- is the source of the coefficientslast
- is the index of the last coefficient copiedfirst
- is the index of the first coefficient copiedg
- is the weird valuepublic void copyColumn(Equation fp, int src, int dest)
public void zeroColumn(int col)
public void negateCoefs(int last, int first)
last
- is the index of the last coefficient negatedfirst
- is the index of the first coefficient negatedpublic void negateCoefs(Equation from, int last, int first)
last
- is the index of the last coefficient negatedfirst
- is the index of the first coefficient negatedpublic void negate(int nVars)
public void negateCoefficients(int nVars)
public void multCoefs(int nVars, int mult)
public void multCoefs(Equation f1, int nVars, int mult)
mult
- is the scalar usedpublic void checkMultCoefs(int nVars, int mult)
mult
- is the scalar usedpublic void checkMultCoefs(Equation f1, int nVars, int mult)
mult
- is the scalar usedpublic void multAndSub(Equation f1, int mult, int nVars)
mult
- is the scalar usedpublic void sumOfMult(Equation f1, int mult1, Equation f2, int mult2, int nVars)
(coef[i] = mult1 * f1.coef[i] + mult2 * f2.coef[i];)
.
public void combineColumns(int src, int dest)
public void swapVars(int v1, int v2)
public boolean findDifference(int nVars)
(v1 - coef >= v2)
.
public void intModHat(int var, int b)
public void intModHatI(int i, int nVars)
public boolean intModHat(int first, int last, int b)
public int gcdCoefs(int last, int first)
last
- is index of the last coefficientfirst
- is index of the first coefficientpublic int gcdSumOfProd(Equation eq2, int mult1, int mult2, int last, int first)
public int computeHashcode(int topVar, int[] packing)
public boolean anyNZCoef(int last, int first)
public int numNZCoefs(int last, int first)
public int numOneCoefs(int last, int first)
public int lastOneCoef(int last, int first)
public int lastNZCoef(int last, int first)
public int lastNZCoef(int v1, int v2, int last, int first)
v1
- specifies the first index to be skippedv2
- specifies the second index to be skippedpublic int lastCoefGt1(int last, int first)
public int findSmallestNZ(int last, int first)
public int findLargestNZ(int last, int first)
public int lastDiffModZero(Equation eq2, int g, int i, int last, int first)
public int crossProduct(int last, int first)
public void setTrueIfNotZero(boolean[] res, int last, int first)
public int packNZIndexes(int[] indexes, int last, int first)
public boolean isGoodEquation(Equation eq2, int mult, int last, int first)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |