
Sorry, I have no idea why you have posted all that code. You need to do some investigation and debugging to find out what is happening.





ok sir i'm doing some research and giving you a follow up of my research.
Thank you for your patience and your availability





The files you need to "distribute" are in your "bin\Release" folder.
Create your setup and test on your machine.
Then "zip it" and send it to your fiends via the "cloud".
No "CD burning".
DVD/CD drives are "optional" these days ... not the ".NET framework"; unless your friends are running XP.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal





Thank you sir but I have an error message when I want to make a recording: Failed to connect to the data source
attempt to write a readonly database
I am looking for documentation to this problem but not in continuation





What's "in the database"? Nothing? Then create it on site.
Read SQLite goes "read only" with certain installations; nothing to do with C#.
Google "sqlite read only" for lots of "answers".
Shoulda used SQL Server CE.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal





Hello Gerry Schmitz and thank you for your help, I will document and make you a return, But I would like you to guide me on a code that I saw during but research:
Read only connection
Data Source = c: \ mydb.db; Version = 3; Read Only = True;
I even use this connection but the same error message is displayed ...





Sorry, don't understand the "question".
I said the "install" is the problem; not the "connection string".
My "solution" is SQL Server CE; otherwise, you have the internet's "solutions" ... because, I do not use SQLite.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal





thank you very much I am always looking for the solution of my problem. I hope to escape





I've sought guidance on this issue before, but I figure some concrete code would make it easier to get to the heart of the matter. The IntegerPolynomial, ModdedPolynomial, RationalPolynomial, and FieldElement classes are mostly the same, but with different types for the Coefficient field. I was able to factor out some of the shared algorithms, but notably not the one used by IntegerPolynomial.GetGCD() and FieldElement.GetGCD(), which makes for a pretty awful amount of code repetition. It seems like there should be a way to improve the situation with a generic polynomial class whose type parameter determines the type of the coefficients, but if I were to try to get by with just that one class, it seems like it would be messy to handle the few but significant differences between the classes as I have them now. Several methods would have to check the runtime type of the generic parameter to determine which algorithm to use, which wouldn't be so bad, but the fact that the class would need to have a Characteristic and a MinimalPolynomial field when they are each only applicable for certain types seems worse. I've tried using inheritance to specialize the generic class in different ways for different types, but I run into seemingly insurmountable difficulties where, say, the inherited arithmetic operations for IntegerPolynomial all end up returning objects of type Polynomial<integer> when I need them to return objects of type IntegerPolynomial lest I have to do a conversion every time I do invoke an operation. I also tried using extension methods, and that got very messy too. As highly redundant as it is, the way I have it now is by far the cleanest solution I've found. Any advice?
static class Solver
{
struct Division<T>
{
public T Quotient;
public T Remainder;
public Division(T quotient, T remainder)
{
Quotient = quotient;
Remainder = remainder;
}
}
interface IArithmetic<T>
{
T GetAdditiveIdentity();
T Plus(T n);
T Minus(T n);
T GetMultiplicativeIdentity();
T Times(T n);
Division<T> EuclideanDivideBy(T divisor);
}
static T GetGCD<T>(T a, T b) where T : IArithmetic<T>
{
T c;
while (!b.Equals(a.GetAdditiveIdentity()))
{
c = b;
b = a.EuclideanDivideBy(b).Remainder;
a = c;
}
return a;
}
static T GetGCD<T>(List<T> list) where T : IArithmetic<T>
{
T GCD = list[0];
for (int i = 1; i < list.Count; ++i)
GCD = GetGCD(GCD, list[i]);
return GCD;
}
abstract class Number : IArithmetic<Number>
{
...
}
abstract class Rational : Number, IArithmetic<Rational>
{
...
}
class Integer : Rational, IArithmetic<Integer>
{
...
}
static List<T> CoefficientAdd<T>(List<T> coefficientsA, List<T> coefficientsB)
where T : IArithmetic<T>
{
if (coefficientsA.Count < coefficientsB.Count)
return CoefficientAdd(coefficientsB, coefficientsA);
List<T> output = new List<T>(coefficientsA);
for (int i = 0; i < coefficientsB.Count; ++i)
output[i] = output[i].Plus(coefficientsB[i]);
return output;
}
static List<T> CoefficientMultiply<T>(List<T> coefficientsA,
List<T> coefficientsB) where T : IArithmetic<T>
{
List<T> output = new List<T>();
T instance;
if (coefficientsA.Count > 0)
instance = coefficientsA[0];
else if (coefficientsB.Count > 0)
instance = coefficientsB[0];
else
return output;
for (int i = 0; i < coefficientsA.Count + coefficientsB.Count  1; ++i)
output.Add(instance.GetAdditiveIdentity());
for (int i = 0; i < coefficientsA.Count; ++i)
for (int j = 0; j < coefficientsB.Count; ++j)
output[i + j] =
output[i + j].Plus(coefficientsA[i].Times(coefficientsB[j]));
return output;
}
static List<Integer> CoefficientGetDerivative(List<Integer> coefficients)
{
List<Integer> output = new List<Integer>();
for (int i = 1; i < coefficients.Count; ++i)
output.Add(coefficients[i] * new Integer(i));
return output;
}
class IntegerPolynomial : IArithmetic<IntegerPolynomial>
{
public List<Integer> Coefficients { get; }
public IntegerPolynomial(List<Integer> coefficients)
{
Coefficients = new List<Integer>();
while (coefficients.Count != 0 &&
coefficients[coefficients.Count  1] == Number.Zero)
coefficients.RemoveAt(coefficients.Count  1);
}
public static IntegerPolynomial Zero = new IntegerPolynomial(new List<Integer>());
public IntegerPolynomial GetAdditiveIdentity()
{
return Zero;
}
public IntegerPolynomial Plus(IntegerPolynomial a)
{
return this + a;
}
public static IntegerPolynomial operator +(IntegerPolynomial a, IntegerPolynomial b)
{
return new IntegerPolynomial(CoefficientAdd(a.Coefficients, b.Coefficients));
}
public IntegerPolynomial Minus(IntegerPolynomial a)
{
return this  a;
}
public IntegerPolynomial Negative()
{
List<Integer> output = new List<Integer>();
foreach (Integer coefficient in Coefficients)
output.Add(coefficient);
return new IntegerPolynomial(output);
}
public static IntegerPolynomial operator (IntegerPolynomial a, IntegerPolynomial b)
{
return a + b.Negative();
}
public static IntegerPolynomial One =
new IntegerPolynomial(new List<Integer> { Number.One });
public IntegerPolynomial GetMultiplicativeIdentity()
{
return One;
}
public IntegerPolynomial Times(IntegerPolynomial a)
{
return this * a;
}
public static IntegerPolynomial operator *(IntegerPolynomial a, IntegerPolynomial b)
{
return new IntegerPolynomial(CoefficientMultiply(a.Coefficients, b.Coefficients));
}
public static IntegerPolynomial operator *(IntegerPolynomial a, Integer b)
{
return a * new IntegerPolynomial(new List<Integer> { b });
}
public static IntegerPolynomial operator *(Integer a, IntegerPolynomial b)
{
return new IntegerPolynomial(new List<Integer> { a }) * b;
}
IntegerPolynomial DivideBy(Integer a)
{
List<Integer> coefficients = new List<Integer>();
foreach (Integer coefficient in Coefficients)
coefficients.Add(coefficient.EuclideanDivideBy(a).Quotient);
return new IntegerPolynomial(coefficients);
}
public Division<IntegerPolynomial> EuclideanDivideBy(IntegerPolynomial divisor)
{
Division<IntegerPolynomial> division;
List<Integer> quotient = new List<Integer>();
List<Integer> remainder = new List<Integer>(Coefficients);
if (divisor.Coefficients.Count <= Coefficients.Count)
for (int i = 0; i <= Coefficients.Count  divisor.Coefficients.Count; ++i)
{
Number quotientCoefficient = remainder[remainder.Count  1] /
divisor.Coefficients[divisor.Coefficients.Count  1];
if (quotientCoefficient is Integer integer)
{
quotient.Insert(0, integer);
remainder.RemoveAt(remainder.Count  1);
for (int j = 1; j < divisor.Coefficients.Count; ++j)
remainder[remainder.Count  j] =
remainder[remainder.Count  j]  quotient[0] *
divisor.Coefficients[divisor.Coefficients.Count  j  1];
}
else
{
division.Quotient = null;
division.Remainder = null;
return division;
}
}
division.Quotient = new IntegerPolynomial(quotient);
division.Remainder = new IntegerPolynomial(remainder);
return division;
}
public static IntegerPolynomial operator /(IntegerPolynomial a, IntegerPolynomial b)
{
return a.EuclideanDivideBy(b).Quotient;
}
public static IntegerPolynomial operator %(IntegerPolynomial a, IntegerPolynomial b)
{
return a.EuclideanDivideBy(b).Remainder;
}
public IntegerPolynomial GetDerivative()
{
return new IntegerPolynomial(CoefficientGetDerivative(Coefficients));
}
public IntegerPolynomial GetPrimitivePart()
{
return DivideBy(Solver.GetGCD(Coefficients));
}
public static IntegerPolynomial GetGCD(IntegerPolynomial a, IntegerPolynomial b)
{
if (b.Coefficients.Count > a.Coefficients.Count)
{
if (a.Coefficients.Count == 0)
return b;
IntegerPolynomial t = a;
a = new IntegerPolynomial(new List<Integer>(b.Coefficients));
b = new IntegerPolynomial(new List<Integer>(t.Coefficients));
}
else
{
if (b.Coefficients.Count == 0)
return a;
a = new IntegerPolynomial(new List<Integer>(a.Coefficients));
b = new IntegerPolynomial(new List<Integer>(b.Coefficients));
}
Integer aContent = Solver.GetGCD(a.Coefficients);
Integer bContent = Solver.GetGCD(b.Coefficients);
a = a.DivideBy(aContent);
b = b.DivideBy(bContent);
Integer d = Solver.GetGCD(aContent, bContent);
Integer g = Number.One;
Number h = Number.One;
Integer degree = new Integer(a.Coefficients.Count  b.Coefficients.Count);
IntegerPolynomial remainder = ((Integer)b.Coefficients[b.Coefficients.Count  1].
Exponentiate(degree + Number.One) * a).EuclideanDivideBy(b).Remainder;
while (remainder.Coefficients.Count > 1)
{
a = b;
Number divisor = (g * h).Exponentiate(degree);
b = remainder;
for (int i = 0; i < b.Coefficients.Count; ++i)
b.Coefficients[i] = (Integer)(b.Coefficients[i] / divisor);
g = a.Coefficients[a.Coefficients.Count  1];
h = h.Exponentiate(Number.One  degree) * g.Exponentiate(degree);
degree = new Integer(a.Coefficients.Count  b.Coefficients.Count);
remainder = ((Integer)b.Coefficients[b.Coefficients.Count  1].Exponentiate(
degree + Number.One) * a).EuclideanDivideBy(b).Remainder;
}
if (remainder.Coefficients.Count == 1)
return new IntegerPolynomial(new List<Integer> { d });
return d * b.GetPrimitivePart();
}
public List<IntegerPolynomial> GetFactors()
{
}
}
class ModdedPolynomial : IArithmetic<ModdedPolynomial>
{
public List<Integer> Coefficients { get; }
public Integer Characteristic { get; }
public ModdedPolynomial(List<Integer> coefficients, Integer characteristic)
{
Coefficients = new List<Integer>();
foreach (Integer coefficient in coefficients)
{
Integer remainder = coefficient.EuclideanDivideBy(characteristic).Remainder;
if (remainder.Sign < 0)
Coefficients.Add(remainder + characteristic);
else
Coefficients.Add(remainder);
}
while (Coefficients.Count != 0 &&
Coefficients[Coefficients.Count  1] == Number.Zero)
Coefficients.RemoveAt(Coefficients.Count  1);
Characteristic = characteristic;
}
public ModdedPolynomial GetAdditiveIdentity()
{
return new ModdedPolynomial(new List<Integer>(), Characteristic);
}
public ModdedPolynomial Plus(ModdedPolynomial a)
{
return this + a;
}
public static ModdedPolynomial operator +(ModdedPolynomial a, ModdedPolynomial b)
{
return new ModdedPolynomial(CoefficientAdd(a.Coefficients, b.Coefficients),
a.Characteristic);
}
public ModdedPolynomial Minus(ModdedPolynomial a)
{
return this  a;
}
public ModdedPolynomial Negative()
{
List<Integer> output = new List<Integer>();
foreach (Integer coefficient in Coefficients)
output.Add(coefficient);
return new ModdedPolynomial(output, Characteristic);
}
public static ModdedPolynomial operator (ModdedPolynomial a, ModdedPolynomial b)
{
return a + b.Negative();
}
public ModdedPolynomial GetMultiplicativeIdentity()
{
return new ModdedPolynomial(new List<Integer> { Number.One }, Characteristic);
}
public ModdedPolynomial Times(ModdedPolynomial a)
{
return this * a;
}
public static ModdedPolynomial operator *(ModdedPolynomial a, ModdedPolynomial b)
{
return new ModdedPolynomial(CoefficientMultiply(a.Coefficients, b.Coefficients),
a.Characteristic);
}
public static ModdedPolynomial operator *(Integer a, ModdedPolynomial b)
{
return new ModdedPolynomial(new List<Integer> { a }, b.Characteristic) * b;
}
public static ModdedPolynomial operator *(ModdedPolynomial a, Integer b)
{
return a * new ModdedPolynomial(new List<Integer> { b }, a.Characteristic);
}
public Division<ModdedPolynomial> EuclideanDivideBy(ModdedPolynomial divisor)
{
Division<ModdedPolynomial> division;
List<Integer> quotient = new List<Integer>();
List<Integer> remainder = new List<Integer>(Coefficients);
if (divisor.Coefficients.Count <= Coefficients.Count)
for (int i = 0; i <= Coefficients.Count  divisor.Coefficients.Count; ++i)
{
quotient.Insert(0, remainder[remainder.Count  1] *
divisor.Coefficients[divisor.Coefficients.Count  1].Reciprocal(
Characteristic));
remainder.RemoveAt(remainder.Count  1);
for (int j = 1; j < divisor.Coefficients.Count; ++j)
remainder[remainder.Count  j] =
remainder[remainder.Count  j]  quotient[0] *
divisor.Coefficients[divisor.Coefficients.Count  j  1];
}
division.Quotient = new ModdedPolynomial(quotient, Characteristic);
division.Remainder = new ModdedPolynomial(remainder, Characteristic);
return division;
}
public static ModdedPolynomial operator /(ModdedPolynomial a, ModdedPolynomial b)
{
return a.EuclideanDivideBy(b).Quotient;
}
public static ModdedPolynomial operator %(ModdedPolynomial a, ModdedPolynomial b)
{
return a.EuclideanDivideBy(b).Remainder;
}
public ModdedPolynomial GetDerivative()
{
return new ModdedPolynomial(CoefficientGetDerivative(Coefficients), Characteristic);
}
public List<ModdedPolynomial> GetFactorsOfSquarefree()
{
}
}
class RationalPolynomial : IArithmetic<RationalPolynomial>
{
public List<Rational> Coefficients { get; }
RationalPolynomial MinimalPolynomial;
public RationalPolynomial(List<Rational> coefficients,
RationalPolynomial minimalPolynomial = null)
{
while (coefficients.Count != 0 &&
coefficients[coefficients.Count  1] == Number.Zero)
coefficients.RemoveAt(coefficients.Count  1);
Coefficients = coefficients;
MinimalPolynomial = minimalPolynomial;
}
public RationalPolynomial GetAdditiveIdentity()
{
return new RationalPolynomial(new List<Rational>(), MinimalPolynomial);
}
public RationalPolynomial Plus(RationalPolynomial a)
{
return this + a;
}
public static RationalPolynomial operator +(RationalPolynomial a, RationalPolynomial b)
{
return new RationalPolynomial(CoefficientAdd(a.Coefficients, b.Coefficients),
a.MinimalPolynomial);
}
public RationalPolynomial Minus(RationalPolynomial a)
{
return this  a;
}
public RationalPolynomial Negative()
{
List<Rational> output = new List<Rational>();
foreach (Rational coefficient in Coefficients)
output.Add(coefficient);
return new RationalPolynomial(output, MinimalPolynomial);
}
public static RationalPolynomial operator (RationalPolynomial a, RationalPolynomial b)
{
return a + b.Negative();
}
public RationalPolynomial GetMultiplicativeIdentity()
{
return new RationalPolynomial(new List<Rational> { Number.One }, MinimalPolynomial);
}
public RationalPolynomial Times(RationalPolynomial a)
{
return this * a;
}
public static RationalPolynomial operator *(RationalPolynomial a, RationalPolynomial b)
{
List<Rational> coefficients = CoefficientMultiply(a.Coefficients, b.Coefficients);
for (int i = coefficients.Count; i >= a.MinimalPolynomial.Coefficients.Count; i)
{
for (int j = 0; j < a.MinimalPolynomial.Coefficients.Count  1; ++j)
coefficients[i  a.MinimalPolynomial.Coefficients.Count + j] =
a.MinimalPolynomial.Coefficients[j];
coefficients.RemoveAt(coefficients.Count  1);
}
return new RationalPolynomial(coefficients, a.MinimalPolynomial);
}
public static RationalPolynomial operator *(Rational a, RationalPolynomial b)
{
List<Rational> coefficients = new List<Rational>();
for (int i = 0; i < b.Coefficients.Count; ++i)
coefficients.Add(a * b.Coefficients[i]);
return new RationalPolynomial(new List<Rational> { a }, b.MinimalPolynomial);
}
public static RationalPolynomial operator *(RationalPolynomial a, Rational b)
{
return b * a;
}
public Division<RationalPolynomial> EuclideanDivideBy(RationalPolynomial divisor)
{
Division<RationalPolynomial> division;
List<Rational> quotient = new List<Rational>();
List<Rational> remainder = new List<Rational>(Coefficients);
if (divisor.Coefficients.Count <= Coefficients.Count)
for (int i = 0; i <= Coefficients.Count  divisor.Coefficients.Count; ++i)
{
quotient.Insert(0, remainder[remainder.Count  1] /
divisor.Coefficients[divisor.Coefficients.Count  1]);
remainder.RemoveAt(remainder.Count  1);
for (int j = 1; j < divisor.Coefficients.Count; ++j)
remainder[remainder.Count  j] =
remainder[remainder.Count  j]  quotient[0] *
divisor.Coefficients[divisor.Coefficients.Count  j  1];
}
division.Quotient = new RationalPolynomial(quotient, MinimalPolynomial);
division.Remainder = new RationalPolynomial(remainder, MinimalPolynomial);
return division;
}
public static RationalPolynomial operator /(RationalPolynomial a, RationalPolynomial b)
{
return a.EuclideanDivideBy(b).Quotient;
}
public static RationalPolynomial operator %(RationalPolynomial a, RationalPolynomial b)
{
return a.EuclideanDivideBy(b).Remainder;
}
IntegerPolynomial GetPrimitivePart()
{
Integer LCM = Number.One;
foreach (Rational coefficient in Coefficients)
LCM *= coefficient.GetDenominatorLCM();
List<Integer> coefficients = new List<Integer>();
foreach (Rational coefficient in Coefficients)
coefficients.Add((Integer)(LCM * coefficient));
return new IntegerPolynomial(coefficients).GetPrimitivePart();
}
public static RationalPolynomial GetGCD(RationalPolynomial a, RationalPolynomial b)
{
return IntegerPolynomial.GetGCD(a.GetPrimitivePart(), b.GetPrimitivePart());
}
public IntegerPolynomial GetMinimalPolynomial()
{
}
public static implicit operator RationalPolynomial(IntegerPolynomial a)
{
List<Rational> coefficients = new List<Rational>();
foreach (Rational coefficient in a.Coefficients)
coefficients.Add(coefficient);
return new RationalPolynomial(coefficients);
}
}
class FieldElement : IArithmetic<FieldElement>
{
public List<RationalPolynomial> Coefficients { get; }
IntegerPolynomial MinimalPolynomial;
public FieldElement(List<RationalPolynomial> coefficients,
IntegerPolynomial minimalPolynomial)
{
Coefficients = new List<RationalPolynomial>();
while (Coefficients.Count != 0 &&
Coefficients[Coefficients.Count  1].Coefficients.Count != 0)
Coefficients.RemoveAt(Coefficients.Count  1);
MinimalPolynomial = minimalPolynomial;
}
public FieldElement GetAdditiveIdentity()
{
return new FieldElement(new List<RationalPolynomial>(), MinimalPolynomial);
}
public FieldElement Plus(FieldElement a)
{
return this + a;
}
public static FieldElement operator +(FieldElement a, FieldElement b)
{
return new FieldElement(CoefficientAdd(a.Coefficients, b.Coefficients),
a.MinimalPolynomial);
}
public FieldElement Minus(FieldElement a)
{
return this  a;
}
public FieldElement Negative()
{
List<RationalPolynomial> output = new List<RationalPolynomial>();
foreach (RationalPolynomial coefficient in Coefficients)
output.Add(coefficient.Negative());
return new FieldElement(output, MinimalPolynomial);
}
public static FieldElement operator (FieldElement a, FieldElement b)
{
return a + b.Negative();
}
public FieldElement GetMultiplicativeIdentity()
{
return new FieldElement(new List<RationalPolynomial> { new RationalPolynomial(
new List<Rational> { Number.One }, MinimalPolynomial) }, MinimalPolynomial);
}
public FieldElement Times(FieldElement a)
{
return this * a;
}
public static FieldElement operator *(FieldElement a, FieldElement b)
{
return new FieldElement(CoefficientMultiply(a.Coefficients, b.Coefficients),
a.MinimalPolynomial);
}
public static FieldElement operator *(RationalPolynomial a, FieldElement b)
{
List<RationalPolynomial> coefficients = new List<RationalPolynomial>();
for (int i = 0; i < b.Coefficients.Count; ++i)
coefficients.Add(a * b.Coefficients[i]);
return new FieldElement(coefficients, b.MinimalPolynomial);
}
public static FieldElement operator *(FieldElement a, RationalPolynomial b)
{
return b * a;
}
FieldElement DivideBy(RationalPolynomial a)
{
List<RationalPolynomial> coefficients = new List<RationalPolynomial>();
foreach (RationalPolynomial coefficient in Coefficients)
coefficients.Add(coefficient.EuclideanDivideBy(a).Quotient);
return new FieldElement(coefficients, MinimalPolynomial);
}
public Division<FieldElement> EuclideanDivideBy(FieldElement divisor)
{
Division<FieldElement> division;
List<RationalPolynomial> quotient = new List<RationalPolynomial>();
List<RationalPolynomial> remainder = new List<RationalPolynomial>(Coefficients);
if (divisor.Coefficients.Count <= Coefficients.Count)
for (int i = 0; i <= Coefficients.Count  divisor.Coefficients.Count; ++i)
{
quotient.Insert(0, remainder[remainder.Count  1] /
divisor.Coefficients[divisor.Coefficients.Count  1]);
remainder.RemoveAt(remainder.Count  1);
for (int j = 1; j < divisor.Coefficients.Count; ++j)
remainder[remainder.Count  j] =
remainder[remainder.Count  j]  quotient[0] *
divisor.Coefficients[divisor.Coefficients.Count  j  1];
}
division.Quotient = new FieldElement(quotient, MinimalPolynomial);
division.Remainder = new FieldElement(remainder, MinimalPolynomial);
return division;
}
FieldElement GetDerivative()
{
List<RationalPolynomial> coefficients = new List<RationalPolynomial>();
for (int i = 1; i < Coefficients.Count; ++i)
coefficients.Add(Coefficients[i] * new Integer(i));
return new FieldElement(coefficients, MinimalPolynomial);
}
FieldElement GetPrimitivePart()
{
return DivideBy(Solver.GetGCD(Coefficients));
}
static FieldElement GetGCD(FieldElement a, FieldElement b)
{
if (b.Coefficients.Count > a.Coefficients.Count)
{
if (a.Coefficients.Count == 0)
return b;
FieldElement t = a;
a = new FieldElement(new List<RationalPolynomial>(b.Coefficients),
b.MinimalPolynomial);
b = new FieldElement(new List<RationalPolynomial>(t.Coefficients),
t.MinimalPolynomial);
}
else
{
if (b.Coefficients.Count == 0)
return a;
a = new FieldElement(new List<RationalPolynomial>(a.Coefficients),
a.MinimalPolynomial);
b = new FieldElement(new List<RationalPolynomial>(b.Coefficients),
b.MinimalPolynomial);
}
RationalPolynomial aContent = Solver.GetGCD(a.Coefficients);
RationalPolynomial bContent = Solver.GetGCD(b.Coefficients);
a = a.DivideBy(aContent);
b = b.DivideBy(bContent);
RationalPolynomial d = Solver.GetGCD(aContent, bContent);
RationalPolynomial g = a.Coefficients[0].GetMultiplicativeIdentity();
RationalPolynomial h = a.Coefficients[0].GetMultiplicativeIdentity();
Integer degree = new Integer(a.Coefficients.Count  b.Coefficients.Count);
FieldElement remainder = (Exponentiate(b.Coefficients[b.Coefficients.Count  1],
degree + Number.One) * a).EuclideanDivideBy(b).Remainder;
while (remainder.Coefficients.Count > 1)
{
a = b;
b = remainder;
for (int i = 0; i < b.Coefficients.Count; ++i)
b.Coefficients[i] = b.Coefficients[i] / Exponentiate(g * h, degree);
g = a.Coefficients[a.Coefficients.Count  1];
h = Exponentiate(h, Number.One  degree) * Exponentiate(g, degree);
degree = new Integer(a.Coefficients.Count  b.Coefficients.Count);
remainder = (Exponentiate(b.Coefficients[b.Coefficients.Count  1],
degree + Number.One) * a).EuclideanDivideBy(b).Remainder;
}
return d * b.GetPrimitivePart();
}
}
}





I don't have an actual answer to your problem (that's a LOT of code), but I think if you use outlining to collapse all of the methods into their prototype, and organize the methods by grouping them something like this:
class IntegerPolynomial : IArithmetic<IntegerPolynomial>
{
public List<Integer> Coefficients { get; }
public static IntegerPolynomial Zero = new IntegerPolynomial(new List<Integer>());
public static IntegerPolynomial One = new IntegerPolynomial(new List<Integer> { Number.One });
public IntegerPolynomial(List<Integer> coefficients)...
public IntegerPolynomial GetAdditiveIdentity()...
public IntegerPolynomial GetDerivative()...
public List<IntegerPolynomial> GetFactors()...
public IntegerPolynomial GetMultiplicativeIdentity()...
public IntegerPolynomial GetPrimitivePart()...
public IntegerPolynomial Negative()...
public IntegerPolynomial Plus(IntegerPolynomial a)...
public IntegerPolynomial Minus(IntegerPolynomial a)...
public IntegerPolynomial Times(IntegerPolynomial a)...
public IntegerPolynomial DivideBy(Integer a)...
public Division<IntegerPolynomial> EuclideanDivideBy(IntegerPolynomial divisor)...
public static IntegerPolynomial GetGCD(IntegerPolynomial a, IntegerPolynomial b)...
public static IntegerPolynomial operator +(IntegerPolynomial a, IntegerPolynomial b)...
public static IntegerPolynomial operator (IntegerPolynomial a, IntegerPolynomial b)...
public static IntegerPolynomial operator *(IntegerPolynomial a, IntegerPolynomial b)...
public static IntegerPolynomial operator *(IntegerPolynomial a, Integer b)...
public static IntegerPolynomial operator *(Integer a, IntegerPolynomial b)...
public static IntegerPolynomial operator /(IntegerPolynomial a, IntegerPolynomial b)...
public static IntegerPolynomial operator %(IntegerPolynomial a, IntegerPolynomial b)...
}
...you might be able to more easily discern patterns that can be optimized through the use of a base class and/or generics, or even just leave the code alone now that the methods are grouped together in a way that makes sense.
".45 ACP  because shooting twice is just silly"  JSOP, 2010  You can never have too much ammo  unless you're swimming, or on fire.  JSOP, 2010  When you pry the gun from my cold dead hands, be careful  the barrel will be very hot.  JSOP, 2013





I already have a handle on what the patterns are  it's really because I know how many patterns there are that I want to restructure it, and the problem is that I can't figure out how to use the language features to do it. I can't even figure out how to factor out just the algorithm shared by IntegerPolynomial.GetGCD() and FieldElement.GetGCD(). If someone could help me with just that, the rest might fall into place.
Given that I do understand the code as it stands, do you think it's okay to leave it this way? I figured the amount of repetition would be considered bad style, not to mention the fact that if I needed a kind of polynomial with yet another type of coefficient, I'd have to duplicate it all yet again.





You didn't provide all of the code, so we can't play with it without compiler errors, but...
0) Generally speaking, if it works (well), comment the hell out of it, move on with your project, and don't look back.
1) You could create an (abstract?) base class with a GetGCD method that accepts/returns a generic object, and while that would probably make the base class fairly complex, at least that complexity would be concealed in derived classes.
".45 ACP  because shooting twice is just silly"  JSOP, 2010  You can never have too much ammo  unless you're swimming, or on fire.  JSOP, 2010  When you pry the gun from my cold dead hands, be careful  the barrel will be very hot.  JSOP, 2013





Are you thinking of a setup something like this (I would probably create a ModdedInteger class and use that instead of Integers plus a Characteristic field if I could make this approach work)?
abstract class Polynomial<T> where T : IArithmetic<T>...
class IntegerPolynomial : Polynomial<Integer>, IArithmetic<IntegerPolynomial>...
class ModdedPolynomial : Polynomial<ModdedInteger>, IArithmetic<ModdedPolynomial>...
class RationalPolynomial : Polynomial<Rational>, IArithmetic<RationalPolynomial>...
class FieldElement : Polynomial<RationalPolynomial>, IArithmetic<FieldElement>...
The problem I've had with that is, suppose I'm trying to genericize the Integer.GetGCD/FieldElement.GetGCD algorithm to act on Polynomial objects. The only thing I can think to do with the signature is this:
Polynomial<T> GetGCD<T>(Polynomial<T> a, Polynomial<T> b) where T : IArithmetic<T>
But then if I pass IntegerPolynomial objects, I get back a Polynomial<integer>, when what I really want is another IntegerPolynomial. I have the same problem with every other method that returns an object whose type is the same as the class it belongs to. I would have to extract the coefficients from the Polynomial object and use them to construct an object of the derived type I actually wanted almost every time I used any of them. This is why I mentioned considering the possibility of shoving everything into a single generic class  in that case I would be passing Polynomial<integer> objects, and the Polynomial<integer> object I'd get back would be exactly what I'd want.
In case you're inclined to play with it, here's the whole program.





Reality  If your code is complex, nothing you do is going to actually reduce the complexity of the code (short of using someone else's library of code) . It's just going to move that complexity to one or more new locations.
Opinion  Given the complexity of your code, your actual aim should be to make the code as efficient as possible, and that means reducing/eliminating casting/boxing to the extent that it is possible, and avoiding the use of linq and reflection. Put your code into an assembly and let 'er rip. Overthinking it is not worth delaying further development of your project.
".45 ACP  because shooting twice is just silly"  JSOP, 2010  You can never have too much ammo  unless you're swimming, or on fire.  JSOP, 2010  When you pry the gun from my cold dead hands, be careful  the barrel will be very hot.  JSOP, 2013





I don't get all the nuances, but maybe you can consider a "componentbased" approach; where the needed "behaviours" are "attached"; versus inherited and / or defined explicitly.
Unity (and "VB") is based on that; with "scripting" (pretty well) limited to filling in handlers.
Sort of like: it has "legs" "attached" or it doesn't; it has a "voice" or it doesn't; etc.
All Unity "components" are just "children" of a "higher" component.
The run time "infers" what every component does or is doing for each "frame".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal





Is it possible to be more concrete about what this would involve? Would it involve using different C# language features, or is it more of a general design paradigm?





It's more of a general design pattern.
In terms of C#, "everything" derives from Object.
And if at its core, there is a class defined as:
Class Component : object {
List<component> Components;
}
then you can model any object and behaviour by "attaching" "child" components to "parent" components.
In your case, you would probably use a "factory" to create "math" components and wire them up into "higherclass" math / poly objects.
If you can create a "hierarchy" / mind map of your poly model; then it may make more sense.
I don't need to say: bicycle; unicycle; or trike ... I just count the wheels; if there are any.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal





Hello, I try to use an Javascript to autofill a textbox.
HtmlElement headElement = webBrowser3.Document.GetElementsByTagName("head")[0];
HtmlElement scriptElement = webBrowser3.Document.CreateElement("script");
IHTMLScriptElement element = (IHTMLScriptElement)scriptElement.DomElement;
element.text = "function fillbox() { document.getElementById('ember891').value = 'test@test.com' }";
headElement.AppendChild(scriptElement);
webBrowser3.Document.InvokeScript("fillbox");
I try it here: account.sonyentertainmentnetwork.com/home/index.action , when you click the bottom button the register, then start and there the first textbox for the email.
When I open google chrome on this site and enter :
javascript:document.getElementById('ember891').value = 'test@test.de' in the console, everything is just fine, but it won't work with the c# application. So I want to get it working, that I am able to fill the textbox with a button click per Javascript.
modified 17Apr18 10:39am.





The page shows up as blank in my browser.
Most companies had to add code to prevent people from automating the signup proces; it is the reason captcha's exist.
If what you are doing is a valid usecase, then the people from Sony will probably help out.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics."  Some Bell.





I updated the link, account.sonyentertainmentnetwork.com/home/index.action you have to click on the bottom button to register a new account, then click on Start and there is the site that I speak from.





That's something they don't want to automate or allow; good luck with the "I'm not a robot" test
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics."  Some Bell.





The I'm not a Robot test pops now out, so the user can verify it and the program does the rest. Everything works now, used another site to create psn accounts. Problem solved by myself.





Have to agree; the whole thing stinks.
I heard 40  60% of all accounts are faked; you are part of the problem.
You're probabably not even from "Switzerland" (test.de).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal





Lol I do not have to prove anything to you. I am Swiss believe it or not





But you don't deny faking accounts?
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal




