/* Inverse equations
-----------------
342266
function inverse$17(p) {
        var lon, lat, x, y, i;
        var al, bl;
        var phi, dphi;
        x = p.x - this.x0;
        y = p.y - this.y0;

        if (this.sphere) {
            if (Math.abs(y + this.a * this.lat0) <= EPSLN) {
                lon = adjust_lon(x / this.a + this.long0);
                lat = 0;
            }
            else {
                al = this.lat0 + y / this.a;
                bl = x * x / this.a / this.a + al * al;
                phi = al;
                var tanphi;
                for (i = MAX_ITER$2; i; --i) {
                    tanphi = Math.tan(phi);
                    dphi = -1 * (al * (phi * tanphi + 1) - phi - 0.5 * (phi * phi + bl) * tanphi) / ((phi - al) / tanphi - 1);
                    phi += dphi;
                    if (Math.abs(dphi) <= EPSLN) {
                        lat = phi;
                        break;
                    }
                }
                lon = adjust_lon(this.long0 + (Math.asin(x * Math.tan(phi) / this.a)) / Math.sin(lat));
            }
        }
        else {
            if (Math.abs(y + this.ml0) <= EPSLN) {
                lat = 0;
                lon = adjust_lon(this.long0 + x / this.a);
            }
            else {

                al = (this.ml0 + y) / this.a;
                bl = x * x / this.a / this.a + al * al;
                phi = al;
                var cl, mln, mlnp, ma;
                var con;
                for (i = MAX_ITER$2; i; --i) {
                    con = this.e * Math.sin(phi);
                    cl = Math.sqrt(1 - con * con) * Math.tan(phi);
                    mln = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, phi);
                    mlnp = this.e0 - 2 * this.e1 * Math.cos(2 * phi) + 4 * this.e2 * Math.cos(4 * phi) - 6 * this.e3 * Math.cos(6 * phi);
                    ma = mln / this.a;
                    dphi = (al * (cl * ma + 1) - ma - 0.5 * cl * (ma * ma + bl)) / (this.es * Math.sin(2 * phi) * (ma * ma + bl - 2 * al * ma) / (4 * cl) + (al - ma) * (cl * mlnp - 2 / Math.sin(2 * phi)) - mlnp);
                    phi -= dphi;
                    if (Math.abs(dphi) <= EPSLN) {
                        lat = phi;
                        break;
                    }
                }

                //lat=phi4z(this.e,this.e0,this.e1,this.e2,this.e3,al,bl,0,0);
                cl = Math.sqrt(1 - this.es * Math.pow(Math.sin(lat), 2)) * Math.tan(lat);
                lon = adjust_lon(this.long0 + Math.asin(x * cl / this.a) / Math.sin(lat));
            }
        }

        p.x = lon;
        p.y = lat;
        return p;
    }
434265
public function inverse($p)
    {
        $p->x -= $this->x0;
        $p->y = $this->rh - $p->y + $this->y0;

        if ($this->ns >= 0) {
            $rh1 = sqrt( $p->x * $p->x + $p->y * $p->y );
            $con = 1.0;
        } else {
            $rh1 = -sqrt( $p->x * $p->x + $p->y * $p->y );
            $con = -1.0;
        }

        $theta = 0.0;

        if ($rh1 != 0.0) {
            $theta = atan2($con * $p->x, $con * $p->y);
        }

        $ml = $this->g - $rh1 / $this->a;

        $lat = $this->phi3z( $ml, $this->e0, $this->e1, $this->e2, $this->e3 );
        $lon = Common::adjust_lon( $this->long0 + $theta / $this->ns );

        $p->x = $lon;
        $p->y = $lat;

        return $p;
    }
454136
function inverse$10(p) {
        var u, deltav, s, d, eps, ro, fi1;
        var ok;

        /* Transformation */
        /* revert y, x*/
        var tmp = p.x;
        p.x = p.y;
        p.y = tmp;
        if (!this.czech) {
            p.y *= -1;
            p.x *= -1;
        }
        ro = Math.sqrt(p.x * p.x + p.y * p.y);
        eps = Math.atan2(p.y, p.x);
        d = eps / Math.sin(this.s0);
        s = 2 * (Math.atan(Math.pow(this.ro0 / ro, 1 / this.n) * Math.tan(this.s0 / 2 + this.s45)) - this.s45);
        u = Math.asin(Math.cos(this.ad) * Math.sin(s) - Math.sin(this.ad) * Math.cos(s) * Math.cos(d));
        deltav = Math.asin(Math.cos(s) * Math.sin(d) / Math.cos(u));
        p.x = this.long0 - deltav / this.alfa;
        fi1 = u;
        ok = 0;
        var iter = 0;
        do {
            p.y = 2 * (Math.atan(Math.pow(this.k, - 1 / this.alfa) * Math.pow(Math.tan(u / 2 + this.s45), 1 / this.alfa) * Math.pow((1 + this.e * Math.sin(fi1)) / (1 - this.e * Math.sin(fi1)), this.e / 2)) - this.s45);
            if (Math.abs(fi1 - p.y) < 0.0000000001) {
                ok = 1;
            }
            fi1 = p.y;
            iter += 1;
        } while (ok === 0 && iter < 15);
        if (iter >= 15) {
            return null;
        }

        return (p);
    }
922337
public BiMap<V, K> inversed() {
        return (inverse == null) ? inverse = new BiMap<>(valueMap, keyMap) : inverse;
    }
1107358
public static <K, V> Map<V, K> inverse(Map<K, V> map) {
        return inverse(map, false);
    }
349578
public function inverse($p)
    {
        /* Transformation */
        /* revert y, x */
        $tmp = $p->x;
        $p->x = $p->y;
        $p->y = $tmp;

        if ($this->czech) {
            $p->y *= -1.0;
            $p->x *= -1.0;
        }

        $ro = sqrt( $p->x * $p->x + $p->y * $p->y );
        $eps = atan2( $p->y, $p->x );
        $d = $eps / sin( $this->s0 );
        $s = 2. * (atan( pow( $this->ro0 / $ro, 1. / $this->n ) * tan( $this->s0 / 2. + $this->s45 ) ) - $this->s45);
        $u = asin( cos( $this->ad ) * sin( $s ) - sin( $this->ad ) * cos( $s ) * cos( $d ) );
        $deltav = asin( cos( $s ) * sin( $d ) / cos( $u ) );
        $p->x = $this->long0 - $deltav / $this->alfa;

        /* ITERATION FOR $lat */
        $fi1 = $u;
        $ok = 0;
        $iter = 0;
        do {
            $p->y = 2. * ( atan( pow( $this->k, -1. / $this->alfa ) *
                                pow( tan( $u / 2. + $this->s45 ), 1. / $this->alfa ) *
                                pow( (1. + $this->e * sin( $fi1 )) / (1. - $this->e * sin( $fi1 )), $this->e / 2. )
                      ) - $this->s45);
            if (abs( $fi1 - $p->y ) < 0.0000000001)
                $ok = 1;
            $fi1 = $p->y;
            $iter += 1;
        } while ($ok == 0 && $iter < 15);

        if ($iter >= 15) {
            Proj4php::reportError( "PHI3Z-CONV:Latitude failed to converge after 15 iterations" );
            //console.log('iter:', iter);
            return null;
        }

        return $p;
    }
209503
public static double Inverse(double y0) {
        if (y0 <= 0.0) {
            if (y0 == 0) return Double.NEGATIVE_INFINITY;
            try {
                throw new IllegalArgumentException("y0");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (y0 >= 1.0) {
            if (y0 == 1) return Double.POSITIVE_INFINITY;
            try {
                throw new IllegalArgumentException("y0");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }


        double s2pi = Math.sqrt(2.0 * Math.PI);
        int code = 1;
        double y = y0;
        double x;

        double[] P0 =
                {
                        -59.963350101410789,
                        98.001075418599967,
                        -56.676285746907027,
                        13.931260938727968,
                        -1.2391658386738125
                };

        double[] Q0 =
                {
                        1.9544885833814176,
                        4.6762791289888153,
                        86.360242139089053,
                        -225.46268785411937,
                        200.26021238006066,
                        -82.037225616833339,
                        15.90562251262117,
                        -1.1833162112133
                };

        double[] P1 =
                {
                        4.0554489230596245,
                        31.525109459989388,
                        57.162819224642128,
                        44.080507389320083,
                        14.684956192885803,
                        2.1866330685079025,
                        -0.14025607917135449,
                        -0.035042462682784818,
                        -0.00085745678515468545
                };

        double[] Q1 =
                {
                        15.779988325646675,
                        45.390763512887922,
                        41.317203825467203,
                        15.04253856929075,
                        2.5046494620830941,
                        -0.14218292285478779,
                        -0.038080640769157827,
                        -0.00093325948089545744
                };

        double[] P2 =
                {
                        3.2377489177694603,
                        6.9152288906898418,
                        3.9388102529247444,
                        1.3330346081580755,
                        0.20148538954917908,
                        0.012371663481782003,
                        0.00030158155350823543,
                        2.6580697468673755E-06,
                        6.2397453918498331E-09
                };

        double[] Q2 =
                {
                        6.02427039364742,
                        3.6798356385616087,
                        1.3770209948908132,
                        0.21623699359449663,
                        0.013420400608854318,
                        0.00032801446468212774,
                        2.8924786474538068E-06,
                        6.7901940800998127E-09
                };

        if (y > 0.8646647167633873) {
            y = 1.0 - y;
            code = 0;
        }

        if (y > 0.1353352832366127) {
            y -= 0.5;
            double y2 = y * y;
            x = y + y * ((y2 * Special.Polevl(y2, P0, 4)) / Special.P1evl(y2, Q0, 8));
            x *= s2pi;
            return x;
        }

        x = Math.sqrt(-2.0 * Math.log(y));
        double x0 = x - Math.log(x) / x;
        double z = 1.0 / x;
        double x1;

        if (x < 8.0) {
            x1 = (z * Special.Polevl(z, P1, 8)) / Special.P1evl(z, Q1, 8);
        } else {
            x1 = (z * Special.Polevl(z, P2, 8)) / Special.P1evl(z, Q2, 8);
        }

        x = x0 - x1;

        if (code != 0)
            x = -x;

        return x;
    }
368902
@Override
    public void solve(ZMatrixRMaj B, ZMatrixRMaj X) {
        if( X.numRows != numCols )
            throw new IllegalArgumentException("Unexpected dimensions for X: X rows = "+X.numRows+" expected = "+numCols);
        else if( B.numRows != numRows || B.numCols != X.numCols )
            throw new IllegalArgumentException("Unexpected dimensions for B");

        U = decomposer.getR(U,true);
        final double gammas[] = decomposer.getGammas();
        final double dataQR[] = QR.data;

        final int BnumCols = B.numCols;

        // solve each column one by one
        for( int colB = 0; colB < BnumCols; colB++ ) {

            // make a copy of this column in the vector
            for( int i = 0; i < numRows; i++ ) {
                int indexB = (i*BnumCols + colB)*2;
                a[i*2]   = B.data[indexB];
                a[i*2+1] = B.data[indexB+1];
            }

            // Solve Qa=b
            // a = Q'b
            // a = Q_{n-1}...Q_2*Q_1*b
            //
            // Q_n*b = (I-gamma*u*u^H)*b = b - u*(gamma*U^H*b)
            for( int n = 0; n < numCols; n++ ) {
                int indexU = (n*numRows + n + 1)*2;

                double realUb = a[n*2];
                double imagUb = a[n*2+1];

                // U^H*b
                for( int i = n+1; i < numRows; i++ ) {
                    double realU = dataQR[indexU++];
                    double imagU = -dataQR[indexU++];

                    double realB = a[i*2];
                    double imagB = a[i*2+1];

                    realUb += realU*realB - imagU*imagB;
                    imagUb += realU*imagB + imagU*realB;
                }

                // gamma*U^T*b
                realUb *= gammas[n];
                imagUb *= gammas[n];

                a[n*2]   -= realUb;
                a[n*2+1] -= imagUb;

                indexU = (n*numRows + n + 1)*2;
                for( int i = n+1; i < numRows; i++) {
                    double realU = dataQR[indexU++];
                    double imagU = dataQR[indexU++];

                    a[i*2]   -= realU*realUb - imagU*imagUb;
                    a[i*2+1] -= realU*imagUb + imagU*realUb;
                }
            }

            // solve for Rx = b using the standard upper triangular solver
            TriangularSolver_ZDRM.solveU(U.data, a, numCols);

            // save the results

            for( int i = 0; i < numCols; i++ ) {
                int indexX = (i*X.numCols+colB)*2;

                X.data[indexX]   = a[i*2];
                X.data[indexX+1] = a[i*2+1];
            }
        }
    }
644027
function forward$11(p) {

        /* Forward equations
         -----------------*/
        var x, y;
        var lam = p.x;
        var phi = p.y;
        lam = adjust_lon(lam - this.long0);

        if (this.sphere) {
            x = this.a * Math.asin(Math.cos(phi) * Math.sin(lam));
            y = this.a * (Math.atan2(Math.tan(phi), Math.cos(lam)) - this.lat0);
        }
        else {
            //ellipsoid
            var sinphi = Math.sin(phi);
            var cosphi = Math.cos(phi);
            var nl = gN(this.a, this.e, sinphi);
            var tl = Math.tan(phi) * Math.tan(phi);
            var al = lam * Math.cos(phi);
            var asq = al * al;
            var cl = this.es * cosphi * cosphi / (1 - this.es);
            var ml = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, phi);

            x = nl * al * (1 - asq * tl * (1 / 6 - (8 - tl + 8 * cl) * asq / 120));
            y = ml - this.ml0 + nl * sinphi / cosphi * asq * (0.5 + (5 - tl + 6 * cl) * asq / 24);


        }

        p.x = x + this.x0;
        p.y = y + this.y0;
        return p;
    }
1144320
def inverse_jacobian(self, maps):
        
        m1 = maps[parameters.mass1]
        m2 = maps[parameters.mass2]
        return conversions.mchirp_from_mass1_mass2(m1, m2)/m2**2.
1251297
def inverse(self, N):
        
        if N == 0:
            return 0
        lm, hm = 1, 0
        low, high = N % self.P, self.P
        while low > 1:
            r = high//low
            nm, new = hm - lm * r, high - low * r
            lm, low, hm, high = nm, new, lm, low

        return lm % self.P
35332
public void reverse() {
		for (int i = 0; i < size / 2; i++) {
			T tmp = data[i];
			data[i] = data[size - i - 1];
			data[size - i - 1] = tmp;
		}
	}
700385
public void inverse(Transformation2D inverse) {
		double det = xx * yy - xy * yx;

		if (det == 0) {
			inverse.setZero();
			return;
		}

		det = 1 / det;

		inverse.xd = (xy * yd - xd * yy) * det;
		inverse.yd = (xd * yx - xx * yd) * det;
		inverse.xx = yy * det;
		inverse.xy = -xy * det;
		inverse.yx = -yx * det;
		inverse.yy = xx * det;
	}
178877
public function inverse($p)
    {
        $x = ($p->x - $this->x0) / $this->a;   /* descale and de-offset */
        $y = ($p->y - $this->y0) / $this->a;

        /*
        $lon;
        $lat;
        $cosphi;
        $sinphi;
        $rho;
        $tp = 0.0;
        $phi_l = 0.0;
        $i;
        */

        $halfe = 0.0;
        $pi2 = 0.0;

        if ($this->sphere) {
            /*
            $c;
            $rh;
            $sinc;
            $cosc;
            */

            $rh = sqrt( $x * $x + $y * $y );
            $c = 2. * atan( $rh / $this->akm1 );
            $sinc = sin( $c );
            $cosc = cos( $c );
            $lon = 0.;

            switch ($this->mode) {
                case $this->EQUIT:
                    if (abs( $rh ) <= Common::EPSLN) {
                        $lat = 0.;
                    } else {
                        $lat = asin( $y * $sinc / $rh );
                    }
                    if ($cosc != 0. || $x != 0.0)
                        $lon = atan2( $x * $sinc, $cosc * $rh );
                    break;

                case $this->OBLIQ:
                    if (abs($rh) <= Common::EPSLN) {
                        $lat = $this->phi0;
                    } else {
                        $lat = asin( $cosc * $this->sinph0 + $y * $sinc * $this->cosph0 / $rh );
                    }
                    $c = $cosc - $this->sinph0 * sin( $lat );
                    if ($c != 0. || $x != 0.0) {
                        $lon = atan2( $x * $sinc * $this->cosph0, $c * $rh );
                    }
                    break;

                case $this->N_POLE:
                    $y = -$y;

                case $this->S_POLE:
                    if (abs($rh) <= Common::EPSLN) {
                        $lat = $this->phi0;
                    } else {
                        $lat = asin( $this->mode == $this->S_POLE ? -$cosc : $cosc  );
                    }
                    $lon = ($x == 0. && $y == 0.0) ? 0. : atan2($x, $y);
                    break;
            }

            $p->x = Common::adjust_lon( $lon + $this->long0 );
            $p->y = $lat;
        } else {
            $rho = sqrt($x * $x + $y * $y);

            switch ($this->mode) {
                case $this->OBLIQ:
                case $this->EQUIT:
                    $tp = 2. * atan2( $rho * $this->cosX1, $this->akm1 );
                    $cosphi = cos( $tp );
                    $sinphi = sin( $tp );
                    if ($rho == 0.0) {
                        $phi_l = asin($cosphi * $this->sinX1);
                    } else {
                        $phi_l = asin($cosphi * $this->sinX1 + ($y * $sinphi * $this->cosX1 / $rho));
                    }

                    $tp = tan( .5 * (Common::HALF_PI + $phi_l) );
                    $x *= $sinphi;
                    $y = $rho * $this->cosX1 * $cosphi - $y * $this->sinX1 * $sinphi;
                    $pi2 = Common::HALF_PI;
                    $halfe = .5 * $this->e;
                    break;

                case $this->N_POLE:
                    $y = -$y;

                case $this->S_POLE:
                    $tp = - $rho / $this->akm1;
                    $phi_l = Common::HALF_PI - 2. * atan( $tp );
                    $pi2 = -Common::HALF_PI;
                    $halfe = -.5 * $this->e;
                    break;
            }

            for ($i = $this->NITER; $i--; $phi_l = $lat) { //check this
                $sinphi = $this->e * sin($phi_l);
                $lat = 2.0 * atan( $tp * pow((1.0 + $sinphi) / (1.0 - $sinphi), $halfe)) - $pi2;

                if (abs( phi_l - lat ) < $this->CONV) {
                    if ($this->mode == $this->S_POLE) {
                        $lat = -$lat;
                    }

                    $lon = ($x == 0. && $y == 0.0) ? 0. : atan2($x, $y);
                    $p->x = Common::adjust_lon( $lon + $this->long0);
                    $p->y = $lat;

                    return $p;
                }
            }
        }
    }
853385
public function inverse($p)
    {
        $p->x -= $this->x0;
        $p->y -= $this->y0;
        $x = $p->x / $this->a;
        $y = $p->y / $this->a;

        if ($this->sphere) {
            $this->dd = $y + $this->lat0;
            $phi = asin(sin($this->dd) * cos($x));
            $lam = atan2(tan($x), cos($this->dd));
        } else {
            // ellipsoid
            $ph1 = Common::pj_inv_mlfn($this->m0 + $y, $this->es, $this->en);
            $this->tn = tan($ph1);
            $this->t = $this->tn * $this->tn;
            $this->n = sin($ph1);
            $this->r = 1.0 / (1.0 - $this->es * $this->n * $this->n);
            $this->n = sqrt($this->r);
            $this->r *= (1.0 - $this->es) * $this->n;
            $this->dd = $x / $this->n;
            $this->d2 = $this->dd * $this->dd;
            $phi = $ph1 - ($this->n * $this->tn / $this->r) * $this->d2 * (0.5 - (1.0 + 3.0 * $this->t) * $this->d2 * $this->C3);
            $lam = $this->dd * (1.0 + $this->t * $this->d2 * (-$this->C4 + (1.0 + 3. * $this->t) * $this->d2 * $this->C5)) / cos($ph1);
        }

        $p->x = Common::adjust_lon($this->long0 + $lam);
        $p->y = $phi;

        return $p;
    }
453364
function inverse$15(p) {
        p.x -= this.x0;
        p.y -= this.y0;
        var lon, lat;

        if (this.sphere) {
            lon = adjust_lon(this.long0 + (p.x / this.a) / Math.cos(this.lat_ts));
            lat = Math.asin((p.y / this.a) * Math.cos(this.lat_ts));
        }
        else {
            lat = iqsfnz(this.e, 2 * p.y * this.k0 / this.a);
            lon = adjust_lon(this.long0 + p.x / (this.a * this.k0));
        }

        p.x = lon;
        p.y = lat;
        return p;
    }
1165685
private void solveInternalL() {
        // This takes advantage of the diagonal elements always being real numbers

        // solve L*y=b storing y in x
        TriangularSolver_ZDRM.solveL_diagReal(t, vv, n);

        // solve L^T*x=y
        TriangularSolver_ZDRM.solveConjTranL_diagReal(t, vv, n);
    }