public static Vector weightedSuperposition(Vector left,double leftWeight,Vector right,double rightWeight){
  if ((left.getVectorType() != right.getVectorType()) || (left.getDimension() != right.getDimension())) {
    throw new IncompatibleVectorsException(String.format("Incompatible vectors:\n%s\n%s",left.toString(),right.toString()));
  }
switch (left.getVectorType()) {
case REAL:
case COMPLEX:
    Vector superposition=VectorFactory.createZeroVector(left.getVectorType(),left.getDimension());
  superposition.superpose(left,leftWeight,null);
superposition.superpose(right,rightWeight,null);
superposition.normalize();
return superposition;
case BINARY:
return BinaryVectorUtils.weightedSuperposition((BinaryVector)left,leftWeight,(BinaryVector)right,rightWeight);
default :
throw new IncompatibleVectorsException("Type not recognized: " + left.getVectorType());
}
}

public static Vector weightedSuperposition ( Vector left , double leftWeight , Vector right , double rightWeight ) { if ( ( left . getVectorType ( ) != right . getVectorType ( ) ) || ( left . getDimension ( ) != right . getDimension ( ) ) ) { throw new IncompatibleVectorsException ( String . format ( "Incompatible vectors:\n%s\n%s" , left . toString ( ) , right . toString ( ) ) ) ; } switch ( left . getVectorType ( ) ) { case REAL : case COMPLEX : Vector superposition = VectorFactory . createZeroVector ( left . getVectorType ( ) , left . getDimension ( ) ) ; superposition . superpose ( left , leftWeight , null ) ; superposition . superpose ( right , rightWeight , null ) ; superposition . normalize ( ) ; return superposition ; case BINARY : return BinaryVectorUtils . weightedSuperposition ( ( BinaryVector ) left , leftWeight , ( BinaryVector ) right , rightWeight ) ; default : throw new IncompatibleVectorsException ( "Type not recognized: " + left . getVectorType ( ) ) ; } }
returns a superposition of the form leftweight * left + rightweight * right .
