private void pivot( int p, int q ) {

		// everything but row p and column q
		for( int i = 0; i < N; i++ ) {
			double alpha = a[i][q] / a[p][q];
			for( int j = 0; j <= N + N; j++ ) {
				if( i != p && j != q ) a[i][j] -= alpha * a[p][j];
			}
		}

		// zero out column q
		for( int i = 0; i < N; i++ )
			if( i != p ) a[i][q] = 0.0;

		// scale row p (ok to go from q+1 to N, but do this for consistency with simplex pivot)
		for( int j = 0; j <= N + N; j++ )
			if( j != q ) a[p][j] /= a[p][q];
		a[p][q] = 1.0;
	}