Multiply a polynomial with a scalar
555727
def scale(self, scalar):
        ''''''
        return self.__class__([self.coefficients[i] * scalar for i in _range(len(self))])
344534
def mul_at(self, other, k):
        ''''''
        if k > (self.degree + other.degree) or k > self.degree: return 0 # optimization: if the required coefficient is above the maximum coefficient of the resulting polynomial, we can already predict that and just return 0

        term = 0

        for i in _range(min(len(self), len(other))):
            coef1 = self.coefficients[-(k-i+1)]
            coef2 = other.coefficients[-(i+1)]
            if coef1 == 0 or coef2 == 0: continue # log(0) is undefined, skip (and in addition it's a nice optimization)
            term += coef1 * coef2
        return term
194388
function multiplier(x) {
    var parts = x.toString().split('.');
    if (parts.length < 2) {
      return 1;
    }
    return Math.pow(10, parts[1].length);
  }
534755
function multiplyScalar(out, a, b) {
  out[0] = a[0] * b;
  out[1] = a[1] * b;
  out[2] = a[2] * b;
  out[3] = a[3] * b;
  out[4] = a[4] * b;
  out[5] = a[5] * b;
  out[6] = a[6] * b;
  out[7] = a[7] * b;
  out[8] = a[8] * b;
  return out;
}
728280
def multiplyQuats(q1, q2):
    """"""
    return np.array([
            q1[0]*q2[0] - q1[1]*q2[1] - q1[2]*q2[2] - q1[3]*q2[3],
            q1[2]*q2[3] - q2[2]*q1[3] + q1[0]*q2[1] + q2[0]*q1[1],
            q1[3]*q2[1] - q2[3]*q1[1] + q1[0]*q2[2] + q2[0]*q1[2],
            q1[1]*q2[2] - q2[1]*q1[2] + q1[0]*q2[3] + q2[0]*q1[3]])
981721
def scalar(magnitude = 1)
      terms.reduce(1) do |prod, term|
        prod * term.scalar(magnitude)
      end
    end
95343
public static void multiply( GrayU8 input , double value , GrayU8 output ) {

		output.reshape(input.width,input.height);

		int columns = input.width;
		if(BoofConcurrency.USE_CONCURRENT ) {
			ImplPixelMath_MT.multiplyU_A(input.data,input.startIndex,input.stride,value , 
					output.data,output.startIndex,output.stride,
					input.height,columns);
		} else {
			ImplPixelMath.multiplyU_A(input.data,input.startIndex,input.stride,value , 
					output.data,output.startIndex,output.stride,
					input.height,columns);
		}
	}
1098365
public function multiply(array $e):Polynomial{
		$n = \array_fill(0, \count($this->num) + \count($e) - 1, 0);

		foreach($this->num as $i => $vi){
			$vi = $this->glog($vi);

			foreach($e as $j => $vj){
				$n[$i + $j] ^= $this->gexp($vi + $this->glog($vj));
			}

		}

		$this->setNum($n);

		return $this;
	}
1273861
function multiply(str, multiplier, scale) {
    var res = [];
    var carry = 0;
    var i = str.length;
    var n;
    while(--i >= 0) {
      n = hexNumber(str[i]) * multiplier + carry;
      carry = Math.floor(n / scale);
      res.push(n % scale);
    }
    while(carry > 0) {
      res.push(carry % scale);
      carry = Math.floor(carry / scale);
    }
    return res.reverse().join('');
  }
1181772
def _algebraic_rules_scalar():
    """"""
    a = wc("a", head=SCALAR_VAL_TYPES)
    b = wc("b", head=SCALAR_VAL_TYPES)
    x = wc("x", head=SCALAR_TYPES)
    y = wc("y", head=SCALAR_TYPES)
    z = wc("z", head=SCALAR_TYPES)

    indranges__ = wc("indranges__", head=IndexRangeBase)

    ScalarTimes._binary_rules.update(check_rules_dict([
        ('R001', (
            pattern_head(a, b),
            lambda a, b: a * b)),
        ('R002', (
            pattern_head(x, x),
            lambda x: x**2)),
        ('R003', (
            pattern_head(Zero, x),
            lambda x: Zero)),
        ('R004', (
            pattern_head(x, Zero),
            lambda x: Zero)),
        ('R005', (
            pattern_head(
                pattern(ScalarPower, x, y),
                pattern(ScalarPower, x, z)),
            lambda x, y, z: x**(y+z))),
        ('R006', (
            pattern_head(x, pattern(ScalarPower, x, -1)),
            lambda x: One)),
    ]))

    ScalarPower._rules.update(check_rules_dict([
        ('R001', (
            pattern_head(a, b),
            lambda a, b: a**b)),
        ('R002', (
            pattern_head(x, 0),
            lambda x: One)),
        ('R003', (
            pattern_head(x, 1),
            lambda x: x)),
        ('R004', (
            pattern_head(pattern(ScalarPower, x, y), z),
            lambda x, y, z: x**(y*z))),
    ]))

    def pull_constfactor_from_sum(x, y, indranges):
        bound_symbols = set([r.index_symbol for r in indranges])
        if len(x.free_symbols.intersection(bound_symbols)) == 0:
            return x * ScalarIndexedSum.create(y, *indranges)
        else:
            raise CannotSimplify()

    ScalarIndexedSum._rules.update(check_rules_dict([
        ('R001', (  # sum over zero -> zero
            pattern_head(Zero, indranges__),
            lambda indranges: Zero)),
        ('R002', (  # pull constant prefactor out of sum
            pattern_head(pattern(ScalarTimes, x, y), indranges__),
            lambda x, y, indranges:
                pull_constfactor_from_sum(x, y, indranges))),
    ]))
394792
def *(other)
      case other
      when Mat4    then mul_mat4(other)
      when Mat3    then mul_mat3(other)
      when Vec3    then mul_vec3(other)
      when Vec4    then mul_vec4(other)
      when Numeric then mul_scalar(other)
      else raise ArgumentError, "Don't know how to multiply Mat4 with object: #{other.inspect}"
      end
    end
373300
def _call(self, x, out):
        """"""
        if self.domain.is_real:
            # Real domain, multiply separately
            out.real = self.scalar.real * x
            out.imag = self.scalar.imag * x
        else:
            # Complex domain
            out.lincomb(self.scalar, x)
1185109
def scalar(cls, value):
    """"""
    return lambda i, name: cls(i, name, (value,), lambda a: a[0], None)
1198121
private BigRational multiply(BigDecimal value) {
		BigDecimal n = numerator.multiply(value);
		BigDecimal d = denominator;
		return of(n, d);
	}
593362
function scalarScalar(a, b) {
  var x = a + b
  var bv = x - a
  var av = x - bv
  var br = b - bv
  var ar = a - av
  var y = ar + br
  if(y) {
    return [y, x]
  }
  return [x]
}
1046725
def polynomial_multiply_mod( m1, m2, polymod, p ):
  """"""

  # This is just a seat-of-the-pants implementation.

  # This module has been tested only by extensive use
  # in calculating modular square roots.

  # Initialize the product to zero:

  prod = ( len( m1 ) + len( m2 ) - 1 ) * [0]

  # Add together all the cross-terms:

  for i in range( len( m1 ) ):
    for j in range( len( m2 ) ):
      prod[i+j] = ( prod[i+j] + m1[i] * m2[j] ) % p

  return polynomial_reduce_mod( prod, polymod, p )
564198
public static void multiply(Complex_F64 a, Complex_F64 b, Complex_F64 result) {
        result.real = a.real * b.real - a.imaginary*b.imaginary;
        result.imaginary = a.real*b.imaginary + a.imaginary*b.real;
    }