Auxiliar method. Computes $base^((1/2)^$index)

@param  string  $base
@param  integer $index
@param  integer $out_scale
@return string
963852
private static function compute2NRoot(string $base, int $index, int $out_scale): string
    {
        $result = $base;

        for ($i = 0; $i < $index; $i++) {
            $result = \bcsqrt($result, ($out_scale + 1) * ($index - $i) + 1);
        }

        return self::innerRound($result, $out_scale);
    }
747607
private function get_scale($scaleid) {
        global $DB;
        $scaletext = $DB->get_field('scale', 'scale', array('id' => $scaleid), IGNORE_MISSING);
        $scale = explode ( ',', $scaletext);
        return $scale;

    }
732903
public function returnsArgument(int $index = 0): Stub
    {
        return $this->doesWith(
            function ($arguments) use ($index) {
                return $arguments->get($index);
            },
            [],
            false,
            true,
            false
        );
    }
318150
function getNotesUp($scalenum, $root, $octaves, $hand) {
        $initialnote = clone($root);
        $str = "\n % going up \n";
        $clef = ''; // this will force a clef to be defined for the first note
        for ($o=0; $o<$octaves; $o++) {
            $scale = new Scale($scalenum, $initialnote, 'ascending');
            $pitches = $scale->getPitches();
            $degree = 0;
            foreach ($pitches as $pitch) {
                $newclef = ($initialnote->interval($this->middleC) > 0) ? 'bass' : 'treble';
                if ($newclef != $clef) {
                    $clef = $newclef;
                    $str .= '\\clef "' . $clef . '" ';
                }
                $str .= $pitch->toLilypond() . $this->duration;

                $isbottom = $pitch->isEnharmonic($root);
                $finger = $this->getFinger($scalenum, $initialnote, $hand, $degree, false, $isbottom);
                $str .= '-' . $finger;

                $str .= ' ';
                $degree++;
            }
            $initialnote->transpose(12);
        }
        return $str;
    }
114133
protected function parentIndex($index)
	{
		$r = false;
		
		if($index > 1)
		{
			$r = floor($index / 2);
		}
		else if($index === 1)
		{
			$r = null;
		}
		
		return $r;
	}
852859
protected function _base($base = null) {
		if ($base === null) {
			$base = preg_replace('/[^\/]+$/', '', $this->env('PHP_SELF'));
		}
		$base = trim(str_replace(["/app/webroot", '/webroot'], '', $base), '/');
		return $base ? '/' . $base : '';
	}
68286
public static function add($arg1, $arg2, $scale = null) : string {
		return self::__operator('bcadd', $arg1, $arg2, $scale ?? self::$scale);
	}
455639
public <T extends MPBase> T getByIndex(int index) {
        T resource = (T) _resourceArray.get(index);
        return resource;
    }
236068
def get_index_from_base_index(self, base_index):
        
        r = self.rawdata
        try:
            index = r.get_reverse_index(base_index)
        except IndexError:
            raise IndexError("index %d not in this segment" % base_index)
        if index < 0:
            raise IndexError("index %d not in this segment" % base_index)
        return int(index)
195915
public static function mod($base, $modulus)
    {
        if (!static::is($base) || !static::is($modulus)) {
            throw new \InvalidArgumentException("The \$base and \$modulus parameters must be of type int.");
        }

        if ($modulus == 0) {
            throw new \InvalidArgumentException("Cannot divide by zero. The \$modulus parameter cannot be zero.");
        }

        return ($base % $modulus);
    }
564050
public static function getStringBaseValue($index, $default)
    {
        if (self::hasCustom($index)) {
            return (string) self::getCustom($index);
        }

        return (string) self::get($index, $default);
    }
512943
public function parent(Int $index = 1) : stdClass
    {
        return $this->_layer($this->debug, $index, $index + 1);
    }
542793
public org.tensorflow.framework.OpDef.ArgDef getOutputArg(int index) {
    return outputArg_.get(index);
  }
422001
public static double getHaltonNumberForGivenBase(long index, int base) {
		index += 1;

		double x = 0.0;
		double factor = 1.0 / base;
		while(index > 0) {
			x += (index % base) * factor;
			factor /= base;
			index /= base;
		}

		return x;
	}
679378
protected function IPLongBaseConvert($long, $fromBase=10, $toBase=36)
    {
        $str = trim($long);
        if (intval($fromBase) != 10) {
            $len = strlen($str);
            $q = 0;
            for ($i=0; $i<$len; $i++) {
                $r = base_convert($str[$i], $fromBase, 10);
                $q = bcadd(bcmul($q, $fromBase), $r);
            }
        } else {
            $q = $str;
        }

        if (intval($toBase) != 10) {
            $s = '';
            while (bccomp($q, '0', 0) > 0) {
                $r = intval(bcmod($q, $toBase));
                $s = base_convert($r, 10, $toBase) . $s;
                $q = bcdiv($q, $toBase, 0);
            }
        } else {
            $s = $q;
        }

        return $s;
    }
791613
function modularScale(power, ratio, bases) {
  const scale = []
  let step = 0

  while (Math.abs(step) <= Math.abs(power)) {
    for (let i = 0; i < bases.length; i++) {
      scale.push(bases[i] * Math.pow(ratio, step))
    }

    step += 1

    if (power < 0) {
      step -= 2
    }
  }

  return Array.from(new Set(scale))[Math.abs(step) - 1] // eslint-disable-line no-undef
}
52547
public static function getArrayBaseValue($index, $default = [])
    {
        $values = (array) self::getCustom($index, []);

        return array_merge((array) self::get($index, $default), $values);
    }