Esempio n. 1
0
File: vector.c Progetto: clyde7/iv
Vector vector_perpendicular(Vector v)
{
    int index = vector_min_index(v);
    error_check(index == -1, "cannot make zero vector perpendicular");

    Vector u = vector_dimension(index);

    return vector_normalize(cross(v, u));
}
Esempio n. 2
0
int toScalarR(int code, KDVEC(x), DVEC(r)) {
    REQUIRES(rn==1,BAD_SIZE);
    DEBUGMSG("toScalarR");
    double res;
    integer one = 1;
    integer n = xn;
    switch(code) {
        case 0: { res = dnrm2_(&n,xp,&one); break; }
        case 1: { res = dasum_(&n,xp,&one);  break; }
        case 2: { res = vector_max_index(V(x));  break; }
        case 3: { res = vector_max(V(x));  break; }
        case 4: { res = vector_min_index(V(x)); break; }
        case 5: { res = vector_min(V(x)); break; }
        default: ERROR(BAD_CODE);
    }
    rp[0] = res;
    OK
}