Esempio n. 1
0
/**
 * \return Angle between this vector and XY plane (horizontal plane).
 */
double RVector::getAngleToPlaneXY() const {
    RVector n(0, 0, 1);

    if (getMagnitude() < 1.0e-4) {
        return M_PI / 2;
    } else if ((getDotProduct(*this, n) / (getMagnitude() * 1)) > 1.0) {
        return 0.0;
    } else {
        return M_PI / 2 - acos(getDotProduct(*this, n) / (getMagnitude() * 1));
    }
}
Esempio n. 2
0
File: jacobi.c Progetto: Egor-mn/NSU
double getRayleighQuotient(int id, matrix a, matrix eigen_vectors, int size) {
    vector v1, e;
    for (int i = 0; i < size; i++)
        e[i] = eigen_vectors[i][id];

    multiplyMatrixVector(a, e, size, v1);
    double n = getDotProduct(e, v1, size);
    double d = getDotProduct(e, e, size);

    return n / d;
}
	/* PUBLIC MEMBER FUNCTIONS */
	float Vector2f::getAngle(const Vector2f &v) const
	{
		// WARNING: this may not work

		float length = (getMagnitude() * v.getMagnitude());
        if (length == 0.0f)
        {
            return 0.0f;
        }
        
		return (float)acos(getDotProduct(v) / length);
	}
Esempio n. 4
0
double GetFact::getH() {
	updateCacheW();	//update rpCache
	for (UINT i = 0; i < R; i++)
		index[i] = i;
// derive lambda for other vectors
	double frobNormSq = 0;
	for (UINT ind = 0; ind < N; ind++) {
		for (UINT rpInd2 = 0; rpInd2 < R; rpInd2++)
			xTz[rpInd2] = getDotProduct(X[ind].F, X[ind].fSize, W[rpInd2]);
//		double norm = deriveHi(ind);
//		std::cout<<norm<<"\t"<<X[ind].nrm<<"\n";
		frobNormSq += deriveHi(ind);
	}
	return sqrt(frobNormSq);
}
Esempio n. 5
0
/**
 * \return The angle from zero to this vector (in rad).
 */
double RVector::getAngle() const {
    double ret = 0.0;
    double m = getMagnitude2D();

    if (m > 1.0e-6) {
        double dp = getDotProduct(*this, RVector(1.0, 0.0));
        if (dp / m >= 1.0) {
            ret = 0.0;
        } else if (dp / m < -1.0) {
            ret = M_PI;
        } else {
            ret = acos(dp / m);
        }
        if (y < 0.0) {
            ret = 2*M_PI - ret;
        }
    }
    return ret;
}
Esempio n. 6
0
File: jacobi.c Progetto: Egor-mn/NSU
void analysisOfResults(matrix m, matrix orig, matrix eigen_vectors, int size) {
    int c = 0, n, id;
    double N;
    vector v, v2;

    while (c != 4) {
        printf("\nAnalysis of results: (1) residual vector, (2) Rayleigh quotient, (3) dot product of two eigenvectors (4) end? ");
        scanf("%d", &c);
        switch (c) {
            case 1:
                printf("Enter the number of Eigenvalues (1-matrix size) and number of norm (1-3): ");
                scanf("%d %d", &n, &id);
                for (int i = 0; i < size; i++)
                    v[i] = eigen_vectors[i][n-1];

                N = getResidualNorm(id, orig, v, v, m[n-1][n-1], size);
                printf("Norm of residual vector: %e\n", N);
                break;
            case 2:
                printf("Enter the number of eigenvector (1-matrix size): ");
                scanf("%d", &n);

                N = getRayleighQuotient(n, orig, eigen_vectors, size);
                printf("Rayleigh quotient: %e\n", N);
                break;
            case 3:
                printf("Enter two numbers of eigenvector (1-matrix size): ");
                scanf("%d %d", &n, &id);
                for (int i = 0; i < size; i++) {
                    v[i] = eigen_vectors[i][n-1];
                    v2[i] = eigen_vectors[i][id -1];
                }

                N = getDotProduct(v, v2, size);
                printf("Dot product: %e\n", N);
                break;
            default: return;
        }
    }
}
Esempio n. 7
0
auto getReflected(const T1& mVec, const T2& mNormal)
{
    return mVec - (mNormal * (2.f * getDotProduct(mVec, mNormal)));
}
Esempio n. 8
0
	real operator dot(const vec3& rexp) const { return getDotProduct(rexp); }