⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reconocimientosenhal.java

📁 This is a example about programming a neural network
💻 JAVA
字号:
/*
 * ReconocimientoSenhal.java
 *
 * Created on 9 de marzo de 2008, 02:11 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package rah;

/**
 *
 * @author JhonFranko
 */
import java.awt.*;
import java.util.*;

public class ReconocimientoSenhal {
    
    /** Creates a new instance of ReconocimientoSenhal */
    public ReconocimientoSenhal() {
    }

    //************************************************************************************
    // PARTE DE RECONOCIMIENTO
    public double d(double[][] A,double[][] B,int i,int j)
    {
      double D=0;
      double suma=0;
      
            for(int k=0;k<A.length;k++)
            {
              double distancia=Math.abs(A[k][i]-B[k][j]);
              suma+=Math.pow(distancia,2.0);        
            }      
            D=Math.sqrt(suma); 
      return D;
    }
    public double minDistancia(double[][] A,double[][] B,double[][] g,int i,int j,int p)
    {
      
      double min=g[j-1][i-1]+2*(d(A,B,i,j));
      
	  if(p==0 || (p==1 && (i<2 || j<2)))	
	  {
	    if(min>g[j][i-1]+d(A,B,i,j))
	    {
	      if(g[j][i-1]!=0)	
	      {
	      	min=g[j][i-1]+d(A,B,i,j);	
	      }
	      
	    }	
	    if(min>g[j-1][i]+d(A,B,i,j))
	    {
	      if(g[j-1][i]!=0)	
	      {
	        min=g[j-1][i]+d(A,B,i,j);	    	
	      }	    	

	    }	
	    	
	  }
	  if(p==1)	
	  {
		  if(i>=2 && j>=2)
		  {
			    if(min>g[j-1][i-2]+2*d(A,B,i,j-1)+d(A,B,i,j))
			    {
			      if(g[j-1][i-2]!=0)	
			      {
			      	min=g[j-1][i-2]+2*d(A,B,i,j-1)+d(A,B,i,j);	
			      }
			      
			    }	
			    if(min>g[j-2][i-1]+2*d(A,B,i-1,j)+d(A,B,i,j))
			    {
			      if(g[j-2][i-1]!=0)	
			      {
			        min=g[j-2][i-1]+2*d(A,B,i-1,j)+d(A,B,i,j);	    	
			      }	    	
		
			    }	  			  		
	  	}
	  }  
      return min;
    }    	

	public double DTW(double[][] A,double[][] B, int p)
	{
	  double D=0;
	  
	  int i=0,j=0;
	  //--------------------------------------------------
	  int I=A[0].length;
	  int J=B[0].length;
	  double[][] A1=A;
	  double[][] B1=B;
	  
	  if(J>A[0].length) 
	  {
	  	J=A[0].length;
	  	I=B[0].length;	  	  	
	  	A1=B;
	  	B1=A;	
	  } 
          //****************************************************
                int r=I/2; //RADIO DE AJUSTE DE VENTANA
                double N=I+J;                
                double[][] g=new double[J][I];                
          //****************************************************
	 // System.out.println("I,J= "+I+","+J);
	  
	  //--------------------------------------------------
          // Comienza el algoritmo

	  g[0][0]=2*(d(A1,B1,0,0));
	  //System.out.println("g(0,0)= "+g[0][0]);
	  
	  do{
	  	  i++;
	  	  
	  	  if((i>j+r && i<I) || i>I-1)
	  	  {
	  	  	j++;
	  	  	if(j>J-1)
	  	  	{
	  	  	  D=g[J-1][I-1]/N;	
	  	  	}
	  	  	else{
	  	  		if(j<=r)
	  	  		{
	  	  		  i=-1;	
	  	  		}
	  	  		else
	  	  		{
	  	  		  i=j-r-1;	
	  	  		}
	  	  	}	  	  	
	  	  }
	  	  else{
	  	       if(i<I && j<J)
	  	       {
		  	  	 if(j==0)
		  	  	 {
		  	  	   g[j][i]=g[j][i-1]+d(A1,B1,i,j);	
		  	  	 }
		  	  	 else
		  	  	 {
			  	  	 if(i==0)
			  	  	 {
			  	  	   g[j][i]=g[j-1][i]+d(A1,B1,i,j);	  	  	 	
			  	  	 }
			  	  	 else
			  	  	 {
			  	  	 	g[j][i]= minDistancia(A1,B1,g,i,j,p);
			  	  	 } 		  	  	 	
			  	  }	  	       	
	  	       }    	
	  	  	  
	  	  }  	  
	  	  
	  	
	  	}while(i<I && j<J);
	  
 
	  return D;	
		
	} 
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -