![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Hobbyist Programmer
Join Date: Feb 2005
Posts: 112
Rep Power: 4
![]() |
Definatley a one post member, maybe a few more to come and tell us off... But unless this is Chinese: zxasqwedc then who would want that to be their name everyone calls them? Ex:
"Hey zxasqwedc "... Wtf? Lol... |
|
|
|
|
|
#12 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Meh. Well, it's the two leftmost keys at the bottom, followed by the two in the middle, then the two at the top, and finally the third key from top to bottom. Don't ask me why though.
|
|
|
|
|
|
#13 | |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6
![]() |
Quote:
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
|
#14 |
|
Programming Guru
![]() |
some kid paid me £50 to do his homework once, i did it in about 20 minutes was a nice little earner, i only did it cause he just needed toi pass teh class and then he would have no more programming to do again. Just a silly uni subject.
|
|
|
|
|
|
#15 |
|
Newbie
Join Date: Apr 2005
Posts: 5
Rep Power: 0
![]() |
thanks for your help....
here is my sollution clever guys... public class SparseVector{
protected int dimension=0;
private int index=0;
public NonZero[] vector;
public SparseVector(int dim){
dimension=dim;
}
public void put(int loc,int val){
NonZero a=new NonZero(loc,val);
vector[index]=a;
index=index+1;
}
public int get(int where){
int walue=0;
for(int i=0;i<=index;i++){
if(vector[i].location==where)
walue=vector[i].value;
}
return walue;
}
public SparseVector add(SparseVector a,SparseVector b){
int temp1=0;
int temp2=0;
int control=2;
SparseVector sum=new SparseVector(a.dimension);
for(int y=0;y<(a.vector).length;y++){
int locA=(a.vector)[y].location;
for(int z=0;z<(b.vector).length;z++){
if(locA==(((b.vector)[z]).location)){
temp1=((a.vector)[y].value)+((b.vector)[z].value);
control=1;
}
else{
temp2=((a.vector)[y].value);
}
if(control==1)
sum.put(locA,temp1);
else
sum.put(locA,temp2);
control=2;
}
}
for(int x=0;x<(b.vector).length;x++){
int locB=(b.vector)[x].location;
for(int v=0;v<(a.vector).length;v++){
if(locB==(a.vector)[v].location){
control=1;
}
else{
temp2=(b.vector)[x].value;
}
if(control==2)
sum.put(locB,temp2);
control=2;
}
}
return sum;
}
public SparseVector multiply(int constant){
for(int m=0;m<(this.vector).length;m++){
(this.vector)[m].value=((this.vector)[m].value)*constant;
}
return this;
}
}public class NonZero{
public int location,locationX,locationY, value;
public NonZero(int loc, int val){
location=loc;
value=val;
}
public NonZero(int locx,int locy, int val){
locationX=locx;
locationY=locy;
value=val;
}
} |
|
|
|
|
|
#16 | |
|
Newbie
Join Date: Apr 2005
Posts: 5
Rep Power: 0
![]() |
Quote:
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;
}
} |
|
|
|
|
|
|
#17 |
|
Programming Guru
![]() |
and now wasnt it better that you did it yourself?
|
|
|
|
|
|
#18 |
|
Newbie
Join Date: Apr 2005
Posts: 5
Rep Power: 0
![]() |
the original one done with arraylist class...
by the way, i'm not from china 3===================> Last edited by zxasqwedc; Apr 26th, 2005 at 7:35 AM. |
|
|
|
|
|
#19 |
|
Professional Programmer
|
If you would have shown a small amount of effort, and not just give us the problem and expect to solve it ... you would have been treated allot better.
Ps: are u sure YOU wrote that code ?.. or did someone had merci on you? ![]()
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
|
|
#20 |
|
Programming Guru
![]() ![]() ![]() |
Wow, proved us wrong a 1+ poster...
Although, I still think you need to try it on your own first before having it done for you... that's how you learn.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|