/// <summary> /// Form Vector From QsValues that are scalars or vector. /// </summary> /// <param name="values">Scalars</param> /// <returns></returns> public static QsValue VectorFromValues(params QsValue[] values) { QsVector vec = new QsVector(values.Length); foreach (var val in values) { if (val is QsScalar) { vec.AddComponent((QsScalar)val); } else if (val is QsVector) { var vc = val as QsVector; foreach (var component in vc) { vec.AddComponent(component); } } else { throw new QsException("Component is not a scalar or vector value."); } } return(vec); }
public QsVector PowerScalar(QsScalar scalar) { QsVector v = new QsVector(this.Count); for (int i = 0; i < this.Count; i++) { v.AddComponent(this[i].PowerScalar(scalar)); } return(v); }
/// <summary> /// Copy the vector to another instance with the same components. /// </summary> /// <param name="vector"></param> /// <returns></returns> public static QsVector CopyVector(QsVector vector) { QsVector vec = new QsVector(vector.Count); foreach (var q in vector) { vec.AddComponent((QsScalar)q.Clone()); } return(vec); }
private QsValue ModuloScalar(QsScalar scalar) { QsVector v = new QsVector(this.Count); for (int i = 0; i < this.Count; i++) { v.AddComponent(this[i] % scalar); } return(v); }
public QsVector DivideScalar(QsScalar scalar) { QsVector v = new QsVector(this.Count); for (int i = 0; i < this.Count; i++) { v.AddComponent(this[i] / scalar); } return(v); }
private QsVector MultiplyScalar(QsScalar s) { QsVector v = new QsVector(this.Count); for (int i = 0; i < this.Count; i++) { v.AddComponent(this[i] * s); } return(v); }
/// <summary> /// Subtract scalar from the vector components. /// </summary> /// <param name="s"></param> /// <returns></returns> private QsVector SubtractScalar(QsScalar s) { QsVector v = new QsVector(this.Count); for (int i = 0; i < this.Count; i++) { v.AddComponent(this[i] - s); } return(v); }
/// <summary> /// Differentiate every component in vectpr with the scalar. /// </summary> /// <param name="scalar"></param> /// <returns></returns> public QsVector DifferentiateScalar(QsScalar scalar) { QsVector v = new QsVector(this.Count); for (int i = 0; i < this.Count; i++) { v.AddComponent((QsScalar)this[i].DifferentiateScalar(scalar)); } return(v); }
/// <summary> /// Parse Vector text. /// </summary> /// <param name="vector"></param> /// <returns>QsVector on the form of QsValue.</returns> public static QsValue ParseVector(string vector) { string[] qs = vector.Split(','); QsVector v = new QsVector(qs.Length); foreach (string q in qs) { v.AddComponent(new QsScalar { NumericalQuantity = q.ToQuantity() }); } return(v); }
public override QsValue RightShiftOperation(QsValue vl) { QsValue times; if (vl is QsReference) { times = ((QsReference)vl).ContentValue; } else { times = vl; } int itimes = Qs.IntegerFromQsValue((QsScalar)times); if (itimes > this.Count) { itimes = itimes % this.Count; } // 1 2 3 4 5 >> 2 == 4 5 1 2 3 QsVector vec = new QsVector(this.Count); for (int i = this.Count - itimes; i < this.Count; i++) { vec.AddComponent(this[i]); } for (int i = 0; i < (this.Count - itimes); i++) { vec.AddComponent(this[i]); } return(vec); }