/**
*
*/
public class Matice {
protected int ai, aj;
protected double[][] a;
Matice( int i , int j ) {
a = new double[ i ][ j ];
ai = a.length;
aj = a[ 0 ].length;
}
Matice( double[][] a ) {
ai = a.length;
aj = a[ 0 ].length;
this.a = new double[ ai ][ aj ];
System.arraycopy( a, 0, this.a, 0, ai );
}
public int numRows() {
return ai;
}
public int numCols() {
return aj;
}
public double getA( int i, int j ) {
return a[ i ][ j ];
}
public void setA( int i, int j, double k ){
a[ i ][ j ] = k ;
}
Matice multiply( Matice b ) {
double pom;
if( aj == b.numRows() ){
//double[][] c = new double [ ai ][ b.numCols];
//Matice mc = new Matice( c );
Matice mc = new Matice( ai , b.numCols() );
for ( int l = 0 ; l < ai ; ++l ){
for ( int j = 0 ; j < b.numCols() ; ++j ){
pom = 0;
for( int i = 0 ; i < aj ; ++i ){
pom += a[ l ][ i ] * b.getA( i , j );
mc.setA( l , j , pom );
}
}
}
return mc;
}
else {
System.out.println( \"Matice nelze nasobit\" );
return null;
}
}
double[][] multiply( double[][] b ) {
int bi = b.length;
int bj = b[ 0 ].length;
double[][] c;
if ( aj == bi ) {
c = new double[ ai ][ bj ];
for ( int l = 0 ; l < ai ; ++l ){
for ( int j=0 ; j < bj ; ++j ){
for( int i = 0 ; i < aj ; ++i ){
c[ l ][ j ] += a[ l ][ i ] * b[ i ][ j ];
}
}
}
} else {
c = null;
System.out.println( \"nelze nasobit\" );
}
return c;
}
Matice vratSegment(int i,int ni, int j, int nj){
Matice ms = null;
double o,p;
long q,r;
o = (double)ai/(double)ni; p = ( double )aj / ( double )nj;
if( ( ( ai - ni ) < 0.2 ) || ( ( aj - nj ) < 0.0002 ) ){
System.out.println( \"prilis mnoho segmentu\" );/*prikaz pro preruseni metody*/
}
if( ( i >= ni ) || ( j >= nj ) ){
System.out.println(\"spatne zadane souradnice\");/*prikaz pro preruseni metody*/
}
q = Math.round( o ); r = Math.round( p );
//-----------------------------------------------------------------------------
// bezny segment v tele matice
if( ( ( i + 1 ) < ni ) && ( ( j + 1 ) < nj ) ){
ms = new Matice( ( int )q , ( int )r );
for( int m = 0 ; m < q ; m++ ){
for ( int n = 0 ; n < r ; n++ )
ms.setA( m , n , a[ m + i * ( int )q ][ n + j * ( int )r]);
}
for( int m = 0 ; m < q ; m++ ){
System.out.println();
for( int n = 0 ; n < r ; n++ )
System.out.print( ms.getA( m , n ) + \" \");
}
}
//------------------------------------------------------------------------------
// segment vlevo dole
if(((i+1)==ni)&&((j+1)