Powers this matrix of given exponent {code n}.

@param n the exponent

@return the powered matrix
767806
public Matrix power(int n) {
        if (n < 0) {
            fail("The exponent should be positive: " + n + ".");
        }

        Matrix result = blankOfShape(rows, rows);
        Matrix that = this;

        for (int i = 0; i < rows; i++) {
            result.set(i, i, 1.0);
        }

        while (n > 0) {
            if (n % 2 == 1) {
                result = result.multiply(that);
            }

            n /= 2;
            that = that.multiply(that);
        }

        return result;
    }
337781
public Matrix times(Matrix B)
    {
        if (B.m != n)
        {
            throw new IllegalArgumentException("Matrix inner dimensions must agree.");
        }
        Matrix X = new Matrix(m, B.n);
        double[][] C = X.getArray();
        double[] Bcolj = new double[n];
        for (int j = 0; j < B.n; j++)
        {
            for (int k = 0; k < n; k++)
            {
                Bcolj[k] = B.A[k][j];
            }
            for (int i = 0; i < m; i++)
            {
                double[] Arowi = A[i];
                double s = 0;
                for (int k = 0; k < n; k++)
                {
                    s += Arowi[k] * Bcolj[k];
                }
                C[i][j] = s;
            }
        }
        return X;
    }
152049
public static double[] pow(double[] a, double c) {
    double[] result = new double[a.length];
    for (int i = 0; i < a.length; i++) {
      result[i] = Math.pow(a[i], c);
    }
    return result;
  }
1342044
def power(n, m)
      result = 1
      v = n
      while m > 0
        result = mod result * v if m.odd?
        v = square v
        m >>= 1
      end
      result
    end
1232157
public static List<int[]> createList( int N )
    {
        int data[] = new int[ N ];
        for( int i = 0; i < data.length; i++ ) {
            data[i] = -1;
        }

        List<int[]> ret = new ArrayList<int[]>();

        createList(data,0,-1,ret);

        return ret;
    }
646210
@Inline(value="$1.pow($2)")
	@Pure
	public static BigInteger operator_power(BigInteger a, int exponent) {
		return a.pow(exponent);
	}
821032
public RoundedMoney pow(int n) {
        return new RoundedMoney(number.pow(n, Optional.ofNullable(
                monetaryContext.get(MathContext.class)).orElse(MathContext.DECIMAL64)),
                currency, rounding).with(rounding);
    }
1075047
@Override
    public int nextInt(int n) {
        if (n <= 0) {
            throw new IllegalArgumentException("n must be positive");
        }

        // the special treatment of powers of 2 as in Random.nextInt(int) shouldn't be necessary
        int bits, val;
        do {
            bits = nextInt() >>> 1;
            val = bits % n;
        } while (bits - val + (n - 1) < 0);
        return val;
    }
531018
public static double pow(Number baseNumber, int exponent) {
        return exponent < 1 ? 1
                : exponent > 1
                ? baseNumber.doubleValue()
                * pow(baseNumber, exponent - 1)
                : baseNumber.doubleValue();
    }
103386
public Set<N> getParents(N n)
    {
        Pair<HashSet<N>, HashSet<N>> p = nodes.get(n);
        
        if(p == null)
            return null;
        
        return p.getIncoming();
    }
15176
def power_cubic(n, m)
      if n < 1
	raise "cubic(< 1, m) called"
      elsif n == 1
	yield( (0...m).collect{0} )# point of origin
      else
	0.upto m do |dim|
	  Combinatorial.comb(m, dim) do |s|
	    power_cubic(n-1, dim) do |a|
	      yield inject(a, s.sort, m)
	    end
	  end
	end
      end
    end
340076
public static BigDecimal power(EvaluationContext ctx, Object number, Object power) {
        BigDecimal _number = Conversions.toDecimal(number, ctx);
        BigDecimal _power = Conversions.toDecimal(power, ctx);
        return ExpressionUtils.decimalPow(_number, _power);
    }
1367739
public static int log2 (int n){
    int log = 0;

    for(int k=1; k < n; k *= 2, log++);

    if (n != (1 << log))
      return -1 ; /* n is not a power of 2 */
    return log; }
1281408
public static Matrix identity(int m, int n)
    {
        Matrix A = new Matrix(m, n);
        double[][] X = A.getArray();
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < n; j++)
            {
                X[i][j] = (i == j ? 1.0 : 0.0);
            }
        }
        return A;
    }
721149
function(sbm, n) {
    if (n == 0) {
      return this.identity(n)
    } else if (n == 1) {
      return sbm
    } else if (n % 2 == 0) {
      return this.pow(this.multiply(sbm, sbm), n/2)
    } else {
      return this.multiply(sbm, this.pow(this.multiply(sbm, sbm), (n-1)/2))
    }
  }
248884
public static int ceiling(int n, int m) {
        return n >= 0 ? ((n + m - 1) / m) * m : (n / m) * m;
    }
262494
public static Number power(Number self, Number exponent) {
        double base, exp, answer;
        base = self.doubleValue();
        exp = exponent.doubleValue();

        answer = Math.pow(base, exp);
        if ((double) ((int) answer) == answer) {
            return (int) answer;
        } else if ((double) ((long) answer) == answer) {
            return (long) answer;
        } else {
            return answer;
        }
    }