public double constrOpt(DoubleMatrix1D constraints[], int indices[], boolean useMin){
         //constraints[0] is DOF minima and constraints[1] is DOF maxima
        //Return the minimum or maximum (according to useMin) of this GenCoord given the
        //constraints on the regular DOFs
        //(indices in the constraint vectors given)
        switch(type){

            case REGULAR:
                if(useMin)
                    return constraints[0].get(indices[0]);
                else
                    return constraints[1].get(indices[0]);

            case SUMSQ:
                double sum=0;
                for(int q:indices){
                    double sq1 = Math.pow( constraints[0].get(q), 2);
                    double sq2 = Math.pow( constraints[1].get(q), 2);
                    if(useMin)
                        sum += Math.min(sq1,sq2);
                    else
                        sum += Math.max(sq1,sq2);
                }
                return Math.sqrt(sum);

            case LINCOMB:
                double ans=0;
                for(int a=0; a<coeffs.length; a++){
                    double val1 = coeffs[a]*constraints[0].get(indices[a]);
                    double val2 = coeffs[a]*constraints[1].get(indices[a]);
                    if(useMin)
                        ans += Math.min(val1,val2);
                    else
                        ans += Math.max(val1,val2);
                }
                return ans;
                
            default:
                System.err.println("ERROR: Unrecognized generalized coordinate type: "+type);
                System.exit(1);
                return 0;
        }
    }