cvmaxplane.cpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By
00003 downloading, copying, installing or using the software you agree to this
00004 license. If you do not agree to this license, do not download, install, copy or
00005 use the software.
00006 
00007 Contributors License Agreement
00008 
00009 Copyright© 2007, Akhmed Umyarov. All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without modification,
00012 are permitted provided that the following conditions are met:
00013 - Redistributions of source code must retain the above copyright notice, this
00014 list of conditions and the following disclaimer.
00015 - Redistributions in binary form must reproduce the above copyright notice, this
00016 list of conditions and the following disclaimer in the documentation and/or
00017 other materials provided with the distribution.
00018 - The name of Contributor may not be used to endorse or promote products derived
00019 from this software without specific prior written permission.
00020 
00021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00022 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00023 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00024 DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
00025 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00027 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00028 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00029 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00030 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031 All information provided related to future Intel products and plans is
00032 preliminary and subject to change at any time, without notice.
00033 *****************************************************************************/
00034 
00041 #include "cvmaxplane.h"
00042 #include <iostream>
00043 #include <sstream>
00044 
00045 using namespace std;
00046 
00047 // Constructors/Destructors
00048 //  
00049 
00056 CvMaxPlane::CvMaxPlane (std::string id)
00057         : CvGenericPlane(id, cvSize(1,1), cvSize(1,1) ) 
00058 {
00059         m_weight.clear();
00060 }
00061 
00062 CvMaxPlane::~CvMaxPlane ( ) 
00063 {
00064 }
00065 
00066 //  
00067 // Methods
00068 //  
00069 
00075 CvMat * CvMaxPlane::fprop ( )
00076 {
00077         assert( m_connected );
00078         if (!m_connected)
00079         {
00080 #ifdef DEBUG
00081                 cout << "CvMaxPlane::fprop(): Not connected!" << endl;
00082 #endif
00083                 return NULL;
00084         }
00085 
00086         // Get the values at parent planes
00087         int no_parents = m_pplane.size();
00088         m_parentval.resize( no_parents );
00089         for (int i = 0; i < no_parents; i++)
00090         {
00091                 m_parentval[i] = cvmGet( m_pfmap[i], 0, 0 );
00092         }
00093 
00094         // Now find the maximum of m_parentval
00095         vector<double>::iterator itr = max_element(m_parentval.begin(),m_parentval.end());
00096 
00097         // The index of maximum is our network's prediction!
00098         int pos = distance(m_parentval.begin(), itr);
00099 
00100         cvmSet(m_fmap,0,0,(double) pos );
00101 
00102         return m_fmap;
00103 }
00104 
00105 
00114 string CvMaxPlane::toString ( ) 
00115 {
00116         ostringstream xml;
00117         xml << "\t<plane id=\"" << m_id << "\" type=\"max\">" << endl;
00118         
00119         for (int i=0; i <m_pplane.size(); i++)
00120         {
00121                 xml << "\t\t<connection to=\"" << m_pplane[i]->getid() << "\"> " << endl;
00122                 xml << "</connection>" << endl;
00123         }
00124         xml << "\t</plane>" << endl;
00125         
00126         return xml.str();
00127 }
00128 
00131 int CvMaxPlane::setweight(std::vector<double> &weights)
00132 {       
00133         // Just dummy function
00134         return 1;
00135 }

Generated on Fri Aug 3 16:17:27 2007 for ConvNet by  doxygen 1.5.0