View Single Post
Old Apr 26th, 2005, 2:01 AM   #16
zxasqwedc
Newbie
 
Join Date: Apr 2005
Posts: 5
Rep Power: 0 zxasqwedc is an unknown quantity at this point
Quote:
Originally Posted by bl00dninja
yeah i was trying to be nice thinking he might post back with some effort. he can suck a donkey dick.


and this is the SparseMatrix class right up into your ass...

public class SparseMatrix{

	protected int verticalDimension=0;
	protected int horizontalDimension=0;
	private int index=0;
	public NonZero[] vector;
	
	public SparseMatrix(int dimv, int dimh){
		verticalDimension=dimv;
		horizontalDimension=dimh;
		
	}
	
	
	public void put(int locX,int locY,int val){
		NonZero a=new NonZero(locY,locX,val);
		vector[index]=a;
		index=index+1;
	}
	
	
	public int get(int whereX,int whereY){
		int walue=0;
		for(int i=0;i<=index;i++){
			if(vector[i].locationX==whereX && vector[i].locationY==whereY)
			walue=vector[i].value;
			
		}
		return walue;
	}
	
	
	
	public SparseMatrix add(SparseMatrix a,SparseMatrix b){
		
		int temp1=0; 
		int temp2=0;
		int control=2;
		SparseMatrix sum=new SparseMatrix(a.verticalDimension,a.horizontalDimension);
		for(int y=0;y<(a.vector).length;y++){
			int locAy=(a.vector)[y].locationY;
			int locAx=(a.vector)[y].locationX;
			for(int z=0;z<(b.vector).length;z++){
				if((locAy==(((b.vector)[z]).locationY))&&(locAx==(((b.vector)[z]).locationX))){
					temp1=((a.vector)[y].value)+((b.vector)[z].value);
					control=1;
				}
				else{
					temp2=((a.vector)[y].value);
							
				}
				if(control==1)
				sum.put(locAy,locAx,temp1);
				else
				sum.put(locAy,locAx,temp2);
				
				control=2;	
			}
		}
		
		for(int x=0;x<(b.vector).length;x++){
			int locBy=(b.vector)[x].locationY;
			int locBx=(b.vector)[x].locationX;
			for(int v=0;v<(a.vector).length;v++){
				if((locBy==(a.vector)[v].locationY)&&(locBx==(a.vector)[v].locationX)){
					control=1;
				}
				else{
					temp2=(b.vector)[x].value;
				}
				
				if(control==2)
					sum.put(locBy,locBx,temp2);
					
				control=2;
			}
		}
		
		
		return sum;
		
		
	}
	
	
	
	
	public SparseMatrix multiply(int constant){
			for(int m=0;m<(this.vector).length;m++){
			(this.vector)[m].value=((this.vector)[m].value)*constant;
						
		}
	return this;	
	}
	
	

	
	
	
}
zxasqwedc is offline   Reply With Quote