added example for benchmark/polynomial

This commit is contained in:
Andreas Meyer 2007-01-11 20:39:20 +00:00
parent 8285a5c49c
commit 9155d47df8
3 changed files with 109 additions and 51 deletions

1
.gitattributes vendored
View File

@ -334,6 +334,7 @@ Benchmark/doc_tex/Benchmark/fig/Conics_14_1.png -text svneol=unset#image/png
Benchmark/doc_tex/Benchmark/fig/classification.eps -text svneol=unset#application/postscript
Benchmark/doc_tex/Benchmark/fig/classification.gif -text svneol=unset#image/gif
Benchmark/doc_tex/Benchmark/fig/classification.pdf -text svneol=unset#application/pdf
Benchmark/examples/Benchmark/polynomial.cpp -text
Benchmark/src/Benchmark/benchmark_lexer.l -text
Boolean_set_operations_2/demo/Boolean_set_operations_2/boolean_operations.vcproj eol=crlf
Boolean_set_operations_2/demo/Boolean_set_operations_2/data/vlsi_1.dxf -text svneol=unset#application/octet-stream

View File

@ -1,51 +0,0 @@
# Created by the script cgal_create_makefile
# This is the makefile for compiling a CGAL application.
#---------------------------------------------------------------------#
# include platform specific settings
#---------------------------------------------------------------------#
# Choose the right include file from the <cgalroot>/make directory.
# CGAL_MAKEFILE = ENTER_YOUR_INCLUDE_MAKEFILE_HERE
include $(CGAL_MAKEFILE)
#---------------------------------------------------------------------#
# compiler flags
#---------------------------------------------------------------------#
CXXFLAGS = \
-I../../include \
$(CGAL_CXXFLAGS) \
$(LONG_NAME_PROBLEM_CXXFLAGS) -O2
#---------------------------------------------------------------------#
# linker flags
#---------------------------------------------------------------------#
LIBPATH = $(CGAL_LIBPATH)
LDFLAGS = $(LONG_NAME_PROBLEM_LDFLAGS) $(CGAL_LDFLAGS)
#---------------------------------------------------------------------#
# target entries
#---------------------------------------------------------------------#
all: check_syntax$(EXE_EXT) simple$(EXE_EXT) leftturn$(EXE_EXT)
check_syntax$(EXE_EXT): check_syntax$(OBJ_EXT)
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)check_syntax $? $(LDFLAGS)
simple$(EXE_EXT): simple$(OBJ_EXT)
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)simple $? $(LDFLAGS)
leftturn$(EXE_EXT): leftturn$(OBJ_EXT)
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)leftturn $? $(LDFLAGS)
clean: check_syntax.clean simple.clean leftturn.clean
#---------------------------------------------------------------------#
# suffix rules
#---------------------------------------------------------------------#
.cpp$(OBJ_EXT):
$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $<

View File

@ -0,0 +1,108 @@
/**************************************************************************
// Copyright (c) 2004 Max-Planck-Institut Saarbruecken (Germany)
// All rights reserved.
//
// This file is part of BenchmarkParser; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; version 2.1 of the License.
// See the file LICENSE.LGPL distributed with BenchmarkParser.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $Source: /KM/projects/ecg/CVS/BMTools/parser/src/check_syntax.C,v $
// $Revision: 34400 $ $Date: 2006-09-20 12:52:41 +0200 (Wed, 20 Sep 2006) $
// $Name: $
//
// Author(s) : Andreas Meyer
**************************************************************************/
#include <iostream>
#include "CGAL/Benchmark/benchmark_format.hpp"
namespace cb = CGAL::benchmark;
struct Polynomial_reader: public cb::Benchmark_visitor {
unsigned char current_variable_name;
bool inside_monom;
bool first_monom;
Polynomial_reader() : inside_monom( false ) {}
virtual void
token_not_handled( std::string s)
{}
// accept everything
virtual void accept_classification( std::string problem,
std::string geom,
std::string clas,
std::string family,
std::string instance,
std::string release) {}
virtual void
begin_polynomial( unsigned int variables,
std::string coeff_typename )
{
std::cout << "begin poly" << std::endl;
//std::cout << "number of variables: " << variables << std::endl;
//std::cout << "typename: " << coeff_typename << std::endl;
first_monom = true;
}
virtual void
end_polynomial()
{
std::cout << std::endl << "end poly" << std::endl;
}
virtual void
begin_monom( std::string coefficient )
{
if( ! first_monom ) {
std::cout << " + ";
}
first_monom = false;
if( coefficient == "1" )
coefficient = "";
else if( coefficient == "-1" )
coefficient = "-";
std::cout << coefficient << "(";
current_variable_name = 'a';
inside_monom = true;
}
virtual void
end_monom()
{
std::cout << ")";
inside_monom = false;
}
// NOTE: this only works for polynoms with type==int
virtual void
accept_integer( std::string s )
{
if( ! inside_monom )
return;
if( s != "0" )
std::cout << current_variable_name << "^" << s;
++current_variable_name;
}
};
int main( int argc, char* argv[] ) {
int exit_status = 0;
if ( argc < 2) {
Polynomial_reader reader;
if ( !cb::benchmark_parse_stream( std::cin, "<cin>", & reader)) {
std::cerr << "input malformed." << std::endl;
exit_status = 1;
}
}
return exit_status;
}