public void pow(final double[] operand,final int operandOffset,final int n,final double[] result,final int resultOffset){
  if (n == 0) {
    result[resultOffset]=1.0;
    Arrays.fill(result,resultOffset + 1,resultOffset + getSize(),0);
    return;
  }
  double[] function=new double[1 + order];
  if (n > 0) {
    final int maxOrder=FastMath.min(order,n);
    double xk=FastMath.pow(operand[operandOffset],n - maxOrder);
    for (int i=maxOrder; i > 0; --i) {
      function[i]=xk;
      xk*=operand[operandOffset];
    }
    function[0]=xk;
  }
 else {
    final double inv=1.0 / operand[operandOffset];
    double xk=FastMath.pow(inv,-n);
    for (int i=0; i <= order; ++i) {
      function[i]=xk;
      xk*=inv;
    }
  }
  double coefficient=n;
  for (int i=1; i <= order; ++i) {
    function[i]*=coefficient;
    coefficient*=n - i;
  }
  compose(operand,operandOffset,function,result,resultOffset);
}

public void pow ( final double [ ] operand , final int operandOffset , final int n , final double [ ] result , final int resultOffset ) { if ( n == 0 ) { result [ resultOffset ] = 1.0 ; Arrays . fill ( result , resultOffset + 1 , resultOffset + getSize ( ) , 0 ) ; return ; } double [ ] function = new double [ 1 + order ] ; if ( n > 0 ) { final int maxOrder = FastMath . min ( order , n ) ; double xk = FastMath . pow ( operand [ operandOffset ] , n - maxOrder ) ; for ( int i = maxOrder ; i > 0 ; -- i ) { function [ i ] = xk ; xk *= operand [ operandOffset ] ; } function [ 0 ] = xk ; } else { final double inv = 1.0 / operand [ operandOffset ] ; double xk = FastMath . pow ( inv , - n ) ; for ( int i = 0 ; i <= order ; ++ i ) { function [ i ] = xk ; xk *= inv ; } } double coefficient = n ; for ( int i = 1 ; i <= order ; ++ i ) { function [ i ] *= coefficient ; coefficient *= n - i ; } compose ( operand , operandOffset , function , result , resultOffset ) ; }
compute integer power of a derivative structure .
