public class Coef
extends java.lang.Object
P(x) = [2(a_1)^3(b) + 3b^2]x^4 - (a_2)(b_4)x^2 + 7ab + b_2
2(a_1)^3(b)+3b^2 is a Coef, as is -(a_2)(b_4) and 7ab + b_2. The first and third have length 2 (two Terms) the middle has length 1 (one term)
Constructor | Description |
---|---|
Coef() |
Default constructor.
|
Coef(char letter) |
Construct a Coef with just one letter (no numerical coefficient or exponent).
|
Coef(double constant) |
Construct a Coef with just a constant.
|
Coef(Atom atom) |
Construct a Coef with just 1 Atom.
|
Coef(Term term) |
Construct a Coef with just 1 term.
|
Coef(Term[] terms) |
Constructor that takes an array of Terms and copies the values into the terms array.
|
Modifier and Type | Method | Description |
---|---|---|
Term[] |
getTerms() |
Get terms array.
|
void |
insert(Term term) |
Inserts given Term in a convenient order or combines it with a like another like Term
|
boolean |
isConstantCoef() |
True if Coef consists only of a double, false otherwise.
|
boolean |
isDouble() |
Deprecated.
use
isConstantCoef() instead. |
boolean |
isZero() |
If the Coef is zero, it returns true.
|
Coef |
paste(Term term) |
Creates new Coef array with the new Term at the front of the array of Terms.
|
Coef |
place(Term term) |
Creates a new Coef with the Term inserted in a convenient order or combines it with a like another like Term
|
Coef |
plus(Coef coef) |
Add Coefs by combining like Terms and adding unlike Terms
|
Term |
pop() |
Remove first Term.
|
void |
print() |
Deprecated.
Use
toString() instead. |
void |
push(Term term) |
Inserts new Term at the front of the array of Terms.
|
void |
reduce() |
Combines like terms and writes them in order.
|
void |
setTerms(Term term) |
Set terms array with this term as the only element
|
void |
setTerms(Term[] terms) |
Set terms array.
|
Coef |
simplify() |
Combines like terms and writes them in order.
|
Coef |
snip() |
Create new Ceof array with the first Term removed.
|
Coef |
times(double scalar) |
Multiplies each Term in the Coef by a scalar (double)
|
Coef |
times(Coef coef) |
Multiply a Coefficient by another Coefficient.
|
java.lang.String |
toString() |
Compose a printable string of the Coef.
|
public Coef()
public Coef(Term[] terms)
terms
- the Term array to copypublic Coef(Term term)
term
- A single Term that becomes the Coef.public Coef(Atom atom)
atom
- Atom object used to initialize a term which will be the only element in the terms array.public Coef(double constant)
constant
- public Coef(char letter)
letter
- Used to create the term, which is the only element in the Term array.public Term[] getTerms()
public void setTerms(Term[] terms)
terms
- public void setTerms(Term term)
term
- term that will make up the terms arraypublic Coef snip()
public Term pop()
public Coef paste(Term term)
term
- Term to place in front.public void push(Term term)
term
- Term to place in front.public Coef place(Term term)
term
- public void insert(Term term)
term
- public Coef simplify()
public void reduce()
public Coef times(Coef coef)
coef
- The Coef object to multiply to this one.public Coef times(double scalar)
scalar
- The double to multiply it bypublic Coef plus(Coef coef)
coef
- Coef to be added to the first Coefpublic boolean isZero()
@Deprecated public boolean isDouble()
isConstantCoef()
instead.public boolean isConstantCoef()
@Deprecated public void print()
toString()
instead.public java.lang.String toString()
toString
in class java.lang.Object