Java Code Examples for cern.colt.matrix.DoubleMatrix1D#copy()

The following examples show how to use cern.colt.matrix.DoubleMatrix1D#copy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SeqBlas.java    From database with GNU General Public License v2.0 5 votes vote down vote up
public void drot(DoubleMatrix1D x, DoubleMatrix1D y, double c, double s) {
	x.checkSize(y);
	DoubleMatrix1D tmp = x.copy();
	
	x.assign(F.mult(c));
	x.assign(y,F.plusMult(s));

	y.assign(F.mult(c));
	y.assign(tmp,F.minusMult(s));
}
 
Example 2
Source File: CCDMinimizer.java    From OSPREY3 with GNU General Public License v2.0 5 votes vote down vote up
DoubleMatrix1D getAnglesInRange(DoubleMatrix1D u){
    //Given a vector of this minimizer's DOFs, identify those that are angles
    //add multiples of 360 if possible to get them in the [DOFmin,DOFmax] range
    //angles are assumed to be bounded
    //either on both max and min side or not at all
    //this is for preparing initial values
    
    //we will move each out-of-range angle to the first equivalent angle after DOFmin
    DoubleMatrix1D ans = u.copy();
    
    for(int dof=0; dof<numDOFs; dof++){
        
        if( objFcn.isDOFAngle(dof) ){
        
            if(ans.get(dof)<DOFmin.get(dof)-0.001){
                ans.set(dof,
                        DOFmin.get(dof) + (ans.get(dof)-DOFmin.get(dof))%(360) + 360 );
            }
            else if(ans.get(dof)>DOFmax.get(dof)+0.001){
                ans.set(dof,
                        DOFmin.get(dof) + (ans.get(dof)-DOFmin.get(dof))%(360) );
            }
        }
    }

    return ans;
}
 
Example 3
Source File: IdealSeparableReference.java    From OSPREY3 with GNU General Public License v2.0 5 votes vote down vote up
public IdealSeparableReference(EnergyFunction ef, ConfSpace cSpace, RCTuple RCTup, 
        DoubleMatrix1D center){
    super(ef,cSpace,RCTup);
    super.setDOFs(center);
    centerE = efunc.getEnergy();
    fullCurDOFVals = center.copy();
    
    baseValForDOF = new double[getNumDOFs()];
    for(int dof=0; dof<getNumDOFs(); dof++){
        if(partialEFuncs != null)
            baseValForDOF[dof] = partialEFuncs.get(dof).getEnergy();
        else
            baseValForDOF[dof] = efunc.getEnergy();
    }
}
 
Example 4
Source File: SubThreshSampler.java    From OSPREY3 with GNU General Public License v2.0 5 votes vote down vote up
DoubleMatrix1D getScaleAdaptive(DoubleMatrix1D sp){
    //Get an appropriate scale for sampling around some starting point sp
    /*
    //initially, we'll go about a tenth of the way across the voxel
    //in each dimension
    samplingScale = DOFmax.copy();
    samplingScale.assign(DOFmin,Functions.minus);
    samplingScale.assign( Functions.mult(0.1) );*/
    
    //Let's aim for a scaling based on what dimensions allow more flexibility
    //we'll let the scale in each dimension be ~ the distance we can go from our starting point (current x)
    //in that dimension (sum of farthest we can go in positive and negative directions)
    DoubleMatrix1D ans = DoubleFactory1D.dense.make(numDOFs);
    
    for(int dim=0; dim<numDOFs; dim++){
        
        DoubleMatrix1D y = sp.copy();
        //we'll just try and estimate distances within a factor of two
        double upDist = 1e-6;//how far up we can go in this dimension
        double downDist = 1e-6;//how far down
        
        do {
            upDist*=2;
            y.set(dim, sp.get(dim)+upDist);
        } while(checkValidPt(y));
        
        do {
            downDist*=2;
            y.set(dim, sp.get(dim)-downDist);
        } while(checkValidPt(y));
        
        
        ans.set(dim,(upDist+downDist)/6);//divide by 6 so we can make moves within the allowed region
        //though tuneScale should handle uniform scaling of samplingScale better
        //if not adapativeScale..
    }
    
    return ans;
}
 
Example 5
Source File: FlexLab.java    From OSPREY3 with GNU General Public License v2.0 5 votes vote down vote up
private static ParametricMolecule addDofs(ParametricMolecule pmol, List<BoundedDof> newDofs) {

		// expand the dofs
		List<DegreeOfFreedom> combinedDofs = new ArrayList<>(pmol.dofs);
		for (BoundedDof bdof : newDofs) {
			combinedDofs.add(bdof.dof);
		}

		// expand the dof bounds
		DoubleMatrix1D mins = DoubleFactory1D.dense.make(pmol.dofs.size() + newDofs.size());
		DoubleMatrix1D maxs = mins.copy();
		for (int i=0; i<pmol.dofs.size(); i++) {
			mins.set(i, pmol.dofBounds.getMin(i));
			maxs.set(i, pmol.dofBounds.getMax(i));
		}
		for (int i=0; i<newDofs.size(); i++) {
			mins.set(i + pmol.dofs.size(), newDofs.get(i).min);
			maxs.set(i + pmol.dofs.size(), newDofs.get(i).max);
		}

		// build a new pmol
		return new ParametricMolecule(
			pmol.mol,
			combinedDofs,
			new ObjectiveFunction.DofBounds(new DoubleMatrix1D[] { mins, maxs })
		);
	}
 
Example 6
Source File: SeqBlas.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void drot(DoubleMatrix1D x, DoubleMatrix1D y, double c, double s) {
	x.checkSize(y);
	DoubleMatrix1D tmp = x.copy();
	
	x.assign(F.mult(c));
	x.assign(y,F.plusMult(s));

	y.assign(F.mult(c));
	y.assign(tmp,F.minusMult(s));
}
 
Example 7
Source File: SimpleCCDMinimizer.java    From OSPREY3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Minimizer.Result minimizeFrom(DoubleMatrix1D startx) {

	int n = f.getNumDOFs();
	DoubleMatrix1D herex = startx.copy();
	DoubleMatrix1D nextx = startx.copy();

	// ccd is pretty simple actually
	// just do a line search along each dimension until we stop improving
	// we deal with cycles by just capping the number of iterations
	
	// get the current objective function value
	double herefx = f.getValue(herex);
	
	for (int iter=0; iter<MaxIterations; iter++) {
		
		// update all the dofs using line search
		for (int d=0; d<n; d++) {
			
			LineSearcher lineSearcher = lineSearchers.get(d);
			if (lineSearcher != null) {
				
				// get the next x value for this dof
				double xd = nextx.get(d);
				xd = lineSearcher.search(xd);
				nextx.set(d, xd);
			}
		}
		
		// how much did we improve?
		double nextfx = f.getValue(nextx);
		double improvement = herefx - nextfx;
		
		if (improvement > 0) {
			
			// take the step
			herex.assign(nextx);
			herefx = nextfx;
			
			if (improvement < ConvergenceThreshold) {
				break;
			}
			
		} else {
			break;
		}
	}

	// update the protein conf, one last time
	f.setDOFs(herex);

	return new Minimizer.Result(herex, herefx);
}
 
Example 8
Source File: EPoly.java    From OSPREY3 with GNU General Public License v2.0 4 votes vote down vote up
DoubleMatrix1D toRelCoords(DoubleMatrix1D x){
    //convert coordinates to be relative to center
    DoubleMatrix1D ans = x.copy();
    ans.assign(center,Functions.minus);
    return ans;
}
 
Example 9
Source File: EPoly.java    From OSPREY3 with GNU General Public License v2.0 4 votes vote down vote up
DoubleMatrix1D toAbsCoords(DoubleMatrix1D z){
    //convert coordinates to be relative to center
    DoubleMatrix1D ans = z.copy();
    ans.assign(center,Functions.plus);
    return ans;
}