Class Polynom
- Namespace
- CADability
- Assembly
- CADability.dll
A Polynom in multiple variables, often named x,y,z, but may be any dimension. e.g. ax³ + bx²y + cxy² +dy³ + ex² + fxy + gy² + hx + iy + j (deg(ree)==3, dim(ension)==2: (x,y))
public class Polynom : IEnumerable<monom>, IEnumerable
- Inheritance
-
Polynom
- Implements
- Inherited Members
- Extension Methods
Constructors
Polynom(double, int)
Creates a constant Polynom (often 1 or 0) with the provided dimension
public Polynom(double cv, int dim)
Parameters
Polynom(int, int)
Creates an empty polynom with all coefficients set to 0, prepared to have a maximum degree of deg and a dimension of dim (number of variables)
public Polynom(int deg, int dim)
Parameters
Polynom(int[], double)
Creates a polynom with a single monom where m are the exponents and v is the facctor
public Polynom(int[] m, double v)
Parameters
Polynom(params object[])
Creates a polynom as specified by the parameters. Expects input like (3, "x2", 4, "x", 5, "", 6, "y2", 7, "z", 8, "x2y") a alternating sequence of double values and strings. The charcters in the strings are interpreted as follows: A letter, which is the name of the variable, followed by an optional digit, which is the exponent of the variable (when missing "1" is assumed). An empty string is for the constant. The number of different variable names defines the dimension. The highest degree is derived from the exponents. The indices of the variables are in alphabetical order. The variable names have no further meaning and are not conserved.
public Polynom(params object[] def)
Parameters
defobject[]the definition of the polynom
Properties
Degree
public int Degree { get; }
Property Value
Dimension
public int Dimension { get; }
Property Value
LeadingTerm
public int[] LeadingTerm { get; }
Property Value
- int[]
Methods
Add(Polynom)
Adds the provided Polynom to this Polynom. The degree of the provided Polynom may not exceed the degree of this Polynom.
public void Add(Polynom b)
Parameters
bPolynom
Clone()
public Polynom Clone()
Returns
Derivate(params int[])
public Polynom Derivate(params int[] diff)
Parameters
diffint[]
Returns
Divide(Polynom, out Polynom)
public Polynom Divide(Polynom devideBy, out Polynom remainder)
Parameters
Returns
Eval(params double[])
Inserts the values for the variables and calculates the result of the Polynom
public double Eval(params double[] values)
Parameters
valuesdouble[]
Returns
Get(params int[])
public double Get(params int[] exp)
Parameters
expint[]
Returns
GetEnumerator()
public IEnumerator<monom> GetEnumerator()
Returns
Integrate(params int[])
Returns the integrated polynom
public Polynom Integrate(params int[] intg)
Parameters
intgint[]variables to integrate
Returns
LagrangeReduction2(Polynom)
public static ModOp2D LagrangeReduction2(Polynom polynom)
Parameters
polynomPolynom
Returns
Modified(ModOp)
Modifies the Polynom (which must be 3-dimensional) by the provided Modop
public Polynom Modified(ModOp m)
Parameters
mModOp
Returns
Modified(ModOp2D)
Modifies the Polynom (which must be 2-dimensional) by the provided Modop
public Polynom Modified(ModOp2D m)
Parameters
mModOp2D
Returns
NormalizeLeadingTerm()
public void NormalizeLeadingTerm()
Offset(params double[])
public Polynom Offset(params double[] off)
Parameters
offdouble[]
Returns
Reversed()
reverses all variables, replaces x by -x, y by -y, etc.
public Polynom Reversed()
Returns
Roots()
Calculates the (real) roots of this Polynom. The Polynom must be 1-dimensional
public double[] Roots()
Returns
- double[]
Set(double, params int[])
Sets the factor for the term specified by the parameter
public void Set(double v, params int[] exp)
Parameters
SingleDim(params double[])
public static Polynom SingleDim(params double[] c)
Parameters
cdouble[]
Returns
SingleDimLinear(double, double)
public static Polynom SingleDimLinear(double c0, double c1)
Parameters
Returns
SolveTwoSquared(Polynom, Polynom, double[])
Sloves two polynoms (==0) of degree 2 and dimension 2. the optinal minmax parameter gives bounds for the first (index 0,1) and the second (indes 2,3) variable
public static List<double[]> SolveTwoSquared(Polynom p1, Polynom p2, double[] minmax = null)
Parameters
Returns
Substitute(params Polynom[])
Replaces the variables by new polynomes and calculates the resulting Polynom. The number of provided polynoms must match the number of variables of this Polynom, which is the degree.
public Polynom Substitute(params Polynom[] substWith)
Parameters
substWithPolynom[]
Returns
SubstituteRational(Polynom, Polynom, Polynom, Polynom)
public Polynom SubstituteRational(Polynom px, Polynom py, Polynom pz, Polynom pw)
Parameters
Returns
Subtract(Polynom)
public Polynom Subtract(Polynom b)
Parameters
bPolynom
Returns
ToString()
public override string ToString()
Returns
reduce()
Reduces the degree of the Polynom, when the highest degree of all terms is less than the degree of this Polynom. Saves space.
public void reduce()
Operators
operator +(Polynom, Polynom)
Adds two Polynoms, which must have the same dimension
public static Polynom operator +(Polynom a, Polynom b)
Parameters
Returns
operator +(Polynom, double)
public static Polynom operator +(Polynom a, double b)
Parameters
Returns
operator +(double, Polynom)
public static Polynom operator +(double b, Polynom a)
Parameters
Returns
operator /(Polynom, double)
public static Polynom operator /(Polynom b, double a)
Parameters
Returns
operator ^(Polynom, int)
public static Polynom operator ^(Polynom b, int n)
Parameters
Returns
operator *(Polynom, Polynom)
Multiplies two Polynoms, which must have the same dimension
public static Polynom operator *(Polynom a, Polynom b)
Parameters
Returns
operator *(Polynom, double)
public static Polynom operator *(Polynom b, double a)
Parameters
Returns
operator *(double, Polynom)
public static Polynom operator *(double a, Polynom b)
Parameters
Returns
operator -(Polynom, Polynom)
public static Polynom operator -(Polynom a, Polynom b)
Parameters
Returns
operator -(Polynom, double)
public static Polynom operator -(Polynom a, double b)
Parameters
Returns
operator -(double, Polynom)
public static Polynom operator -(double b, Polynom a)
Parameters
Returns
operator -(Polynom)
public static Polynom operator -(Polynom a)
Parameters
aPolynom