blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M โ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
969d7d98c462d0be3b24e8ebda29e956e9aae3a3 | c90a56e7d7752b041fc5eb38257c5573cef346c6 | /src-macOS/Transfer.cpp | bc53f930361f0a6c6248c72502797b972bc81eb5 | [] | no_license | random-builder/design_cadquery_ocp | a4c572a72699bad52ca5f43f30bb7c15d89072ff | 2af799a9f1b2d81fd39e519b2f73e12b34a14c0a | refs/heads/master | 2021-05-21T23:10:23.833461 | 2020-03-29T15:34:46 | 2020-03-29T15:34:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 56,779 | cpp |
// std lib related includes
#include <tuple>
// pybind 11 related includes
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
namespace py = pybind11;
// Standard Handle
#include <Standard_Handle.hxx>
// includes to resolve forward declarations
#include <Transfer_TransferFailure.hxx>
#include <Transfer_Binder.hxx>
#include <Interface_Check.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Interface_Check.hxx>
#include <Transfer_TransferFailure.hxx>
#include <Interface_EntityIterator.hxx>
#include <Transfer_TransferIterator.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_Protocol.hxx>
#include <Transfer_FinderProcess.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_InterfaceError.hxx>
#include <Transfer_TransientMapper.hxx>
#include <Message_Messenger.hxx>
#include <Transfer_TransferFailure.hxx>
#include <Message_Messenger.hxx>
#include <Transfer_ActorOfProcessForFinder.hxx>
#include <Message_ProgressIndicator.hxx>
#include <Interface_InterfaceError.hxx>
#include <Transfer_TransferFailure.hxx>
#include <Transfer_IteratorOfProcessForFinder.hxx>
#include <Message_Msg.hxx>
#include <Interface_Check.hxx>
#include <Interface_CheckIterator.hxx>
#include <Interface_InterfaceError.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_Protocol.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Transfer_ProcessForFinder.hxx>
#include <Transfer_ActorOfProcessForFinder.hxx>
#include <Transfer_ProcessForFinder.hxx>
#include <Transfer_IteratorOfProcessForFinder.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <Transfer_DataInfo.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Transfer_TransferFailure.hxx>
#include <Transfer_ActorOfTransientProcess.hxx>
#include <Interface_Protocol.hxx>
#include <Interface_Graph.hxx>
#include <Interface_EntityIterator.hxx>
#include <Transfer_ProcessForTransient.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Interface_Check.hxx>
#include <Transfer_TransferFailure.hxx>
#include <Interface_InterfaceError.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_Protocol.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Standard_TypeMismatch.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_HGraph.hxx>
#include <Interface_Graph.hxx>
#include <Message_Messenger.hxx>
#include <Interface_EntityIterator.hxx>
#include <Message_Messenger.hxx>
#include <Transfer_ActorOfProcessForTransient.hxx>
#include <Message_ProgressIndicator.hxx>
#include <Interface_InterfaceError.hxx>
#include <Transfer_TransferFailure.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <Message_Msg.hxx>
#include <Interface_Check.hxx>
#include <Interface_CheckIterator.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Transfer_ResultFromTransient.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Interface_CheckIterator.hxx>
#include <Transfer_Finder.hxx>
#include <Transfer_ProcessForFinder.hxx>
#include <Transfer_FinderProcess.hxx>
#include <Transfer_ProcessForTransient.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <Transfer_ProcessForTransient.hxx>
#include <Transfer_ActorOfProcessForTransient.hxx>
// module includes
#include <Transfer_ActorDispatch.hxx>
#include <Transfer_ActorOfFinderProcess.hxx>
#include <Transfer_ActorOfProcessForFinder.hxx>
#include <Transfer_ActorOfProcessForTransient.hxx>
#include <Transfer_ActorOfTransientProcess.hxx>
#include <Transfer_Binder.hxx>
#include <Transfer_BinderOfTransientInteger.hxx>
#include <Transfer_DataInfo.hxx>
#include <Transfer_DispatchControl.hxx>
#include <Transfer_Finder.hxx>
#include <Transfer_FinderProcess.hxx>
#include <Transfer_FindHasher.hxx>
#include <Transfer_HSequenceOfBinder.hxx>
#include <Transfer_HSequenceOfFinder.hxx>
#include <Transfer_IteratorOfProcessForFinder.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <Transfer_MapContainer.hxx>
#include <Transfer_MultipleBinder.hxx>
#include <Transfer_ProcessForFinder.hxx>
#include <Transfer_ProcessForTransient.hxx>
#include <Transfer_ResultFromModel.hxx>
#include <Transfer_ResultFromTransient.hxx>
#include <Transfer_SequenceOfBinder.hxx>
#include <Transfer_SequenceOfFinder.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <Transfer_StatusExec.hxx>
#include <Transfer_StatusResult.hxx>
#include <Transfer_TransferDeadLoop.hxx>
#include <Transfer_TransferDispatch.hxx>
#include <Transfer_TransferFailure.hxx>
#include <Transfer_TransferInput.hxx>
#include <Transfer_TransferIterator.hxx>
#include <Transfer_TransferMapOfProcessForFinder.hxx>
#include <Transfer_TransferMapOfProcessForTransient.hxx>
#include <Transfer_TransferOutput.hxx>
#include <Transfer_TransientListBinder.hxx>
#include <Transfer_TransientMapper.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Transfer_UndefMode.hxx>
#include <Transfer_VoidBinder.hxx>
// template related includes
// ./opencascade/Transfer_SequenceOfBinder.hxx
#include "NCollection_tmpl.hxx"
// ./opencascade/Transfer_SequenceOfFinder.hxx
#include "NCollection_tmpl.hxx"
// user-defined pre
#include "OCP_specific.inc"
// user-defined inclusion per module
// Module definiiton
void register_Transfer(py::module &main_module) {
py::module m = static_cast<py::module>(main_module.attr("Transfer"));
//Python trampoline classes
class Py_Transfer_Binder : public Transfer_Binder{
public:
using Transfer_Binder::Transfer_Binder;
// public pure virtual
opencascade::handle<Standard_Type> ResultType() const override { PYBIND11_OVERLOAD_PURE(opencascade::handle<Standard_Type>,Transfer_Binder,ResultType,) };
Standard_CString ResultTypeName() const override { PYBIND11_OVERLOAD_PURE(Standard_CString,Transfer_Binder,ResultTypeName,) };
// protected pure virtual
// private pure virtual
};
class Py_Transfer_Finder : public Transfer_Finder{
public:
using Transfer_Finder::Transfer_Finder;
// public pure virtual
Standard_Boolean Equates(const opencascade::handle<Transfer_Finder> & other) const override { PYBIND11_OVERLOAD_PURE(Standard_Boolean,Transfer_Finder,Equates,other) };
// protected pure virtual
// private pure virtual
};
// classes
static_cast<py::class_<Transfer_ActorOfProcessForFinder ,opencascade::handle<Transfer_ActorOfProcessForFinder> , Standard_Transient>>(m.attr("Transfer_ActorOfProcessForFinder"))
// constructors
// custom constructors
// methods
.def("Recognize",
(Standard_Boolean (Transfer_ActorOfProcessForFinder::*)( const opencascade::handle<Transfer_Finder> & ) ) static_cast<Standard_Boolean (Transfer_ActorOfProcessForFinder::*)( const opencascade::handle<Transfer_Finder> & ) >(&Transfer_ActorOfProcessForFinder::Recognize),
R"#(Prerequesite for Transfer : the method Transfer is called on a starting object only if Recognize has returned True on it This allows to define a list of Actors, each one processing a definite kind of data TransferProcess calls Recognize on each one before calling Transfer. But even if Recognize has returned True, Transfer can reject by returning a Null Binder (afterwards rejection), the next actor is then invoked)#" , py::arg("start"))
.def("Transferring",
(opencascade::handle<Transfer_Binder> (Transfer_ActorOfProcessForFinder::*)( const opencascade::handle<Transfer_Finder> & , const opencascade::handle<Transfer_ProcessForFinder> & ) ) static_cast<opencascade::handle<Transfer_Binder> (Transfer_ActorOfProcessForFinder::*)( const opencascade::handle<Transfer_Finder> & , const opencascade::handle<Transfer_ProcessForFinder> & ) >(&Transfer_ActorOfProcessForFinder::Transferring),
R"#(Specific action of Transfer. The Result is stored in the returned Binder, or a Null Handle for "No result" (Default defined as doing nothing; should be deffered) "mutable" allows the Actor to record intermediate information, in addition to those of TransferProcess)#" , py::arg("start"), py::arg("TP"))
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_ActorOfProcessForFinder::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_ActorOfProcessForFinder::*)() const>(&Transfer_ActorOfProcessForFinder::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_ActorOfProcessForFinder::get_type_name),
R"#(None)#" )
.def_static("get_type_descriptor_s",
(const opencascade::handle<Standard_Type> & (*)() ) static_cast<const opencascade::handle<Standard_Type> & (*)() >(&Transfer_ActorOfProcessForFinder::get_type_descriptor),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_ActorOfProcessForTransient ,opencascade::handle<Transfer_ActorOfProcessForTransient> , Standard_Transient>>(m.attr("Transfer_ActorOfProcessForTransient"))
// constructors
// custom constructors
// methods
.def("Recognize",
(Standard_Boolean (Transfer_ActorOfProcessForTransient::*)( const opencascade::handle<Standard_Transient> & ) ) static_cast<Standard_Boolean (Transfer_ActorOfProcessForTransient::*)( const opencascade::handle<Standard_Transient> & ) >(&Transfer_ActorOfProcessForTransient::Recognize),
R"#(Prerequesite for Transfer : the method Transfer is called on a starting object only if Recognize has returned True on it This allows to define a list of Actors, each one processing a definite kind of data TransferProcess calls Recognize on each one before calling Transfer. But even if Recognize has returned True, Transfer can reject by returning a Null Binder (afterwards rejection), the next actor is then invoked)#" , py::arg("start"))
.def("Transferring",
(opencascade::handle<Transfer_Binder> (Transfer_ActorOfProcessForTransient::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Transfer_ProcessForTransient> & ) ) static_cast<opencascade::handle<Transfer_Binder> (Transfer_ActorOfProcessForTransient::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Transfer_ProcessForTransient> & ) >(&Transfer_ActorOfProcessForTransient::Transferring),
R"#(Specific action of Transfer. The Result is stored in the returned Binder, or a Null Handle for "No result" (Default defined as doing nothing; should be deffered) "mutable" allows the Actor to record intermediate information, in addition to those of TransferProcess)#" , py::arg("start"), py::arg("TP"))
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_ActorOfProcessForTransient::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_ActorOfProcessForTransient::*)() const>(&Transfer_ActorOfProcessForTransient::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_ActorOfProcessForTransient::get_type_name),
R"#(None)#" )
.def_static("get_type_descriptor_s",
(const opencascade::handle<Standard_Type> & (*)() ) static_cast<const opencascade::handle<Standard_Type> & (*)() >(&Transfer_ActorOfProcessForTransient::get_type_descriptor),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_Binder ,opencascade::handle<Transfer_Binder>,Py_Transfer_Binder , Standard_Transient>>(m.attr("Transfer_Binder"))
// constructors
// custom constructors
// methods
.def("IsMultiple",
(Standard_Boolean (Transfer_Binder::*)() const) static_cast<Standard_Boolean (Transfer_Binder::*)() const>(&Transfer_Binder::IsMultiple),
R"#(Returns True if a Binder has several results, either by itself or because it has next results Can be defined by sub-classes.)#" )
.def("ResultType",
(opencascade::handle<Standard_Type> (Transfer_Binder::*)() const) static_cast<opencascade::handle<Standard_Type> (Transfer_Binder::*)() const>(&Transfer_Binder::ResultType),
R"#(Returns the Type which characterizes the Result (if known))#" )
.def("ResultTypeName",
(Standard_CString (Transfer_Binder::*)() const) static_cast<Standard_CString (Transfer_Binder::*)() const>(&Transfer_Binder::ResultTypeName),
R"#(Returns the Name of the Type which characterizes the Result Can be returned even if ResultType itself is unknown)#" )
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_Binder::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_Binder::*)() const>(&Transfer_Binder::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_Binder::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
// default constructor
register_default_constructor<Transfer_DataInfo , shared_ptr<Transfer_DataInfo>>(m,"Transfer_DataInfo");
static_cast<py::class_<Transfer_DataInfo , shared_ptr<Transfer_DataInfo> >>(m.attr("Transfer_DataInfo"))
// constructors
// custom constructors
// methods
// methods using call by reference i.s.o. return
// static methods
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_DispatchControl ,opencascade::handle<Transfer_DispatchControl> , Interface_CopyControl>>(m.attr("Transfer_DispatchControl"))
// constructors
// custom constructors
// methods
.def("Clear",
(void (Transfer_DispatchControl::*)() ) static_cast<void (Transfer_DispatchControl::*)() >(&Transfer_DispatchControl::Clear),
R"#(Clears the List of Copied Results)#" )
.def("Bind",
(void (Transfer_DispatchControl::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Standard_Transient> & ) ) static_cast<void (Transfer_DispatchControl::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Standard_Transient> & ) >(&Transfer_DispatchControl::Bind),
R"#(Binds a (Transient) Result to a (Transient) Starting Entity)#" , py::arg("ent"), py::arg("res"))
.def("Search",
(Standard_Boolean (Transfer_DispatchControl::*)( const opencascade::handle<Standard_Transient> & , opencascade::handle<Standard_Transient> & ) const) static_cast<Standard_Boolean (Transfer_DispatchControl::*)( const opencascade::handle<Standard_Transient> & , opencascade::handle<Standard_Transient> & ) const>(&Transfer_DispatchControl::Search),
R"#(Searches for the Result bound to a Starting Entity If Found, returns True and fills <res> Else, returns False and nullifies <res>)#" , py::arg("ent"), py::arg("res"))
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_DispatchControl::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_DispatchControl::*)() const>(&Transfer_DispatchControl::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_DispatchControl::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
// default constructor
register_default_constructor<Transfer_FindHasher , shared_ptr<Transfer_FindHasher>>(m,"Transfer_FindHasher");
static_cast<py::class_<Transfer_FindHasher , shared_ptr<Transfer_FindHasher> >>(m.attr("Transfer_FindHasher"))
// constructors
// custom constructors
// methods
// methods using call by reference i.s.o. return
// static methods
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_Finder ,opencascade::handle<Transfer_Finder>,Py_Transfer_Finder , Standard_Transient>>(m.attr("Transfer_Finder"))
// constructors
// custom constructors
// methods
.def("Equates",
(Standard_Boolean (Transfer_Finder::*)( const opencascade::handle<Transfer_Finder> & ) const) static_cast<Standard_Boolean (Transfer_Finder::*)( const opencascade::handle<Transfer_Finder> & ) const>(&Transfer_Finder::Equates),
R"#(Specific testof equallity : to be defined by each sub-class, must be False if Finders have not the same true Type, else their contents must be compared)#" , py::arg("other"))
.def("ValueType",
(opencascade::handle<Standard_Type> (Transfer_Finder::*)() const) static_cast<opencascade::handle<Standard_Type> (Transfer_Finder::*)() const>(&Transfer_Finder::ValueType),
R"#(Returns the Type of the Value. By default, returns the DynamicType of <me>, but can be redefined)#" )
.def("ValueTypeName",
(Standard_CString (Transfer_Finder::*)() const) static_cast<Standard_CString (Transfer_Finder::*)() const>(&Transfer_Finder::ValueTypeName),
R"#(Returns the name of the Type of the Value. Default is name of ValueType, unless it is for a non-handled object)#" )
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_Finder::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_Finder::*)() const>(&Transfer_Finder::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_Finder::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_HSequenceOfBinder ,opencascade::handle<Transfer_HSequenceOfBinder> , Transfer_SequenceOfBinder, Standard_Transient>>(m.attr("Transfer_HSequenceOfBinder"))
// constructors
.def(py::init< >() )
.def(py::init< const NCollection_Sequence<opencascade::handle<Transfer_Binder> > & >() , py::arg("theOther") )
// custom constructors
// methods
.def("Sequence",
(const Transfer_SequenceOfBinder & (Transfer_HSequenceOfBinder::*)() const) static_cast<const Transfer_SequenceOfBinder & (Transfer_HSequenceOfBinder::*)() const>(&Transfer_HSequenceOfBinder::Sequence),
R"#(None)#" )
.def("Append",
(void (Transfer_HSequenceOfBinder::*)( const opencascade::handle<Transfer_Binder> & ) ) static_cast<void (Transfer_HSequenceOfBinder::*)( const opencascade::handle<Transfer_Binder> & ) >(&Transfer_HSequenceOfBinder::Append),
R"#(None)#" , py::arg("theItem"))
.def("Append",
(void (Transfer_HSequenceOfBinder::*)( NCollection_Sequence<opencascade::handle<Transfer_Binder> > & ) ) static_cast<void (Transfer_HSequenceOfBinder::*)( NCollection_Sequence<opencascade::handle<Transfer_Binder> > & ) >(&Transfer_HSequenceOfBinder::Append),
R"#(None)#" , py::arg("theSequence"))
.def("ChangeSequence",
(Transfer_SequenceOfBinder & (Transfer_HSequenceOfBinder::*)() ) static_cast<Transfer_SequenceOfBinder & (Transfer_HSequenceOfBinder::*)() >(&Transfer_HSequenceOfBinder::ChangeSequence),
R"#(None)#" )
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_HSequenceOfBinder::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_HSequenceOfBinder::*)() const>(&Transfer_HSequenceOfBinder::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_HSequenceOfBinder::get_type_name),
R"#(None)#" )
.def_static("get_type_descriptor_s",
(const opencascade::handle<Standard_Type> & (*)() ) static_cast<const opencascade::handle<Standard_Type> & (*)() >(&Transfer_HSequenceOfBinder::get_type_descriptor),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_HSequenceOfFinder ,opencascade::handle<Transfer_HSequenceOfFinder> , Transfer_SequenceOfFinder, Standard_Transient>>(m.attr("Transfer_HSequenceOfFinder"))
// constructors
.def(py::init< >() )
.def(py::init< const NCollection_Sequence<opencascade::handle<Transfer_Finder> > & >() , py::arg("theOther") )
// custom constructors
// methods
.def("Sequence",
(const Transfer_SequenceOfFinder & (Transfer_HSequenceOfFinder::*)() const) static_cast<const Transfer_SequenceOfFinder & (Transfer_HSequenceOfFinder::*)() const>(&Transfer_HSequenceOfFinder::Sequence),
R"#(None)#" )
.def("Append",
(void (Transfer_HSequenceOfFinder::*)( const opencascade::handle<Transfer_Finder> & ) ) static_cast<void (Transfer_HSequenceOfFinder::*)( const opencascade::handle<Transfer_Finder> & ) >(&Transfer_HSequenceOfFinder::Append),
R"#(None)#" , py::arg("theItem"))
.def("Append",
(void (Transfer_HSequenceOfFinder::*)( NCollection_Sequence<opencascade::handle<Transfer_Finder> > & ) ) static_cast<void (Transfer_HSequenceOfFinder::*)( NCollection_Sequence<opencascade::handle<Transfer_Finder> > & ) >(&Transfer_HSequenceOfFinder::Append),
R"#(None)#" , py::arg("theSequence"))
.def("ChangeSequence",
(Transfer_SequenceOfFinder & (Transfer_HSequenceOfFinder::*)() ) static_cast<Transfer_SequenceOfFinder & (Transfer_HSequenceOfFinder::*)() >(&Transfer_HSequenceOfFinder::ChangeSequence),
R"#(None)#" )
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_HSequenceOfFinder::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_HSequenceOfFinder::*)() const>(&Transfer_HSequenceOfFinder::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_HSequenceOfFinder::get_type_name),
R"#(None)#" )
.def_static("get_type_descriptor_s",
(const opencascade::handle<Standard_Type> & (*)() ) static_cast<const opencascade::handle<Standard_Type> & (*)() >(&Transfer_HSequenceOfFinder::get_type_descriptor),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_MapContainer ,opencascade::handle<Transfer_MapContainer> , Standard_Transient>>(m.attr("Transfer_MapContainer"))
// constructors
// custom constructors
// methods
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_MapContainer::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_MapContainer::*)() const>(&Transfer_MapContainer::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_MapContainer::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_ProcessForFinder ,opencascade::handle<Transfer_ProcessForFinder> , Standard_Transient>>(m.attr("Transfer_ProcessForFinder"))
// constructors
// custom constructors
// methods
.def("PrintTrace",
(void (Transfer_ProcessForFinder::*)( const opencascade::handle<Transfer_Finder> & , const opencascade::handle<Message_Messenger> & ) const) static_cast<void (Transfer_ProcessForFinder::*)( const opencascade::handle<Transfer_Finder> & , const opencascade::handle<Message_Messenger> & ) const>(&Transfer_ProcessForFinder::PrintTrace),
R"#(Prints a short information on a starting object. By default prints its Dynamic Type. Can be redefined)#" , py::arg("start"), py::arg("S"))
.def("CheckNum",
(Standard_Integer (Transfer_ProcessForFinder::*)( const opencascade::handle<Transfer_Finder> & ) const) static_cast<Standard_Integer (Transfer_ProcessForFinder::*)( const opencascade::handle<Transfer_Finder> & ) const>(&Transfer_ProcessForFinder::CheckNum),
R"#(Computes a number to be associated to a starting object in a check or a check-list By default, returns 0; can be redefined)#" , py::arg("start"))
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_ProcessForFinder::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_ProcessForFinder::*)() const>(&Transfer_ProcessForFinder::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_ProcessForFinder::get_type_name),
R"#(None)#" )
.def_static("get_type_descriptor_s",
(const opencascade::handle<Standard_Type> & (*)() ) static_cast<const opencascade::handle<Standard_Type> & (*)() >(&Transfer_ProcessForFinder::get_type_descriptor),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_ProcessForTransient ,opencascade::handle<Transfer_ProcessForTransient> , Standard_Transient>>(m.attr("Transfer_ProcessForTransient"))
// constructors
// custom constructors
// methods
.def("PrintTrace",
(void (Transfer_ProcessForTransient::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Message_Messenger> & ) const) static_cast<void (Transfer_ProcessForTransient::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Message_Messenger> & ) const>(&Transfer_ProcessForTransient::PrintTrace),
R"#(Prints a short information on a starting object. By default prints its Dynamic Type. Can be redefined)#" , py::arg("start"), py::arg("S"))
.def("CheckNum",
(Standard_Integer (Transfer_ProcessForTransient::*)( const opencascade::handle<Standard_Transient> & ) const) static_cast<Standard_Integer (Transfer_ProcessForTransient::*)( const opencascade::handle<Standard_Transient> & ) const>(&Transfer_ProcessForTransient::CheckNum),
R"#(Computes a number to be associated to a starting object in a check or a check-list By default, returns 0; can be redefined)#" , py::arg("start"))
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_ProcessForTransient::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_ProcessForTransient::*)() const>(&Transfer_ProcessForTransient::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_ProcessForTransient::get_type_name),
R"#(None)#" )
.def_static("get_type_descriptor_s",
(const opencascade::handle<Standard_Type> & (*)() ) static_cast<const opencascade::handle<Standard_Type> & (*)() >(&Transfer_ProcessForTransient::get_type_descriptor),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_ResultFromModel ,opencascade::handle<Transfer_ResultFromModel> , Standard_Transient>>(m.attr("Transfer_ResultFromModel"))
// constructors
// custom constructors
// methods
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_ResultFromModel::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_ResultFromModel::*)() const>(&Transfer_ResultFromModel::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_ResultFromModel::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_ResultFromTransient ,opencascade::handle<Transfer_ResultFromTransient> , Standard_Transient>>(m.attr("Transfer_ResultFromTransient"))
// constructors
// custom constructors
// methods
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_ResultFromTransient::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_ResultFromTransient::*)() const>(&Transfer_ResultFromTransient::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_ResultFromTransient::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_TransferDispatch , shared_ptr<Transfer_TransferDispatch> , Interface_CopyTool>>(m.attr("Transfer_TransferDispatch"))
// constructors
// custom constructors
// methods
.def("Copy",
(Standard_Boolean (Transfer_TransferDispatch::*)( const opencascade::handle<Standard_Transient> & , opencascade::handle<Standard_Transient> & , const Standard_Boolean , const Standard_Boolean ) ) static_cast<Standard_Boolean (Transfer_TransferDispatch::*)( const opencascade::handle<Standard_Transient> & , opencascade::handle<Standard_Transient> & , const Standard_Boolean , const Standard_Boolean ) >(&Transfer_TransferDispatch::Copy),
R"#(Copies an Entity by calling the method Transferring from the TransferProcess. If this called produces a Null Binder, then the standard, inherited Copy is called)#" , py::arg("entfrom"), py::arg("entto"), py::arg("mapped"), py::arg("errstat"))
// methods using call by reference i.s.o. return
// static methods
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_TransferInput , shared_ptr<Transfer_TransferInput> >>(m.attr("Transfer_TransferInput"))
// constructors
// custom constructors
// methods
// methods using call by reference i.s.o. return
// static methods
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_TransferIterator , shared_ptr<Transfer_TransferIterator> >>(m.attr("Transfer_TransferIterator"))
// constructors
// custom constructors
// methods
// methods using call by reference i.s.o. return
// static methods
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_TransferOutput , shared_ptr<Transfer_TransferOutput> >>(m.attr("Transfer_TransferOutput"))
// constructors
// custom constructors
// methods
// methods using call by reference i.s.o. return
// static methods
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_ActorOfFinderProcess ,opencascade::handle<Transfer_ActorOfFinderProcess> , Transfer_ActorOfProcessForFinder>>(m.attr("Transfer_ActorOfFinderProcess"))
// constructors
// custom constructors
// methods
.def("Transferring",
(opencascade::handle<Transfer_Binder> (Transfer_ActorOfFinderProcess::*)( const opencascade::handle<Transfer_Finder> & , const opencascade::handle<Transfer_ProcessForFinder> & ) ) static_cast<opencascade::handle<Transfer_Binder> (Transfer_ActorOfFinderProcess::*)( const opencascade::handle<Transfer_Finder> & , const opencascade::handle<Transfer_ProcessForFinder> & ) >(&Transfer_ActorOfFinderProcess::Transferring),
R"#(None)#" , py::arg("start"), py::arg("TP"))
.def("Transfer",
(opencascade::handle<Transfer_Binder> (Transfer_ActorOfFinderProcess::*)( const opencascade::handle<Transfer_Finder> & , const opencascade::handle<Transfer_FinderProcess> & ) ) static_cast<opencascade::handle<Transfer_Binder> (Transfer_ActorOfFinderProcess::*)( const opencascade::handle<Transfer_Finder> & , const opencascade::handle<Transfer_FinderProcess> & ) >(&Transfer_ActorOfFinderProcess::Transfer),
R"#(None)#" , py::arg("start"), py::arg("TP"))
.def("TransferTransient",
(opencascade::handle<Standard_Transient> (Transfer_ActorOfFinderProcess::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Transfer_FinderProcess> & ) ) static_cast<opencascade::handle<Standard_Transient> (Transfer_ActorOfFinderProcess::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Transfer_FinderProcess> & ) >(&Transfer_ActorOfFinderProcess::TransferTransient),
R"#(None)#" , py::arg("start"), py::arg("TP"))
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_ActorOfFinderProcess::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_ActorOfFinderProcess::*)() const>(&Transfer_ActorOfFinderProcess::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_ActorOfFinderProcess::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_ActorOfTransientProcess ,opencascade::handle<Transfer_ActorOfTransientProcess> , Transfer_ActorOfProcessForTransient>>(m.attr("Transfer_ActorOfTransientProcess"))
// constructors
// custom constructors
// methods
.def("Transferring",
(opencascade::handle<Transfer_Binder> (Transfer_ActorOfTransientProcess::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Transfer_ProcessForTransient> & ) ) static_cast<opencascade::handle<Transfer_Binder> (Transfer_ActorOfTransientProcess::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Transfer_ProcessForTransient> & ) >(&Transfer_ActorOfTransientProcess::Transferring),
R"#(None)#" , py::arg("start"), py::arg("TP"))
.def("Transfer",
(opencascade::handle<Transfer_Binder> (Transfer_ActorOfTransientProcess::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Transfer_TransientProcess> & ) ) static_cast<opencascade::handle<Transfer_Binder> (Transfer_ActorOfTransientProcess::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Transfer_TransientProcess> & ) >(&Transfer_ActorOfTransientProcess::Transfer),
R"#(None)#" , py::arg("start"), py::arg("TP"))
.def("TransferTransient",
(opencascade::handle<Standard_Transient> (Transfer_ActorOfTransientProcess::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Transfer_TransientProcess> & ) ) static_cast<opencascade::handle<Standard_Transient> (Transfer_ActorOfTransientProcess::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Transfer_TransientProcess> & ) >(&Transfer_ActorOfTransientProcess::TransferTransient),
R"#(None)#" , py::arg("start"), py::arg("TP"))
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_ActorOfTransientProcess::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_ActorOfTransientProcess::*)() const>(&Transfer_ActorOfTransientProcess::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_ActorOfTransientProcess::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_FinderProcess ,opencascade::handle<Transfer_FinderProcess> , Transfer_ProcessForFinder>>(m.attr("Transfer_FinderProcess"))
// constructors
// custom constructors
// methods
.def("PrintTrace",
(void (Transfer_FinderProcess::*)( const opencascade::handle<Transfer_Finder> & , const opencascade::handle<Message_Messenger> & ) const) static_cast<void (Transfer_FinderProcess::*)( const opencascade::handle<Transfer_Finder> & , const opencascade::handle<Message_Messenger> & ) const>(&Transfer_FinderProcess::PrintTrace),
R"#(Specific printing to trace a Finder (by its method ValueType))#" , py::arg("start"), py::arg("S"))
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_FinderProcess::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_FinderProcess::*)() const>(&Transfer_FinderProcess::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_FinderProcess::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_IteratorOfProcessForFinder , shared_ptr<Transfer_IteratorOfProcessForFinder> , Transfer_TransferIterator>>(m.attr("Transfer_IteratorOfProcessForFinder"))
// constructors
// custom constructors
// methods
// methods using call by reference i.s.o. return
// static methods
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_IteratorOfProcessForTransient , shared_ptr<Transfer_IteratorOfProcessForTransient> , Transfer_TransferIterator>>(m.attr("Transfer_IteratorOfProcessForTransient"))
// constructors
// custom constructors
// methods
// methods using call by reference i.s.o. return
// static methods
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_MultipleBinder ,opencascade::handle<Transfer_MultipleBinder> , Transfer_Binder>>(m.attr("Transfer_MultipleBinder"))
// constructors
// custom constructors
// methods
.def("IsMultiple",
(Standard_Boolean (Transfer_MultipleBinder::*)() const) static_cast<Standard_Boolean (Transfer_MultipleBinder::*)() const>(&Transfer_MultipleBinder::IsMultiple),
R"#(Returns True if a starting object is bound with SEVERAL results : Here, returns allways True)#" )
.def("ResultType",
(opencascade::handle<Standard_Type> (Transfer_MultipleBinder::*)() const) static_cast<opencascade::handle<Standard_Type> (Transfer_MultipleBinder::*)() const>(&Transfer_MultipleBinder::ResultType),
R"#(Returns the Type permitted for Results, i.e. here Transient)#" )
.def("ResultTypeName",
(Standard_CString (Transfer_MultipleBinder::*)() const) static_cast<Standard_CString (Transfer_MultipleBinder::*)() const>(&Transfer_MultipleBinder::ResultTypeName),
R"#(Returns the Name of the Type which characterizes the Result Here, returns "(list)")#" )
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_MultipleBinder::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_MultipleBinder::*)() const>(&Transfer_MultipleBinder::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_MultipleBinder::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_SimpleBinderOfTransient ,opencascade::handle<Transfer_SimpleBinderOfTransient> , Transfer_Binder>>(m.attr("Transfer_SimpleBinderOfTransient"))
// constructors
// custom constructors
// methods
.def("ResultType",
(opencascade::handle<Standard_Type> (Transfer_SimpleBinderOfTransient::*)() const) static_cast<opencascade::handle<Standard_Type> (Transfer_SimpleBinderOfTransient::*)() const>(&Transfer_SimpleBinderOfTransient::ResultType),
R"#(Returns the Effective (Dynamic) Type of the Result (Standard_Transient if no Result is defined))#" )
.def("ResultTypeName",
(Standard_CString (Transfer_SimpleBinderOfTransient::*)() const) static_cast<Standard_CString (Transfer_SimpleBinderOfTransient::*)() const>(&Transfer_SimpleBinderOfTransient::ResultTypeName),
R"#(Returns the Effective Name of (Dynamic) Type of the Result (void) if no result is defined)#" )
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_SimpleBinderOfTransient::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_SimpleBinderOfTransient::*)() const>(&Transfer_SimpleBinderOfTransient::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_SimpleBinderOfTransient::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_TransientListBinder ,opencascade::handle<Transfer_TransientListBinder> , Transfer_Binder>>(m.attr("Transfer_TransientListBinder"))
// constructors
// custom constructors
// methods
.def("IsMultiple",
(Standard_Boolean (Transfer_TransientListBinder::*)() const) static_cast<Standard_Boolean (Transfer_TransientListBinder::*)() const>(&Transfer_TransientListBinder::IsMultiple),
R"#(None)#" )
.def("ResultType",
(opencascade::handle<Standard_Type> (Transfer_TransientListBinder::*)() const) static_cast<opencascade::handle<Standard_Type> (Transfer_TransientListBinder::*)() const>(&Transfer_TransientListBinder::ResultType),
R"#(None)#" )
.def("ResultTypeName",
(Standard_CString (Transfer_TransientListBinder::*)() const) static_cast<Standard_CString (Transfer_TransientListBinder::*)() const>(&Transfer_TransientListBinder::ResultTypeName),
R"#(None)#" )
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_TransientListBinder::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_TransientListBinder::*)() const>(&Transfer_TransientListBinder::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_TransientListBinder::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_TransientMapper ,opencascade::handle<Transfer_TransientMapper> , Transfer_Finder>>(m.attr("Transfer_TransientMapper"))
// constructors
// custom constructors
// methods
.def("Equates",
(Standard_Boolean (Transfer_TransientMapper::*)( const opencascade::handle<Transfer_Finder> & ) const) static_cast<Standard_Boolean (Transfer_TransientMapper::*)( const opencascade::handle<Transfer_Finder> & ) const>(&Transfer_TransientMapper::Equates),
R"#(Specific testof equallity : defined as False if <other> has not the same true Type, else contents are compared (by C++ operator ==))#" , py::arg("other"))
.def("ValueType",
(opencascade::handle<Standard_Type> (Transfer_TransientMapper::*)() const) static_cast<opencascade::handle<Standard_Type> (Transfer_TransientMapper::*)() const>(&Transfer_TransientMapper::ValueType),
R"#(Returns the Type of the Value. By default, returns the DynamicType of <me>, but can be redefined)#" )
.def("ValueTypeName",
(Standard_CString (Transfer_TransientMapper::*)() const) static_cast<Standard_CString (Transfer_TransientMapper::*)() const>(&Transfer_TransientMapper::ValueTypeName),
R"#(Returns the name of the Type of the Value. Default is name of ValueType, unless it is for a non-handled object)#" )
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_TransientMapper::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_TransientMapper::*)() const>(&Transfer_TransientMapper::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_TransientMapper::get_type_name),
R"#(None)#" )
.def_static("get_type_descriptor_s",
(const opencascade::handle<Standard_Type> & (*)() ) static_cast<const opencascade::handle<Standard_Type> & (*)() >(&Transfer_TransientMapper::get_type_descriptor),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_TransientProcess ,opencascade::handle<Transfer_TransientProcess> , Transfer_ProcessForTransient>>(m.attr("Transfer_TransientProcess"))
// constructors
// custom constructors
// methods
.def("PrintTrace",
(void (Transfer_TransientProcess::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Message_Messenger> & ) const) static_cast<void (Transfer_TransientProcess::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Message_Messenger> & ) const>(&Transfer_TransientProcess::PrintTrace),
R"#(Specific printing to trace an entity : prints label and type (if model is set))#" , py::arg("start"), py::arg("S"))
.def("CheckNum",
(Standard_Integer (Transfer_TransientProcess::*)( const opencascade::handle<Standard_Transient> & ) const) static_cast<Standard_Integer (Transfer_TransientProcess::*)( const opencascade::handle<Standard_Transient> & ) const>(&Transfer_TransientProcess::CheckNum),
R"#(Specific number of a starting object for check-list : Number in model)#" , py::arg("ent"))
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_TransientProcess::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_TransientProcess::*)() const>(&Transfer_TransientProcess::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_TransientProcess::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_VoidBinder ,opencascade::handle<Transfer_VoidBinder> , Transfer_Binder>>(m.attr("Transfer_VoidBinder"))
// constructors
// custom constructors
// methods
.def("ResultType",
(opencascade::handle<Standard_Type> (Transfer_VoidBinder::*)() const) static_cast<opencascade::handle<Standard_Type> (Transfer_VoidBinder::*)() const>(&Transfer_VoidBinder::ResultType),
R"#(while a VoidBinder admits no Result, its ResultType returns the type of <me>)#" )
.def("ResultTypeName",
(Standard_CString (Transfer_VoidBinder::*)() const) static_cast<Standard_CString (Transfer_VoidBinder::*)() const>(&Transfer_VoidBinder::ResultTypeName),
R"#(Returns "(void)")#" )
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_VoidBinder::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_VoidBinder::*)() const>(&Transfer_VoidBinder::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_VoidBinder::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_ActorDispatch ,opencascade::handle<Transfer_ActorDispatch> , Transfer_ActorOfTransientProcess>>(m.attr("Transfer_ActorDispatch"))
// constructors
// custom constructors
// methods
.def("Transfer",
(opencascade::handle<Transfer_Binder> (Transfer_ActorDispatch::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Transfer_TransientProcess> & ) ) static_cast<opencascade::handle<Transfer_Binder> (Transfer_ActorDispatch::*)( const opencascade::handle<Standard_Transient> & , const opencascade::handle<Transfer_TransientProcess> & ) >(&Transfer_ActorDispatch::Transfer),
R"#(Specific action : it calls the method Transfer from CopyTool i.e. the general service Copy, then returns the Binder produced by the TransientProcess)#" , py::arg("start"), py::arg("TP"))
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_ActorDispatch::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_ActorDispatch::*)() const>(&Transfer_ActorDispatch::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_ActorDispatch::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
static_cast<py::class_<Transfer_BinderOfTransientInteger ,opencascade::handle<Transfer_BinderOfTransientInteger> , Transfer_SimpleBinderOfTransient>>(m.attr("Transfer_BinderOfTransientInteger"))
// constructors
// custom constructors
// methods
.def("DynamicType",
(const opencascade::handle<Standard_Type> & (Transfer_BinderOfTransientInteger::*)() const) static_cast<const opencascade::handle<Standard_Type> & (Transfer_BinderOfTransientInteger::*)() const>(&Transfer_BinderOfTransientInteger::DynamicType),
R"#(None)#" )
// methods using call by reference i.s.o. return
// static methods
.def_static("get_type_name_s",
(const char * (*)() ) static_cast<const char * (*)() >(&Transfer_BinderOfTransientInteger::get_type_name),
R"#(None)#" )
// static methods using call by reference i.s.o. return
// operators
// additional methods and static methods
;
// functions
// ./opencascade/Transfer_MultipleBinder.hxx
// ./opencascade/Transfer_TransferMapOfProcessForTransient.hxx
// ./opencascade/Transfer_TransferMapOfProcessForFinder.hxx
// ./opencascade/Transfer_StatusExec.hxx
// ./opencascade/Transfer_ResultFromTransient.hxx
// ./opencascade/Transfer_TransferDeadLoop.hxx
// ./opencascade/Transfer_TransferIterator.hxx
// ./opencascade/Transfer_Finder.hxx
// ./opencascade/Transfer_UndefMode.hxx
// ./opencascade/Transfer_DataInfo.hxx
// ./opencascade/Transfer_TransferInput.hxx
// ./opencascade/Transfer_HSequenceOfBinder.hxx
// ./opencascade/Transfer_DispatchControl.hxx
// ./opencascade/Transfer_FinderProcess.hxx
// ./opencascade/Transfer_SimpleBinderOfTransient.hxx
// ./opencascade/Transfer_ProcessForFinder.hxx
// ./opencascade/Transfer_ActorDispatch.hxx
// ./opencascade/Transfer_IteratorOfProcessForFinder.hxx
// ./opencascade/Transfer_SequenceOfBinder.hxx
// ./opencascade/Transfer_ActorOfProcessForFinder.hxx
// ./opencascade/Transfer_SequenceOfFinder.hxx
// ./opencascade/Transfer_TransientMapper.hxx
// ./opencascade/Transfer_TransferOutput.hxx
// ./opencascade/Transfer_BinderOfTransientInteger.hxx
// ./opencascade/Transfer_MapContainer.hxx
// ./opencascade/Transfer_ActorOfTransientProcess.hxx
// ./opencascade/Transfer_Binder.hxx
// ./opencascade/Transfer_TransferDispatch.hxx
// ./opencascade/Transfer_TransientListBinder.hxx
// ./opencascade/Transfer_TransferFailure.hxx
// ./opencascade/Transfer_TransientProcess.hxx
// ./opencascade/Transfer_ProcessForTransient.hxx
// ./opencascade/Transfer_HSequenceOfFinder.hxx
// ./opencascade/Transfer_ResultFromModel.hxx
// ./opencascade/Transfer_FindHasher.hxx
// ./opencascade/Transfer_ActorOfFinderProcess.hxx
// ./opencascade/Transfer_VoidBinder.hxx
// ./opencascade/Transfer_ActorOfProcessForTransient.hxx
// ./opencascade/Transfer_IteratorOfProcessForTransient.hxx
// ./opencascade/Transfer_StatusResult.hxx
// Additional functions
// operators
// register typdefs
register_template_NCollection_Sequence<opencascade::handle<Transfer_Binder> >(m,"Transfer_SequenceOfBinder");
register_template_NCollection_Sequence<opencascade::handle<Transfer_Finder> >(m,"Transfer_SequenceOfFinder");
// exceptions
register_occ_exception<Transfer_TransferFailure>(m, "Transfer_TransferFailure");
register_occ_exception<Transfer_TransferDeadLoop>(m, "Transfer_TransferDeadLoop");
// user-defined post-inclusion per module in the body
};
// user-defined post-inclusion per module
// user-defined post
| [
"adam.jan.urbanczyk@gmail.com"
] | adam.jan.urbanczyk@gmail.com |
c402ffd68723be663a8743d43a981ce61569c0cb | 64386b38d0f3502677ce3f94e253fbbe62c2d18b | /ProtoLegacy/VertexReadingOrder.cpp | 97fd92d1fbb0b3439f848aa953b523258de70597 | [] | no_license | bigans01/Organic | d5b6d8bf43b56a4dd60f77d347ad8b769e9aa0ad | 9420b36f793092c2257e7eb6613d4e443a0d54fc | refs/heads/master | 2021-01-01T16:59:00.892774 | 2018-07-27T15:09:31 | 2018-07-27T15:09:31 | 97,968,633 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 274 | cpp | #pragma once
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <map>
#include <array>
#include "VertexReadingOrder.h"
void VertexReadingOrder::SetOrder()
{
std::array<char, 6> rowone = { 0,0,0,0,0,0 };
ReadOrder.insert(std::make_pair(3, rowone));
}
| [
"bigans01@gmail.com"
] | bigans01@gmail.com |
e6486a01d0bca0f0ee18c18aa421f3e5b7804339 | 68fcc15f2033d09da1550ccafeacd9d0aa48a9f0 | /lab-01-sort-in-place/includes/sort.cpp | 3273deb1414c13a708d3e4c05648818264e3ff01 | [] | no_license | NikolayValev/DataStructures | bd4029d054d957b10e4b66baadbcd4aed3956ec7 | ee5f298ba3b9e53d50961af7d820c64a8b9ba50b | refs/heads/master | 2020-08-02T01:22:42.298459 | 2019-12-06T00:29:51 | 2019-12-06T00:29:51 | 211,190,143 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 200 | cpp | void sort_in_place(int &x, int &y, int &z)
{
if (x > y){
int temp =y;
y=x;
x=temp;
}
if (y > z) {
int temp =z;
z=y;
y=temp;
}
if (x > y){
int temp =y;
y=x;
x=temp;
}
} | [
"noreply@github.com"
] | noreply@github.com |
041965b5462a6fb3bd77052378642255ed7fa2eb | 04127e6a2625f692795b524683fad077d26d2f05 | /tuple/tuple.cpp | e920d78fc90e22fc657857ce7bbe8f2a37060653 | [] | no_license | Rohitimb/mycodepractice | cc5084e337436e3c859e679e3a0be7e76e6d405d | bc3de2ff0032a3bc8e6140481c945e559de3eafe | refs/heads/master | 2020-04-07T19:36:55.776151 | 2019-02-15T07:27:26 | 2019-02-15T07:27:26 | 158,655,308 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 414 | cpp | #include<iostream>
#include<tuple>
using namespace std;
int main()
{
tuple <char,int,float> t;
t = make_tuple('a',10,4.5f);
cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << endl;
get<0>(t) = 'b';
get<1>(t) = 40+20;
get<2>(t) = 56.7;
cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << endl;
cout << "tuple_size = " << tuple_size<decltype(t)> :: value << endl;
return 0;
}
| [
"rohit.eceng@gmail.com"
] | rohit.eceng@gmail.com |
9d88b586e579f82719795df8d619e186bc708ae8 | 2bcbb89decab77b4567016eb66c08397cefebeff | /src/GTimer.cpp | a42511a544af2647d41dd079eb36357f035bb5bd | [
"MIT"
] | permissive | ZUP3R/GordonVita002 | 6726dc23d9e965d9915609352144d98278808512 | 197e0894e3ab9df69fa079953b553f4b84bc6f35 | refs/heads/master | 2022-04-01T01:33:59.830929 | 2020-01-23T12:09:29 | 2020-01-23T12:09:29 | 233,018,917 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,423 | cpp | #include "GTimer.h"
#include <psp2/rtc.h>
GTimer::Measure::Measure(bool startnow)
{
_start = 0;
_stop = 0;
if(startnow)
start();
}
void GTimer::Measure::start()
{
_start = GTimer::GetTickCount();
}
void GTimer::Measure::reset()
{
Measure();
start();
}
void GTimer::Measure::stop()
{
_stop = GetTickCount();
}
uint64_t GTimer::Measure::now()
{
if (_start == 0)
return 0;
return GTimer::GetTickCount() - _start;
}
uint64_t GTimer::Measure::elapsedStopTime()
{
return _stop - _start;
}
uint64_t GTimer::Measure::initialTime()
{
return _start;
}
uint64_t GTimer::Measure::stopTime()
{
return _stop;
}
uint64_t GTimer::GetTickCount()
{
SceRtcTick tick{ 0 };
sceRtcGetCurrentTick(&tick);
return tick.tick;
}
GTimer::GTimer(const uint64_t &value)
{
_usec = value;
_started = false;
_stopped = false;
}
void GTimer::start()
{
_started = true;
_stopped = false;
m.start();
}
bool GTimer::started()
{
return _started;
}
bool GTimer::finished()
{
if (_started) {
if (!running()) {
_started = false;
return true;
}
}
return false;
}
bool GTimer::running()
{
if (_usec >= m.now())
return true;
return false;
}
void GTimer::restart()
{
m.stop();
start();
}
void GTimer::stop()
{
m.stop();
_started = false;
_stopped = true;
} | [
"57206783+ZUP3R@users.noreply.github.com"
] | 57206783+ZUP3R@users.noreply.github.com |
7d6a11f338e7b6d67220b2d5c871be0c6068040c | aa4d25bbf4130b01050c4f87d7262cf7eb0293b1 | /C++/librpc/include/xmlrpc/serializer.h | 92bec3f111881891f9ebca5053f018df5fcf3920 | [] | no_license | viperman1271/Hue | 4c8281eeee4234b04b557758421861a7e650c911 | 94e0590eaa5159f41d6aaef72740cc120fa123b1 | refs/heads/master | 2021-01-17T12:48:52.451030 | 2016-06-29T02:47:55 | 2016-06-29T02:47:55 | 57,857,538 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 360 | h | #pragma once
namespace xmlrpc
{
class serializer
{
public:
template<class T>
void serialize(const T& value);
template<class T, class... Args>
void serialize(const T& value, Args... args);
const std::vector<std::string>& get_serialized() const { return serialized; }
private:
std::vector<std::string> serialized;
};
}
#include <xmlrpc/serializer.hpp> | [
"mfilion@mikefilion.com"
] | mfilion@mikefilion.com |
c20c8abc5fde12f4b4f7ea2a6f53da15f0e41a2c | bb59c9cb3097ddba923c45158d7d6ab44e5b9330 | /SDiIS/Lab2/Lab_2/Professor.cpp | 05437f94e226b450f5865c07dcd900db41b86ee7 | [] | no_license | pilipeikoko/Course2 | ef4025d15397e376d23ddff27b8f4e45f21b9a20 | c69976c5f3ee8a007ed592625bf4bd4826f134a1 | refs/heads/master | 2023-02-15T15:55:53.268774 | 2021-01-10T21:48:27 | 2021-01-10T21:48:27 | 327,057,550 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 705 | cpp | #include "Professor.h"
using namespace scientist;
Professor::Professor(string name, int age, int salary, string degree, string subject, int year_of_service, string publication)
{
this->name = name;
this->age = age;
this->salary = salary;
this->degree = degree;
this->subject = subject;
this->year_of_service = year_of_service;
this->publication = publication;
}
void Professor::print()
{
cout << "Object of Professor class: \n Name: " << this->name << "\n Age: " << this->age << "\n Degree " << this->degree << "\n Salary: " << this->salary << "\n Year of service: " << this->year_of_service << "\n Subject: " << this->subject << "\n Publication: " << this->publication << endl;
} | [
"pilipeikoko@gmail.com"
] | pilipeikoko@gmail.com |
836e170d5eece6c862c3a39a9ca94244498dce6e | 57ac85ca91d0f218be2a97e41ad7f8967728e7b9 | /blazetest/src/mathtest/dmatdmatschur/DHbDHb.cpp | e15addcc1f10cc55b2c526378f65a280258b5694 | [
"BSD-3-Clause"
] | permissive | AuroraDysis/blaze | b297baa6c96b77c3d32de789e0e3af27782ced77 | d5cacf64e8059ca924eef4b4e2a74fc9446d71cb | refs/heads/master | 2021-01-01T16:49:28.921446 | 2017-07-22T23:24:26 | 2017-07-22T23:24:26 | 97,930,727 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,868 | cpp | //=================================================================================================
/*!
// \file src/mathtest/dmatdmatschur/DHbDHb.cpp
// \brief Source file for the DHbDHb dense matrix/dense matrix Schur product math test
//
// Copyright (C) 2013 Klaus Iglberger - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD License. Redistribution and use in source and binary
// forms, with or without modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
// 3. Neither the names of the Blaze development group nor the names of its contributors
// may be used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
*/
//=================================================================================================
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <cstdlib>
#include <iostream>
#include <blaze/math/DiagonalMatrix.h>
#include <blaze/math/HybridMatrix.h>
#include <blazetest/mathtest/Creator.h>
#include <blazetest/mathtest/dmatdmatschur/OperationTest.h>
#include <blazetest/system/MathTest.h>
//=================================================================================================
//
// MAIN FUNCTION
//
//=================================================================================================
//*************************************************************************************************
int main()
{
std::cout << " Running 'DHbDHb'..." << std::endl;
using blazetest::mathtest::TypeB;
try
{
// Matrix type definitions
typedef blaze::DiagonalMatrix< blaze::HybridMatrix<TypeB,128UL,128UL> > DHb;
// Creator type definitions
typedef blazetest::Creator<DHb> CDHb;
// Running tests with small matrices
for( size_t i=0UL; i<=9UL; ++i ) {
RUN_DMATDMATSCHUR_OPERATION_TEST( CDHb( i ), CDHb( i ) );
}
// Running tests with large matrices
RUN_DMATDMATSCHUR_OPERATION_TEST( CDHb( 67UL ), CDHb( 67UL ) );
RUN_DMATDMATSCHUR_OPERATION_TEST( CDHb( 128UL ), CDHb( 128UL ) );
}
catch( std::exception& ex ) {
std::cerr << "\n\n ERROR DETECTED during dense matrix/dense matrix Schur product:\n"
<< ex.what() << "\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
//*************************************************************************************************
| [
"klaus.iglberger@gmail.com"
] | klaus.iglberger@gmail.com |
2c56270f80c8ceac5fcd89b78220f83f0684cce9 | cb3817cdbe227b1fa040012d5c78df28d19dda7c | /spray_control_2017/test_2camera/test_2camera.ino | adb66c890ebc4e19afd25e1881aff15cf3faa20a | [] | no_license | mdkhan48/AgBot_2017 | 7ebd9825a9138bf4cf3897d045964230ac1f628a | fd7bf83f1d5750977042fff1ff5dd6ce30cb0ccd | refs/heads/master | 2021-05-04T05:25:33.052096 | 2018-02-05T17:39:29 | 2018-02-05T17:39:29 | 120,338,306 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,347 | ino | #include <Servo.h>
int servoPin1 = 3;
Servo Servo1;
int incomingBit = 0;
void setup() {
Servo1.attach(servoPin1);
pinMode(servoPin1, OUTPUT);
Serial.begin(19200);
}
void loop() {
if (Serial.available() > 0) {
incomingBit = Serial.read();
switch (incomingBit) {
// for RHS camera (dirtection:from front facing AgBot)
case '1':
//weed detected,move spray to weed
// servo 180 degree,facing right side weed(dirtection:from front facing AgBot)
Servo1.write(180);
//spray for 3 second
delay(3000);
// Servo 90 degree, facing earth
Servo1.write(90);
break;
case '2' : //no weed detected, rest spray facing earth
Servo1.write(90);
break;
// for LHS camera (dirtection:from front facing AgBot)
case '7':
//weed detected,move spray to weed
// servo 0 degree,facing left side weed(dirtection:from front facing AgBot)
Servo1.write(0);
//spray for 3 second
delay(3000);
// Servo 90 degree, facing earth
Servo1.write(90);
break;
case '8' : //no weed detected, rest spray facing earth
Servo1.write(90);
break;
default://rest facing earth
Servo1.write(90);
break;
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
3a2408420985ba2b3b2f323c4f7e555de71dfa93 | 70668b85b4946bb23e918db1b4a68a54910d9b36 | /codeForces/663/B.cpp | 5555e507d1e0d65992b5bcc80015aff5f750a1d9 | [] | no_license | Ishaan29/fuzzy-chainsaw-algo | 397e9feddca2a25902081a9d9316923c151779f1 | b4fa1f69721f5fe53745303879f9c8ff2c1a8e79 | refs/heads/master | 2021-06-25T00:26:34.720087 | 2021-02-28T08:24:52 | 2021-02-28T08:24:52 | 201,107,127 | 3 | 0 | null | 2021-02-28T08:24:52 | 2019-08-07T18:34:25 | C++ | UTF-8 | C++ | false | false | 2,100 | cpp | /**
* Author: Ishaan Bajpai
**/
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
void c_p_c()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("/Users/ishan/Desktop/fuzzy-chainsaw-algo/input.txt", "r", stdin);
freopen("/Users/ishan/Desktop/fuzzy-chainsaw-algo/output.txt", "w", stdout);
#endif
}
const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================
ll int pow(ll int x, ll int n,ll int mod){
if(n == 0){
return 1;
}
ll int subprob = pow(x, n/2, mod)%mod;
if(n&1){
return (x * subprob * subprob)%mod;
}
return (subprob * subprob)%mod;
}
void solve() {
int m,n;cin>>m>>n;
char arr[m+1][n+1];
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++){
cin>>arr[i][j];
}
}
int cnt = 0;
for(int i = 0; i < m; i++){
if(arr[i][n-1] == 'R'){
cnt++;
}
}
for(int i = 0; i < n; i++){
if(arr[m-1][i] == 'D'){
cnt++;
}
}
cout<<cnt<<endl;
}
int main() {
c_p_c();
int t = 1;
cin >> t;
while(t--) {
solve();
}
return 0;
}
| [
"bajpaiishan@yahoo.in"
] | bajpaiishan@yahoo.in |
3bcf546bd49aaba9ca2317627f1d176120e31267 | f05c3ad59ab3272c8809f6c50a3028230d794340 | /src/gen_pattern.cpp | c9b4d81c200194056bfa6b81d45763929c191b18 | [
"MIT"
] | permissive | Yaozhuwa/DVS-Calibration | 9b462cfb9220fa32a35be09e7f11ed91c891d048 | 20f05fa0c0f322ff4789c3b87f4c40f83d075f00 | refs/heads/master | 2022-12-23T03:23:02.724850 | 2020-09-29T20:24:55 | 2020-09-29T20:24:55 | 299,605,976 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 448 | cpp | #include "PatternMaker.h"
#include <iostream>
using namespace std;
using namespace cv;
int main(){
Monitor monitor(15.6, 1920, 1080);
monitor.printInfo();
PatternMaker pmaker(monitor);
// Mat pattern = pmaker.make_acircles_pattern(7, 5, 20, 2);
Mat pattern = pmaker.make_acircles_pattern(7, 5, 20, 2.2);
// imshow("pattern",pattern);
// pmaker.blink(10);
pmaker.show("pattern");
// waitKey(0);
return 0;
} | [
"yaozuye@zju.edu.cn"
] | yaozuye@zju.edu.cn |
d26d0ef428a236f3e9080068e0019846329acbd2 | c2294dc7e7bc7edb1db29e2e4f70e58a0461a6b9 | /Problemset/create-sorted-array-through-instructions/create-sorted-array-through-instructions.cpp | 4330ec7c380fa869e7f18332df1ee8931cbc3646 | [
"MIT"
] | permissive | Singularity0909/LeetCode | 64fedd0794f3addcb734caae65c3d4a7fb35ed0c | d46fb1c8ed9b16339d46d5c37f69d44e5c178954 | refs/heads/master | 2021-04-04T10:11:40.365341 | 2020-11-22T17:11:36 | 2020-11-22T17:11:36 | 248,447,594 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,999 | cpp |
// @Title: ้่ฟๆไปคๅๅปบๆๅบๆฐ็ป (Create Sorted Array through Instructions)
// @Author: Singularity0909
// @Date: 2020-11-08 11:15:15
// @Runtime: 1140 ms
// @Memory: 117.1 MB
class SegmentTree {
private:
struct node {
int l, r, v;
} tree[410000];
public:
inline int ls(int cur)
{
return cur << 1;
}
inline int rs(int cur)
{
return cur << 1 | 1;
}
void build(int cur, int l, int r)
{
tree[cur].l = l;
tree[cur].r = r;
tree[cur].v = 0;
if (l == r) return;
int mid = (l + r) >> 1;
build(ls(cur), l, mid);
build(rs(cur), mid + 1, r);
}
void insert(int cur, int pos)
{
++tree[cur].v;
if (tree[cur].l == pos and tree[cur].r == pos) return;
int mid = (tree[cur].l + tree[cur].r) >> 1;
if (pos <= mid) {
insert(ls(cur), pos);
} else {
insert(rs(cur), pos);
}
}
int query(int cur, int l, int r)
{
if (tree[cur].l == l and tree[cur].r == r) {
return tree[cur].v;
}
int mid = (tree[cur].l + tree[cur].r) >> 1;
if (r <= mid) {
return query(ls(cur), l, r);
}
if (l > mid) {
return query(rs(cur), l, r);
}
return query(ls(cur), l, mid) + query(rs(cur), mid + 1, r);
}
};
class Solution {
public:
SegmentTree tree;
int createSortedArray(vector<int>& instructions)
{
vector<int> nums;
tree.build(1, 1, 100000);
const int mod(1e9 + 7);
int sum = 0;
for (int x : instructions) {
int c1 = 0, c2 = 0;
if (x > 1) {
c1 = tree.query(1, 1, x - 1);
}
if (x < 100000) {
c2 = tree.query(1, x + 1, 100000);
}
tree.insert(1, x);
sum = (sum + min(c1, c2)) % mod;
}
return sum;
}
};
| [
"904854724@qq.com"
] | 904854724@qq.com |
1387b8be411b44f5191890a86ca3f41e22631714 | 887b19aaff44a6578918fce2a20c40d5aff20619 | /Plugins/Wwise/Source/AudiokineticTools/Private/AkEventAssetBroker.h | cf63d2e12cb4300717db443c5e2bd39764eaa113 | [] | no_license | TheAmazingZigZag/Camp | 1931aea7bb9145784a8fb6b269f7d1c7fd878e37 | d26761c7df04c67d6e60eb250fdee1f505b1deb4 | refs/heads/master | 2023-04-15T14:22:40.466740 | 2021-04-23T20:15:45 | 2021-04-23T20:15:45 | 360,970,303 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,610 | h | /********************************************************************************
The content of the files in this repository include portions of the AUDIOKINETIC
Wwise Technology released in source code form as part of the SDK package.
Commercial License Usage
Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
may use these files in accordance with the end user license agreement provided
with the software or, alternatively, in accordance with the terms contained in a
written agreement between you and Audiokinetic Inc.
Copyright (c) 2021 Audiokinetic Inc.
********************************************************************************/
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "ComponentAssetBroker.h"
#include "AkAudioEvent.h"
//////////////////////////////////////////////////////////////////////////
// FAkEventAssetBroker
class FAkEventAssetBroker : public IComponentAssetBroker
{
public:
UClass* GetSupportedAssetClass() override
{
return UAkAudioEvent::StaticClass();
}
virtual bool AssignAssetToComponent(UActorComponent* InComponent, UObject* InAsset) override
{
UAkComponent* AkComp = Cast<UAkComponent>(InComponent);
UAkAudioEvent* AkEvent = Cast<UAkAudioEvent>(InAsset);
if (AkComp && AkEvent)
{
AkComp->AkAudioEvent = AkEvent;
return true;
}
return false;
}
virtual UObject* GetAssetFromComponent(UActorComponent* InComponent) override
{
UAkComponent* AkComp = Cast<UAkComponent>(InComponent);
if (AkComp)
{
return AkComp->AkAudioEvent;
}
return NULL;
}
};
| [
"maxmen30@icloud.com"
] | maxmen30@icloud.com |
9482329dd989d5cb809cbddfab090100545b2a83 | 641b000da21d8bc523155865bba65d5af59f4869 | /TemplateMatrix.cpp | 86fb536ae30a4ff108962679d93e6336f3e8b902 | [] | no_license | Lightwing-Ng/Online-Codings | f3ada5890390e5d434d6e2815d0a24dcdb331ba3 | 56b79143eeeb0a1012cedf645a3358d12b5e16f6 | refs/heads/master | 2021-04-03T01:31:39.795860 | 2018-03-11T20:03:35 | 2018-03-11T20:03:35 | 124,793,855 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,016 | cpp | /*็จc่ฏญ่จไธญ็ๅฝๆฐ้ๅฝ่ฐ็จ็ฎๆณๅฎ็ฐn้ถ็ฉ้ต็nๆฌกๅน*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
//ๅๅปบ็ฉ้ต๏ผ็ฉ้ต็จไธ็ปดๆฐ็ปๅญๅจ
double *matCreate(unsigned int m, unsigned int n) {
double *p = (double *)malloc(sizeof(double) * m * n);
if (p == NULL)
printf("ๅๅปบ็ฉ้ตๅคฑ่ดฅ๏ผ\n");
return p;
}
//่พๅ
ฅ็ฉ้ตๅ
็ด
void matInput(double *a, unsigned int m, unsigned int n) {
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
scanf("%lf ", &a[i * n + j]);
}
}
return;
}
//้ๆบไบง็็ฉ้ตๅ
็ด ๏ผๅๅๅๅธไบ[from to]
void matInitRand(double *a, unsigned int m, unsigned int n, double from, double to) {
if (a == NULL || m <= 0 || n <= 0)
return;
double x;
srand(time(NULL));
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
x = (1.0 * rand()) * (to - from) + from;
a[i * n + j] = x;
}
}
return;
}
//่ฝฌ็ฝฎ
void matTranspose(double *a, double *b, unsigned int m, unsigned int n) {
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
b[j * n + i] = a[i * n + j];
}
}
}
//่พๅบ็ฉ้ต
void matPrint(double *a, unsigned int m, unsigned int n) {
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
printf("%8.4f ", a[i * n + j]);
}
putchar('\n');
}
return;
}
//็ฉ้ตไนๆณc=a*b
void matMul(double *a, double *b, double *c, unsigned int m, unsigned int n, unsigned int k) {
if (a == NULL || b == NULL || c == NULL || m <= 0 || n <= 0 || k <= 0)
return;
double x = 0.0f;
for (int i = 0; i < m; ++i) {
for (int u = 0; u < k; ++u) {
x = 0.0f;
for (int j = 0; j < n; ++j) {
x += a[i * n + j] * b[j * k + u];
}
c[i * k + u] = x;
}
}
return;
}
// b=a^n, a:m*m้ถ็ฉ้ต
void matFac(double *a, double *b, unsigned int n, unsigned int m) {
double *c = (double *)malloc(sizeof(double) * m * m); //ไฟๅญไธดๆถ็ปๆ
if (n > 1) {
matFac(a, c, n - 1, m);
matMul(a, c, b, m, m, m);
} else
memcpy(b, a, sizeof(double) * m * m);
free(c); //ๅๆถๅ
ๅญ
return;
}
#define M 3
#define N 4
#define K N
int main(int argc, char const *argv[]) {
double *A, *B, *B1, *BT, *C;
A = matCreate(M, N);
B = matCreate(N, K);
B1 = matCreate(N, K);
BT = matCreate(K, N);
C = matCreate(M, K);
if (!A || !B || !B1 || !BT || !C)
return -1;
matInitRand(A, M, N, 0.0f, 1.0f);
printf("A=\n");
matPrint(A, M, N);
matInitRand(B, N, K, 0.0f, 1.0f);
printf("B=\n");
matPrint(B, N, K);
matTranspose(B, BT, N, K);
printf("B'=\n");
matPrint(BT, K, N);
matMul(A, B, C, M, N, K);
printf("C=A*B\n");
matPrint(C, M, N);
matFac(B, B1, 4, N);
printf("B^4\n");
matPrint(B1, N, K);
return 0;
}
| [
"rodney_ng@icloud.com"
] | rodney_ng@icloud.com |
c7f660dfb1a0718d64b5fd9c193fc9c242818c0f | 6366eca7b91c795a0c3a559d34239028a4f40bd3 | /Grid/Block/Block.hpp | 74cb05c577b831fce1cd8a52e68c04a09cc056be | [
"MIT"
] | permissive | CostasPitharoulios/Arcade-RPG | 7cfb640d52f438cfead517360f0c4bfd00544830 | dc32fda844a8bd676cb50e1dd87f7c3133ac8978 | refs/heads/master | 2020-06-20T18:39:49.267527 | 2019-07-16T14:30:58 | 2019-07-16T14:30:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 354 | hpp | #pragma once
#include "../../Living/Hero/Hero.hpp"
enum block_type { NON_ACCESSIBLE, MARKET, COMMON};
class Block{
protected:
block_type type; //mporw na to valw const?
public:
block_type get_type();
virtual void show_Market();
virtual void buy(Hero& HERO);
virtual void sell(Hero& HERO);
Block();
virtual ~Block();
};
| [
"noreply@github.com"
] | noreply@github.com |
e2d7384e61fd02a8a9386dcf332f5b50eb62d264 | 037d518773420f21d74079ee492827212ba6e434 | /blazetest/src/mathtest/dmatsmatschur/LDbMIa.cpp | aea9f0ba52c5803c490a3708f76c854540fc802a | [
"BSD-3-Clause"
] | permissive | chkob/forked-blaze | 8d228f3e8d1f305a9cf43ceaba9d5fcd603ecca8 | b0ce91c821608e498b3c861e956951afc55c31eb | refs/heads/master | 2021-09-05T11:52:03.715469 | 2018-01-27T02:31:51 | 2018-01-27T02:31:51 | 112,014,398 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,050 | cpp | //=================================================================================================
/*!
// \file src/mathtest/dmatsmatschur/LDbMIa.cpp
// \brief Source file for the LDbMIa dense matrix/sparse matrix Schur product math test
//
// Copyright (C) 2012-2018 Klaus Iglberger - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD License. Redistribution and use in source and binary
// forms, with or without modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
// 3. Neither the names of the Blaze development group nor the names of its contributors
// may be used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
*/
//=================================================================================================
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <cstdlib>
#include <iostream>
#include <blaze/math/DynamicMatrix.h>
#include <blaze/math/IdentityMatrix.h>
#include <blaze/math/LowerMatrix.h>
#include <blazetest/mathtest/Creator.h>
#include <blazetest/mathtest/dmatsmatschur/OperationTest.h>
#include <blazetest/system/MathTest.h>
//=================================================================================================
//
// MAIN FUNCTION
//
//=================================================================================================
//*************************************************************************************************
int main()
{
std::cout << " Running 'LDbMIa'..." << std::endl;
using blazetest::mathtest::TypeA;
using blazetest::mathtest::TypeB;
try
{
// Matrix type definitions
typedef blaze::LowerMatrix< blaze::DynamicMatrix<TypeB> > LDb;
typedef blaze::IdentityMatrix<TypeA> MIa;
// Creator type definitions
typedef blazetest::Creator<LDb> CLDb;
typedef blazetest::Creator<MIa> CMIa;
// Running tests with small matrices
for( size_t i=0UL; i<=6UL; ++i ) {
RUN_DMATSMATSCHUR_OPERATION_TEST( CLDb( i ), CMIa( i ) );
}
// Running tests with large matrices
RUN_DMATSMATSCHUR_OPERATION_TEST( CLDb( 67UL ), CMIa( 67UL ) );
RUN_DMATSMATSCHUR_OPERATION_TEST( CLDb( 128UL ), CMIa( 128UL ) );
}
catch( std::exception& ex ) {
std::cerr << "\n\n ERROR DETECTED during dense matrix/sparse matrix Schur product:\n"
<< ex.what() << "\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
//*************************************************************************************************
| [
"klaus.iglberger@gmail.com"
] | klaus.iglberger@gmail.com |
90f57d9bada7258225e26990a5b925364562db9e | 44b99cd0efb0ecda00967f127afc8d851fa2ec78 | /src/PinholeModel.cpp | dbb2c311a6ded2cd43a852b6b6641c54422c46b6 | [] | no_license | jongsik-moon/DVL-SLAM_reimplementation | 05b2cb76d908ff742a2749e912fb5b2c1cdbc508 | 90054aa3a18b8257007a1e79a5e0276aac289dae | refs/heads/main | 2023-02-28T11:41:49.281697 | 2021-01-18T02:18:51 | 2021-01-18T02:18:51 | 307,628,285 | 8 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,637 | cpp | //
// Created by jongsik on 20. 12. 4..
//
#include "PinholeModel.h"
PinholeModel::PinholeModel(Config& config)
:config_(config)
{
}
PinholeModel::~PinholeModel()
{
}
Eigen::Vector2f PinholeModel::PointCloudXyz2Uv(Eigen::Vector3f point){
float U = config_.cameraConfig.fx * (point(0) / point(2)) + config_.cameraConfig.cx;
float V = config_.cameraConfig.fy * (point(1) / point(2)) + config_.cameraConfig.cy;
Eigen::Vector2f uv(U, V);
return uv;
}
std::vector<Eigen::Vector2f> PinholeModel::PointCloudXyz2UvVec(const pcl::PointCloud<pcl::PointXYZRGB>& pc, float scale){
std::vector<Eigen::Vector2f> uvSet;
for(auto point:pc){
float X = point.x / point.z;
float Y = point.y / point.z;
float U = config_.cameraConfig.fx * X + config_.cameraConfig.cx;
float V = config_.cameraConfig.fy * Y + config_.cameraConfig.cy;
// std::cout << "[PinholeModel] point.x : " << point.x << std::endl;
// std::cout << "[PinholeModel] point.z : " << point.z << std::endl;
// std::cout << "[PinholeModel]point.x / point.z : " << point.x / point.z << std::endl;
// std::cout << "[PinholeModel]X : " << X << std::endl;
// std::cout << "[PinholeModel]config_.cameraConfig.fx" << config_.cameraConfig.fx << std::endl;
// std::cout << "[PinholeModel]config_.cameraConfig.fx * (point.x / point.z)" << config_.cameraConfig.fx * (point.x / point.z) << std::endl;
// std::cout << "[PinholeModel]config_.cameraConfig.fx * X" << config_.cameraConfig.fx * X << std::endl;
// std::cout << "[PinholeModel] U : " << U << std::endl;
Eigen::Vector2f uv(U, V);
uvSet.push_back(uv*scale);
}
return uvSet;
}
| [
"jongsik.moon@nearthlab.com"
] | jongsik.moon@nearthlab.com |
bea0b85e22689c9a7dff088a96098d331eafd5ae | d4788b2db9ea43e8893bda4bfd7babb75f9e9ea1 | /RockMan2/Rock.h | d9ac61ede48fa7b6479f0b3e88dd23a18eb002f5 | [] | no_license | Bindagooner/rockman2 | 96fefe14b1a0608ee272584598183b2d127d20c7 | 16743b1b7838488e9aac1a748ebdd025f6d2425e | refs/heads/master | 2016-09-01T05:56:11.177507 | 2015-12-15T02:46:36 | 2015-12-15T02:46:36 | 45,175,607 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,212 | h | ๏ปฟ#pragma once
#include "GameObject.h"
class CRock : public CStaticObject
{
public:
//-----------------------------------------------------------------------------
// Khแปi tแบกo tแบฅt cแบฃ cรกc thร nh phแบงn cแปงa 1 ฤแปi tฦฐแปฃng vแปi cรกc giรก trรญ ฤรฃ cรณ
//
// Trแบฃ vแป 0 nแบฟu lแปi hoแบทc 1 nแบฟu thร nh cรดng
//-----------------------------------------------------------------------------
int init() override;
//-----------------------------------------------------------------------------
// Vแบฝ tแบฅt cแบฃ cรกc thร nh phแบงn cแปงa 1 ฤแปi tฦฐแปฃng
//
// + gameTime : Thแปi gian cแบญp nhแบญt hแป thแปng
// + graphics : cแป vแบฝ ฤแปi tฦฐแปฃng
//-----------------------------------------------------------------------------
void render(CGameTime* gameTime, CGraphic* graphic) override;
//-----------------------------------------------------------------------------
// Cแบญp nhแบญt tแบฅt cแบฃ cรกc logic cแปงa 1 ฤแปi tฦฐแปฃng
//
// + gameTime : Thแปi gian cแบญp nhแบญt hแป thแปng
//-----------------------------------------------------------------------------
void update(CGameTime* gameTime) override;
void updateBox() override;
CRock();
~CRock();
};
| [
"roobingas@gmail.com"
] | roobingas@gmail.com |
810b786bc75dc7ecb1761c2c743bedc398bc2dbf | d960fad4c2a93e9dc692ed361b5818e71f3dd2c3 | /FirstVCLApp.cpp | 2a1356649f164ae01dc5bb9685d8895c49bbf6af | [] | no_license | qiyubrother/FirstVCLApp | 658a5fa0fe3c414255df5834c43c16a83fbe7e6b | 0aefb304f2cf1e353205f96e88b1541e5019379c | refs/heads/master | 2020-07-31T22:18:46.446565 | 2019-09-25T06:57:57 | 2019-09-25T06:57:57 | 210,771,640 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 849 | cpp | //---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <tchar.h>
//---------------------------------------------------------------------------
USEFORM("UnitMain.cpp", frmMain);
//---------------------------------------------------------------------------
int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
try
{
Application->Initialize();
Application->MainFormOnTaskBar = true;
Application->CreateForm(__classid(TfrmMain), &frmMain);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//---------------------------------------------------------------------------
| [
"qiyubrother"
] | qiyubrother |
742b588a91212c3addec17110e7e7db72e5cd20d | f3e0509cbc6811b1fab82d9c585d3dcd40f9f8fd | /hw_6/manager.h | bcd1066f219997fe8f1fb180c81d0c67df0382ae | [] | no_license | AnushaKamat/ECE590 | 06a5c2684189c5a599c3d8a82996bada715fe691 | 935ca3a8d524c95bbc0b2b022b8dd0a1334dea98 | refs/heads/master | 2020-04-16T22:03:15.870763 | 2019-03-19T17:08:51 | 2019-03-19T17:08:51 | 165,951,448 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,338 | h | #ifndef MANAGER_H
#define MANAGER_H
#include <vector>
#include <map>
#include <chrono>
#include <functional>
#include <tuple>
#include "elma.h"
namespace elma {
using std::string;
using std::vector;
using std::map;
using std::tuple;
using namespace std::chrono;
class Channel;
class Process;
class Manager {
public:
Manager() {}
Manager& add_channel(Channel&);
Manager& schedule(Process& process, high_resolution_clock::duration period);
Channel& channel(string);
Manager& drop(Process&);
Manager& all(std::function<void(Process&)> f);
Manager& init();
Manager& start();
Manager& stop();
Manager& run(high_resolution_clock::duration);
// Question 5
map<string, tuple<string, double, double, int>> ps();
//map<string, string> ps();
// should this be private?
Manager& update();
inline high_resolution_clock::time_point start_time() { return _start_time; }
inline high_resolution_clock::duration elapsed() { return _elapsed; }
private:
vector<Process *> _processes;
map<string, Channel *> _channels;
high_resolution_clock::time_point _start_time;
high_resolution_clock::duration _elapsed;
};
}
#endif | [
"38510945+AnushaKamat@users.noreply.github.com"
] | 38510945+AnushaKamat@users.noreply.github.com |
7d9213ac76b705c3f6db14edeade5344531bcf07 | 4ce0126375b3e686558f72ad754afe12c9d98507 | /week5/main.cpp | 88b5db8d1e5027886e97c01d4c5510652cfd84f6 | [] | no_license | SplitSky/Object-Oriented-C | 110bebe2d5a881bc050f43f716c86485dff53ed9 | 7cc2100d86a3ebeb4088e73b412fc319a3827c67 | refs/heads/main | 2023-05-03T22:26:25.897589 | 2021-05-24T23:02:02 | 2021-05-24T23:02:02 | 336,069,225 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,870 | cpp | // PHYS 30762 Programming in C++
// Assignment 5
// Tomasz Neska - ID: 10294857
// Matrix Determinants and inverses
#include <fstream>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<array>
#include<iterator>
#include<cstring>
// Things to do
// The class:
// 1. Contain no. of rows, no. of columns and a pointer to the matrix data (type double)
// 2. Constructor using dynamic memory allocation
// 3. Store data in a one dimensional array. For a matrix by m x n. The location is given by (j-1) + (i-1)*n
// 4. the destructor should delete dynamically allocated memory
// 5. Assignment operator and copy constructor functions would perform deep copies of data
// 6. Recursive calculation of a determinant:
// 7.
class matrix {
friend std::ostream& operator<<(std::ostream &os, matrix &numbers);
friend std::ifstream& operator>>(std::ifstream &os, matrix &numbers);
private:
int row;
int col;
double *data;
double calc_det(int row, std::vector<double> matrix) {
// takes in array, mxn
if (row == 2) { // col must also be 2 because its a square
return matrix[0]*matrix[3] - matrix[1]*matrix[2]; // base case
} else {
double determinant{0};
for (int j{1}; j<=row; j++) {
determinant += pow(-1, 1+j) * matrix[j-1] * calc_det(row-1, splice_matrix(1,j,matrix));
}
return determinant;
}
}
std::vector<double> splice_matrix(int i_pivot, int j_pivot, std::vector<double> matrix) {
// no need to invlude row and column as it always returns a matrix one smaller in each dimension
std::vector<double> new_matrix = {};
int col = pow(matrix.size(), 0.5);
for (int i{1}; i<=col; i++) {
for (int j{1}; j<=col; j++) {
if ((i != i_pivot) && (j != j_pivot)) {
new_matrix.push_back(matrix[(i-1)*col + (j-1)]);
}
}
}
return new_matrix;
}
public:
// constructor default
matrix() {
this->data = nullptr;
this->row = 0;
this->col = 0;
}
// parameter constructor
matrix(int row, int col, double data_in[]): row{row}, col{col} {
this->data = new double[row*col];
for (int i{0}; i<row*col; i++) {
this->data[i] = data_in[i];
}
}
// destructor
~matrix(){
for (size_t i{0}; i< row*col ; i++) {std::cout << "The data: " << *(this->data+i) << std::endl;}
//this->data = nullptr;
this->data = nullptr;
delete[] this->data;
}
int get_row(){return this->row;}
int get_col(){return this->col;}
void set_row(int row){this->row=row;}
void set_col(int col){this->col=col;}
void set_data(double* data_2, size_t size){
this->data = new double[size];
for (size_t i{0}; i< size; i++) {
this->data[i] = data_2[i];
// copies data from one pointer location to the other
}
return;
}
matrix operator+(matrix &numbers) const {
if ((this->row == numbers.row) && (this->col == numbers.col)) {
matrix temp; // defines object
std::vector<double> data_added;
for (int i{0}; i<this->row*this->col ;i++) {
data_added.push_back(this->data[i] + numbers.data[i]);
}
double* data_assigned = new double[this->row*this->col];
std::copy(data_added.begin(), data_added.end(), data_assigned);
temp.set_col(numbers.get_col());
temp.set_row(numbers.get_row());
temp.set_data(data_assigned, data_added.size());
delete[] data_assigned;
return temp;
} else {
matrix temp;
std::cout << "The dimensions don't match" << std::endl;
return temp;
}
}
matrix operator-(matrix &numbers) const {
if ((this->row == numbers.row) && (this->col == numbers.col)) {
matrix temp; // defines object
std::vector<double> data_added;
for (int i{0}; i<this->row*this->col ;i++) {
data_added.push_back(this->data[i] - numbers.data[i]);
}
double* data_assigned = new double[this->row*this->col];
std::copy(data_added.begin(), data_added.end(), data_assigned);
//matrix temp(this->row, this->col, data_assigned);
//delete[] data_assigned;
temp.set_col(numbers.get_col());
temp.set_row(numbers.get_row());
temp.set_data(data_assigned, data_added.size());
delete[] data_assigned;
return temp;
} else {
matrix temp;
std::cout << "The dimensions don't match" << std::endl;
return temp;
}
}
matrix operator*(matrix &numbers) {
if (this->row == numbers.col) {
double sum{0};
std::vector<double> data_multiplied;
//double *data_multiplied = new double[this->row*numbers.col];
for (int j{1}; j<=numbers.col;j++) {
for (int i{1}; i <= this->row; i++) {
sum = 0;
for (int k{1};k <= this->col; k++) {
sum += this->data[(k-1)+(i-1)*this->col] * numbers.data[(j-1)+(k-1)*numbers.col];
}
data_multiplied.push_back(sum); // adds the entry to the result array
}
}
matrix temp;
double* data_assigned = new double[this->row*this->col];
std::copy(data_multiplied.begin(), data_multiplied.end(), data_assigned);
temp.set_col(numbers.get_col());
temp.set_row(this->get_row());
temp.set_data(data_assigned, data_multiplied.size());
delete[] data_assigned;
return temp;
} else {
matrix temp;
std::cout << "The dimensions don't match" << std::endl;
return temp;
}
}
matrix& operator=(matrix &numbers) {
if (&numbers == this) {return *this;} // no self assignment
delete[] data;
data = nullptr;
col = 0;row = 0;
col = numbers.col;
row = numbers.row;
if (row*col>0) {
data = new double[row*col];
for (size_t i{}; i<col*row; i++) {data[i]=numbers.data[i];}
}
return *this;
}
std::string show_data() const {
std::string temp[this->row];
std::string temp_string;
for (int i{1}; i <= this->row; i++) {
temp_string += "[";
for (int j{1}; j <= this->col; j++) {
temp_string += " ";
temp_string += std::to_string(this->data[(j-1)+this->col*(i-1)]) + ", ";
}
temp_string = temp_string.substr(0,temp_string.size()-2);
temp_string += "], ";
}
temp_string = temp_string.substr(0,temp_string.size()-2);
return temp_string;
}
double find_determinant() {
std::vector<double> temp_vector;
temp_vector.assign(this->data, this->data+(this->row*this->col));// assigns an array to a vector
return this->calc_det(this->row, temp_vector); // use private function as a helper
}
void slice_matrix2(int i_pivot, int j_pivot) {
std::vector<double> new_data;
for (size_t i{0}; i<this->row*this->col; i++) {
new_data.push_back(this->data[i]);
}
this->row = this->row - 1;
this->col = this->col - 1;
delete[] this->data;
this->data = new double[this->row * this->col];
// purges and resets the data variables
new_data = this->splice_matrix(i_pivot, j_pivot, new_data); // uses the helper function to splice the vector
std::copy(new_data.begin(), new_data.end(), this->data);// copies the data into the pointer location
// copies the array into a memory location that doesn't disappear when it goes out of scope.
return;
}
};
std::ostream& operator<<(std::ostream& os, matrix &numbers) {
os << "Printing the matrix:" << std::endl;
std::string temp[numbers.get_row()];
std::string temp_string;
for (int i{1}; i <= numbers.get_row(); i++) {
temp_string += "[";
for (int j{1}; j <= numbers.get_col(); j++) {
temp_string += " ";
temp_string += std::to_string(numbers.data[(j-1)+numbers.get_col()*(i-1)]) + ", ";
}
temp_string = temp_string.substr(0,temp_string.size()-2);
temp_string += "]";
os << temp_string << std::endl;
temp_string = "";
}
//temp_string = temp_string.substr(0,temp_string.size()-2);
//os << numbers.show_data() << std::endl;
return os;
}
std::istream& operator>>(std::istream& os, matrix &numbers) {
//std::string input = "2,2,{1,0,0,1}";
std::cout << "Enter the number of rows: " << std::endl;
std::string input;
os >> input; // gets the input
numbers.set_row(std::stoi(input));
input = "";
std::cout << "Enter the number of columns: " << std::endl;
os >> input;
numbers.set_col(std::stoi(input));
std::cout << "Enter the matrix in form: {a,b...}: " << std::endl;
input = "";
os >> input;
std::vector<double> data;
double temp_number;
std::string temp_string;
int i{1};
std::cout << "the input: " << input << std::endl;
bool number_start;
while (i != input.length()) {
number_start = true;
temp_string = "";
while (number_start) {
if (input[i]==',') {
temp_number = std::stod(temp_string);
data.push_back(temp_number);
i++;
break;
} else if (input[i] =='}') {
number_start=false;
temp_number = stold(temp_string);
data.push_back(temp_number);
} else {
temp_string += input[i];
}
i++;
}
}
double* new_data = new double[data.size()];
std::copy(data.begin(), data.end(), new_data);
// copies the array into a memory location that doesn't disappear when it goes out of scope.
// convert a vector into double array
numbers.set_data(&new_data[0],data.size()); // assigns the data onto the matrix
return os;
}
int main() {
int row{2};
int col{2};
double data[4] = {1,2,3,4};
double data2[4] = {2,3,4,5};
matrix matrix1(row, col, data);
matrix matrix2(row, col, data2);
matrix matrix3 = matrix1+matrix2;
//matrix matrix4 = matrix1-matrix2;
//matrix matrix5 = matrix1*matrix2;
//double data3[9] = {1,8,7,1,5,3,1,8,4}; // the determinant is 9
//double data4[36] = {1,2,5,4,8,15,4,5,2,6,4,2,3,8,7,4,5,6,2,1,5,5,5,5,4,8,8,7,5,4,2,1,5,6,3,4}; // determinant is 1464
//matrix matrix6{3,3,data3};
//matrix matrix7{6,6,data4};
//std::cout << "Attempting to multiply the matrices with incorrect sizes" << std::endl;
//matrix matrix8 = matrix6*matrix7;
//double det_a{matrix1.find_determinant()};
//double det_b{matrix6.find_determinant()};
//double det_c{matrix7.find_determinant()};
//matrix matrix9;
//std::cin >> matrix9; // the input testing
//printing all the matrices
std::cout << "matrix A: " << matrix1 << std::endl;
std::cout << "matrix B: " << matrix2 << std::endl;
std::cout << "matrix C=A+B: " << matrix3 << std::endl;
//matrix1 = matrix2; // modifies the original matrix
//std::cout << "matrix C after A was overwritten with B: " << matrix3;
//std::cout << "matrix A: " <<matrix1 << std::endl;
//std::cout << "matrix B: " << matrix2 << std::endl;
//std::cout << "matric D=A-B: " << matrix4 << std::endl;
//std::cout << "matrix E=A*B: " << matrix5 << std::endl;
//std::cout << "3x3 matrix: " << matrix6 << std::endl;
//std::cout << "6x6 matrix: " << matrix7 << std::endl;
//std::cout << "the input matrix: " << matrix9 << std::endl;
//std::cout << "Det 2x2: " << det_a << std::endl;
//std::cout << "Det 3x3: " << det_b << std::endl;
//std::cout << "Det 4x4: " << det_c << std::endl;
// the demonstration of the "member function that returns a matrix with ith and jth row deleted"
// is a part of the determinant calculation
// This function is modified and repeated under a name slice_matrix2.
// Operation is demonstrated below
//matrix6.slice_matrix2(1,1);
//std::cout << "Slice the 3x3 matrix by removing 1st column and 1st row." << std::endl;
//std::cout << "Printing the sliced matrix: "<< matrix6 << std::endl;
// showing memory assignment is correct
//matrix1 = matrix2;
//std::cout << "Matrix A overwritten by B: " << matrix1 << std::endl;
//std::cout << "Matrix B: " << matrix2 << std::endl;
//std::cout << "Matrix C is unchanged: " << matrix3 << std::endl;
return 0;
}
| [
"opop.neska60@gmail.com"
] | opop.neska60@gmail.com |
7d87fb7b02cf97dec605fbab1a14066239168700 | 52d2e0109e02f45c43a6f73a10cd967b77e3f2bf | /Code/Projects/Eldritch/src/Components/wbcompeldrope.h | 4c31409209682891654136f99f697d04b6db3988 | [
"Zlib"
] | permissive | Johnicholas/EldritchCopy | 542ac5ffee97fdcad9b1bacd12213b29174272b8 | 96b49cee8b5d4f0a72784ff19bdbec6ee0c96a30 | refs/heads/master | 2021-01-21T07:41:58.543794 | 2014-06-06T20:31:10 | 2014-06-06T20:31:10 | 20,576,842 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,048 | h | #ifndef WBCOMPELDROPE_H
#define WBCOMPELDROPE_H
#include "wbeldritchcomponent.h"
#include "vector.h"
#include "simplestring.h"
class WBCompEldRope : public WBEldritchComponent
{
public:
WBCompEldRope();
virtual ~WBCompEldRope();
DEFINE_WBCOMP( EldRope, WBEldritchComponent );
virtual int GetTickOrder() { return ETO_NoTick; }
virtual void HandleEvent( const WBEvent& Event );
virtual uint GetSerializationSize();
virtual void Save( const IDataStream& Stream );
virtual void Load( const IDataStream& Stream );
protected:
virtual void InitializeFromDefinition( const SimpleString& DefinitionName );
private:
void DropRope();
Vector Quantize( const Vector& V ) const;
float m_CollisionFatten; // Config
float m_MeshFatten; // Config
float m_EndpointSpacing; // Config
float m_AnchorDepth; // Config
float m_HookLength; // Config
float m_DangleHeight; // Config
SimpleString m_HookEntity; // Config
Vector m_Anchor; // Serialized
bool m_Dropped; // Serialized
};
#endif // WBCOMPELDROPE_H | [
"johnicholas.hines@gmail.com"
] | johnicholas.hines@gmail.com |
bceec2f4564f5caea854514df38481162b8fd575 | f9260f63f06e5a39032e408ab431fdfd64dacaa1 | /serialcom.h | 862f8d090f361a5250e390ed2ee751bd21d0952d | [] | no_license | MrAndMrswang/serialRadar | 4d6f15c19c3a77d910de8d5dc5c0ed62780a470d | 237310164be4e3cebfd4101f4cc827bd240368c4 | refs/heads/main | 2023-06-26T11:33:03.195365 | 2021-07-14T13:02:02 | 2021-07-14T13:02:02 | 384,408,367 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,367 | h | #ifndef SERIALCOM_H
#define SERIALCOM_H
#include <lidarpoint.h>
#include <QThread>
#include <QWidget>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
namespace Ui {
class SerialCom;
}
class SerialCom : public QWidget {
Q_OBJECT
//
class InvokeThread : public QThread {
public:
void run();
void doInvoke();
QList<LidarPoint> getPoints();
void savePoints(QList<LidarPoint> list0);
void setPortName(QString portName);
void setBaudRate(uint32_t baudRate);
void startInvoke();
void stopInvoke();
void clearPoints();
private:
QString _portName;
uint32_t _baudRate;
QList<LidarPoint> _points; // ็ปๅถ็น
bool _startInvoke;
};
//
public:
explicit SerialCom(QWidget *parent = nullptr, int _exportInterval = 500);
signals:
void exportPoints(QList<LidarPoint>);
void startScan(bool);
protected:
// ๅฎๆถๅจไบไปถ
void timerEvent(QTimerEvent *event);
private:
QSerialPort *serial;
Ui::SerialCom *ui;
bool _canInvoke;
int _timerId; // ๅฎๆถๅจID
int _exportInterval;
InvokeThread _invokeThread0;
int _exportCnt; // ๅฏผๅบๆฐๆฎ็่ฎกๆฐๅจ
void init();
void onOpenSerialButtonClicked();
void changeEditMod(bool);
void startInvoke();
void stopInvoke();
void showPoints(const QList<LidarPoint> &list0);
};
#endif // SERIALCOM_H
| [
"chaowang93@163.com"
] | chaowang93@163.com |
83f4d97b6697e93d74b8dbeae6a923fb584f3b2e | ffad405edc4319ca17c73b46f69a1beaf19a7b5a | /CodeRedPracticeBot2015/src/Commands/PrintBytes.h | f90941c1031e7f7c2f3c32cf943898b774b9242d | [] | no_license | CRRobotics/Robots | 9f3177749018e0059aa084559caae74f366f77bf | 2f518d484ee5b44749ab3ae3d547ff37050bf8f2 | refs/heads/master | 2020-12-25T13:44:45.239573 | 2016-01-23T21:42:42 | 2016-01-23T21:42:42 | 3,215,092 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 874 | h | // RobotBuilder Version: 1.5
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// C++ from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.
#ifndef AUTONOMOUS_COMMAND_H
#define AUTONOMOUS_COMMAND_H
#include "Commands/Subsystem.h"
#include "../Robot.h"
/**
*
*
* @author ExampleAuthor
*/
class PrintBytes: public Command {
public:
PrintBytes();
virtual void Initialize();
virtual void Execute();
virtual bool IsFinished();
virtual void End();
virtual void Interrupted();
};
#endif
| [
"CRRProgrammer@gmail.com"
] | CRRProgrammer@gmail.com |
5585a852ff745fcbf2371fc84ed5fd98f5ac3956 | aabf134f80d3db2f2609e562fe18d37d0469f6cc | /HZOJ440.cpp | 8c21386cf7a2eab5fb082f84898b573fa9ea9b4b | [] | no_license | panxiuxu/HaiZei_Online_Judge | 5c892500d691f11fc84372e9996807fb6e688e85 | 65faec326f44f94cd34b44b8be039af1b07a37f8 | refs/heads/master | 2020-07-06T15:06:32.909672 | 2019-09-07T12:54:24 | 2019-09-07T12:54:24 | 202,162,072 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 318 | cpp | #include <iostream>
using namespace std;
int main() {
int n, x, cnt = 0;;
cin >> n >> x;
for (int i = 1; i <= n; i++) {
int j = i;
while (j) {
if (j % 10 == x) {
cnt++;
}
j /= 10;
}
}
cout << cnt << endl;
return 0;
}
| [
"panxiuxu@gmail.com"
] | panxiuxu@gmail.com |
0cfa2892fb0c43e1748d5a8916dd8e9b8d041a7e | 220ab14e8734e24793aef43b772f6599aad35dff | /NG/load-ng-image-details.cxx | 8765168cd176b3ad9d23acb24b2b91e639582225 | [] | no_license | suryakiran/CodeSamples | 1ab93ae76d6d473fdf72b2ba663b4a43d382fbec | f2e18e8fa7611bca25f92fbd167a6a5a97b66a55 | refs/heads/master | 2016-09-15T13:57:35.113621 | 2016-02-07T15:54:55 | 2016-02-07T15:54:55 | 828,790 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,571 | cxx | #include <iostream>
#include <fstream>
#include <vector>
#include <fstream>
#include <sstream>
#include <boost/program_options.hpp>
#include <boost/algorithm/string_regex.hpp>
#include <boost/foreach.hpp>
#include "ng-details.hpp"
using namespace boost::algorithm ;
using namespace std ;
namespace po = boost::program_options ;
string inputFile, reqdType ;
NgImageDetails ngImageDetails ;
void parse_args (int argc, char **argv)
{
po::options_description desc ("Allowed Options") ;
desc.add_options()
("input-file", po::value <string>(), "Path to serialized xml file")
("description", "Get Description of Image File")
("title", "Get Title of Image")
("image-name", "Get Image Name")
;
po::variables_map vm ;
po::store (po::parse_command_line (argc, argv, desc), vm) ;
po::notify (vm) ;
if (vm.count ("input-file"))
inputFile=vm["input-file"].as<string>() ;
if (vm.count ("description"))
reqdType = "Description" ;
if (vm.count ("title"))
reqdType = "Title" ;
if (vm.count ("image-name"))
reqdType = "ImageName" ;
}
void load_ng_details (void)
{
try
{
ngImageDetails.loadTree(inputFile);
ngImageDetails.printTree();
string output ;
output = ngImageDetails.getValue<string>(reqdType);
cout << output ;
}
catch (std::exception& e)
{
cout << "Error:" << e.what() << endl ;
}
}
int main (int argc, char **argv)
{
try
{
parse_args (argc, argv) ;
}
catch (std::exception& e)
{
cout << "Exception from load-image-details: " << e.what() << endl ;
}
load_ng_details () ;
return 0 ;
}
| [
"suryagullapalli@a1ae422f-012c-4595-b219-9b566b4fa53f"
] | suryagullapalli@a1ae422f-012c-4595-b219-9b566b4fa53f |
f581151849a31ebb8d4fa067696aaf1e56dc8d44 | 17f85d33f388ea0830715e703269b5b81923d864 | /object/object.h | fbb563cabac7c395694d67c56e09643795b45612 | [] | no_license | zzy7896321/SchemeInterpreter | 7e91c3b772bbeaff9258ea3043a6c6192e18cd43 | b0d1aa1929ce1294029adaf3d49b0f735a2c3bef | refs/heads/master | 2020-04-21T06:20:07.289062 | 2013-08-16T14:09:58 | 2013-08-16T14:09:58 | 11,720,545 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,199 | h | /** @file
* object.h defines the public base class of all objects.
*/
#ifndef OBJECT_H_INCLUDED
#define OBJECT_H_INCLUDED
#include <iostream>
#include <string>
#include <memory>
namespace ObjectDef{
enum class ObjectType{
OBJECT, // object of any type
BOOLEAN, // boolean
INT, BIGINT, RATIONAL, REAL, COMPLEX, //numbers
PROC, // user-defined and library procedures
BUILTIN, //built-in procedures
PAIR, //pair
LIST, // list
SYMBOL, //symbol
CHAR, //character
STRING, //string
VECTOR, //vector
EMPTYLIST, //empty list
ENVIRONMENT, //environment
PAIRDOT, // . to denote the dot
VOID, // void object, used as unspecified results
PROMISE, //promise made by delay syntax
EXPRESSIONPACK //internal expression pack
};
class Object{
public:
Object():type(ObjectType::OBJECT){}
Object(ObjectType _type):type(_type){}
virtual ~Object(){}
void setType(ObjectType _type){
type = _type;
}
ObjectType getType() const {
return type;
}
virtual std::string getExternalRep() const{
return "<Object>";
}
virtual std::shared_ptr<Object> clone(){
return std::shared_ptr<Object>(new Object(*this));
}
protected:
ObjectType type;
};
}
#endif //OBJECT_H_INCLUDED
| [
"zzy7896321@163.com"
] | zzy7896321@163.com |
ff62a5d37fc1e840843d2e1274db07eb2b460563 | 490de48e4d0ddc319cf051548ebca6b5ba7ea6c1 | /include/mco/est/basic/kruskal_st_solver.h | 0066a76f70ef609f5fca2bb83e9ecbcd9fdaf611 | [] | no_license | FritzBo/mco | 3227be6b813f3363df0a5dbfff119b3fb57f876d | 5bacfa02269a385315307cdc2b79f12f8cc89321 | refs/heads/master | 2021-04-29T13:56:53.377683 | 2014-07-23T16:02:06 | 2014-07-23T16:02:06 | 121,762,565 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 796 | h | #pragma once
/*
* prim_st_solver.h
*
* Created on: 27.09.2013
* Author: fritz
*/
#ifndef PRIM_ST_SOLVER_H_
#define PRIM_ST_SOLVER_H_
#include <map>
#include <vector>
#include <ogdf/basic/Graph.h>
namespace mco {
class KruskalSTSolver {
public:
KruskalSTSolver(const ogdf::Graph & g, const ogdf::EdgeArray<double> & costs);
virtual ~KruskalSTSolver();
void Solve();
const std::vector<ogdf::edge> & spanning_tree();
double min_cost();
private:
const ogdf::Graph &graph_;
const ogdf::EdgeArray<double> &costs_;
std::vector<ogdf::edge> spanning_tree_;
double cost_;
ogdf::NodeArray<ogdf::node> sets_;
void make_set(ogdf::node n);
ogdf::node find_set(ogdf::node n);
void set_union(ogdf::node u, ogdf::node v);
};
} /* namespace mco */
#endif /* PRIM_ST_SOLVER_H_ */
| [
"fritz.boekler@tu-dortmund.de"
] | fritz.boekler@tu-dortmund.de |
eb497ffb5e5bbc8c44741d6c8763e9a0dcea5664 | bd7d4c148df27f8be6649d313efb24f536b7cf34 | /src/armnn/LayersFwd.hpp | e79149f28f3379bfb32d79ccf75a9b5f7dfd8181 | [
"MIT"
] | permissive | codeaudit/armnn | 701e126a11720760ee8209cc866aa095554696c2 | c577f2c6a3b4ddb6ba87a882723c53a248afbeba | refs/heads/master | 2020-03-29T00:48:17.399665 | 2018-08-31T08:22:23 | 2018-08-31T08:22:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,815 | hpp | ๏ปฟ//
// Copyright ยฉ 2017 Arm Ltd. All rights reserved.
// See LICENSE file in the project root for full license information.
//
#pragma once
#include "InternalTypes.hpp"
#include "layers/ActivationLayer.hpp"
#include "layers/AdditionLayer.hpp"
#include "layers/BatchNormalizationLayer.hpp"
#include "layers/ConstantLayer.hpp"
#include "layers/ConvertFp16ToFp32Layer.hpp"
#include "layers/ConvertFp32ToFp16Layer.hpp"
#include "layers/Convolution2dLayer.hpp"
#include "layers/DepthwiseConvolution2dLayer.hpp"
#include "layers/FakeQuantizationLayer.hpp"
#include "layers/FloorLayer.hpp"
#include "layers/FullyConnectedLayer.hpp"
#include "layers/InputLayer.hpp"
#include "layers/L2NormalizationLayer.hpp"
#include "layers/LstmLayer.hpp"
#include "layers/MemCopyLayer.hpp"
#include "layers/MergerLayer.hpp"
#include "layers/MultiplicationLayer.hpp"
#include "layers/NormalizationLayer.hpp"
#include "layers/OutputLayer.hpp"
#include "layers/PermuteLayer.hpp"
#include "layers/Pooling2dLayer.hpp"
#include "layers/ReshapeLayer.hpp"
#include "layers/ResizeBilinearLayer.hpp"
#include "layers/SoftmaxLayer.hpp"
#include "layers/SplitterLayer.hpp"
namespace armnn
{
template <LayerType Type>
struct LayerTypeOfImpl;
template <LayerType Type>
using LayerTypeOf = typename LayerTypeOfImpl<Type>::Type;
template <typename T>
constexpr LayerType LayerEnumOf(const T* = nullptr);
#define DECLARE_LAYER_IMPL(_, LayerName) \
class LayerName##Layer; \
template <> \
struct LayerTypeOfImpl<LayerType::_##LayerName> \
{ \
using Type = LayerName##Layer; \
}; \
template <> \
constexpr LayerType LayerEnumOf(const LayerName##Layer*) \
{ \
return LayerType::_##LayerName; \
}
#define DECLARE_LAYER(LayerName) DECLARE_LAYER_IMPL(, LayerName)
DECLARE_LAYER(Activation)
DECLARE_LAYER(Addition)
DECLARE_LAYER(BatchNormalization)
DECLARE_LAYER(Constant)
DECLARE_LAYER(ConvertFp16ToFp32)
DECLARE_LAYER(ConvertFp32ToFp16)
DECLARE_LAYER(Convolution2d)
DECLARE_LAYER(DepthwiseConvolution2d)
DECLARE_LAYER(FakeQuantization)
DECLARE_LAYER(Floor)
DECLARE_LAYER(FullyConnected)
DECLARE_LAYER(Input)
DECLARE_LAYER(L2Normalization)
DECLARE_LAYER(Lstm)
DECLARE_LAYER(MemCopy)
DECLARE_LAYER(Merger)
DECLARE_LAYER(Multiplication)
DECLARE_LAYER(Normalization)
DECLARE_LAYER(Output)
DECLARE_LAYER(Permute)
DECLARE_LAYER(Pooling2d)
DECLARE_LAYER(Reshape)
DECLARE_LAYER(ResizeBilinear)
DECLARE_LAYER(Softmax)
DECLARE_LAYER(Splitter)
}
| [
"telmo.soares@arm.com"
] | telmo.soares@arm.com |
a857597d2e17951f0c862977cd9532da8d1b9890 | 011224433894878974bfe00736de22139672411d | /about.h | 4b1e815955942134466d02df2e71eee4cf4f3b90 | [] | no_license | jiaoxiumomo/WeLab | 75fa9b428539eeb62a6a094cef46b8a7c1aa0d4d | d01d40595b27bc2243efc34cc3662db8966f3fbd | refs/heads/master | 2020-05-18T00:53:49.895717 | 2019-04-29T13:21:52 | 2019-04-29T13:21:52 | 184,074,820 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 271 | h | #ifndef ABOUTSYXT_H
#define ABOUTSYXT_H
#include <QDialog>
#include <QLabel>
class about:public QDialog
{
Q_OBJECT
public:
explicit about(QWidget *parent=0);
~about();
QLabel *label1,*label2,*label3;
};
#endif // ABOUTSYXT_H
| [
"noreply@github.com"
] | noreply@github.com |
345dee2c9d81c14b504c9765c3b021aed4994a99 | 79746327bcbe27daf7bfc7b7a9e3f8f560f2311d | /Pods/FirebaseFirestore/Firestore/core/src/firebase/firestore/remote/watch_change.cc | 8c38440347ff6cfcb998b696364bdce31e46aef5 | [
"MIT"
] | permissive | MrsTrier/RememberArt | 7b4ed46adfb551e2e2b76fab1f9480b4d755ae98 | 90314d1f05a1d63b9885ebb17d37bab5134a24f3 | refs/heads/master | 2020-09-26T14:15:03.364618 | 2019-12-11T17:59:13 | 2019-12-11T17:59:13 | 226,270,827 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 129 | cc | version https://git-lfs.github.com/spec/v1
oid sha256:0730dee02b7415a2d4af08ed7345f6c0cec2f39c0163f4c684d1efce98a99a0f
size 2288
| [
"romancheremin@MacBook-Pro-Roman.local"
] | romancheremin@MacBook-Pro-Roman.local |
7e3c788d9affee51f96ae0af6a9bcadaba66991f | 0459547ccd36f02371d67e885946e93147fc5567 | /libbiosim/tools/compare.h | 26f3d560ac13ad51c441c93316f0fbffec2488e8 | [
"MIT"
] | permissive | shze/biosim | 4e44eb5bf29d6a2ccd4294a0e444f7e09e465538 | e9e6d97de0ccf8067e1db15980eb600389fff6ca | refs/heads/master | 2021-01-10T18:38:13.467565 | 2016-03-10T16:23:00 | 2016-03-10T16:23:00 | 23,708,591 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 642 | h | #ifndef tools_compare_h
#define tools_compare_h
namespace biosim {
namespace tools {
// class to use any comparison function as functor; for the function template parameter see:
// http://bytes.com/topic/c/answers/138989-class-template-parameter-function
template <class T, bool F(T const &, T const &)>
class compare {
public:
// function operator taking two instances of type T and using F for the comparison
bool operator()(T const &__instance1, T const &__instance2) { return F(__instance1, __instance2); }
}; // class compare
} // namespace tools
} // namespace biosim
#endif // tools_compare_h
| [
"shze@gmx.de"
] | shze@gmx.de |
0d0c39fa85295832782fa4f16736c431aac2cd5f | a41940688b2761f3cdd1b9ca9b13cbec72790503 | /HKOI_D/CPP/D103.cpp | 2e3f2f75c5a0d469b774d4802ac9d540dbf1e2d3 | [] | no_license | sjcmst/HKOI-New-Solutions | 01a9907cdd1997e319ba77d8d6ab58bd56e3d680 | 86d7a693d0e46746eba78c243198a8b513c2f0a7 | refs/heads/master | 2021-07-14T04:04:59.071481 | 2020-07-15T15:49:28 | 2020-07-15T15:49:28 | 186,787,346 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 233 | cpp | #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
int a;
int b;
int c;
cin >> a;
cin >> b;
cin >> c;
printf("%.3f",1/2.0*a*b*sin(c/180.0*3.1415926));
return 0;
} | [
"oscarmui1127@gmail.com"
] | oscarmui1127@gmail.com |
521117d9c02a630408cff5418192aa31269fac2c | 69289711ad8d4252ea3cd636a93b33d884ed23e2 | /A_Bachgold_Problem.cpp | 70543637d844bb9c97f20b38e0fd8e023cd26650 | [] | no_license | shinigamirex888/A2oj-ladders | 75672819835eab7cb9043c65c1d967ff7ed1196c | 65e76f1a1378e5bc0d4a11a089b80f1525bddab4 | refs/heads/main | 2023-07-25T03:05:09.569120 | 2021-09-03T08:52:07 | 2021-09-03T08:52:07 | 356,104,026 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 377 | cpp | # include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define INF 2000000000
using namespace std;
int main(){
int n;
cin >> n;
int count = n / 2;
cout << count << endl;
for (int i = 0; i < count - 1; i++)
{
cout << 2 << ' ';
}
if (n & 1)
{
cout << 3 << endl;
} else {
cout << 2 << endl;
}
return 0;
} | [
"noreply@github.com"
] | noreply@github.com |
271307ae16c7de8395eeb3f7aa373e7549566d22 | fb4c97fd8bd4b4f7ff0a5804dd11a8018b8e0496 | /c++/gfgCpp/redirect_cout_to_file.cpp | 28a361cdecaa0ec45dab54605033611308428d55 | [] | no_license | mohitarya/geeksforgeeks | 9c78ae57fcd609dda46e20b95479b1368061331e | 19eecf795419675df22d9cf35e39000a2115a25d | refs/heads/master | 2021-04-22T13:05:19.625360 | 2021-03-04T06:05:32 | 2021-03-04T06:05:32 | 53,909,330 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 987 | cpp | #include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main()
{
// AIM === Redirect Cout to a file
// open a file in out mode (Data can be written to the file)
// Save the default cout buffer
// Get the stream buffer of the file
// redirct stream buffer of cout to the file buffer
// Write something to file
// Reset every thing
// Write something to cout
// It should print on Monitor
fstream file;
file.open("cout.txt", ios::out);
streambuf* stream_buf_cout = cout.rdbuf();
// Stream Buf of the file
streambuf* stream_buf_file = file.rdbuf();
// Set cout rdbuf to file buf
cout.rdbuf(stream_buf_file);
// Write some thing to cout it should redirct to file
cout << "This Line written to the file" << endl;
// Redirct cout streambuffer to default one
cout.rdbuf(stream_buf_cout);
cout << "This line written to screen" << endl;
file.close();
return 0;
}
| [
"mohitarya8@gmail.com"
] | mohitarya8@gmail.com |
2e7e33018def5b49d4664cd230d68c66d1b3b59e | 793c8848753f530aab28076a4077deac815af5ac | /src/dskphone/uilogic/diruilogic/src/ldapcontactcontroler.cpp | bcb735f67ad2ad456422667508d79646fbf22c7c | [] | no_license | Parantido/sipphone | 4c1b9b18a7a6e478514fe0aadb79335e734bc016 | f402efb088bb42900867608cc9ccf15d9b946d7d | refs/heads/master | 2021-09-10T20:12:36.553640 | 2018-03-30T12:44:13 | 2018-03-30T12:44:13 | 263,628,242 | 1 | 0 | null | 2020-05-13T12:49:19 | 2020-05-13T12:49:18 | null | UTF-8 | C++ | false | false | 10,887 | cpp | #include "directorycommon.h"
#include "ldapcontactcontroler.h"
#include "translateiddefine.h"
#include "uilogiccommon/include/uilogiclanghelper.h"
#include "diruiadapter.h"
#if DIR_UI_SUPPORT_LOAD_DATA_LIST
#include "ildapuihelper.h"
#endif
#include "commonapi/stringhelperapi.h"
#include "configiddefine/configiddefine.h"
#include "configparser/modconfigparser.h"
typedef YLList<LdapContactData> LIST_LDAP_CONTACT_DATA;
CLDAPContactControler::CLDAPContactControler()
: CDirectoryControler(DIRECTORY_TYPE_LDAP)
{
}
CLDAPContactControler::~CLDAPContactControler()
{
}
CLDAPContactControler * CLDAPContactControler::GetControler(CDirectoryControlerPtr & pControler)
{
if (pControler.IsEmpty() || DIRECTORY_TYPE_LDAP != pControler->GetType())
{
return NULL;
}
return (CLDAPContactControler *)pControler.Get();
}
bool CLDAPContactControler::IsEmptyKeySearch() const
{
return true;
}
bool CLDAPContactControler::PreSearchContact()
{
const yl::string & strSearchKey = GetSearchKey();
DIRUI_INFO("LDAP_ReqSearch(%s)", strSearchKey.c_str());
m_strLastSearchKey = strSearchKey;
// ้่ฟๆ็ดขๆถๆฏ่ฟๅ
if (LDAP_ReqSearch(strSearchKey))
{
if (!m_pUIHelper.IsEmpty())
{
m_pUIHelper->RefreshUI(DIR_UI_REFRESH_TYPE_LIST_VIEW | DIR_UI_REFRESH_TYPE_TITLE,
DIR_UI_REFRESH_PARAM_ALL);
}
return false;
}
return true;
}
#if DIR_UI_FEATURE_LOAD_DATA_LIST
bool CLDAPContactControler::LoadMenuData(int nDataIndex, int nDataCount)
{
return false;
}
bool CLDAPContactControler::LoadListData(int nDataIndex, int nDataCount)
{
ILDAPUIHelper * pLDAPUIHelper = g_DirUIAdapter.GetLDAPUIHelper(m_pUIHelper);
if (NULL == pLDAPUIHelper)
{
return false;
}
const yl::string & strSearchKey = GetSearchKey();
LdapListData listData;
listData.m_nIndexFrom = nDataIndex;
listData.m_nCountToGet = nDataCount;
LDAP_GetContactList(&listData, strSearchKey);
#ifdef DIR_SUPPORT_SWITCH_DETAIL
SetTotalCount(listData.m_nTotalCount);
#endif
return pLDAPUIHelper->FillLDAPContactList(listData);
}
#endif
bool CLDAPContactControler::OnAction(int nAction, int nDataIndex, int nId)
{
DIRUI_INFO("CLDAPContactControler::OnAction(Action:%d Index:%d Id:%d)",
nAction, nDataIndex, nId);
switch (nAction)
{
case DIR_ACTION_COMMON_DETAIL:
{
LdapContactData ldapContact;
if (!GetDetailByIndex(nId, ldapContact))
{
DIRUI_ERR("GetDetailByIndex(%d) fail in CLDAPContactControler::OnAction", nId);
return false;
}
m_nDetailStatus = GetState();
#ifdef DIR_SUPPORT_SWITCH_DETAIL
SetCurIndex(nDataIndex);
#endif
UpdateDetailData(ldapContact);
g_DirUIAdapter.EnterUI(m_nType, DIR_UI_STATE_DETAIL, nAction, nId);
}
break;
case DIR_ACTION_COMMON_SEND:
{
DialContact(nId);
}
break;
case DIR_ACTION_LOCAL_ENTER_COPY_TO_CONTACTS:
{
OnCopyContact(nId, DIR_ACTION_LOCAL_COPY_TO_CONTACTS, kszAllContactId);
}
break;
case DIR_ACTION_LOCAL_ENTER_COPY_TO_BLACKLIST:
{
OnCopyContact(nId, DIR_ACTION_LOCAL_COPY_TO_BLACKLIST, kszBlackListGroupId);
}
break;
#if IF_FEATURE_34162
case DIR_ACTION_LDAP_CHG_PWD:
{
LDAP_ReSetLdapOption();
g_DirUIAdapter.ExitCurrentUI(DIR_UI_STATE_LDAP_CHG_PWD, false);
PreSearchContact();
}
break;
#endif
default:
{
DIRUI_ERR("Action:%d is not be Processed in OnAction", nAction);
return false;
}
break;
}
return true;
}
bool CLDAPContactControler::DialContact(int nContactId, int nAccountId/* = AUTO_ACCOUNT_IDENTIFY*/)
{
LdapContactData ldapContact;
if (!GetDetailByIndex(nContactId, ldapContact))
{
return false;
}
LIST_ATTRIBUTE lsAttr;
ST_CONTACT_ATTRIBUTE stAttr;
bool bDisplayNumber = (0 == configParser_GetConfigInt(kszLdapNumberDisplayMode));//ๅท็ ๅฑๆงๆพ็คบๆฏๅฆไธบNumber
int nNumberCount = ldapContact.m_listNumber.size();
for (int i = 0; i < nNumberCount; ++i)
{
stAttr.m_strName = bDisplayNumber ? _UILOGIC_LANG_TRAN(TRID_NUMBER) : ldapContact.GetNameByIndex(i);
if (bDisplayNumber && nNumberCount > 1)
{
stAttr.m_strName = commonAPI_FormatString("%s%d", stAttr.m_strName.c_str(), i + 1);
}
stAttr.m_strValue = ldapContact.GetNumberByIndex(i);
lsAttr.push_back(stAttr);
}
g_DirUIAdapter.Dial(nAccountId, ldapContact.m_strDisplayName, lsAttr, GetDialAction());
return true;
}
bool CLDAPContactControler::GetContactShowName(yl::string & strName)
{
VEC_DETAIL_DATA::iterator iter = m_vecDetail.begin();
for (; iter != m_vecDetail.end(); ++iter)
{
ST_DETAIL_DATA & stDetail = *iter;
if (DETAIL_DATA_TYPE_NONE == stDetail.nType)
{
strName = stDetail.stAttr.m_strValue;
return true;
}
}
return false;
}
#ifdef DIR_SUPPORT_SWITCH_DETAIL
void CLDAPContactControler::GetDetailInfo(int & nId, int & nIndex, int & nCount) const
{
nIndex = GetCurIndex();
nId = nIndex;
nCount = GetTotalCount();
}
bool CLDAPContactControler::GetContactImage(int nId, yl::string & strImage) const
{
strImage = "";
return true;
}
bool CLDAPContactControler::SwitchContact(int & nId, int & nIndex)
{
LdapListData listData;
listData.m_nIndexFrom = nIndex;
listData.m_nCountToGet = 1;
LDAP_GetContactList(&listData, m_strLastSearchKey);
LIST_LDAP_CONTACT_DATA::iterator iter = listData.m_listData.begin();
if (iter != listData.m_listData.end())
{
UpdateDetailData(*iter);
SetCurIndex(nIndex);
return true;
}
return false;
}
#endif
int CLDAPContactControler::GetBrowseItemAmount()
{
return DIR_INVALID_AMOUNT;
}
int CLDAPContactControler::GetSearchItemAmount()
{
LdapListData listData;
listData.m_nIndexFrom = 0;
listData.m_nCountToGet = 1;
LDAP_GetContactList(&listData, GetSearchKey());
return listData.m_nTotalCount;
}
LRESULT CLDAPContactControler::OnMessage(msgObject & refMessage)
{
if (refMessage.message < LDAP_MESSAGE_BEGIN || refMessage.message > LDAP_MESSAGE_END)
{
return FALSE;
}
DIRUI_INFO("CLDAPContactControler::OnMessage(msg:%d wp:%d lp:%d)",
refMessage.message, refMessage.wParam, refMessage.lParam);
if (LDAP_STATUS_CHANGED == refMessage.message)
{
if (0 == refMessage.lParam)
{
g_DirUIAdapter.ExitAllUI(m_nType);
}
return TRUE;
}
else if (LDAP_SRARCH_RESULT == refMessage.message)
{
char * pszSearchKey = (char *)refMessage.GetExtraData();
if (NULL != pszSearchKey && (0 == strcmp(pszSearchKey, m_strLastSearchKey.c_str())))
{
if (!m_pUIHelper.IsEmpty())
{
m_pUIHelper->RefreshUI(DIR_UI_REFRESH_TYPE_LIST_VIEW | DIR_UI_REFRESH_TYPE_TITLE,
DIR_UI_REFRESH_PARAM_ALL);
}
}
#if IF_FEATURE_34162
if (0 != refMessage.lParam)
{
yl::string strError;
LDAP_GetErrorStringByCode(refMessage.lParam, strError);
bool bAuthError = LDAP_IsAuthError(refMessage.lParam);
g_DirUIAdapter.ShowMsgBox(strError.c_str(), NULL,
bAuthError ? DIR_ACTION_LDAP_ENTER_CHG_PWD : DIR_ACTION_NONE);
}
#endif
return TRUE;
}
return FALSE;
}
int CLDAPContactControler::GetContactAmount()
{
LdapListData listData;
listData.m_nIndexFrom = 0;
listData.m_nCountToGet = 1;
LDAP_GetContactList(&listData, GetSearchKey());
return listData.m_nTotalCount;
}
bool CLDAPContactControler::GetDetailByIndex(int nIndex, LdapContactData & ldapContact)
{
LdapListData listData;
listData.m_nIndexFrom = nIndex;
listData.m_nCountToGet = 1;
LDAP_GetContactList(&listData, m_strLastSearchKey);
LIST_LDAP_CONTACT_DATA::iterator iter = listData.m_listData.begin();
if (iter != listData.m_listData.end())
{
ldapContact = *iter;
return true;
}
return false;
}
void CLDAPContactControler::OnCopyContact(int nIndex, int nAction, int nGroupId)
{
LdapContactData ldapContact;
if (!GetDetailByIndex(nIndex, ldapContact))
{
return;
}
LIST_ATTRIBUTE lsAttr;
ST_CONTACT_ATTRIBUTE stAttr;
stAttr.m_strName = DIR_ATTR_NAME;
stAttr.m_strValue = ldapContact.m_strDisplayName;
lsAttr.push_back(stAttr);
for (int nNumIndex = 0; nNumIndex < ldapContact.m_listNumber.size(); ++nNumIndex)
{
stAttr.m_strName = DIR_ATTR_NUMBER;
stAttr.m_strValue = ldapContact.GetNumberByIndex(nNumIndex);
lsAttr.push_back(stAttr);
}
SetAttributeList(m_nType, lsAttr);
g_DirUIAdapter.EnterUI(DIRECTORY_TYPE_LOCAL, DIR_UI_STATE_ADDITION, nAction, nGroupId);
}
void CLDAPContactControler::UpdateDetailData(LdapContactData & ldapContact)
{
m_vecDetail.clear();
ST_DETAIL_DATA stDetail;
stDetail.nType = DETAIL_DATA_TYPE_NONE;
stDetail.stAttr.m_strName = _UILOGIC_LANG_TRAN(TRID_NAME);
if (ldapContact.m_strDisplayName.empty())
{
stDetail.stAttr.m_strValue = _UILOGIC_LANG_TRAN(TRID_NAME_UNKNOWN);
}
else
{
stDetail.stAttr.m_strValue = ldapContact.m_strDisplayName;
}
m_vecDetail.push_back(stDetail);
bool bDisplayNumber = (0 == configParser_GetConfigInt(kszLdapNumberDisplayMode));//ๅท็ ๅฑๆงๆพ็คบๆฏๅฆไธบNumber
int nNumberCount = ldapContact.m_listNumber.size();
for (int i = 0; i < nNumberCount; ++i)
{
stDetail.nType = DETAIL_DATA_TYPE_NUMBER;
stDetail.stAttr.m_strName = bDisplayNumber ? _UILOGIC_LANG_TRAN(TRID_NUMBER) : ldapContact.GetNameByIndex(i);
if (bDisplayNumber && nNumberCount > 1)
{
stDetail.stAttr.m_strName = commonAPI_FormatString("%s%d", stDetail.stAttr.m_strName.c_str(), i + 1);
}
stDetail.stAttr.m_strValue = ldapContact.GetNumberByIndex(i);
m_vecDetail.push_back(stDetail);
}
}
bool CLDAPContactControler::ExecAction(int nAction, int nDataIndex, int nId)
{
switch (nAction)
{
#if IF_FEATURE_34162
case DIR_ACTION_LDAP_ENTER_CHG_PWD:
{
g_DirUIAdapter.EnterUI(DIRECTORY_TYPE_LDAP, DIR_UI_STATE_LDAP_CHG_PWD, DIR_ACTION_LDAP_CHG_PWD,
knInvalidRId);
return true;
}
break;
#endif
default:
break;
}
return false;
}
| [
"rongxx@yealink.com"
] | rongxx@yealink.com |
2c0f1046d1eee3b44984960d811904160c1be1a0 | d6da79793a93d6684f0b813976c6a479c43a431b | /hw_6/test.cpp | 5c602f2463eb2d6a9b52a19b90452ab610de9cdd | [] | no_license | saladcat/DSC_hw | 03995b71c66788cbc2e68520ae2aed291773933b | 9b13fe898fb252311e917b1da3d9756ebb57eb55 | refs/heads/master | 2021-04-03T06:48:07.724698 | 2018-05-30T17:50:57 | 2018-05-30T17:50:57 | 124,854,394 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 315 | cpp | //
// Created by zhu on 2018/5/30.
//
#include <sstream>
#include <string>
#include <iostream>
using namespace std;
int main() {
string A("ss11");
stringstream ss;
ss << A;
string tem;
int tem2;
ss >> tem;
cout << tem << endl;
ss >> tem2;
cout << tem2 << endl;
return 0;
} | [
"djytyang@gmail.com"
] | djytyang@gmail.com |
9d84104230314536c4847057abaa20ea6119b5ba | ecf8df5e6f3435551133a17f700485f9d4b05053 | /validator/cpp/htmlparser/tokenizer_test.cc | 8c5c9a119fea2ab01f45cdf90652c95564a82334 | [
"Apache-2.0"
] | permissive | ampproject/amphtml | 6565e0c6327ba462166b7ff79bdc69aba736417b | 49ee0db2df07f23511a4525ec116ec60c321d3ea | refs/heads/main | 2023-09-01T19:17:02.576769 | 2023-09-01T18:27:36 | 2023-09-01T18:27:36 | 41,766,002 | 17,232 | 5,216 | Apache-2.0 | 2023-09-14T13:24:04 | 2015-09-01T22:10:53 | JavaScript | UTF-8 | C++ | false | false | 13,206 | cc | #include "cpp/htmlparser/tokenizer.h"
#include "gtest/gtest.h"
#include "cpp/htmlparser/token.h"
// TODO: Add more complex html not-well-formed documents to cover
// complex tokenization scenarios. Eg. <html>><head><<body;>> etc..
TEST(TokenizerTest, BasicTokenizationOfADocument) {
std::string html =
"<html><head><title>hello</title></head><body><div>"
"Hello&World Number # 123</div>"
"<textarea id=\"my-text\" class=\"my-style\">Foo & Bar "
"Number # 123</textarea>"
"<img src=\"foo.png\" /></body></html>";
htmlparser::Tokenizer t(html);
std::vector<htmlparser::Token> tokens;
while (!t.IsEOF()) {
htmlparser::TokenType tt = t.Next();
if (tt == htmlparser::TokenType::ERROR_TOKEN) break;
htmlparser::Token token = t.token();
tokens.push_back(token);
}
EXPECT_EQ(tokens.size(), 16) << "Total 15 tokens generated by tokenizer";
// First three start tags. <html><head><title>.
EXPECT_EQ(tokens[0].token_type, htmlparser::TokenType::START_TAG_TOKEN)
<< "<html> start tag 0";
EXPECT_EQ(tokens[1].token_type, htmlparser::TokenType::START_TAG_TOKEN)
<< "<head> start tag 1";
EXPECT_EQ(tokens[2].token_type, htmlparser::TokenType::START_TAG_TOKEN)
<< "<title> start tag 2";
// Text "hello".
EXPECT_EQ(tokens[3].token_type , htmlparser::TokenType::TEXT_TOKEN)
<< "Text hello in title tag 3";
// End tags. </title></head>.
EXPECT_EQ(tokens[4].token_type , htmlparser::TokenType::END_TAG_TOKEN)
<< "</title> end tag 4";
EXPECT_EQ(tokens[5].token_type , htmlparser::TokenType::END_TAG_TOKEN)
<< "</head end tag 5";
// Start tags. <body><div>
EXPECT_EQ(tokens[6].token_type , htmlparser::TokenType::START_TAG_TOKEN)
<< "<body> start tag 6";
EXPECT_EQ(tokens[7].token_type , htmlparser::TokenType::START_TAG_TOKEN)
<< "<div> start tag 6";
// Text "Hello"
EXPECT_EQ(tokens[8].token_type , htmlparser::TokenType::TEXT_TOKEN)
<< "Hello text token 8";
EXPECT_EQ(tokens[8].data , "Hello&World Number # 123")
<< "Hello string inside <div> 8";
// End div.
EXPECT_EQ(tokens[9].token_type , htmlparser::TokenType::END_TAG_TOKEN)
<< "</div> end tag 9";
// Start textarea.
EXPECT_EQ(tokens[10].token_type , htmlparser::TokenType::START_TAG_TOKEN)
<< "<textarea> start tag 10";
// Two attributes in <textarea>
EXPECT_EQ(tokens[10].attributes.size() , 2)
<< "<textarea 2 attributes.";
EXPECT_EQ(tokens[10].attributes[0].key , "id")
<< "textarea first attribute is id";
EXPECT_EQ(tokens[10].attributes[0].value , "my-text")
<< "textarea first attribute id value is my-text";
EXPECT_EQ(tokens[10].attributes[1].key , "class")
<< "textarea second attribute is class";
EXPECT_EQ(tokens[10].attributes[1].value , "my-style")
<< "textarea second attribute class value is my-style";
// Text content in text area.
EXPECT_EQ(tokens[11].token_type, htmlparser::TokenType::TEXT_TOKEN);
EXPECT_EQ(tokens[11].data, "Foo & Bar Number # 123");
// End textarea.
EXPECT_EQ(tokens[12].token_type , htmlparser::TokenType::END_TAG_TOKEN)
<< "<textarea> end tag 11";
// img tag. self closing.
EXPECT_EQ(tokens[13].token_type ,
htmlparser::TokenType::SELF_CLOSING_TAG_TOKEN)
<< "<img> self closing tag 12";
EXPECT_EQ(tokens[13].attributes.size() , 1)
<< "img only one attribute";
EXPECT_EQ(tokens[13].attributes[0].key , "src")
<< "img first attribute is src";
EXPECT_EQ(tokens[13].attributes[0].value , "foo.png")
<< "img first attribute src value is foo.png";
// Close body, html.
EXPECT_EQ(tokens[14].token_type , htmlparser::TokenType::END_TAG_TOKEN)
<< "body close tag 13";
EXPECT_EQ(tokens[15].token_type , htmlparser::TokenType::END_TAG_TOKEN)
<< "html close tag 14";
EXPECT_EQ(t.LinesProcessed(), 1);
html = R"HTML(
<html>
<head>
<title>hello</title>
</head>
<body>
<div>Hello</div>
<textarea id="my-text" class="my-style"></textarea>
<img src="foo.png" />
</body>
</html>)HTML";
// ^--------- 7th column.
htmlparser::Tokenizer t2(html);
tokens.clear();
while (!t2.IsEOF()) {
htmlparser::TokenType tt = t2.Next();
if (tt == htmlparser::TokenType::ERROR_TOKEN) break;
htmlparser::Token token = t2.token();
if (tt == htmlparser::TokenType::START_TAG_TOKEN) {
switch (token.atom) {
case htmlparser::Atom::TITLE:
EXPECT_EQ(token.line_col_in_html_src.first, 4);
EXPECT_EQ(token.line_col_in_html_src.second, 5);
break;
case htmlparser::Atom::BODY:
EXPECT_EQ(token.line_col_in_html_src.first, 6);
EXPECT_EQ(token.line_col_in_html_src.second, 3);
break;
case htmlparser::Atom::IMG:
EXPECT_EQ(token.line_col_in_html_src.first, 9);
EXPECT_EQ(token.line_col_in_html_src.second, 5);
break;
default:
break;
}
}
tokens.push_back(token);
}
EXPECT_EQ(t2.LinesProcessed(), 11);
EXPECT_EQ(t2.CurrentPosition().first, 11 /* </html> line */);
EXPECT_EQ(t2.CurrentPosition().second, 7 /* end of </html> */);
EXPECT_EQ(tokens.size(), 25 /* 15 + 10 new lines */);
html = R"HTML(
<html>
<head>
<title>hello</title>
</head>
<body>
<div>Hello</div>
<textarea id="my-text" class="my-style"></textarea>
<h1>foo</h1><h2>bar</h2><img src="foo.png" /></body></html>)HTML";
htmlparser::Tokenizer t3(html);
tokens.clear();
while (!t3.IsEOF()) {
htmlparser::TokenType tt = t3.Next();
if (tt == htmlparser::TokenType::ERROR_TOKEN) break;
htmlparser::Token token = t3.token();
tokens.push_back(token);
}
EXPECT_EQ(t3.LinesProcessed(), 9);
EXPECT_EQ(t3.CurrentPosition().first, 9 /* </html> line */);
EXPECT_EQ(t3.CurrentPosition().second, 63 /* end of </html> */);
EXPECT_EQ(tokens.size(), 29 /* 21 + 8 new lines */);
// Multiple tags (especially raw text tags (textarea, noscript, style) on the
// same line.
html = R"HTML(
<html>
<head>
<title>hello</title>
</head>
<body>
<div id="one">helloworld</div><div id="two">anotherdivonsameline</div>
<style id="first">.foo{color:red;}</style><noscript><style id="second">.foo{color:black;}</style></noscript>
</body>
</html>)HTML";
htmlparser::Tokenizer t4(html);
tokens.clear();
while (!t4.IsEOF()) {
htmlparser::TokenType tt = t4.Next();
if (tt == htmlparser::TokenType::ERROR_TOKEN) break;
htmlparser::Token token = t4.token();
if (tt == htmlparser::TokenType::START_TAG_TOKEN) {
tokens.push_back(token);
switch (token.atom) {
case htmlparser::Atom::DIV:
if (token.attributes.at(0).value == "one") {
EXPECT_EQ(token.line_col_in_html_src.first, 7);
EXPECT_EQ(token.line_col_in_html_src.second, 3);
} else {
EXPECT_EQ(token.line_col_in_html_src.first, 7);
EXPECT_EQ(token.line_col_in_html_src.second, 33);
}
break;
case htmlparser::Atom::STYLE:
if (token.attributes.at(0).value == "first") {
EXPECT_EQ(token.line_col_in_html_src.first, 8);
EXPECT_EQ(token.line_col_in_html_src.second, 3);
} else {
EXPECT_EQ(token.line_col_in_html_src.first, 8);
EXPECT_EQ(token.line_col_in_html_src.second, 55);
}
break;
case htmlparser::Atom::NOSCRIPT:
EXPECT_EQ(token.line_col_in_html_src.first, 8);
EXPECT_EQ(token.line_col_in_html_src.second, 45);
break;
default:
break;
}
}
}
EXPECT_EQ(tokens.size(), 8);
// TODO: DO NOT ADD MORE TESTS HERE. Split all above tests in
// their respective test cases.
}
TEST(TokenizerTest, TestMustangTemplateCase) {
std::string_view template_html = R"HTML(<html>
<head></head>
<body>
<template type="amp-mustache">
<p {{#bluetheme}}class=foo{{/bluetheme}}>
<script {{#fastrender}}async{{/fastrender}} src="big.js"></script>
<div data-{{variable}}="hello">hello world</div>
<span data-{{\notallowed}}="hello">hi world</span>
<h1 data-{{/notallowed}}="hello">hi world</h1>
<h2 data-{{#allowed}}foo{{/allowed}}="hello">hi world</h1>
<img {{#border}}class=border src=foo.png>
</template>
</body>
</html>)HTML";
std::vector<htmlparser::Token> tokens;
htmlparser::Tokenizer t(template_html);
while (!t.IsEOF()) {
htmlparser::TokenType tt = t.Next(true);
if (tt == htmlparser::TokenType::ERROR_TOKEN) break;
htmlparser::Token token = t.token();
if (tt == htmlparser::TokenType::START_TAG_TOKEN) {
tokens.push_back(token);
switch (token.atom) {
case htmlparser::Atom::TEMPLATE:
EXPECT_EQ(token.attributes.size(), 1);
EXPECT_EQ(token.attributes.at(0).key, "type");
EXPECT_EQ(token.attributes.at(0).value, "amp-mustache");
break;
case htmlparser::Atom::P:
EXPECT_EQ(token.attributes.size(), 1);
EXPECT_EQ(token.attributes.at(0).key,
"{{#bluetheme}}class");
EXPECT_EQ(token.attributes.at(0).value, "foo{{/bluetheme}}");
break;
case htmlparser::Atom::SCRIPT:
EXPECT_EQ(token.attributes.size(), 2);
EXPECT_EQ(token.attributes.at(0).key,
"{{#fastrender}}async{{/fastrender}}");
EXPECT_EQ(token.attributes.at(0).value, "");
EXPECT_EQ(token.attributes.at(1).key, "src");
EXPECT_EQ(token.attributes.at(1).value, "big.js");
break;
case htmlparser::Atom::DIV:
EXPECT_EQ(token.attributes.size(), 1);
EXPECT_EQ(token.attributes.at(0).key, "data-{{variable}}");
EXPECT_EQ(token.attributes.at(0).value, "hello");
break;
case htmlparser::Atom::SPAN:
EXPECT_EQ(token.attributes.size(), 1);
EXPECT_EQ(token.attributes.at(0).key, "data-{{\\notallowed}}");
EXPECT_EQ(token.attributes.at(0).value, "hello");
break;
case htmlparser::Atom::H1:
EXPECT_EQ(token.attributes.size(), 2);
EXPECT_EQ(token.attributes.at(0).key, "data-{{");
EXPECT_EQ(token.attributes.at(0).value, "");
EXPECT_EQ(token.attributes.at(1).key, "notallowed}}");
EXPECT_EQ(token.attributes.at(1).value, "hello");
break;
case htmlparser::Atom::H2:
EXPECT_EQ(token.attributes.size(), 1);
EXPECT_EQ(token.attributes.at(0).key,
"data-{{#allowed}}foo{{/allowed}}");
EXPECT_EQ(token.attributes.at(0).value, "hello");
break;
case htmlparser::Atom::IMG:
EXPECT_EQ(token.attributes.size(), 2);
EXPECT_EQ(token.attributes.at(0).key, "{{#border}}class");
EXPECT_EQ(token.attributes.at(0).value, "border");
EXPECT_EQ(token.attributes.at(1).key, "src");
EXPECT_EQ(token.attributes.at(1).value, "foo.png");
break;
default:
break;
}
}
}
EXPECT_EQ(tokens.size(), 11);
// Tokenization differs slightly in non-template mode.
tokens.clear();
htmlparser::Tokenizer t2(template_html);
while (!t2.IsEOF()) {
htmlparser::TokenType tt = t2.Next(false);
if (tt == htmlparser::TokenType::ERROR_TOKEN) break;
htmlparser::Token token = t2.token();
if (tt == htmlparser::TokenType::START_TAG_TOKEN) {
tokens.push_back(token);
switch (token.atom) {
case htmlparser::Atom::TEMPLATE:
EXPECT_EQ(token.attributes.size(), 1);
EXPECT_EQ(token.attributes.at(0).key, "type");
EXPECT_EQ(token.attributes.at(0).value, "amp-mustache");
break;
case htmlparser::Atom::P:
EXPECT_EQ(token.attributes.size(), 1);
EXPECT_EQ(token.attributes.at(0).key,
"{{#bluetheme}}class");
EXPECT_EQ(token.attributes.at(0).value, "foo{{/bluetheme}}");
break;
case htmlparser::Atom::SCRIPT:
EXPECT_EQ(token.attributes.size(), 3); // <-- template mode 2.
EXPECT_EQ(token.attributes.at(0).key,
"{{#fastrender}}async{{"); // template mode entire block.
EXPECT_EQ(token.attributes.at(0).value, "");
EXPECT_EQ(token.attributes.at(1).key, "fastrender}}");
EXPECT_EQ(token.attributes.at(1).value, "");
EXPECT_EQ(token.attributes.at(2).key, "src");
EXPECT_EQ(token.attributes.at(2).value, "big.js");
break;
case htmlparser::Atom::DIV:
EXPECT_EQ(token.attributes.size(), 1);
EXPECT_EQ(token.attributes.at(0).key, "data-{{variable}}");
EXPECT_EQ(token.attributes.at(0).value, "hello");
break;
case htmlparser::Atom::IMG:
EXPECT_EQ(token.attributes.size(), 2);
EXPECT_EQ(token.attributes.at(0).key, "{{#border}}class");
EXPECT_EQ(token.attributes.at(0).value, "border");
EXPECT_EQ(token.attributes.at(1).key, "src");
EXPECT_EQ(token.attributes.at(1).value, "foo.png");
break;
default:
break;
}
}
}
EXPECT_EQ(tokens.size(), 11);
}
| [
"noreply@github.com"
] | noreply@github.com |
f81a06f1ac8c847bc2dad794cad4c043c31ac0d9 | 0f3d5fc915dda8062659451181733998cd190840 | /Ch 3/even_n_odd_numbers/even_n_odd_numbers/main.cpp | 741cd120104830ab92d36b4bae6cf45f0d7bad6f | [] | no_license | art-lux/Stroustrup | c65dd513385af214a6da703683b1890e918155c7 | a17e25b280bef5594659f28d3cadccc47f3a4eb6 | refs/heads/master | 2020-04-14T19:51:03.049633 | 2018-06-21T13:21:12 | 2018-06-21T13:21:12 | 68,118,602 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 394 | cpp | #include <iostream>
#include <conio.h>
#include <string>
using namespace std;
void main()
{
string res;
cout << "Input 0 for exit." << endl;
while (cin >> res)
{
if (int number = atoi(res.c_str()))
{
cout << "Number " << number << " is ";
if (number % 2 == 0)
{
cout << "even." << endl;
}
else
{
cout << "odd." << endl;
}
}
else
{
break;
}
}
} | [
"180116art.gmail.com"
] | 180116art.gmail.com |
96e5bea1eb856c1dac508b67cf60bc042d795b82 | 78683361a94e2fae93f4ec0f4384c395e6be4b45 | /line_following/Motors.h | ba7935695b180aeb9b04de58a72075ac67451a1c | [] | no_license | msahmed1/romi | 9dfe33d4d36fb47bc18a09839ce79e846d15a467 | d349ce12bb6d0ab9e662a5998f5e1a317d81580f | refs/heads/master | 2022-12-30T08:39:04.844043 | 2020-10-16T11:07:24 | 2020-10-16T11:07:24 | 302,466,952 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 425 | h | #ifndef MY_MOTORS_H
#define MY_MOTORS_H
#include "arduino.h"
class motors_c {
public:
motors_c( byte set_L_PWM_PIN, byte set_L_DIR_PIN, byte set_R_PWM_PIN , byte set_R_DIR_PIN );
~motors_c();
steering(float dir);
breaks() {
analogWrite( L_PWM_PIN, 0 );
analogWrite( R_PWM_PIN, 0 );
}
private:
byte L_PWM_PIN;
byte L_DIR_PIN;
byte R_PWM_PIN;
byte R_DIR_PIN;
};
#endif
| [
"shabaj_ahmed@outlook.com"
] | shabaj_ahmed@outlook.com |
d498e86ea17d0605043d229319aea9b11908e8c1 | dba4b0d853efbdf7752d30054394d0b7f6f66051 | /fifteen.cpp | aae058b3fc463bba0ceba7e3ec393972866cd277 | [] | no_license | dbondin/am15-ds | b3a404c3bf60b2ec20f805b5077f8ce05bd8ba0d | bc5d665820a8c56aa460e309902cbe0948191510 | refs/heads/master | 2021-01-22T03:58:12.115281 | 2018-02-19T09:05:16 | 2018-02-19T09:05:16 | 81,488,391 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,703 | cpp | #include <iostream>
#include <cstring>
#include <cstdarg>
#include <cmath>
#include <list>
#define FIELD_WIDTH 3
#define FIELD_HEIGHT 3
enum MOVE_DIRECTION {
_START = 0, LEFT = 0, RIGHT, UP, DOWN, _END
};
class Field {
private:
unsigned char elem[FIELD_HEIGHT * FIELD_WIDTH];
unsigned char zero_pos;
public:
Field();
Field(int e, ...);
bool move(MOVE_DIRECTION md);
bool equals(const Field & other) const;
long get_check_index() const;
void print() const;
};
void
Field::print() const {
for(int i=0; i<FIELD_HEIGHT; ++i) {
for(int j=0; j<FIELD_WIDTH; ++j) {
char e = elem[i * FIELD_WIDTH + j];
if(e == 0) {
e = '_';
}
else {
e += '0';
}
std::cout<<e<<" ";
}
std::cout<<std::endl;
}
}
long
Field::get_check_index() const {
long result = 0;
for(int i=0; i<FIELD_HEIGHT * FIELD_WIDTH; ++i) {
result *= (FIELD_HEIGHT * FIELD_WIDTH);
result += elem[i];
}
return result;
}
Field::Field() {
zero_pos = 0;
}
bool Field::equals(const Field & other) const {
return (memcmp(this->elem, other.elem, FIELD_WIDTH * FIELD_HEIGHT) == 0);
}
bool Field::move(MOVE_DIRECTION md) {
unsigned char new_zero_pos;
switch (md) {
case LEFT:
if((zero_pos % FIELD_WIDTH) == 0) {
return false;
}
new_zero_pos = zero_pos - 1;
break;
case RIGHT:
if((zero_pos % FIELD_WIDTH) == (FIELD_WIDTH - 1)) {
return false;
}
new_zero_pos = zero_pos + 1;
break;
case UP:
if(zero_pos < FIELD_WIDTH) {
return false;
}
new_zero_pos = zero_pos - FIELD_WIDTH;
break;
case DOWN:
if(zero_pos >= (FIELD_WIDTH * (FIELD_HEIGHT - 1))) {
return false;
}
new_zero_pos = zero_pos + FIELD_WIDTH;
break;
default:
return false;
}
unsigned char tmp = elem[zero_pos];
elem[zero_pos] = elem[new_zero_pos];
elem[new_zero_pos] = tmp;
zero_pos = new_zero_pos;
return true;
}
Field::Field(int e, ...) {
va_list argp;
va_start(argp, e);
//TODO: Add check to ensure all values are valid
elem[0] = e;
for(int i=1; i<FIELD_WIDTH * FIELD_HEIGHT; ++i) {
unsigned char el = (unsigned char) va_arg(argp, int);
elem[i] = el;
}
zero_pos = 0;
for(int i=0; i<FIELD_WIDTH * FIELD_HEIGHT; ++i) {
if(elem[i] == 0) {
zero_pos = i;
break;
}
}
va_end(argp);
}
const Field WIN1(1, 2, 3, 4, 5, 6, 7, 8, 0);
const Field WIN2(1, 2, 3, 5, 4, 6, 8, 7, 0);
bool check_if_win(const Field & f) {
return f.equals(WIN1) || f.equals(WIN2);
}
class TreeNode {
private:
Field field;
const TreeNode * parent;
public:
TreeNode();
TreeNode(const Field & f, const TreeNode * parent);
Field get_field() const;
const TreeNode * get_parent() const;
};
Field
TreeNode::get_field() const {
return this->field;
}
const TreeNode *
TreeNode::get_parent() const {
return this->parent;
}
TreeNode::TreeNode() : field(), parent(NULL) {
}
TreeNode::TreeNode(const Field & f, const TreeNode * parent) {
this->field = f;
this->parent = parent;
}
const Field START(1, 2, 5, 4, 3, 0, 7, 6, 8);
unsigned long factorial(unsigned long i) {
if(i<2) {
return 1;
}
return i * factorial(i-1);
}
TreeNode * NODES;
int CURRENT_NODE = 0;
int NODES_COUNT = 0;
bool * CHECK;
void process_win(int node_index) {
const TreeNode * n = &(NODES[node_index]);
std::list<Field> lst;
while(true) {
lst.push_front(n->get_field());
n = n->get_parent();
if(n == NULL) {
break;
}
}
int num=0;
for(std::list<Field>::iterator i=lst.begin(); i!=lst.end(); ++i) {
std::cout<<"-------------- "<<++num<<std::endl;
i->print();
}
std::cout<<"END"<<std::endl;
}
int main(int argc, char **argv) {
CHECK = new bool[(unsigned long)pow((FIELD_HEIGHT * FIELD_WIDTH), (FIELD_HEIGHT * FIELD_WIDTH))];
memset(CHECK, 0, (unsigned long)pow((FIELD_HEIGHT * FIELD_WIDTH), (FIELD_HEIGHT * FIELD_WIDTH)));
NODES = new TreeNode[factorial(FIELD_WIDTH * FIELD_HEIGHT) / 2];
if(check_if_win(START)) {
std::cout<<"ะกัะฐะทั WIN"<<std::endl;
}
NODES[NODES_COUNT] = TreeNode(START, NULL);
NODES_COUNT++;
bool found = false;
while(!found) {
if(CURRENT_NODE >= NODES_COUNT) {
break;
}
for(long dir = _START; dir < _END; ++dir) {
Field f = NODES[CURRENT_NODE].get_field();
bool status = f.move((MOVE_DIRECTION)dir);
if(status) {
// Already was in place?
long check_index = f.get_check_index();
if(CHECK[check_index] == false) {
CHECK[check_index] = true;
TreeNode new_node(f, &(NODES[CURRENT_NODE]));
NODES[NODES_COUNT] = new_node;
//std::cout<<"ADD NEW ONE"<<std::endl;
//f.print();
if(check_if_win(f)) {
found = true;
process_win(NODES_COUNT);
break;
}
NODES_COUNT++;
}
}
}
CURRENT_NODE ++;
}
delete [] NODES;
delete [] CHECK;
return 0;
}
| [
"dbondin@ya.ru"
] | dbondin@ya.ru |
cab988fd3e88ec6458e65a1d18d9a7cc64a646d4 | d1ca9f9fbb1817a80e9051a5ab2b2a31efb1bb07 | /tests/unit/core/OrgIterator.cpp | f0dd3d0c2909091c335a2f763b7758179abee3e6 | [
"MIT"
] | permissive | mercere99/MABE2 | dbdf3fdd208b752149cf2bf1f083155b001de79c | 7eba5d316604815a35d1c3bd0e69dde594e77634 | refs/heads/master | 2023-09-03T22:23:56.594269 | 2023-08-29T22:22:24 | 2023-08-29T22:22:24 | 189,902,530 | 5 | 18 | MIT | 2022-07-19T19:26:17 | 2019-06-02T22:44:11 | C++ | UTF-8 | C++ | false | false | 504 | cpp | /**
* @note This file is part of MABE, https://github.com/mercere99/MABE2
* @copyright Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
* @date 2019-2021.
*
* @file OrgIterator.cpp
* @brief TODO. Currently this is a placeholder so codecov will see the untested source code
*/
// CATCH
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
// MABE
#include "core/OrgIterator.hpp"
#include "core/Population.hpp"
TEST_CASE("OrgIterator_Placeholder", "[core]"){ ; }
| [
"ferguson.austin.j@gmail.com"
] | ferguson.austin.j@gmail.com |
2dc4be12d7533bc71f6a873195c82a8a61657001 | 98fc4e8d1c8ee8c9b58028fda6bae3f707c1e453 | /CP/Leetcode/DP/Linear_DP/26_1025_divisor_game.cpp | b7a6a561a056ae9942d7fe554a76b5b2c376b959 | [] | no_license | ak566g/Data-Structures-and-Algorithms | 709d8d94a2dd691946ed4d75a9d77ece8d9362c9 | 3ae969da99bdf6211c2f9bc69b6ddf0c1c7ee642 | refs/heads/master | 2023-08-20T05:48:40.975444 | 2021-10-14T09:51:02 | 2021-10-14T09:51:02 | 287,715,287 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,087 | cpp | // class Solution {
// public:
// bool divisorGame(int n) {
// return n%2==0;
// }
// };
class Solution {
public:
bool divisorGame(int n) {
if(n==1)return false; //base case if n==1 alice can't select any number such that n%i==0 so false
// create a dp table of size n+1 and we fill it in bottom-up fashion i.e if n= 1,2,3...
//then whether alice wins in this cases or not
int dp[n+1];
memset(dp, 0, sizeof(dp)); //initialize all values as false
dp[2]=true; //base case if n==2 2nd player can't make any move so alice wins
//Now fill in bottom-up fashion: for each i we check if alice wins fornot by looping
//values from j=1 to j<=sqrt(i) and check if any values of j in this range divides i
//and dp[i-j] ==false then alice wins this game
for(int i=3;i<=n;i++)
{
for(int j=1;j*j<=i;j++){
if(i%j==0 && dp[i-j]== false)
dp[i]=true;
}
}
//return final ans
return dp[n];
}
}; | [
"anki01.g@gmail.com"
] | anki01.g@gmail.com |
474bf7328a3e225b01c563414dbb18162d98e9bd | c1501a18f6d3fe138b1a1c5ebebefc8fcd24392a | /Codeforces/1299B.cpp | 35e23cfb42b46cfad5dcda142d71bcfe66cf4fa6 | [] | no_license | Simon-0801/CodeHome | 5b2125b5926df4d6f9c63b2e7da993d717ddcda2 | 88ab5c776e5a7b711419928d645212088f3b1858 | refs/heads/master | 2020-12-14T11:06:21.286016 | 2020-10-14T13:19:01 | 2020-10-14T13:19:01 | 234,722,194 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 825 | cpp | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int maxn = 100000 + 5;
struct node
{
ll x,y;
}p[maxn];
int main() {
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%I64d%I64d",&p[i].x,&p[i].y);
}
node pre=p[n];
for(int i=1;i<=n;i++){
node now=p[i];
p[i].x-=pre.x;
p[i].y-=pre.y;
pre=now;
}
if(n&1) printf("NO\n");
else{
int mid=n/2,flag=1;
for(int i=1;i<=mid;i++){
if(p[i].x!=-1*p[i+mid].x||p[i].y!=-1*p[i+mid].y){
flag=0;
break;
}
}
if(flag) printf("YES\n");
else printf("NO\n");
}
return 0;
} | [
"noreply@github.com"
] | noreply@github.com |
a58ab15f65d6b4137aa1f1f81793da985556a562 | e31fb48774c222359a93850ecfd5cb6b188091d2 | /458 - The Decoder.cpp | 9a39c350ce039bddad5a48b49da1fe30cd7e6f8c | [] | no_license | protickcse22/Uva_problem | e9c2eda7378975f85f64662f9c3ff83816b13239 | 1b8e09240648f1f7c2130ed47bf77bbbd34ca7aa | refs/heads/master | 2020-03-27T12:45:45.634215 | 2018-08-29T08:16:54 | 2018-08-29T08:16:54 | 146,567,584 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 307 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
char s;
while((s=getchar())!=EOF)
{
if(s == '\n')
putchar(s);
else
{
int i = s;
int x = i - 7;
char c = x;
putchar(c);
}
}
return 0;
}
| [
"protickju22@gmail.com"
] | protickju22@gmail.com |
67dfab1eddcf9ec99f2a325b3fab13c408d8a553 | 2d572a776b12c8fdaac684d2219eae575473f589 | /Packet.cpp | bd028e540766d2f8edb184577c9a3b9217de20c7 | [] | no_license | MalenaMaffei/TallerTP2 | 73e862e12d1dae0e5a816d9aa36dace65084174f | 44656c4ae5d81c69059f5541b02cf8e2d578d60a | refs/heads/master | 2021-03-16T05:11:41.795128 | 2017-04-18T05:52:27 | 2017-04-18T05:52:27 | 87,730,595 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,201 | cpp | #include <string>
#include <iostream>
#include "Packet.h"
// TODO implementar tema de flags y offsets
Packet::Packet(string id, string src, string dst, unsigned char flag,
short offset, short len) {
this->id = id;
this->src = src;
this->dst = dst;
this->data = "";
this->flag = flag;
this->offset = offset;
this->len = len;
complete = (offset == 0 && flag ==0);
}
Packet::~Packet() {
//por ahora nada que hacer
}
const string &Packet::getData() const {
return data;
}
short Packet::getLength() const {
return len;
}
const string Packet::getId() const {
return id;
}
const string Packet::getSrc() const {
return src;
}
const string Packet::getDst() const {
return dst;
}
const bool Packet::is_complete() const {
return complete;
}
void Packet::setData(const string &data) {
Packet::data = data;
}
bool Packet::operator==(const Packet& other) const{
bool match_src = this->src == other.src;
bool match_dst = this->dst == other.dst;
bool match_id = this->id == other.id;
return match_dst && match_src && match_id;
}
bool Packet::operator>(const Packet& other) const{
//el mayor es el ultimo
return offset > other.offset;
}
bool Packet::operator<(const Packet& other) const{
//el mayor es el ultimo
return offset < other.offset;
}
bool Packet::is_first() const{
return offset == 0;
}
bool Packet::is_last() const{
return flag == 0;
}
bool Packet::is_next(const Packet& other){
// std::cout << "off + len: " << offset + len <<std::endl;
// std::cout << "otro off: " << other.offset << std::endl;
return (offset + len) == other.offset;
}
int Packet::mergePacket(const Packet& nextPacket ){
if (!is_next(nextPacket)){ return -1; }
string first_data = this->data;
string next_data = nextPacket.data;
string complete_data = first_data + " " + next_data;
this->data = complete_data;
this->len += nextPacket.len;
this->flag = nextPacket.flag;
if (is_first() && nextPacket.is_last()){
complete = true;
}
return 0;
}
short Packet::getOffset() const {
return offset;
}
unsigned char Packet::getFlag() const {
return flag;
}
| [
"malenamaffei@hotmail.com"
] | malenamaffei@hotmail.com |
4c271a3edef90bd160f0e30f9b8c8fd0f94ee4d7 | ca8601539e997c57ffffb42e255cd1757834c6d7 | /Source/CarBehaviorTree/ChangeStopSignLocation.h | 25a14ce4c69eae52884aa515f49fe106e9f524ef | [] | no_license | ElonGame/CarBehaviorTree | eadb01d10501454d0f8bf3c9ec314b7c4bd3bbe6 | 50a00109669c28b10869a5909f0fd702a247cf06 | refs/heads/master | 2021-01-04T18:41:23.808400 | 2019-11-26T21:36:41 | 2019-11-26T21:36:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 485 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/Tasks/BTTask_BlackboardBase.h"
#include "ChangeStopSignLocation.generated.h"
/**
*
*/
UCLASS()
class CARBEHAVIORTREE_API UChangeStopSignLocation : public UBTTask_BlackboardBase
{
GENERATED_BODY()
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override;
void PrintLog(FString Text);
};
| [
"jawadefaj006@gmail.com"
] | jawadefaj006@gmail.com |
82f154d7f1ca4af551bb384b4e7b900ccd94ba43 | d2285bab09d40be62c4357f90a5d46b673d1f12b | /src/Menge/MengeVis/Runtime/GoalRenderer/GoalRenderer.cpp | c0b7afda3a6c0a5f356977a5963ef5bdd39b12d2 | [
"Apache-2.0"
] | permissive | mfprado/Menge | 5a6ae2bd53e539adcbdb9f9cbf9af5723078d1a4 | 75b1ebe91989c2a58073444fb2d5908644856372 | refs/heads/master | 2020-04-19T13:10:25.101581 | 2019-02-21T02:11:00 | 2019-02-21T02:11:00 | 168,211,094 | 0 | 0 | Apache-2.0 | 2019-02-21T02:11:01 | 2019-01-29T19:03:59 | C++ | UTF-8 | C++ | false | false | 1,334 | cpp | #include "MengeVis/Runtime/GoalRenderer/GoalRenderer.h"
#include "MengeCore/BFSM/Goals/Goal.h"
#include "MengeVis/SceneGraph/graphCommon.h"
namespace MengeVis {
namespace Runtime {
namespace GoalVis {
using Menge::Math::Vector2;
/////////////////////////////////////////////////////////////////////
// Implementation of GoalRenderer
/////////////////////////////////////////////////////////////////////
void GoalRenderer::drawGL() const {
// TODO: Write the type of the goal as well as displaying the assignment and
// capacity of the goal.
glPushAttrib( GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_POLYGON_BIT |
GL_DEPTH_BUFFER_BIT );
glDepthMask( GL_FALSE );
glColor4f( 0.75f, 0.1f, 0.75f, 0.25f );
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
doDrawGeometry();
glDisable( GL_BLEND );
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
doDrawGeometry();
glPopAttrib();
}
/////////////////////////////////////////////////////////////////////
void GoalRenderer::doDrawGeometry() const {
glBegin( GL_POINTS );
const Vector2 p = _goal->getCentroid();
glVertex3f( p.x(), p.y(), 0.f );
glEnd();
}
}
} // namespace Runtime
} // namespace MengeVIs | [
"menge@cs.unc.edu"
] | menge@cs.unc.edu |
6a1d57f76bf43b311a4d372f9484d0108ff9ff96 | 11a246743073e9d2cb550f9144f59b95afebf195 | /acmsgu/499.cpp | 066e0ed649ec43be3dbbf729452939c07cd19e95 | [] | no_license | ankitpriyarup/online-judge | b5b779c26439369cedc05c045af5511cbc3c980f | 8a00ec141142c129bfa13a68dbf704091eae9588 | refs/heads/master | 2020-09-05T02:46:56.377213 | 2019-10-27T20:12:25 | 2019-10-27T20:12:25 | 219,959,932 | 0 | 1 | null | 2019-11-06T09:30:58 | 2019-11-06T09:30:57 | null | UTF-8 | C++ | false | false | 1,045 | cpp | #include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
constexpr int MAXN = 1e5 + 5;
constexpr int MAXV = 1e6 + 66;
int n;
int freq[MAXV];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n, x;
scanf(" %d", &n);
for (int i = 0; i < n; ++i) {
scanf(" %d", &x);
++freq[x];
}
int ans = 1;
for (int i = 2; i < MAXV; ++i) {
int tot_occ = 0;
for (int j = i; j < MAXV; j += i) {
tot_occ += freq[j];
}
if (tot_occ >= 2)
ans = i;
}
printf("%d\n", ans);
return 0;
}
| [
"arnavsastry@gmail.com"
] | arnavsastry@gmail.com |
140dca798e163981c318f33539638d499185d1ac | e1459066a61cf5ecfe0a1e8ecc4d9799b1ebb90d | /bc25793-TestLife.c++ | 2bdd5dda02ae3e0d2742d88aa87fac55d30e3316 | [] | no_license | baod-rate/life-tests | 5d43d6ff1fcb13d51c842af850a75b3faac08820 | f447c5f94950a4e86f6382de8f7b205477e02560 | refs/heads/master | 2023-07-09T16:51:10.830274 | 2016-11-22T23:36:00 | 2016-11-22T23:36:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,231 | // --------------------------
// projects/life/TestLife.c++
// Copyright (C) 2016
// Glenn P. Downing
// --------------------------
// https://code.google.com/p/googletest/wiki/V1_7_Primer#Basic_Assertions
// --------
// includes
// --------
#include "gtest/gtest.h"
#include "Life.h"
#include <iostream>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// ----
// Cell Tests
// ----
TEST(LifeFixture, Cell_Default_Constructor1) {
Cell a;
ASSERT_EQ(a._p, nullptr);
}
TEST(LifeFixture, Cell_Default_Constructor2) {
Cell a;
Cell b;
ASSERT_EQ(a._p, nullptr);
}
TEST(LifeFixture, Cell_Default_Constructor3) {
Cell a;
Cell b;
ASSERT_EQ(b._p, nullptr);
}
TEST(LifeFixture, Cell_Constructor1) {
Cell a = new ConwayCell(false);
ASSERT_NE(a._p, nullptr);
}
TEST(LifeFixture, Cell_Constructor2) {
Cell a = new ConwayCell(false);
Cell b = new ConwayCell(true);
ASSERT_NE(a._p, nullptr);
if (a._p != nullptr) {
ASSERT_EQ((a._p)->_alive, false);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, Cell_Constructor3) {
Cell a = new ConwayCell(false);
Cell b = new ConwayCell(true);
if (b._p != nullptr) {
ASSERT_NE((b._p)->_alive, false);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, Cell_Copy_Constructor1) {
Cell a = new ConwayCell(false);
Cell b = a;
if (a._p != nullptr && b._p != nullptr) {
ASSERT_FALSE(a._p->_alive);
ASSERT_FALSE(b._p->_alive);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, Cell_Copy_Constructor2) {
Cell a = new ConwayCell(false);
Cell b = new ConwayCell(true);
b = a;
if (a._p != nullptr && b._p != nullptr) {
ASSERT_FALSE(a._p->_alive);
ASSERT_FALSE(b._p->_alive);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, Cell_Copy_Constructor3) {
Cell a = new ConwayCell(false);
Cell b = a;
a = b;
ConwayCell *c = dynamic_cast<ConwayCell *>(a._p);
ConwayCell *d = dynamic_cast<ConwayCell *>(b._p);
if (c != nullptr && d != nullptr) {
bool cb = c->_alive;
ASSERT_FALSE(cb);
bool db = d->_alive;
ASSERT_FALSE(db);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, Cell_Copy_Assignment_Constructor1) {
Cell a = new ConwayCell(false);
Cell b = new ConwayCell(true);
if (a._p != nullptr && b._p != nullptr) {
ASSERT_TRUE(b._p->_alive);
b = a;
ASSERT_NE(b._p, nullptr);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, Cell_Copy_Assignment_Constructor2) {
Cell a = new ConwayCell(false);
Cell b = new ConwayCell(true);
if (a._p != nullptr && b._p != nullptr) {
ASSERT_TRUE(b._p->_alive);
b = a;
a = b;
Cell c = a;
if (c._p != nullptr) {
ASSERT_NE(b._p, nullptr);
ASSERT_NE(c._p, nullptr);
ASSERT_FALSE(b._p->_alive);
}
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, Cell_Copy_Assignment_Constructor3) {
Cell a = new ConwayCell(false);
Cell b = new ConwayCell(true);
if (b._p != nullptr)
ASSERT_TRUE(b._p->_alive);
b = a;
Cell c = new ConwayCell(true);
c = b;
ASSERT_NE(b._p, nullptr);
if (c._p != nullptr) {
ASSERT_FALSE(c._p->_alive);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, Cell_evolve1) {
Cell a = new ConwayCell(true);
vector<Cell *> neighbors(8);
Cell b = (new ConwayCell(true));
neighbors[0] = &b;
Cell c = (new ConwayCell(false));
neighbors[1] = &c;
Cell d = (new ConwayCell(true));
neighbors[2] = &d;
a.evolve(neighbors, false);
ASSERT_EQ(a._p->_alive, true);
}
TEST(LifeFixture, Cell_evolve2) {
Cell a = new ConwayCell(false);
vector<Cell *> neighbors(8);
Cell b = (new ConwayCell(true));
neighbors[0] = &b;
Cell c = (new ConwayCell(false));
neighbors[3] = &c;
Cell d = (new ConwayCell(true));
neighbors[4] = &d;
Cell e = (new ConwayCell(true));
neighbors[6] = &e;
a.evolve(neighbors, false);
ASSERT_EQ(a._p->_alive, true);
}
TEST(LifeFixture, Cell_evolve3) {
Cell a = new FredkinCell(true);
vector<Cell *> neighbors(8);
Cell b = (new FredkinCell(true));
neighbors[0] = &b;
a.evolve(neighbors, false);
ASSERT_EQ(a._p->_alive, false);
ASSERT_EQ((dynamic_cast<FredkinCell *>(a._p))->_age, 0);
}
TEST(LifeFixture, Cell_numAlive1) {
vector<Cell *> neighbors(8);
Cell a = new FredkinCell(true);
neighbors[0] = &a;
Cell b = (new FredkinCell(true));
neighbors[1] = &b;
Cell c = (new FredkinCell(false));
neighbors[2] = &c;
Cell d = (new FredkinCell(true));
neighbors[3] = &d;
Cell e = (new FredkinCell(true));
neighbors[4] = &e;
ASSERT_EQ(Cell::numAlive(neighbors), 4);
}
TEST(LifeFixture, Cell_numAlive2) {
vector<Cell *> neighbors(8);
Cell a = new ConwayCell(true);
neighbors[0] = &a;
Cell b = (new ConwayCell(true));
neighbors[1] = &b;
ASSERT_EQ(Cell::numAlive(neighbors), 2);
}
TEST(LifeFixture, Cell_numAlive3) {
vector<Cell *> neighbors(8);
ASSERT_EQ(Cell::numAlive(neighbors), 0);
}
TEST(LifeFixture, Cell_print1) {
Cell a = new ConwayCell(false);
ostringstream str;
str << a;
ASSERT_EQ(str.str(), ".");
}
TEST(LifeFixture, Cell_print2) {
Cell a = new FredkinCell(true);
ostringstream str;
str << a;
ASSERT_EQ(str.str(), "0");
}
TEST(LifeFixture, Cell_print3) {
Cell a = new ConwayCell(true);
ostringstream str;
str << a;
ASSERT_EQ(str.str(), "*");
}
// ----
// ConwayCell Tests
// ----
TEST(LifeFixture, ConwayCell_Default_Constructor1) {
ConwayCell a;
ASSERT_EQ(a._alive, false);
}
TEST(LifeFixture, ConwayCell_Default_Constructor2) {
ConwayCell a(true);
ConwayCell b;
ASSERT_EQ(a._alive, true);
ASSERT_EQ(b._alive, false);
}
TEST(LifeFixture, ConwayCell_Default_Constructor3) {
ConwayCell *b = new ConwayCell();
Cell a(b);
ASSERT_EQ(b->_alive, false);
ASSERT_EQ(a._p, b);
}
TEST(LifeFixture, ConwayCell_Constructor1) {
Cell b = new ConwayCell(true);
if (b._p != nullptr) {
ASSERT_EQ(b._p->_alive, true);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, ConwayCell_Constructor2) {
Cell a = new ConwayCell(false);
Cell b = new ConwayCell(true);
if (a._p != nullptr && b._p != nullptr) {
ASSERT_EQ(a._p->_alive, false);
ASSERT_EQ(b._p->_alive, true);
}
}
TEST(LifeFixture, ConwayCell_Constructor3) {
Cell b = new ConwayCell(true);
Cell a(b);
ASSERT_NE(a._p, b._p);
}
TEST(LifeFixture, ConwayCell_Copy_Constructor1) {
ConwayCell a(false);
ConwayCell b(a);
ASSERT_FALSE(a._alive);
ASSERT_FALSE(b._alive);
}
TEST(LifeFixture, ConwayCell_Copy_Constructor2) {
ConwayCell a(false);
ConwayCell b(true);
b = a;
ASSERT_FALSE(a._alive);
ASSERT_FALSE(b._alive);
}
TEST(LifeFixture, ConwayCell_Copy_Constructor3) {
ConwayCell a(false);
ConwayCell b = a;
a = b;
ASSERT_FALSE(a._alive);
ASSERT_FALSE(b._alive);
}
TEST(LifeFixture, ConwayCell_evolve1) {
Cell a = new ConwayCell(true);
vector<Cell *> neighbors(8);
Cell b = (new ConwayCell(true));
neighbors[0] = &b;
Cell c = (new ConwayCell(false));
neighbors[1] = &c;
Cell d = (new ConwayCell(true));
neighbors[2] = &d;
a.evolve(neighbors, false);
ASSERT_EQ(a._p->_alive, true);
}
TEST(LifeFixture, ConwayCell_evolve2) {
Cell a = new ConwayCell(false);
vector<Cell *> neighbors(8);
Cell b = (new ConwayCell(true));
neighbors[0] = &b;
Cell c = (new ConwayCell(false));
neighbors[3] = &c;
Cell d = (new ConwayCell(true));
neighbors[4] = &d;
Cell e = (new ConwayCell(true));
neighbors[6] = &e;
a.evolve(neighbors, false);
ASSERT_EQ(a._p->_alive, true);
}
TEST(LifeFixture, ConwayCell_evolve3) {
Cell a = new ConwayCell(false);
vector<Cell *> neighbors(8);
a.evolve(neighbors, false);
ASSERT_EQ(a._p->_alive, false);
}
TEST(LifeFixture, ConwayCell_clone1) {
ConwayCell a(false);
ConwayCell b(a);
ASSERT_EQ(a._alive, false);
ASSERT_EQ(b._alive, false);
}
TEST(LifeFixture, ConwayCell_clone2) {
ConwayCell a(true);
ConwayCell b(a);
ASSERT_EQ(a._alive, true);
ASSERT_EQ(b._alive, true);
}
TEST(LifeFixture, ConwayCell_clone3) {
Cell a = new ConwayCell(false);
if (a._p != nullptr) {
Cell b = a._p->clone();
if (b._p != nullptr)
ASSERT_EQ(b._p->_alive, false);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, ConwayCell_print1) {
ConwayCell a(true);
ASSERT_EQ(a.print(), '*');
}
TEST(LifeFixture, ConwayCell_print2) {
ConwayCell a(false);
ASSERT_EQ(a.print(), '.');
}
TEST(LifeFixture, ConwayCell_print3) {
Cell a = new ConwayCell(true);
ostringstream o;
o << a;
ASSERT_EQ(o.str(), "*");
}
// ----
// FriedKinCell Tests
// ----
TEST(LifeFixture, FredkinCell_Default_Constructor1) {
FredkinCell a;
ASSERT_EQ(a._alive, false);
ASSERT_EQ(a._age, 0);
}
TEST(LifeFixture, FredkinCell_Default_Constructor2) {
FredkinCell a;
FredkinCell b(true);
ASSERT_EQ(a._alive, false);
ASSERT_EQ(b._alive, true);
}
TEST(LifeFixture, FredkinCell_Default_Constructor3) {
FredkinCell *b = new FredkinCell();
Cell a(b);
ASSERT_EQ(a._p, b);
}
TEST(LifeFixture, FredkinCell_Constructor1) {
Cell a = new FredkinCell(false);
Cell b = new FredkinCell(true);
if (a._p != nullptr && b._p != nullptr) {
ASSERT_NE((b._p)->_alive, false);
ASSERT_EQ(dynamic_cast<FredkinCell *>(b._p)->_age, 0);
ASSERT_EQ((b._p)->_alive, true);
ASSERT_EQ(dynamic_cast<FredkinCell *>(b._p)->_age, 0);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, FredkinCell_Constructor2) {
Cell a = new FredkinCell(false);
ASSERT_NE(a._p, nullptr);
if (a._p != nullptr) {
ASSERT_EQ((a._p)->_alive, false);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, FredkinCell_Copy_Constructor1) {
Cell a = new FredkinCell(true);
Cell b = a;
if (a._p != nullptr && b._p != nullptr) {
ASSERT_TRUE(a._p->_alive);
ASSERT_TRUE(b._p->_alive);
ASSERT_EQ(dynamic_cast<FredkinCell *>(b._p)->_age, 0);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, FredkinCell_Copy_Constructor2) {
Cell a = new FredkinCell(false);
Cell b = new FredkinCell(true);
b = a;
if (a._p != nullptr && b._p != nullptr) {
ASSERT_FALSE(a._p->_alive);
ASSERT_FALSE(b._p->_alive);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, FredkinCell_Copy_Constructor3) {
Cell a = new FredkinCell(false);
Cell b = a;
a = b;
if (a._p != nullptr && b._p != nullptr) {
ASSERT_FALSE(a._p->_alive);
ASSERT_FALSE(b._p->_alive);
ASSERT_EQ(dynamic_cast<FredkinCell *>(b._p)->_age, 0);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, FredkinCell_evolve1) {
Cell a = new FredkinCell(false);
vector<Cell *> neighbors(8);
Cell b = (new FredkinCell(true));
neighbors[0] = &b;
Cell c = (new FredkinCell(true));
neighbors[1] = &c;
Cell d = (new FredkinCell(true));
neighbors[2] = &d;
a.evolve(neighbors, false);
ASSERT_EQ(a._p->_alive, true);
}
TEST(LifeFixture, FredkinCell_evolve2) {
Cell a = new FredkinCell(true);
vector<Cell *> neighbors(8);
Cell b = (new FredkinCell(true));
neighbors[0] = &b;
Cell c = (new FredkinCell(false));
neighbors[1] = &c;
Cell d = (new FredkinCell(true));
neighbors[2] = &d;
Cell e = (new FredkinCell(true));
neighbors[3] = &e;
a.evolve(neighbors, false);
ASSERT_EQ(a._p->_alive, true);
ASSERT_EQ(dynamic_cast<FredkinCell *>(a._p)->_age, 1);
}
TEST(LifeFixture, FredkinCell_evolve3) {
Cell a = new FredkinCell(true);
vector<Cell *> neighbors(8);
a.evolve(neighbors, false);
ASSERT_EQ(a._p->_alive, false);
}
TEST(LifeFixture, FredkinCell_clone1) {
Cell a = new FredkinCell(false);
if (a._p != nullptr) {
Cell b = a._p->clone();
ASSERT_EQ(a._p->_alive, false);
ASSERT_EQ(dynamic_cast<FredkinCell *>(a._p)->_age, 0);
if (b._p != nullptr) {
ASSERT_EQ(b._p->_alive, false);
ASSERT_EQ(dynamic_cast<FredkinCell *>(b._p)->_age, 0);
}
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, FredkinCell_clone2) {
Cell a = new FredkinCell(false);
if (a._p != nullptr) {
Cell b = a._p->clone();
if (b._p != nullptr)
ASSERT_EQ(b._p->_alive, false);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, FredkinCell_clone3) {
Cell a = new FredkinCell(false);
if (a._p != nullptr) {
Cell b = a._p->clone();
if (b._p != nullptr)
ASSERT_EQ(b._p->_alive, false);
} else {
ASSERT_FALSE(true);
}
}
TEST(LifeFixture, FredkinCell_print1) {
FredkinCell a(true);
ASSERT_EQ(a.print(), '0');
}
TEST(LifeFixture, FredkinCell_print2) {
FredkinCell a(false);
ASSERT_EQ(a.print(), '-');
}
TEST(LifeFixture, FredkinCell_print3) {
Cell a = new FredkinCell(true);
ostringstream o;
o << a;
ASSERT_EQ(o.str(), "0");
}
// ----
// AbstractCell Tests
// ----
TEST(LifeFixture, AbstractCell_numAlive1) {
vector<Cell *> neighbors(8);
Cell a = new FredkinCell(true);
neighbors[0] = &a;
Cell b = (new FredkinCell(true));
neighbors[1] = &b;
Cell c = (new FredkinCell(false));
neighbors[2] = &c;
Cell d = (new FredkinCell(true));
neighbors[3] = &d;
Cell e = (new FredkinCell(true));
neighbors[4] = &e;
Cell f = (new FredkinCell(true));
neighbors[5] = &f;
ASSERT_EQ(Cell::numAlive(neighbors), 5);
}
TEST(LifeFixture, AbstractCell_numAlive2) {
vector<Cell *> neighbors(8);
Cell a = new ConwayCell(true);
neighbors[0] = &a;
Cell b = (new ConwayCell(true));
neighbors[1] = &b;
ASSERT_EQ(Cell::numAlive(neighbors), 2);
}
TEST(LifeFixture, AbstractCell_numAlive3) {
vector<Cell *> neighbors(8);
Cell a = new FredkinCell(false);
neighbors[0] = &a;
ASSERT_EQ(Cell::numAlive(neighbors), 0);
}
// ----
// Life Tests
// ----
TEST(LifeFixture, Life_at_small) {
istringstream i("0 0");
Life<ConwayCell> x(i);
ASSERT_EQ(x._at(0, 0), 0);
istringstream j("1 1\n.");
Life<ConwayCell> y(j);
ASSERT_EQ(y._at(0, 0), 0);
ASSERT_EQ(y._at(1, 0), 1);
istringstream k("2 2\n..\n..");
Life<ConwayCell> z(k);
ASSERT_EQ(z._at(0, 0), 0);
ASSERT_EQ(z._at(1, 1), 3);
}
TEST(LifeFixture, Life_at_large) {
istringstream i("10 2\n..\n..\n..\n..\n..\n..\n..\n..\n..\n..");
Life<ConwayCell> x(i);
ASSERT_EQ(x._at(4, 0), 8);
istringstream j("2 10\n..........\n..........");
Life<ConwayCell> y(j);
ASSERT_EQ(y._at(1, 8), 18);
}
TEST(LifeFixture, Life_at_mixed) {
istringstream i("3 3\n.*.\n-0-\n*0.");
Life<Cell> x(i);
ASSERT_EQ(x._at(0, 0), 0);
ASSERT_EQ(x._at(1, 1), 4);
ASSERT_EQ(x._at(2, 2), 8);
}
// should many tests on this
TEST(LifeFixture, Life_Constructor_blank) {
istringstream i("0 0");
Life<ConwayCell> x(i);
ASSERT_EQ(x._turn, 0);
ASSERT_EQ(x._rows, 0);
ASSERT_EQ(x._cols, 0);
ASSERT_EQ(x._population, 0);
ASSERT_EQ(x._board.size(), 0);
}
/** Test Life Constructor with ConwayCell template */
TEST(LifeFixture, Life_Constructor_conway) {
istringstream i("2 2\n.*\n*.");
Life<ConwayCell> x(i);
ASSERT_EQ(x._rows, 2);
ASSERT_EQ(x._cols, 2);
ASSERT_EQ(x._population, 2);
ASSERT_EQ(x._board.size(), 4);
Cell &c1 = x._board[x._at(0, 0)];
bool c1a = c1._p->_alive;
ASSERT_FALSE(c1a);
Cell &c2 = x._board[x._at(0, 1)];
bool c2a = c2._p->_alive;
ASSERT_TRUE(c2a);
Cell &c3 = x._board[x._at(1, 0)];
bool c3a = c3._p->_alive;
ASSERT_TRUE(c3a);
Cell &c4 = x._board[x._at(1, 1)];
bool c4a = c4._p->_alive;
ASSERT_FALSE(c4a);
}
/** Test Life Constructor with FredkinCell template */
TEST(LifeFixture, Life_Constructor_fredkin) {
istringstream i("2 2\n-0\n0-");
Life<FredkinCell> x(i);
ASSERT_EQ(x._rows, 2);
ASSERT_EQ(x._cols, 2);
ASSERT_EQ(x._population, 2);
ASSERT_EQ(x._board.size(), 4);
Cell &c1 = x._board[x._at(0, 0)];
bool c1a = c1._p->_alive;
ASSERT_FALSE(c1a);
Cell &c2 = x._board[x._at(0, 1)];
bool c2a = c2._p->_alive;
ASSERT_TRUE(c2a);
Cell &c3 = x._board[x._at(1, 0)];
bool c3a = c3._p->_alive;
ASSERT_TRUE(c3a);
Cell &c4 = x._board[x._at(1, 1)];
bool c4a = c4._p->_alive;
ASSERT_FALSE(c4a);
}
/** Test Life Constructor with Cell template */
TEST(LifeFixture, Life_Constructor_cell) {
istringstream i("2 2\n.*\n0-");
Life<Cell> x(i);
ASSERT_EQ(x._rows, 2);
ASSERT_EQ(x._cols, 2);
ASSERT_EQ(x._population, 2);
ASSERT_EQ(x._board.size(), 4);
Cell &c1 = x._board[x._at(0, 0)];
bool c1a = c1._p->_alive;
ASSERT_FALSE(c1a);
Cell &c2 = x._board[x._at(0, 1)];
bool c2a = c2._p->_alive;
ASSERT_TRUE(c2a);
Cell &c3 = x._board[x._at(1, 0)];
bool c3a = c3._p->_alive;
ASSERT_TRUE(c3a);
Cell &c4 = x._board[x._at(1, 1)];
bool c4a = c4._p->_alive;
ASSERT_FALSE(c4a);
}
TEST(LifeFixture, Life_print_basic) {
istringstream i("1 1\n.");
Life<ConwayCell> x(i);
ostringstream o;
o << x;
ASSERT_EQ(o.str(), "Generation = 0, Population = 0.\n.\n\n");
x.simulate();
ostringstream p;
p << x;
ASSERT_EQ(p.str(), "Generation = 1, Population = 0.\n.\n\n");
}
TEST(LifeFixture, Life_print_conway) {
istringstream i("3 3\n.*.\n***\n.*.");
Life<ConwayCell> x(i);
ostringstream o;
o << x;
ASSERT_EQ(o.str(), "Generation = 0, Population = 5.\n.*.\n***\n.*.\n\n");
x.simulate();
ostringstream p;
p << x;
ASSERT_EQ(p.str(), "Generation = 1, Population = 8.\n***\n*.*\n***\n\n");
x.simulate();
ostringstream q;
q << x;
ASSERT_EQ(q.str(), "Generation = 2, Population = 4.\n*.*\n...\n*.*\n\n");
}
TEST(LifeFixture, Life_print_fredkin) {
istringstream i("3 3\n-0-\n000\n-0-");
Life<ConwayCell> x(i);
ostringstream o;
o << x;
ASSERT_EQ(o.str(), "Generation = 0, Population = 5.\n-0-\n000\n-0-\n\n");
x.simulate();
ostringstream p;
p << x;
ASSERT_EQ(p.str(), "Generation = 1, Population = 4.\n-1-\n1-1\n-1-\n\n");
x.simulate();
ostringstream q;
q << x;
ASSERT_EQ(q.str(), "Generation = 2, Population = 0.\n---\n---\n---\n\n");
}
TEST(LifeFixture, Life_print_cell) {
istringstream i("3 3\n-0-\n0-0\n-0-");
Life<Cell> x(i);
ostringstream o;
o << x;
ASSERT_EQ(o.str(), "Generation = 0, Population = 4.\n-0-\n0-0\n-0-\n\n");
x.simulate();
ostringstream p;
p << x;
ASSERT_EQ(p.str(), "Generation = 1, Population = 0.\n---\n---\n---\n\n");
x.simulate();
ostringstream q;
q << x;
ASSERT_EQ(q.str(), "Generation = 2, Population = 0.\n---\n---\n---\n\n");
}
TEST(LifeFixture, Life_print_cell_complex) {
istringstream i("6 6\n------\n------\n--00--\n-0000-\n------\n------");
Life<Cell> x(i);
ostringstream o;
x.simulate();
x.simulate();
x.simulate();
x.simulate();
o << x;
ASSERT_EQ(o.str(), "Generation = 4, Population = "
"16.\n--00--\n--..--\n0*11*0\n1....1\n-1..1-\n-****-\n\n");
}
TEST(LifeFixture, Life_simulate_basic) {
istringstream i("1 1\n.");
Life<ConwayCell> x(i);
ASSERT_EQ(x._turn, 0);
x.simulate();
ASSERT_EQ(x._turn, 1);
ASSERT_EQ(x._population, 0);
istringstream j("1 1\n-");
Life<FredkinCell> y(j);
ASSERT_EQ(y._turn, 0);
y.simulate();
ASSERT_EQ(y._turn, 1);
ASSERT_EQ(y._population, 0);
}
TEST(LifeFixture, Life_simulate_conway) {
istringstream i("3 3\n...\n***\n...");
Life<ConwayCell> x(i);
ASSERT_EQ(x._turn, 0);
x.simulate();
ASSERT_EQ(x._turn, 1);
ASSERT_EQ(x._population, 3);
x.simulate();
ASSERT_EQ(x._turn, 2);
ASSERT_EQ(x._population, 3);
x.simulate();
ASSERT_EQ(x._turn, 3);
ASSERT_EQ(x._population, 3);
x.simulate();
ASSERT_EQ(x._turn, 4);
ASSERT_EQ(x._population, 3);
}
TEST(LifeFixture, Life_simulate_fredkin) {
istringstream i("3 3\n---\n000\n---");
Life<FredkinCell> x(i);
ASSERT_EQ(x._turn, 0);
x.simulate();
ASSERT_EQ(x._turn, 1);
ASSERT_EQ(x._population, 8);
x.simulate();
ASSERT_EQ(x._turn, 2);
ASSERT_EQ(x._population, 0);
x.simulate();
ASSERT_EQ(x._turn, 3);
ASSERT_EQ(x._population, 0);
}
TEST(LifeFixture, Life_simulate_cell) {
istringstream i("6 6\n------\n------\n--00--\n-0000-\n------\n------");
Life<Cell> x(i);
ASSERT_EQ(x._turn, 0);
x.simulate();
ASSERT_EQ(x._turn, 1);
ASSERT_EQ(x._population, 12);
x.simulate();
ASSERT_EQ(x._turn, 2);
ASSERT_EQ(x._population, 22);
x.simulate();
ASSERT_EQ(x._turn, 3);
ASSERT_EQ(x._population, 18);
x.simulate();
ASSERT_EQ(x._turn, 4);
ASSERT_EQ(x._population, 16);
x.simulate();
ASSERT_EQ(x._turn, 5);
ASSERT_EQ(x._population, 20);
}
| [
"briancui@utexas.edu"
] | briancui@utexas.edu | |
5ee7f99bc042440975124f1f415af0b97b18e560 | 49d83590149ce409c1eb88e2158ba32e0fa45879 | /game_object.h | 92058899ed64f7ce7012960cabb4106789a8b92d | [] | no_license | thebishalthapachhetri/Final-Game | f0ed4e3d83ce25c94b10e0cb6fe06e03349d5fc4 | 554a78bdb5d1d29946fefb58081adf0c5855049d | refs/heads/master | 2022-10-30T11:36:08.573069 | 2020-06-17T07:45:10 | 2020-06-17T07:45:10 | 272,910,786 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 985 | h | #pragma once
#define SDL_MAIN_HANDLED
#include <SDL.h>
#include <string>
#include "assets.h"
#include "input.h"
#include "vector_2D.h"
#include "configuration.h"
#include "circle_2D.h"
#include "scene.h"
class Game_Object
{
public:
Game_Object(std::string id, std::string texture_id);
~Game_Object();
std::string id();
virtual void simulate_AI(Uint32 milliseconds_to_simulate, Assets* assets, Input* input, Scene* scene) = 0;
virtual void simulate_physics(Uint32 milliseconds_to_simulate, Assets* assets, Scene* scene);
virtual void render(Uint32 milliseconds_to_simulate, Assets* assets, SDL_Renderer* renderer, Configuration* config);
Vector_2D translation();
Circle_2D collider();
int height();
int width();
void set_translation(Vector_2D translation);
protected:
std::string _id;
std::string _texture_id;
Circle_2D _collider;
//float _x;
//float _y;
Vector_2D _translation;
Vector_2D _velocity;
int _width;
int _height;
SDL_RendererFlip _flip;
}; | [
"Bishal_thapa32@hotmail.com"
] | Bishal_thapa32@hotmail.com |
ed7481d7a9fdb97841a884d0a1db5319eb8305c9 | 5841293ec44d928a9a15d7acdd5f48d927597adf | /src/framework/shared/inc/private/common/fxiotargetremote.hpp | 82d8e17855aaf48219fad1fff5a50ac85bfe68db | [
"MIT"
] | permissive | travisgoodspeed/Windows-Driver-Frameworks | 0c58bd12e5bbb8571de80b1f34856445060d6f37 | ba410f6b35e858cf94ac504269ba5582aa6f9516 | refs/heads/master | 2021-01-25T02:37:56.155405 | 2015-03-20T14:48:03 | 2015-03-20T14:48:03 | 32,589,166 | 1 | 1 | null | 2015-03-20T14:43:19 | 2015-03-20T14:43:18 | null | UTF-8 | C++ | false | false | 8,888 | hpp | /*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
FxIoTargetRemote.hpp
Abstract:
Derivation of FxIoTarget specializing in targets remote to this device
stack.
Author:
Environment:
Both kernel and user mode
Revision History:
--*/
#ifndef _FXIOTARGETREMOTE_H_
#define _FXIOTARGETREMOTE_H_
enum FxIoTargetRemoteCloseReason {
FxIoTargetRemoteCloseReasonQueryRemove = 1,
FxIoTargetRemoteCloseReasonPlainClose,
FxIoTargetRemoteCloseReasonDelete
};
#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
typedef PVOID MdTargetNotifyHandle;
#else
typedef WUDF_TARGET_CONTEXT MdTargetNotifyHandle;
#endif
class FxIoTargetRemoteNotificationCallback;
struct FxIoTargetQueryRemove : public FxCallback {
FxIoTargetQueryRemove(
__in PFX_DRIVER_GLOBALS FxDriverGlobals
) :
FxCallback(FxDriverGlobals),
m_Method(NULL)
{
}
_Must_inspect_result_
NTSTATUS
Invoke(
__in WDFIOTARGET IoTarget
)
{
NTSTATUS status;
CallbackStart();
status = m_Method(IoTarget);
CallbackEnd();
return status;
}
PFN_WDF_IO_TARGET_QUERY_REMOVE m_Method;
};
struct FxIoTargetRemoveCanceled : public FxCallback {
FxIoTargetRemoveCanceled(
__in PFX_DRIVER_GLOBALS FxDriverGlobals
) :
FxCallback(FxDriverGlobals),
m_Method(NULL)
{
}
VOID
Invoke(
__in WDFIOTARGET Target
)
{
CallbackStart();
m_Method(Target);
CallbackEnd();
}
PFN_WDF_IO_TARGET_REMOVE_CANCELED m_Method;
};
struct FxIoTargetRemoveComplete : public FxCallback {
FxIoTargetRemoveComplete(
__in PFX_DRIVER_GLOBALS FxDriverGlobals
) :
FxCallback(FxDriverGlobals),
m_Method(NULL)
{
}
VOID
Invoke(
__in WDFIOTARGET Target
)
{
CallbackStart();
m_Method(Target);
CallbackEnd();
}
PFN_WDF_IO_TARGET_REMOVE_COMPLETE m_Method;
};
enum FxIoTargetRemoteOpenState {
FxIoTargetRemoteOpenStateClosed = 1,
FxIoTargetRemoteOpenStateOpening,
FxIoTargetRemoteOpenStateOpen,
};
struct FxIoTargetRemoveOpenParams {
FxIoTargetRemoveOpenParams()
{
RtlZeroMemory(this, sizeof(FxIoTargetRemoveOpenParams));
}
VOID
Set(
__in PWDF_IO_TARGET_OPEN_PARAMS OpenParams,
__in PUNICODE_STRING Name,
__in PVOID Ea,
__in ULONG EaLength
);
VOID
Clear(
VOID
);
UNICODE_STRING TargetDeviceName;
WDF_IO_TARGET_OPEN_TYPE OpenType;
ACCESS_MASK DesiredAccess;
ULONG ShareAccess;
ULONG FileAttributes;
ULONG CreateDisposition;
ULONG CreateOptions;
__field_bcount(EaBufferLength) PVOID EaBuffer;
ULONG EaBufferLength;
LARGE_INTEGER AllocationSize;
PLARGE_INTEGER AllocationSizePointer;
};
struct FxIoTargetClearedPointers {
MdDeviceObject TargetPdo;
MdFileObject TargetFileObject;
HANDLE TargetHandle;
};
class FxIoTargetRemote : public FxIoTarget {
public:
static
_Must_inspect_result_
NTSTATUS
_Create(
__in PFX_DRIVER_GLOBALS FxDriverGlobals,
__in PWDF_OBJECT_ATTRIBUTES Attributes,
__in FxDeviceBase* Device,
__out FxIoTargetRemote** Target
);
~FxIoTargetRemote();
NTSTATUS
InitRemote(
__in FxDeviceBase* Device
);
NTSTATUS
InitRemoteModeSpecific(
__in FxDeviceBase* Device
);
_Must_inspect_result_
NTSTATUS
Open(
__in PWDF_IO_TARGET_OPEN_PARAMS OpenParams
);
VOID
Close(
__in FxIoTargetRemoteCloseReason Reason
);
NTSTATUS
GetTargetDeviceRelations(
_Out_ BOOLEAN* Close
);
BOOLEAN
CanRegisterForPnpNotification(
VOID
)
{
BOOLEAN canRegister = FALSE;
#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
if (m_TargetFileObject != NULL) {
canRegister = TRUE;
}
#else // FX_CORE_USER_MODE
if (m_TargetHandle != NULL) {
canRegister = TRUE;
}
#endif
return canRegister;
}
VOID
ResetTargetNotifyHandle(
VOID
)
{
#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
m_TargetNotifyHandle = NULL;
#else // FX_CORE_USER_MODE
m_TargetNotifyHandle = WUDF_TARGET_CONTEXT_INVALID;
#endif
}
NTSTATUS
OpenTargetHandle(
_In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams,
_Inout_ FxIoTargetRemoveOpenParams* pParams
);
VOID
CloseTargetHandle(
VOID
);
HANDLE
GetTargetHandle(
VOID
);
NTSTATUS
RegisterForPnpNotification(
VOID
);
VOID
UnregisterForPnpNotification(
_In_ MdTargetNotifyHandle Handle
);
FORCEINLINE
WDFIOTARGET
GetHandle(
VOID
)
{
return (WDFIOTARGET) GetObjectHandle();
}
virtual
VOID
Remove(
VOID
);
VOID
RemoveModeSpecific(
VOID
);
protected:
FxIoTargetRemote(
__in PFX_DRIVER_GLOBALS FxDriverGlobals
);
virtual
VOID
ClearTargetPointers(
VOID
);
_Must_inspect_result_
NTSTATUS
QueryInterface(
__in FxQueryInterfaceParams* Params
)
{
if (Params->Type == FX_TYPE_IO_TARGET_REMOTE) {
*Params->Object = (FxIoTargetRemote*) this;
return STATUS_SUCCESS;
}
else {
return __super::QueryInterface(Params);
}
}
_Must_inspect_result_
NTSTATUS
FxIoTargetRemote::OpenLocalTargetByFile(
_In_ PWDF_IO_TARGET_OPEN_PARAMS OpenParams
);
#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
static
DRIVER_NOTIFICATION_CALLBACK_ROUTINE
_PlugPlayNotification;
#else // FX_CORE_USER_MODE
//
// I/O dispatcher to be used for IRPs forwarded to this remote target. It is
// created when the CWdfRemoteTarget is created. The win32 handle is
// associated with it via a call to m_pRemoteDispatcher->BindToHandle()
// right after we call CreateFile(...). We must call
// m_pRemoteDispatcher->CloseHandle() to close the handle.
//
// Because of the plug-in pattern of the IoDispatcher, we need two
// interface pointers (one to the outer object, and one to the plug-in.
//
IWudfIoDispatcher * m_pIoDispatcher;
IWudfRemoteDispatcher * m_pRemoteDispatcher;
//
// Implements host's callback interface for pnp notification
//
FxIoTargetRemoteNotificationCallback* m_NotificationCallback;
VOID
Forward(
_In_ MdIrp Irp
)
{
if (m_OpenParams.OpenType == WdfIoTargetOpenLocalTargetByFile) {
//
// Ignore the return value because once we have sent the request, we
// want all processing to be done in the completion routine.
//
(void) Irp->Forward();
}
else {
IWudfIoIrp* pSubmitIrp = FxIrp(Irp).GetIoIrp();
//
// Move the stack location to the next location
//
pSubmitIrp->SetNextIrpStackLocation();
//
// Route it using Remote dispatcher
//
m_pIoDispatcher->Dispatch(pSubmitIrp, NULL);
}
}
private:
NTSTATUS
BindToHandle(
VOID
);
VOID
UnbindHandle(
_In_ FxIoTargetClearedPointers* TargetPointers
);
NTSTATUS
CreateWdfFileObject(
_In_opt_ PUNICODE_STRING FileName,
_Out_ MdFileObject* FileObject
);
VOID
CloseWdfFileObject(
_In_ MdFileObject FileObject
);
#endif // FX_CORE_USER-MODE)
public:
//
// File handle for m_TargetHandle
//
HANDLE m_TargetHandle;
//
// Notification handle returned by IoRegisterPlugPlayNotification for KMDF,
// or host's notification registartion interface for UMDf. Note that host
// uses the term RegistrationId for the same (with WUDF_CONTEXT_TYPE which
// is UINT64).
//
MdTargetNotifyHandle m_TargetNotifyHandle;
//
// Driver writer callbacks to indicate state changes
//
FxIoTargetQueryRemove m_EvtQueryRemove;
FxIoTargetRemoveCanceled m_EvtRemoveCanceled;
FxIoTargetRemoveComplete m_EvtRemoveComplete;
FxCREvent m_OpenedEvent;
FxIoTargetClearedPointers* m_ClearedPointers;
//
// Value from FxIoTargetRemoteOpenState
//
UCHAR m_OpenState;
protected:
FxIoTargetRemoveOpenParams m_OpenParams;
};
#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
#include "FxIoTargetRemoteKm.hpp"
#else
#include "FxIoTargetRemoteUm.hpp"
#endif
#endif // _FXIOTARGETREMOTE_H_
| [
"amargar@microsoft.com"
] | amargar@microsoft.com |
8eed8f866e8de244fa2304ef2ef5e6b622f5bf7c | f926639250ab2f47d1b35b012c143f1127cc4965 | /legacy/platform/mt6755/core/camshot/BurstShot/BurstShot.cpp | dfde6ee220a8b73c58e688a5f46e3570586540af | [] | no_license | cllanjim/stereoCam | 4c5b8f18808c96581ccd14be2593d41de9e0cf35 | e2df856ed1a2c45f6ab8dd52b67d7eae824174cf | refs/heads/master | 2020-03-17T11:26:49.570352 | 2017-03-14T08:48:08 | 2017-03-14T08:48:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 43,239 | cpp | /* Copyright Statement:
*
* This software/firmware and related documentation ("MediaTek Software") are
* protected under relevant copyright laws. The information contained herein
* is confidential and proprietary to MediaTek Inc. and/or its licensors.
* Without the prior written permission of MediaTek inc. and/or its licensors,
* any reproduction, modification, use or disclosure of MediaTek Software,
* and information contained herein, in whole or in part, shall be strictly prohibited.
*/
/* MediaTek Inc. (C) 2010. All rights reserved.
*
* BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
* THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
* CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
* SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
* STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
* CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* The following software/firmware and/or related documentation ("MediaTek Software")
* have been modified by MediaTek Inc. All revisions are subject to any receiver's
* applicable license agreements with MediaTek Inc.
*/
/********************************************************************************************
* LEGAL DISCLAIMER
*
* (Header of MediaTek Software/Firmware Release or Documentation)
*
* BY OPENING OR USING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") RECEIVED
* FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON AN "AS-IS" BASIS
* ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
* A PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY
* WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
* INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK
* ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION
* OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE LIABILITY WITH
* RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION,
TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE
* FEES OR SERVICE CHARGE PAID BY BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE WITH THE LAWS
* OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF LAWS PRINCIPLES.
************************************************************************************************/
#define LOG_TAG "MtkCam/BShot"
//
#include <mtkcam/Log.h>
#if defined(__func__)
#undef __func__
#endif
#define __func__ __FUNCTION__
#define MY_LOGV(fmt, arg...) CAM_LOGV("[%s] " fmt, __func__, ##arg)
#define MY_LOGD(fmt, arg...) CAM_LOGD("[%s] " fmt, __func__, ##arg)
#define MY_LOGI(fmt, arg...) CAM_LOGI("[%s] " fmt, __func__, ##arg)
#define MY_LOGW(fmt, arg...) CAM_LOGW("[%s] " fmt, __func__, ##arg)
#define MY_LOGE(fmt, arg...) CAM_LOGE("[%s] " fmt, __func__, ##arg)
#define MY_LOGA(fmt, arg...) CAM_LOGA("[%s] " fmt, __func__, ##arg)
#define MY_LOGF(fmt, arg...) CAM_LOGF("[%s] " fmt, __func__, ##arg)
#define FUNC_START MY_LOGD("+")
#define FUNC_END MY_LOGD("-")
//
//
#include <mtkcam/common.h>
//
#include <mtkcam/camnode/ICamGraphNode.h>
#include <mtkcam/camnode/pass1node.h>
#include <mtkcam/camnode/pass2node.h>
#include <mtkcam/camnode/JpegEncNode.h>
#include <mtkcam/camnode/ShotCallbackNode.h>
#include <mtkcam/camnode/AllocBufHandler.h>
#include "../inc/BShotCtrlNode.h"
using namespace NSCamNode;
#include <mtkcam/featureio/aaa_hal_common.h>
using namespace NS3A;
//
#include <mtkcam/camshot/_callbacks.h>
#include <mtkcam/camshot/_params.h>
//
#include "../inc/CamShotImp.h"
#include "../inc/BurstShot.h"
//
#include <mtkcam/hwutils/CamManager.h>
using namespace NSCam::Utils;
//
// buffer usage
#include <mtkcam/iopipe/Port.h>
// for debug dump
#include <cutils/properties.h>
using namespace android;
#include <mtkcam/hal/IHalSensor.h>
#define CHECK_OBJECT(x) { if (x == NULL) { MY_LOGE("Null %s Object", #x); return MFALSE;}}
/*******************************************************************************
*
********************************************************************************/
namespace NSCamShot {
////////////////////////////////////////////////////////////////////////////////
//used nodes
enum
{
PASS1NODE = 0x0 ,
CTRLNODE ,
CAPPASS2NODE ,
HWJPEGNODE ,
SWJPEGNODE ,
CALLBACKNODE ,
};
enum
{
DATA_FULLRAW = 0x1 ,
DATA_RESIZEDRAW = 0x2 ,
DATA_MAINYUV = 0x4 ,
DATA_THUMBNAILYUV = 0x8 ,
DATA_POSTVIEW = 0x10 ,
DATA_MAINJPEG = 0x20 ,
DATA_THUMBNAILJPEG = 0x40 ,
DATA_DEBUGINFO = 0x80 ,
DATA_DUMP_IMG3O = 0x100 ,
// extend for connection
DATA_FULLRAW_CB = 0x200 ,
DATA_MAINYUV_CB = 0x400 ,
DATA_POSTVIEW_CB = 0x800 ,
DATA_MAINJPEG_CB = 0x1000,
DATA_THUMBNAILJPEG_CB = 0x2000,
DATA_EIS_CB = 0x4000,
};
#define MAP_TYPE2BIT(datatype, bit) \
static const MUINT32 datatype##_bit = (1<<(bit));
#define bitOf(datatype) (datatype##_bit)
MAP_TYPE2BIT(PASS1_FULLRAW , 0);
MAP_TYPE2BIT(PASS1_RESIZEDRAW , 1);
MAP_TYPE2BIT(PASS2_PRV_SRC , 2);
MAP_TYPE2BIT(PASS2_PRV_DST_0 , 3);
MAP_TYPE2BIT(PASS2_PRV_DST_1 , 4);
MAP_TYPE2BIT(PASS2_CAP_SRC , 5);
MAP_TYPE2BIT(PASS2_CAP_DST_0 , 6);
MAP_TYPE2BIT(PASS2_CAP_DST_1 , 7);
MAP_TYPE2BIT(PASS2_CAP_DST_2 , 8);
MAP_TYPE2BIT(JPEG_ENC_SW_SRC , 9);
MAP_TYPE2BIT(JPEG_ENC_SW_DST , 10);
MAP_TYPE2BIT(JPEG_ENC_HW_SRC , 11);
MAP_TYPE2BIT(JPEG_ENC_HW_DST , 12);
MAP_TYPE2BIT(CONTROL_FULLRAW , 13);
MAP_TYPE2BIT(CONTROL_RESIZEDRAW , 14);
MAP_TYPE2BIT(CONTROL_PRV_SRC , 15);
MAP_TYPE2BIT(CONTROL_CAP_SRC , 16);
MAP_TYPE2BIT(CONTROL_DBGINFO , 17);
MAP_TYPE2BIT(CONTROL_EISDATA , 18);
MAP_TYPE2BIT(SHOTCB_RAWDATA_SRC , 19);
MAP_TYPE2BIT(SHOTCB_YUVDATA_SRC , 20);
MAP_TYPE2BIT(SHOTCB_POSTVIEW_SRC , 21);
MAP_TYPE2BIT(SHOTCB_JPEG_SRC , 22);
MAP_TYPE2BIT(SHOTCB_DBGINFO_SRC , 23);
MAP_TYPE2BIT(SHOTCB_EISDATA_SRC , 24);
MAP_TYPE2BIT(SHOTCB_THUMBNAIL_SRC , 25);
MAP_TYPE2BIT(SHOTCB_RAWDATA_DST , 26);
MAP_TYPE2BIT(SHOTCB_YUVDATA_DST , 27);
MAP_TYPE2BIT(SHOTCB_POSTVIEW_DST , 28);
struct map_data2node
{
MUINT32 data;
MUINT32 nodedata_memory;
MUINT32 datapath;
};
struct connect_data_rule
{
// connect if condition is fulfilled
// data_src , data_dst ,
// node_src , node_dst ,
MUINT32 condition;
MUINT32 src;
MUINT32 dst;
MUINT32 nodesrc;
MUINT32 nodedst;
MUINT8 next_T; //offset to next rule when condition is fulfilled
MUINT8 next_F; //offset to next rule when condition is not fulfilled
};
struct connect_notify_rule
{
MUINT32 notify;
MUINT32 nodesrc;
MUINT32 nodedst;
};
#define bitS2(a, b) (bitOf(a)|bitOf(b))
#define bitS3(a, b, c) (bitS2(a,b)|bitOf(c))
#define bitS4(a, b, c, d) (bitS3(a,b,c)|bitOf(d))
// for memory allocation
static const struct map_data2node gMapData2Node_Cap[] =
{
{ DATA_FULLRAW , PASS1_FULLRAW , bitS2(PASS1_FULLRAW, CONTROL_FULLRAW) } ,
{ DATA_MAINYUV , PASS2_CAP_DST_1 ,
bitS3(CONTROL_CAP_SRC, PASS2_CAP_SRC, PASS2_CAP_DST_1) } ,
{ DATA_POSTVIEW , PASS2_CAP_DST_0 ,
bitS3(CONTROL_CAP_SRC, PASS2_CAP_SRC, PASS2_CAP_DST_0) } ,
{ DATA_THUMBNAILJPEG , JPEG_ENC_SW_DST , bitS2(PASS2_CAP_DST_0, JPEG_ENC_SW_SRC) } ,
{ DATA_DEBUGINFO , 0 , bitS2(CONTROL_DBGINFO, SHOTCB_DBGINFO_SRC) } ,
{ DATA_EIS_CB , 0 , bitS2(CONTROL_EISDATA, SHOTCB_EISDATA_SRC) } ,
{ DATA_DUMP_IMG3O , PASS2_CAP_DST_2 , bitS2(CONTROL_CAP_SRC, PASS2_CAP_SRC) } ,
{ DATA_FULLRAW_CB , 0 , bitS3(CONTROL_CAP_SRC, SHOTCB_RAWDATA_SRC , SHOTCB_RAWDATA_DST) } ,
{ DATA_MAINYUV_CB , 0 , bitS3(PASS2_CAP_DST_1, SHOTCB_YUVDATA_SRC , SHOTCB_YUVDATA_DST) } ,
{ DATA_POSTVIEW_CB , 0 , bitS2(PASS2_CAP_DST_0, SHOTCB_POSTVIEW_SRC) } ,
{ DATA_MAINJPEG_CB , 0 , bitS2(JPEG_ENC_HW_DST, SHOTCB_JPEG_SRC) } ,
{ DATA_THUMBNAILJPEG_CB , 0 , bitS2(JPEG_ENC_SW_DST, SHOTCB_THUMBNAIL_SRC) } ,
{ 0, 0, 0 } ,
};
#define RULE( src, dst, nodesrc, nodedst, nextT, nextF ) \
{ (bitOf(src)|bitOf(dst)), src, dst, nodesrc, nodedst, nextT, nextF }
static const struct connect_data_rule gDataConnectRule_Cap[] =
{
RULE( PASS1_FULLRAW , CONTROL_FULLRAW , PASS1NODE , CTRLNODE , 1, 1 ) ,
//RULE( PASS1_RESIZEDRAW , CONTROL_RESIZEDRAW , PASS1NODE , CTRLNODE , 1, 1 ) ,
// if use raw callback
RULE( CONTROL_CAP_SRC , SHOTCB_RAWDATA_SRC , CTRLNODE , CALLBACKNODE , 1, 2 ) ,
RULE( SHOTCB_RAWDATA_DST , PASS2_CAP_SRC , CALLBACKNODE , CAPPASS2NODE , 2, 2 ) ,
// else
RULE( CONTROL_CAP_SRC , PASS2_CAP_SRC , CTRLNODE , CAPPASS2NODE , 1, 1 ) ,
// endif
// if use yuv callback
RULE( PASS2_CAP_DST_1 , SHOTCB_YUVDATA_SRC , CAPPASS2NODE , CALLBACKNODE , 1, 2 ) ,
RULE( SHOTCB_YUVDATA_DST , JPEG_ENC_HW_SRC , CALLBACKNODE , HWJPEGNODE , 2, 2 ) ,
// else
RULE( PASS2_CAP_DST_1 , JPEG_ENC_HW_SRC , CAPPASS2NODE , HWJPEGNODE , 1, 1 ) ,
// endif
// if use postview callback
RULE( PASS2_CAP_DST_0 , SHOTCB_POSTVIEW_SRC , CAPPASS2NODE , CALLBACKNODE , 1, 2 ) ,
RULE( SHOTCB_POSTVIEW_DST, JPEG_ENC_SW_SRC , CALLBACKNODE , SWJPEGNODE , 2, 2 ) ,
// else
RULE( PASS2_CAP_DST_0 , JPEG_ENC_SW_SRC , CAPPASS2NODE , SWJPEGNODE , 1, 1 ) ,
//endif
RULE( JPEG_ENC_HW_DST , SHOTCB_JPEG_SRC , HWJPEGNODE , CALLBACKNODE , 1, 1 ) ,
RULE( JPEG_ENC_SW_DST , SHOTCB_THUMBNAIL_SRC , SWJPEGNODE , CALLBACKNODE , 1, 1 ) ,
// debug info
RULE( CONTROL_DBGINFO , SHOTCB_DBGINFO_SRC , CTRLNODE , CALLBACKNODE , 1, 1 ) ,
// eis
RULE( CONTROL_EISDATA , SHOTCB_EISDATA_SRC , CTRLNODE , CALLBACKNODE , 1, 1 ) ,
// terminate
{0, 0, 0, 0, 0, 0, 0},
};
static const struct connect_notify_rule gNotifyConnectRule[] =
{
{ PASS1_SOF | PASS1_EOF | PASS1_START_ISP | PASS1_STOP_ISP , PASS1NODE , CTRLNODE } ,
{ CONTROL_SHUTTER , CTRLNODE , CALLBACKNODE } ,
{ CONTROL_STOP_PASS1 , CTRLNODE , PASS1NODE } ,
{ 0, 0, 0 },
};
/*******************************************************************************
*
********************************************************************************/
BurstShot::
BurstShot(
EShotMode const eShotMode,
char const*const szCamShotName
)
: CamShotImp(eShotMode, szCamShotName)
, mShotCount(0)
, mCurCount(0)
, muRegisteredBufType(0x0)
, mpAllocBufHandler(NULL)
, mShotProfile(SHOT_PROFILE_BURST)
, mpMap2Node(NULL)
, mpConnectDataRule(NULL)
, mpConnectNotifyRule(NULL)
, mpGraph(NULL)
, mpPass1(NULL)
, mpCtrl(NULL)
, mpCallback(NULL)
, mpCapPass2(NULL)
, mpJpegencHw(NULL)
, mpJpegencSw(NULL)
, mbDoShutterCb(MTRUE)
, mFinishedData(0x0)
, mIspProfile(EIspProfile_Capture)
, mpCapParams(NULL)
, muCapParamCount(0)
{
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
init()
{
FUNC_START;
MBOOL ret = MTRUE;
if( !mpAllocBufHandler )
{
mpAllocBufHandler = AllocBufHandler::createInstance();
ret = mpAllocBufHandler->init();
}
FUNC_END;
//
return ret && (sem_init(&mShotDone, 0, 0) == 0);
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
uninit()
{
MBOOL ret = MTRUE;
FUNC_START;
if( mpAllocBufHandler )
{
mpAllocBufHandler->uninit();
mpAllocBufHandler->destroyInstance();
mpAllocBufHandler = NULL;
}
FUNC_END;
//
if( sem_destroy(&mShotDone) != 0 )
ret = MFALSE;
return ret;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
start(SensorParam const & rSensorParam, MUINT32 count)
{
FUNC_START;
//
updateProfile(SHOT_PROFILE_BURST);
mSensorParam = rSensorParam;
mShotCount = count;
// dump
dumpSensorParam(mSensorParam);
//
MBOOL ret = MTRUE;
MUINT32 RotPicWidth, RotPicHeight;
MUINT32 RotThuWidth, RotThuHeight;
//
getRotatedPicSize(&RotPicWidth, &RotPicHeight, &RotThuWidth, &RotThuHeight);
//
MY_LOGD("[start] enable msg (notify, data) = (0x%x,0x%x)", mi4NotifyMsgSet, mi4DataMsgSet);
if( !isDataMsgEnabled(ECamShot_DATA_MSG_ALL) && !isNotifyMsgEnabled(ECamShot_NOTIFY_MSG_ALL) )
{
MY_LOGE("[start] no data/msg enabled");
return MFALSE;
}
MUINT32 dataInBit = 0x0;
MUINT32 CBDataSet = 0x0;
MUINT32 nodeDataInBit = 0x0;
updateNeededData(&dataInBit, &CBDataSet);
updateNeededNodeData(dataInBit, &nodeDataInBit);
// overwrite rawtype
if(mSensorParam.u4RawType == 3){ //Eng for process raw
mSensorParam.u4RawType = 1;
MY_LOGD("update shot param: use process raw");
}
if( !mpGraph )
{
mpGraph = ICamGraph::createInstance(mSensorParam.u4OpenID, "BShot");
}
// update registered buffers
ret = ret && doRegisterBuffers();
//assign buffer handler
mpGraph->setBufferHandler( PASS1_FULLRAW , mpAllocBufHandler );
mpGraph->setBufferHandler( PASS1_RESIZEDRAW , mpAllocBufHandler ); //Temp
if( dataInBit & DATA_MAINYUV )
{
ret = ret && enableData(DATA_MAINYUV);
}
if( dataInBit & DATA_POSTVIEW )
{
ret = ret && enableData(DATA_POSTVIEW);
}
else if( dataInBit & DATA_THUMBNAILYUV )
{
ret = ret && enableData(DATA_THUMBNAILYUV);
}
if( dataInBit & DATA_MAINJPEG )
{
ret = ret && enableData(DATA_MAINJPEG);
}
if( dataInBit & DATA_THUMBNAILJPEG )
{
ret = ret && enableData(DATA_THUMBNAILJPEG);
}
if( dataInBit & DATA_DUMP_IMG3O )
{
ret = ret && doDebugDump();
}
ret = ret && createNodes(nodeDataInBit, CBDataSet);
ret = ret && connectNodes(nodeDataInBit);
ret = ret && mpGraph->init();
ret = ret && mpGraph->start();
// prepare pass2/jpeg buffers
if( dataInBit & DATA_MAINYUV )
{
for( MUINT32 i = 0 ; i < mShotCount ; i++ )
{
ret = ret
&& prepareMemory(
DATA_MAINYUV,
RotPicWidth, RotPicHeight,
eImgFmt_YUY2,
mShotParam.u4PictureTransform,
NSCam::NSIoPipe::EPortCapbility_Cap);
}
}
if( dataInBit & DATA_POSTVIEW )
{
for( MUINT32 i = 0 ; i < mShotCount ; i++ )
{
ret = ret
&& prepareMemory(
DATA_POSTVIEW,
mShotParam.u4PostViewWidth, mShotParam.u4PostViewHeight,
mShotParam.ePostViewFmt,
0,
NSCam::NSIoPipe::EPortCapbility_Cap);
}
}
else if( dataInBit & DATA_THUMBNAILYUV )
{
for( MUINT32 i = 0 ; i < mShotCount ; i++ )
{
ret = ret
&& prepareMemory(
DATA_THUMBNAILYUV,
mJpegParam.u4ThumbWidth, mJpegParam.u4ThumbHeight,
eImgFmt_YUY2,
0,
NSCam::NSIoPipe::EPortCapbility_Cap);
}
}
if( dataInBit & DATA_MAINJPEG )
{
for( MUINT32 i = 0 ; i < mShotCount ; i++ )
{
ret = ret
&& prepareMemory(
DATA_MAINJPEG,
RotPicWidth, RotPicHeight,
eImgFmt_JPEG,
0);
}
}
if( dataInBit & DATA_THUMBNAILJPEG )
{
for( MUINT32 i = 0 ; i < mShotCount ; i++ )
{
ret = ret
&& prepareMemory(
DATA_THUMBNAILJPEG,
RotThuWidth, RotThuHeight,
eImgFmt_JPEG,
mShotParam.u4PictureTransform);
}
}
if( ret )
{
MINT32 sem_ret;
while( 0 !=( sem_ret = sem_wait( &mShotDone ) ) && errno == EINTR );
if( sem_ret < 0 )
{
MY_LOGE("errno = %d", errno);
ret = MFALSE;
}
MY_LOGD("shot finished");
}
mpGraph->stop();
mpGraph->uninit();
mpGraph->disconnect();
destroyNodes();
mpGraph->destroyInstance();
mpGraph = NULL;
//
reset();
//
FUNC_END;
//
return ret;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
startOne(SensorParam const & rSensorParam)
{
FUNC_START;
FUNC_END;
//
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
startOne(SensorParam const & rSensorParam, IImageBuffer const *pImgBuffer)
{
FUNC_START;
//
FUNC_END;
//
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
startAsync(SensorParam const & rSensorParam)
{
FUNC_START;
//
FUNC_END;
//
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
stop()
{
FUNC_START;
//#warning [TODO] for continouous shot
//TODO
FUNC_END;
//
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
registerCap3AParam(CaptureParam_T* pCapParams, MUINT32 const length)
{
MY_LOGD("set cap 3A param 0x%x, %d", pCapParams, length);
mpCapParams = pCapParams;
muCapParamCount = length;
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
setIspProfile(EIspProfile_T const profile)
{
mIspProfile = profile;
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
setShotParam(ShotParam const & rParam)
{
FUNC_START;
mShotParam = rParam;
//
dumpShotParam(mShotParam);
FUNC_END;
//
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
setJpegParam(JpegParam const & rParam)
{
FUNC_START;
mJpegParam = rParam;
//
dumpJpegParam(mJpegParam);
FUNC_END;
//
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
registerImageBuffer(ECamShotImgBufType const eBufType, IImageBuffer const *pImgBuffer)
{
MBOOL ret = MTRUE;
MUINT32 internaldata;
MY_LOGD("buf type 0x%x, buf 0x%x", eBufType, pImgBuffer);
switch( eBufType )
{
case ECamShot_BUF_TYPE_RAW:
internaldata = DATA_FULLRAW;
break;
case ECamShot_BUF_TYPE_YUV:
internaldata = DATA_MAINYUV;
break;
case ECamShot_BUF_TYPE_POSTVIEW:
internaldata = DATA_POSTVIEW;
break;
case ECamShot_BUF_TYPE_JPEG:
internaldata = DATA_MAINJPEG;
break;
case ECamShot_BUF_TYPE_THUMBNAIL:
internaldata = DATA_THUMBNAILJPEG;
break;
default:
ret = MFALSE;
break;
}
if( ret ) {
muRegisteredBufType |= internaldata;
regbuf_t buf = { internaldata, pImgBuffer };
mvRegBuf.push_back(buf);
} else {
MY_LOGE("not support buf type(0x%x), buf 0x%x", eBufType, pImgBuffer);
}
//
return ret;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
sendCommand(MINT32 cmd, MINT32 arg1, MINT32 arg2, MINT32 arg3)
{
//FUNC_START;
switch( cmd )
{
default:
break;
}
//FUNC_END;
//
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
fgNodeNotifyCallback(MVOID* user, NodeNotifyInfo const msg)
{
BurstShot* pBurstShot = reinterpret_cast<BurstShot*>(user);
if( pBurstShot )
{
switch( msg.msgType )
{
case NSCamNode::ENode_NOTIFY_MSG_SHUTTER:
if( pBurstShot->mbDoShutterCb )
{
pBurstShot->mbDoShutterCb = MFALSE;
pBurstShot->handleNotifyCallback(ECamShot_NOTIFY_MSG_EOF, 0, 0);
}
break;
default:
break;
}
}
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
fgNodeDataCallback(MVOID* user, NodeDataInfo const msg)
{
BurstShot* pBurstShot = reinterpret_cast<BurstShot*>(user);
if( pBurstShot )
{
MUINT32 data = 0;
switch( msg.msgType )
{
case NSCamNode::ENode_DATA_MSG_RAW:
data = ECamShot_DATA_MSG_RAW;
break;
case NSCamNode::ENode_DATA_MSG_YUV:
data = ECamShot_DATA_MSG_YUV;
break;
case NSCamNode::ENode_DATA_MSG_POSTVIEW:
data = ECamShot_DATA_MSG_POSTVIEW;
break;
case NSCamNode::ENode_DATA_MSG_JPEG:
data = ECamShot_DATA_MSG_JPEG;
break;
case NSCamNode::ENode_DATA_MSG_EISDATA:
data = ECamShot_DATA_MSG_EIS;
break;
default:
break;
}
if( data != 0 )
{
pBurstShot->handleDataCallback(
data,
msg.ext1,
msg.ext2,
msg.pBuffer
);
pBurstShot->updateFinishDataMsg(data);
}
pBurstShot->tryUnRegisterBuffer(msg.pBuffer);
}
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
createNodes(MUINT32 const NodeDataSet, MUINT32 const NodeCbSet)
{
CamManager* pCamMgr = CamManager::getInstance();
Pass1NodeInitCfg p1InitCfg( mSensorParam.u4Scenario, // scenario
3, // ring buf cnt
mSensorParam.u4Bitdepth, // bit depth
pCamMgr->getFrameRate(mSensorParam.u4OpenID), // frame rate
mSensorParam.u4RawType // raw type
);
mpPass1 = Pass1Node::createInstance(p1InitCfg);
mpCtrl = BShotCtrlNode::createInstance(mShotParam);
if( muCapParamCount )
mpCtrl->registerCap3AParam(mpCapParams, muCapParamCount);
mpCtrl->setIspProfile(mIspProfile);
mpCallback = ShotCallbackNode::createInstance(MTRUE);
//optional
if( NodeDataSet & bitOf(PASS2_CAP_SRC) )
mpCapPass2 = Pass2Node::createInstance(PASS2_CAPTURE);
if( NodeDataSet & bitOf(JPEG_ENC_HW_SRC) )
mpJpegencHw = JpegEncNode::createInstance(MTRUE);
if( NodeDataSet & bitOf(JPEG_ENC_SW_SRC) )
mpJpegencSw = JpegEncNode::createInstance(MTRUE);
NSCam::SensorStaticInfo sensorStaticInfo;
getSensorStaticInfo(sensorStaticInfo);
if ((sensorStaticInfo.rawFmtType == SENSOR_RAW_RWB) &&
(meShotMode == eShotMode_HdrShot))
{
// use MDP to do color correction for RWB sensor
mpCapPass2->setGPUProcType(1);
MY_LOGD("RWB is enabled, setGPUProcType(1)");
}
if( mpJpegencHw )
mpJpegencHw->setEncParam(mJpegParam.fgIsSOI, mJpegParam.u4Quality);
if( mpJpegencSw )
mpJpegencSw->setEncParam(mJpegParam.fgThumbIsSOI, mJpegParam.u4ThumbQuality);
// ctrl setting
mpCtrl->setShotCount(mShotCount);
// enalbe callback
mpCallback->setCallbacks(fgNodeNotifyCallback, fgNodeDataCallback, this);
mpCallback->enableDataMsg(NodeCbSet);
if( isNotifyMsgEnabled(ECamShot_NOTIFY_MSG_EOF) )
mpCallback->enableNotifyMsg(ENode_NOTIFY_MSG_SHUTTER);
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
destroyNodes()
{
#define NODE_DESTROY( node ) \
if( node ) \
{ \
node->destroyInstance(); \
node = NULL; \
}
NODE_DESTROY(mpPass1)
NODE_DESTROY(mpCtrl)
NODE_DESTROY(mpCallback)
NODE_DESTROY(mpCapPass2)
NODE_DESTROY(mpJpegencHw)
NODE_DESTROY(mpJpegencSw)
#undef NODE_DESTROY
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
updateProfile(MUINT32 profile)
{
mpMap2Node = NULL;
mpConnectDataRule = NULL;
mpConnectNotifyRule = NULL;
mShotProfile = profile;
MY_LOGD("shot profile %d", mShotProfile);
switch( mShotProfile )
{
case SHOT_PROFILE_BURST:
mpMap2Node = gMapData2Node_Cap;
mpConnectDataRule = gDataConnectRule_Cap;
mpConnectNotifyRule = gNotifyConnectRule;
break;
default:
MY_LOGE("wrong profile %d", mShotProfile);
return MFALSE;
break;
}
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
updateNeededData(MUINT32* pNeededData, MUINT32* pNeededCb) const
{
// map CamShot_DATA to internel data
//
#define updateData( SHOT_DATA_MSG, inter_data, cb, need_data, need_cb) \
if( isDataMsgEnabled(SHOT_DATA_MSG) ){ \
(need_data) |= (inter_data); \
(need_cb) |= (cb); \
}
*pNeededData = DATA_FULLRAW | DATA_DEBUGINFO;
//main jpeg
updateData(
ECamShot_DATA_MSG_JPEG,
DATA_MAINYUV | DATA_MAINJPEG | DATA_MAINJPEG_CB,
ENode_DATA_MSG_JPEG, /* callback enable data */
*pNeededData,
*pNeededCb
);
//thumbnail jpeg
if( mJpegParam.u4ThumbWidth && mJpegParam.u4ThumbHeight )
{
updateData(
ECamShot_DATA_MSG_JPEG,
DATA_THUMBNAILYUV | DATA_THUMBNAILJPEG | DATA_THUMBNAILJPEG_CB,
ENode_DATA_MSG_JPEG, /* callback enable data */
*pNeededData,
*pNeededCb
);
}
//main yuv
updateData(
ECamShot_DATA_MSG_YUV,
DATA_MAINYUV | DATA_MAINYUV_CB,
ENode_DATA_MSG_YUV, /* callback enable data */
*pNeededData,
*pNeededCb
);
//postview
updateData(
ECamShot_DATA_MSG_POSTVIEW,
DATA_POSTVIEW | DATA_POSTVIEW_CB,
ENode_DATA_MSG_POSTVIEW, /* callback enable data */
*pNeededData,
*pNeededCb
);
//raw
updateData(
ECamShot_DATA_MSG_RAW,
DATA_FULLRAW_CB,
ENode_DATA_MSG_RAW, /* callback enable data */
*pNeededData,
*pNeededCb
);
//eis
updateData(
ECamShot_DATA_MSG_EIS,
DATA_EIS_CB,
ENode_DATA_MSG_EISDATA, /* callback enable data */
*pNeededData,
*pNeededCb
);
{ //for debug
char value[PROPERTY_VALUE_MAX] = {'\0'};
property_get( "debug.shot.img3o", value, "0");
if( atoi(value) ) {
MY_LOGD("enable img3o dump");
*pNeededData |= DATA_DUMP_IMG3O;
}
}
#undef updateData
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
updateNeededNodeData(MUINT32 neededData, MUINT32* pNodeData) const
{
if( mpMap2Node == NULL ){
MY_LOGE("mapMap2Node == NULL!");
return MFALSE;
}
struct map_data2node const* pMap2Node = mpMap2Node;
// update needed nodedata
while( pMap2Node->data )
{
if( pMap2Node->data & neededData )
*pNodeData |= pMap2Node->datapath;
pMap2Node++;
}
//
MY_LOGD("data(0x%x) -> nodedata(0x%x)", neededData, *pNodeData);
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
connectNodes(MUINT32 NodeDataSet)
{
MBOOL ret = MTRUE;
if( mpConnectDataRule == NULL ){
MY_LOGE("mpConnectDataRule == NULL!");
return MFALSE;
}
if( mpConnectNotifyRule == NULL ){
MY_LOGE("mpConnectNotifyRule == NULL!");
return MFALSE;
}
// connect data according to the rule
struct connect_data_rule const* rule_data = mpConnectDataRule;
while( rule_data->condition )
{
if( (NodeDataSet & rule_data->condition) == rule_data->condition )
{
ret = ret &&
mpGraph->connectData(
rule_data->src,
rule_data->dst,
getNode(rule_data->nodesrc),
getNode(rule_data->nodedst)
);
rule_data += rule_data->next_T;
}
else
{
rule_data += rule_data->next_F;
}
}
// connect notify
struct connect_notify_rule const* rule_notify = mpConnectNotifyRule;
while( rule_notify->notify )
{
ICamNode* pSrc = getNode(rule_notify->nodesrc);
ICamNode* pDst = getNode(rule_notify->nodedst);
if( pSrc && pDst )
{
ret = ret &&
mpGraph->connectNotify(
rule_notify->notify,
pSrc,
pDst
);
}
rule_notify ++;
}
return ret;
}
/*******************************************************************************
*
********************************************************************************/
MUINT32
BurstShot::
mapToNodeData(MUINT32 dataType) const
{
if( mpMap2Node == NULL ){
MY_LOGE("mapMap2Node == NULL!");
return 0;
}
map_data2node const* pMap2Node = mpMap2Node;
while( pMap2Node->data )
{
if( pMap2Node->data == dataType )
return pMap2Node->nodedata_memory;
pMap2Node++;
}
return 0;
}
/*******************************************************************************
*
********************************************************************************/
MVOID
BurstShot::
getRotatedPicSize(MUINT32 *pW, MUINT32 *pH, MUINT32 *pThumbW, MUINT32 *pThumbH) const
{
if( mShotParam.u4PictureTransform & eTransform_ROT_90 ) //90, 270
{
*pW = mShotParam.u4PictureHeight;
*pH = mShotParam.u4PictureWidth;
*pThumbW = mJpegParam.u4ThumbHeight;
*pThumbH = mJpegParam.u4ThumbWidth;
}
else
{
*pW = mShotParam.u4PictureWidth;
*pH = mShotParam.u4PictureHeight;
*pThumbW = mJpegParam.u4ThumbWidth;
*pThumbH = mJpegParam.u4ThumbHeight;
}
}
/*******************************************************************************
*
********************************************************************************/
ICamNode*
BurstShot::
getNode(MUINT32 node)
{
switch(node)
{
case PASS1NODE:
return mpPass1;
case CTRLNODE:
return mpCtrl;
case CAPPASS2NODE:
return mpCapPass2;
case HWJPEGNODE:
return mpJpegencHw;
case SWJPEGNODE:
return mpJpegencSw;
case CALLBACKNODE:
return mpCallback;
default:
return NULL;
}
return NULL;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
doRegisterBuffers()
{
MBOOL ret = MTRUE;
vector<regbuf_t>::const_iterator pRegbuf = mvRegBuf.begin();
while( pRegbuf != mvRegBuf.end() )
{
MUINT32 nodeDataType = mapToNodeData(pRegbuf->muDATA);
if( nodeDataType ) {
ret = ret && mpAllocBufHandler->registerBuffer(nodeDataType, pRegbuf->mBuffer);
} else {
MY_LOGE("map data fail 0x%x", pRegbuf->muDATA);
ret = MFALSE;
}
pRegbuf++;
}
return ret;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
tryUnRegisterBuffer(IImageBuffer* const pBuf)
{
vector<regbuf_t>::iterator pRegbuf = mvRegBuf.begin();
while( pRegbuf != mvRegBuf.end() )
{
if( pRegbuf->mBuffer == pBuf ) {
// do unRegister
MUINT32 const nodeDataType = mapToNodeData(pRegbuf->muDATA);
if( !mpAllocBufHandler->unRegisterBuffer(nodeDataType, pRegbuf->mBuffer) )
MY_LOGW("unreg failed %p", pBuf);
mvRegBuf.erase(pRegbuf);
return MTRUE;
}
pRegbuf++;
}
return MFALSE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
enableData(MUINT32 const dataType)
{
MUINT32 nodeDataType = mapToNodeData(dataType);
if( nodeDataType == 0 ) {
return MTRUE;
}
MBOOL ret = MTRUE;
MBOOL bRegistered = (muRegisteredBufType & dataType);
ret = ret
&& mpGraph->setBufferHandler( nodeDataType, mpAllocBufHandler )
&& (bRegistered ? MTRUE : mpAllocBufHandler->setDataToAlloc(nodeDataType));
if( !ret ) {
MY_LOGE("enableData %d failed", dataType);
}
return ret;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
prepareMemory(MUINT32 const dataType,
MUINT32 const _w, MUINT32 const _h, EImageFormat const _fmt,
MUINT32 const _trans, MINT32 const usage)
{
const MUINT32 bufusage = eBUFFER_USAGE_SW_MASK | eBUFFER_USAGE_HW_MASK;
MUINT32 nodeDataType = mapToNodeData(dataType);
if( nodeDataType == 0 ) {
return MTRUE;
}
MY_LOGD("mem: nodedata %d, wxh %dx%d, fmt 0x%x, trans %d",
nodeDataType, _w, _h, _fmt, _trans);
MBOOL ret = MTRUE;
MBOOL bRegistered = (muRegisteredBufType & dataType);
ret = ret
&& mpAllocBufHandler->updateRequest( nodeDataType, _trans, usage );
if( !bRegistered )
{
AllocInfo info(_w, _h, _fmt, bufusage);
ret = ret && mpAllocBufHandler->requestBuffer( nodeDataType, info );
}
if( !ret )
{
MY_LOGE("nodedata %d, wxh %dx%d, fmt 0x%x, trans %d",
nodeDataType, _w, _h, _fmt, _trans);
}
return ret;
}
/*******************************************************************************
*
********************************************************************************/
MVOID
BurstShot::
updateFinishDataMsg(MUINT32 datamsg)
{
Mutex::Autolock _l(mLock);
MY_LOGD("update finished data: finished(0x%x), data(0x%x)",
mFinishedData, datamsg);
mFinishedData |= datamsg;
//check if all valid data is processed
if( mFinishedData == (mi4DataMsgSet & ECamShot_DATA_MSG_ALL) )
{
mFinishedData = 0x0;
MY_LOGD("shot count %d done", mCurCount);
mCurCount++;
if( mCurCount == mShotCount )
{
mpCallback->disableDataMsg(ENode_DATA_MSG_ALL);
mpCallback->disableNofityMsg(ENode_NOTIFY_MSG_ALL);
MY_LOGD("shot done, post sem");
if( sem_post(&mShotDone) < 0 )
{
MY_LOGE("errno = %d", errno);
}
}
}
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
reset()
{
mShotCount = 0;
mCurCount = 0;
muRegisteredBufType = 0x0;
mbDoShutterCb = MTRUE;
mFinishedData = 0x0;
return MTRUE;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
doDebugDump()
{
MBOOL ret = MTRUE;
MSize size;
if( !getSensorSizeFmt(&size) )
ret = MFALSE;
ret = ret
&& enableData(DATA_DUMP_IMG3O)
&& prepareMemory(
DATA_DUMP_IMG3O,
size.w, size.h,
eImgFmt_YUY2,
0,
NSCam::NSIoPipe::EPortCapbility_Cap);
return ret;
}
/*******************************************************************************
*
********************************************************************************/
MBOOL
BurstShot::
getSensorSizeFmt(MSize* pSize)
{
MBOOL ret = MTRUE;
NSCam::SensorStaticInfo sensorInfo;
//get sensor size
IHalSensorList* const pHalSensorList = IHalSensorList::get();
MINT32 const sensorNum = pHalSensorList->queryNumberOfSensors();
if(mSensorParam.u4OpenID >= sensorNum)
{
MY_LOGE("wrong sensor idx(%d), sensorNum(%d)", mSensorParam.u4OpenID, sensorNum);
return MFALSE;
}
pHalSensorList->querySensorStaticInfo(
pHalSensorList->querySensorDevIdx(mSensorParam.u4OpenID),
&sensorInfo);
// sensor size
#define scenario_case(scenario, KEY, pSize) \
case scenario: \
(pSize)->w = sensorInfo.KEY##Width; \
(pSize)->h = sensorInfo.KEY##Height; \
break;
switch(mSensorParam.u4Scenario)
{
scenario_case( SENSOR_SCENARIO_ID_NORMAL_PREVIEW, preview, pSize );
scenario_case( SENSOR_SCENARIO_ID_NORMAL_CAPTURE, capture, pSize );
scenario_case( SENSOR_SCENARIO_ID_NORMAL_VIDEO, video, pSize );
scenario_case( SENSOR_SCENARIO_ID_SLIM_VIDEO1, video1, pSize );
scenario_case( SENSOR_SCENARIO_ID_SLIM_VIDEO2, video2, pSize );
default:
MY_LOGE("not support sensor scenario(0x%x)", mSensorParam.u4Scenario);
ret = MFALSE;
break;
}
#undef scenario_case
return ret;
}
MBOOL
BurstShot::
getSensorStaticInfo(NSCam::SensorStaticInfo& sensorStaticInfo)
{
IHalSensorList* const pHalSensorList = IHalSensorList::get();
MINT32 const sensorNum = pHalSensorList->queryNumberOfSensors();
if(mSensorParam.u4OpenID >= sensorNum)
{
MY_LOGE("wrong sensor idx(%d), sensorNum(%d)", mSensorParam.u4OpenID, sensorNum);
return MFALSE;
}
// get sensor static information
pHalSensorList->querySensorStaticInfo(
pHalSensorList->querySensorDevIdx(mSensorParam.u4OpenID),
&sensorStaticInfo);
return MTRUE;
}
////////////////////////////////////////////////////////////////////////////////
}; //namespace NSCamShot
| [
"Bret_liu@tw.shuttle.com"
] | Bret_liu@tw.shuttle.com |
34ae6044ed429e49d4054e2fdafd88ec70efe976 | be0fd22f6a6f2287efed859769bb45b2c1d3364e | /src/projects/Framework/Timing/Timing.h | 66e0b6d2c94a6266b6dd3e08e59ce1e36da58259 | [] | no_license | veldrinlab/thesis-cuda-sparse-voxel-octree | c5a2d1e2b1636621d0201194776d31ce4d5b49a5 | 58357932252927c3bee5670d910614c67771f813 | refs/heads/master | 2021-01-15T12:15:51.510583 | 2013-08-27T09:49:53 | 2013-08-27T09:49:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 583 | h | #ifndef _RESTLESS_TIMING_TIMING_H
#define _RESTLESS_TIMING_TIMING_H
#include "DeltaSampler.h"
namespace restless
{
class Timing
{
public:
Timing();
~Timing();
void initialize();
void reset();
void update();
const float getTimeDelta() const;
const float getTime() const;
const float getTimeDeltaAvarage() const;
const float getFPS() const;
const unsigned int getFrame() const;
protected:
unsigned int frame;
double timeLast;
double timeCurrent;
double timeDelta;
DeltaSampler deltaSampler;
};
}
#endif | [
"jakob@udsholt.dk"
] | jakob@udsholt.dk |
bd8dfdf2f8e103105d48fe9195a9aa4444b2ffb7 | 36b9decf14d266d6babaf1c44085c2ba869c03ce | /Remnant-main/Remnant/SDK/Sebum_Emote_Talk_R_04_classes.h | 4d186a8f13a47607dd16eb3aa6e69d278b2972b8 | [] | no_license | RoryGlenn/RemnantLootSwitcher | 6e309a7b2b7bac88a166b552b640c830b863eb2d | 85c4cb6839b7c0f60cf8143c571d64ca12439a63 | refs/heads/master | 2022-12-29T08:47:15.713546 | 2020-10-23T22:01:45 | 2020-10-23T22:01:45 | 305,910,400 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 721 | h | #pragma once
// Name: Remnant, Version: 6
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
/*!!HELPER_DEF!!*/
/*!!DEFINE!!*/
namespace UFT
{
//---------------------------------------------------------------------------
// Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass Sebum_Emote_Talk_R_04.Sebum_Emote_Talk_R_04_C
// 0x0000 (FullSize[0x0030] - InheritedSize[0x0030])
class USebum_Emote_Talk_R_04_C : public UDialog_Emote
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("BlueprintGeneratedClass Sebum_Emote_Talk_R_04.Sebum_Emote_Talk_R_04_C");
return ptr;
}
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"romglenn@ucsc.edu"
] | romglenn@ucsc.edu |
5e7bf09480b98e823ef68a8359cbb8724d9a74e8 | c776476e9d06b3779d744641e758ac3a2c15cddc | /examples/litmus/c/run-scripts/tmp_1/MP+dmb.sy+addr-ctrl-rfi-ctrlisb-[fr-rf].c.cbmc_out.cpp | 78ef4bf939de0dd665c96cb301ee5e56cc9b467d | [] | no_license | ashutosh0gupta/llvm_bmc | aaac7961c723ba6f7ffd77a39559e0e52432eade | 0287c4fb180244e6b3c599a9902507f05c8a7234 | refs/heads/master | 2023-08-02T17:14:06.178723 | 2023-07-31T10:46:53 | 2023-07-31T10:46:53 | 143,100,825 | 3 | 4 | null | 2023-05-25T05:50:55 | 2018-08-01T03:47:00 | C++ | UTF-8 | C++ | false | false | 61,302 | cpp | // 0:vars:4
// 4:atom_1_X0_1:1
// 9:thr1:1
// 10:thr2:1
// 5:atom_1_X7_1:1
// 6:atom_1_X8_0:1
// 7:atom_1_X10_1:1
// 8:thr0:1
#define ADDRSIZE 11
#define NPROC 4
#define NCONTEXT 1
#define ASSUME(stmt) __CPROVER_assume(stmt)
#define ASSERT(stmt) __CPROVER_assert(stmt, "error")
#define max(a,b) (a>b?a:b)
char __get_rng();
char get_rng( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
char get_rng_th( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
int main(int argc, char **argv) {
// declare arrays for intial value version in contexts
int meminit_[ADDRSIZE*NCONTEXT];
#define meminit(x,k) meminit_[(x)*NCONTEXT+k]
int coinit_[ADDRSIZE*NCONTEXT];
#define coinit(x,k) coinit_[(x)*NCONTEXT+k]
int deltainit_[ADDRSIZE*NCONTEXT];
#define deltainit(x,k) deltainit_[(x)*NCONTEXT+k]
// declare arrays for running value version in contexts
int mem_[ADDRSIZE*NCONTEXT];
#define mem(x,k) mem_[(x)*NCONTEXT+k]
int co_[ADDRSIZE*NCONTEXT];
#define co(x,k) co_[(x)*NCONTEXT+k]
int delta_[ADDRSIZE*NCONTEXT];
#define delta(x,k) delta_[(x)*NCONTEXT+k]
// declare arrays for local buffer and observed writes
int buff_[NPROC*ADDRSIZE];
#define buff(x,k) buff_[(x)*ADDRSIZE+k]
int pw_[NPROC*ADDRSIZE];
#define pw(x,k) pw_[(x)*ADDRSIZE+k]
// declare arrays for context stamps
char cr_[NPROC*ADDRSIZE];
#define cr(x,k) cr_[(x)*ADDRSIZE+k]
char iw_[NPROC*ADDRSIZE];
#define iw(x,k) iw_[(x)*ADDRSIZE+k]
char cw_[NPROC*ADDRSIZE];
#define cw(x,k) cw_[(x)*ADDRSIZE+k]
char cx_[NPROC*ADDRSIZE];
#define cx(x,k) cx_[(x)*ADDRSIZE+k]
char is_[NPROC*ADDRSIZE];
#define is(x,k) is_[(x)*ADDRSIZE+k]
char cs_[NPROC*ADDRSIZE];
#define cs(x,k) cs_[(x)*ADDRSIZE+k]
char crmax_[NPROC*ADDRSIZE];
#define crmax(x,k) crmax_[(x)*ADDRSIZE+k]
char sforbid_[ADDRSIZE*NCONTEXT];
#define sforbid(x,k) sforbid_[(x)*NCONTEXT+k]
// declare arrays for synchronizations
int cl[NPROC];
int cdy[NPROC];
int cds[NPROC];
int cdl[NPROC];
int cisb[NPROC];
int caddr[NPROC];
int cctrl[NPROC];
int cstart[NPROC];
int creturn[NPROC];
// declare arrays for contexts activity
int active[NCONTEXT];
int ctx_used[NCONTEXT];
int r0= 0;
char creg_r0;
int r1= 0;
char creg_r1;
int r2= 0;
char creg_r2;
int r3= 0;
char creg_r3;
int r4= 0;
char creg_r4;
int r5= 0;
char creg_r5;
int r6= 0;
char creg_r6;
int r7= 0;
char creg_r7;
int r8= 0;
char creg_r8;
int r9= 0;
char creg_r9;
int r10= 0;
char creg_r10;
int r11= 0;
char creg_r11;
int r12= 0;
char creg_r12;
int r13= 0;
char creg_r13;
int r14= 0;
char creg_r14;
int r15= 0;
char creg_r15;
int r16= 0;
char creg_r16;
int r17= 0;
char creg_r17;
int r18= 0;
char creg_r18;
int r19= 0;
char creg_r19;
int r20= 0;
char creg_r20;
int r21= 0;
char creg_r21;
int r22= 0;
char creg_r22;
int r23= 0;
char creg_r23;
int r24= 0;
char creg_r24;
int r25= 0;
char creg_r25;
char old_cctrl= 0;
char old_cr= 0;
char old_cdy= 0;
char old_cw= 0;
char new_creg= 0;
buff(0,0) = 0;
pw(0,0) = 0;
cr(0,0) = 0;
iw(0,0) = 0;
cw(0,0) = 0;
cx(0,0) = 0;
is(0,0) = 0;
cs(0,0) = 0;
crmax(0,0) = 0;
buff(0,1) = 0;
pw(0,1) = 0;
cr(0,1) = 0;
iw(0,1) = 0;
cw(0,1) = 0;
cx(0,1) = 0;
is(0,1) = 0;
cs(0,1) = 0;
crmax(0,1) = 0;
buff(0,2) = 0;
pw(0,2) = 0;
cr(0,2) = 0;
iw(0,2) = 0;
cw(0,2) = 0;
cx(0,2) = 0;
is(0,2) = 0;
cs(0,2) = 0;
crmax(0,2) = 0;
buff(0,3) = 0;
pw(0,3) = 0;
cr(0,3) = 0;
iw(0,3) = 0;
cw(0,3) = 0;
cx(0,3) = 0;
is(0,3) = 0;
cs(0,3) = 0;
crmax(0,3) = 0;
buff(0,4) = 0;
pw(0,4) = 0;
cr(0,4) = 0;
iw(0,4) = 0;
cw(0,4) = 0;
cx(0,4) = 0;
is(0,4) = 0;
cs(0,4) = 0;
crmax(0,4) = 0;
buff(0,5) = 0;
pw(0,5) = 0;
cr(0,5) = 0;
iw(0,5) = 0;
cw(0,5) = 0;
cx(0,5) = 0;
is(0,5) = 0;
cs(0,5) = 0;
crmax(0,5) = 0;
buff(0,6) = 0;
pw(0,6) = 0;
cr(0,6) = 0;
iw(0,6) = 0;
cw(0,6) = 0;
cx(0,6) = 0;
is(0,6) = 0;
cs(0,6) = 0;
crmax(0,6) = 0;
buff(0,7) = 0;
pw(0,7) = 0;
cr(0,7) = 0;
iw(0,7) = 0;
cw(0,7) = 0;
cx(0,7) = 0;
is(0,7) = 0;
cs(0,7) = 0;
crmax(0,7) = 0;
buff(0,8) = 0;
pw(0,8) = 0;
cr(0,8) = 0;
iw(0,8) = 0;
cw(0,8) = 0;
cx(0,8) = 0;
is(0,8) = 0;
cs(0,8) = 0;
crmax(0,8) = 0;
buff(0,9) = 0;
pw(0,9) = 0;
cr(0,9) = 0;
iw(0,9) = 0;
cw(0,9) = 0;
cx(0,9) = 0;
is(0,9) = 0;
cs(0,9) = 0;
crmax(0,9) = 0;
buff(0,10) = 0;
pw(0,10) = 0;
cr(0,10) = 0;
iw(0,10) = 0;
cw(0,10) = 0;
cx(0,10) = 0;
is(0,10) = 0;
cs(0,10) = 0;
crmax(0,10) = 0;
cl[0] = 0;
cdy[0] = 0;
cds[0] = 0;
cdl[0] = 0;
cisb[0] = 0;
caddr[0] = 0;
cctrl[0] = 0;
cstart[0] = get_rng(0,NCONTEXT-1);
creturn[0] = get_rng(0,NCONTEXT-1);
buff(1,0) = 0;
pw(1,0) = 0;
cr(1,0) = 0;
iw(1,0) = 0;
cw(1,0) = 0;
cx(1,0) = 0;
is(1,0) = 0;
cs(1,0) = 0;
crmax(1,0) = 0;
buff(1,1) = 0;
pw(1,1) = 0;
cr(1,1) = 0;
iw(1,1) = 0;
cw(1,1) = 0;
cx(1,1) = 0;
is(1,1) = 0;
cs(1,1) = 0;
crmax(1,1) = 0;
buff(1,2) = 0;
pw(1,2) = 0;
cr(1,2) = 0;
iw(1,2) = 0;
cw(1,2) = 0;
cx(1,2) = 0;
is(1,2) = 0;
cs(1,2) = 0;
crmax(1,2) = 0;
buff(1,3) = 0;
pw(1,3) = 0;
cr(1,3) = 0;
iw(1,3) = 0;
cw(1,3) = 0;
cx(1,3) = 0;
is(1,3) = 0;
cs(1,3) = 0;
crmax(1,3) = 0;
buff(1,4) = 0;
pw(1,4) = 0;
cr(1,4) = 0;
iw(1,4) = 0;
cw(1,4) = 0;
cx(1,4) = 0;
is(1,4) = 0;
cs(1,4) = 0;
crmax(1,4) = 0;
buff(1,5) = 0;
pw(1,5) = 0;
cr(1,5) = 0;
iw(1,5) = 0;
cw(1,5) = 0;
cx(1,5) = 0;
is(1,5) = 0;
cs(1,5) = 0;
crmax(1,5) = 0;
buff(1,6) = 0;
pw(1,6) = 0;
cr(1,6) = 0;
iw(1,6) = 0;
cw(1,6) = 0;
cx(1,6) = 0;
is(1,6) = 0;
cs(1,6) = 0;
crmax(1,6) = 0;
buff(1,7) = 0;
pw(1,7) = 0;
cr(1,7) = 0;
iw(1,7) = 0;
cw(1,7) = 0;
cx(1,7) = 0;
is(1,7) = 0;
cs(1,7) = 0;
crmax(1,7) = 0;
buff(1,8) = 0;
pw(1,8) = 0;
cr(1,8) = 0;
iw(1,8) = 0;
cw(1,8) = 0;
cx(1,8) = 0;
is(1,8) = 0;
cs(1,8) = 0;
crmax(1,8) = 0;
buff(1,9) = 0;
pw(1,9) = 0;
cr(1,9) = 0;
iw(1,9) = 0;
cw(1,9) = 0;
cx(1,9) = 0;
is(1,9) = 0;
cs(1,9) = 0;
crmax(1,9) = 0;
buff(1,10) = 0;
pw(1,10) = 0;
cr(1,10) = 0;
iw(1,10) = 0;
cw(1,10) = 0;
cx(1,10) = 0;
is(1,10) = 0;
cs(1,10) = 0;
crmax(1,10) = 0;
cl[1] = 0;
cdy[1] = 0;
cds[1] = 0;
cdl[1] = 0;
cisb[1] = 0;
caddr[1] = 0;
cctrl[1] = 0;
cstart[1] = get_rng(0,NCONTEXT-1);
creturn[1] = get_rng(0,NCONTEXT-1);
buff(2,0) = 0;
pw(2,0) = 0;
cr(2,0) = 0;
iw(2,0) = 0;
cw(2,0) = 0;
cx(2,0) = 0;
is(2,0) = 0;
cs(2,0) = 0;
crmax(2,0) = 0;
buff(2,1) = 0;
pw(2,1) = 0;
cr(2,1) = 0;
iw(2,1) = 0;
cw(2,1) = 0;
cx(2,1) = 0;
is(2,1) = 0;
cs(2,1) = 0;
crmax(2,1) = 0;
buff(2,2) = 0;
pw(2,2) = 0;
cr(2,2) = 0;
iw(2,2) = 0;
cw(2,2) = 0;
cx(2,2) = 0;
is(2,2) = 0;
cs(2,2) = 0;
crmax(2,2) = 0;
buff(2,3) = 0;
pw(2,3) = 0;
cr(2,3) = 0;
iw(2,3) = 0;
cw(2,3) = 0;
cx(2,3) = 0;
is(2,3) = 0;
cs(2,3) = 0;
crmax(2,3) = 0;
buff(2,4) = 0;
pw(2,4) = 0;
cr(2,4) = 0;
iw(2,4) = 0;
cw(2,4) = 0;
cx(2,4) = 0;
is(2,4) = 0;
cs(2,4) = 0;
crmax(2,4) = 0;
buff(2,5) = 0;
pw(2,5) = 0;
cr(2,5) = 0;
iw(2,5) = 0;
cw(2,5) = 0;
cx(2,5) = 0;
is(2,5) = 0;
cs(2,5) = 0;
crmax(2,5) = 0;
buff(2,6) = 0;
pw(2,6) = 0;
cr(2,6) = 0;
iw(2,6) = 0;
cw(2,6) = 0;
cx(2,6) = 0;
is(2,6) = 0;
cs(2,6) = 0;
crmax(2,6) = 0;
buff(2,7) = 0;
pw(2,7) = 0;
cr(2,7) = 0;
iw(2,7) = 0;
cw(2,7) = 0;
cx(2,7) = 0;
is(2,7) = 0;
cs(2,7) = 0;
crmax(2,7) = 0;
buff(2,8) = 0;
pw(2,8) = 0;
cr(2,8) = 0;
iw(2,8) = 0;
cw(2,8) = 0;
cx(2,8) = 0;
is(2,8) = 0;
cs(2,8) = 0;
crmax(2,8) = 0;
buff(2,9) = 0;
pw(2,9) = 0;
cr(2,9) = 0;
iw(2,9) = 0;
cw(2,9) = 0;
cx(2,9) = 0;
is(2,9) = 0;
cs(2,9) = 0;
crmax(2,9) = 0;
buff(2,10) = 0;
pw(2,10) = 0;
cr(2,10) = 0;
iw(2,10) = 0;
cw(2,10) = 0;
cx(2,10) = 0;
is(2,10) = 0;
cs(2,10) = 0;
crmax(2,10) = 0;
cl[2] = 0;
cdy[2] = 0;
cds[2] = 0;
cdl[2] = 0;
cisb[2] = 0;
caddr[2] = 0;
cctrl[2] = 0;
cstart[2] = get_rng(0,NCONTEXT-1);
creturn[2] = get_rng(0,NCONTEXT-1);
buff(3,0) = 0;
pw(3,0) = 0;
cr(3,0) = 0;
iw(3,0) = 0;
cw(3,0) = 0;
cx(3,0) = 0;
is(3,0) = 0;
cs(3,0) = 0;
crmax(3,0) = 0;
buff(3,1) = 0;
pw(3,1) = 0;
cr(3,1) = 0;
iw(3,1) = 0;
cw(3,1) = 0;
cx(3,1) = 0;
is(3,1) = 0;
cs(3,1) = 0;
crmax(3,1) = 0;
buff(3,2) = 0;
pw(3,2) = 0;
cr(3,2) = 0;
iw(3,2) = 0;
cw(3,2) = 0;
cx(3,2) = 0;
is(3,2) = 0;
cs(3,2) = 0;
crmax(3,2) = 0;
buff(3,3) = 0;
pw(3,3) = 0;
cr(3,3) = 0;
iw(3,3) = 0;
cw(3,3) = 0;
cx(3,3) = 0;
is(3,3) = 0;
cs(3,3) = 0;
crmax(3,3) = 0;
buff(3,4) = 0;
pw(3,4) = 0;
cr(3,4) = 0;
iw(3,4) = 0;
cw(3,4) = 0;
cx(3,4) = 0;
is(3,4) = 0;
cs(3,4) = 0;
crmax(3,4) = 0;
buff(3,5) = 0;
pw(3,5) = 0;
cr(3,5) = 0;
iw(3,5) = 0;
cw(3,5) = 0;
cx(3,5) = 0;
is(3,5) = 0;
cs(3,5) = 0;
crmax(3,5) = 0;
buff(3,6) = 0;
pw(3,6) = 0;
cr(3,6) = 0;
iw(3,6) = 0;
cw(3,6) = 0;
cx(3,6) = 0;
is(3,6) = 0;
cs(3,6) = 0;
crmax(3,6) = 0;
buff(3,7) = 0;
pw(3,7) = 0;
cr(3,7) = 0;
iw(3,7) = 0;
cw(3,7) = 0;
cx(3,7) = 0;
is(3,7) = 0;
cs(3,7) = 0;
crmax(3,7) = 0;
buff(3,8) = 0;
pw(3,8) = 0;
cr(3,8) = 0;
iw(3,8) = 0;
cw(3,8) = 0;
cx(3,8) = 0;
is(3,8) = 0;
cs(3,8) = 0;
crmax(3,8) = 0;
buff(3,9) = 0;
pw(3,9) = 0;
cr(3,9) = 0;
iw(3,9) = 0;
cw(3,9) = 0;
cx(3,9) = 0;
is(3,9) = 0;
cs(3,9) = 0;
crmax(3,9) = 0;
buff(3,10) = 0;
pw(3,10) = 0;
cr(3,10) = 0;
iw(3,10) = 0;
cw(3,10) = 0;
cx(3,10) = 0;
is(3,10) = 0;
cs(3,10) = 0;
crmax(3,10) = 0;
cl[3] = 0;
cdy[3] = 0;
cds[3] = 0;
cdl[3] = 0;
cisb[3] = 0;
caddr[3] = 0;
cctrl[3] = 0;
cstart[3] = get_rng(0,NCONTEXT-1);
creturn[3] = get_rng(0,NCONTEXT-1);
// Dumping initializations
mem(0+0,0) = 0;
mem(0+1,0) = 0;
mem(0+2,0) = 0;
mem(0+3,0) = 0;
mem(4+0,0) = 0;
mem(9+0,0) = 0;
mem(10+0,0) = 0;
mem(5+0,0) = 0;
mem(6+0,0) = 0;
mem(7+0,0) = 0;
mem(8+0,0) = 0;
// Dumping context matching equalities
co(0,0) = 0;
delta(0,0) = -1;
co(1,0) = 0;
delta(1,0) = -1;
co(2,0) = 0;
delta(2,0) = -1;
co(3,0) = 0;
delta(3,0) = -1;
co(4,0) = 0;
delta(4,0) = -1;
co(5,0) = 0;
delta(5,0) = -1;
co(6,0) = 0;
delta(6,0) = -1;
co(7,0) = 0;
delta(7,0) = -1;
co(8,0) = 0;
delta(8,0) = -1;
co(9,0) = 0;
delta(9,0) = -1;
co(10,0) = 0;
delta(10,0) = -1;
// Dumping thread 1
int ret_thread_1 = 0;
cdy[1] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[1] >= cstart[1]);
T1BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !39, metadata !DIExpression()), !dbg !48
// br label %label_1, !dbg !49
goto T1BLOCK1;
T1BLOCK1:
// call void @llvm.dbg.label(metadata !47), !dbg !50
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0), metadata !40, metadata !DIExpression()), !dbg !51
// call void @llvm.dbg.value(metadata i64 2, metadata !43, metadata !DIExpression()), !dbg !51
// store atomic i64 2, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !52
// ST: Guess
iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW
old_cw = cw(1,0);
cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM
// Check
ASSUME(active[iw(1,0)] == 1);
ASSUME(active[cw(1,0)] == 1);
ASSUME(sforbid(0,cw(1,0))== 0);
ASSUME(iw(1,0) >= 0);
ASSUME(iw(1,0) >= 0);
ASSUME(cw(1,0) >= iw(1,0));
ASSUME(cw(1,0) >= old_cw);
ASSUME(cw(1,0) >= cr(1,0));
ASSUME(cw(1,0) >= cl[1]);
ASSUME(cw(1,0) >= cisb[1]);
ASSUME(cw(1,0) >= cdy[1]);
ASSUME(cw(1,0) >= cdl[1]);
ASSUME(cw(1,0) >= cds[1]);
ASSUME(cw(1,0) >= cctrl[1]);
ASSUME(cw(1,0) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0) = 2;
mem(0,cw(1,0)) = 2;
co(0,cw(1,0))+=1;
delta(0,cw(1,0)) = -1;
ASSUME(creturn[1] >= cw(1,0));
// call void (...) @dmbsy(), !dbg !53
// dumbsy: Guess
old_cdy = cdy[1];
cdy[1] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[1] >= old_cdy);
ASSUME(cdy[1] >= cisb[1]);
ASSUME(cdy[1] >= cdl[1]);
ASSUME(cdy[1] >= cds[1]);
ASSUME(cdy[1] >= cctrl[1]);
ASSUME(cdy[1] >= cw(1,0+0));
ASSUME(cdy[1] >= cw(1,0+1));
ASSUME(cdy[1] >= cw(1,0+2));
ASSUME(cdy[1] >= cw(1,0+3));
ASSUME(cdy[1] >= cw(1,4+0));
ASSUME(cdy[1] >= cw(1,9+0));
ASSUME(cdy[1] >= cw(1,10+0));
ASSUME(cdy[1] >= cw(1,5+0));
ASSUME(cdy[1] >= cw(1,6+0));
ASSUME(cdy[1] >= cw(1,7+0));
ASSUME(cdy[1] >= cw(1,8+0));
ASSUME(cdy[1] >= cr(1,0+0));
ASSUME(cdy[1] >= cr(1,0+1));
ASSUME(cdy[1] >= cr(1,0+2));
ASSUME(cdy[1] >= cr(1,0+3));
ASSUME(cdy[1] >= cr(1,4+0));
ASSUME(cdy[1] >= cr(1,9+0));
ASSUME(cdy[1] >= cr(1,10+0));
ASSUME(cdy[1] >= cr(1,5+0));
ASSUME(cdy[1] >= cr(1,6+0));
ASSUME(cdy[1] >= cr(1,7+0));
ASSUME(cdy[1] >= cr(1,8+0));
ASSUME(creturn[1] >= cdy[1]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1), metadata !44, metadata !DIExpression()), !dbg !54
// call void @llvm.dbg.value(metadata i64 1, metadata !46, metadata !DIExpression()), !dbg !54
// store atomic i64 1, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !55
// ST: Guess
iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW
old_cw = cw(1,0+1*1);
cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM
// Check
ASSUME(active[iw(1,0+1*1)] == 1);
ASSUME(active[cw(1,0+1*1)] == 1);
ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(cw(1,0+1*1) >= iw(1,0+1*1));
ASSUME(cw(1,0+1*1) >= old_cw);
ASSUME(cw(1,0+1*1) >= cr(1,0+1*1));
ASSUME(cw(1,0+1*1) >= cl[1]);
ASSUME(cw(1,0+1*1) >= cisb[1]);
ASSUME(cw(1,0+1*1) >= cdy[1]);
ASSUME(cw(1,0+1*1) >= cdl[1]);
ASSUME(cw(1,0+1*1) >= cds[1]);
ASSUME(cw(1,0+1*1) >= cctrl[1]);
ASSUME(cw(1,0+1*1) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0+1*1) = 1;
mem(0+1*1,cw(1,0+1*1)) = 1;
co(0+1*1,cw(1,0+1*1))+=1;
delta(0+1*1,cw(1,0+1*1)) = -1;
ASSUME(creturn[1] >= cw(1,0+1*1));
// ret i8* null, !dbg !56
ret_thread_1 = (- 1);
// Dumping thread 2
int ret_thread_2 = 0;
cdy[2] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[2] >= cstart[2]);
T2BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !59, metadata !DIExpression()), !dbg !104
// br label %label_2, !dbg !86
goto T2BLOCK1;
T2BLOCK1:
// call void @llvm.dbg.label(metadata !101), !dbg !106
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1), metadata !62, metadata !DIExpression()), !dbg !107
// %0 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !89
// LD: Guess
old_cr = cr(2,0+1*1);
cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM
// Check
ASSUME(active[cr(2,0+1*1)] == 2);
ASSUME(cr(2,0+1*1) >= iw(2,0+1*1));
ASSUME(cr(2,0+1*1) >= 0);
ASSUME(cr(2,0+1*1) >= cdy[2]);
ASSUME(cr(2,0+1*1) >= cisb[2]);
ASSUME(cr(2,0+1*1) >= cdl[2]);
ASSUME(cr(2,0+1*1) >= cl[2]);
// Update
creg_r0 = cr(2,0+1*1);
crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1));
caddr[2] = max(caddr[2],0);
if(cr(2,0+1*1) < cw(2,0+1*1)) {
r0 = buff(2,0+1*1);
} else {
if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) {
ASSUME(cr(2,0+1*1) >= old_cr);
}
pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1));
r0 = mem(0+1*1,cr(2,0+1*1));
}
ASSUME(creturn[2] >= cr(2,0+1*1));
// call void @llvm.dbg.value(metadata i64 %0, metadata !64, metadata !DIExpression()), !dbg !107
// %conv = trunc i64 %0 to i32, !dbg !90
// call void @llvm.dbg.value(metadata i32 %conv, metadata !60, metadata !DIExpression()), !dbg !104
// %xor = xor i32 %conv, %conv, !dbg !91
creg_r1 = max(creg_r0,creg_r0);
ASSUME(active[creg_r1] == 2);
r1 = r0 ^ r0;
// call void @llvm.dbg.value(metadata i32 %xor, metadata !65, metadata !DIExpression()), !dbg !104
// %add = add nsw i32 2, %xor, !dbg !92
creg_r2 = max(0,creg_r1);
ASSUME(active[creg_r2] == 2);
r2 = 2 + r1;
// %idxprom = sext i32 %add to i64, !dbg !92
// %arrayidx = getelementptr inbounds [4 x i64], [4 x i64]* @vars, i64 0, i64 %idxprom, !dbg !92
r3 = 0+r2*1;
ASSUME(creg_r3 >= 0);
ASSUME(creg_r3 >= creg_r2);
ASSUME(active[creg_r3] == 2);
// call void @llvm.dbg.value(metadata i64* %arrayidx, metadata !67, metadata !DIExpression()), !dbg !112
// %1 = load atomic i64, i64* %arrayidx monotonic, align 8, !dbg !92
// LD: Guess
old_cr = cr(2,r3);
cr(2,r3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM
// Check
ASSUME(active[cr(2,r3)] == 2);
ASSUME(cr(2,r3) >= iw(2,r3));
ASSUME(cr(2,r3) >= creg_r3);
ASSUME(cr(2,r3) >= cdy[2]);
ASSUME(cr(2,r3) >= cisb[2]);
ASSUME(cr(2,r3) >= cdl[2]);
ASSUME(cr(2,r3) >= cl[2]);
// Update
creg_r4 = cr(2,r3);
crmax(2,r3) = max(crmax(2,r3),cr(2,r3));
caddr[2] = max(caddr[2],creg_r3);
if(cr(2,r3) < cw(2,r3)) {
r4 = buff(2,r3);
} else {
if(pw(2,r3) != co(r3,cr(2,r3))) {
ASSUME(cr(2,r3) >= old_cr);
}
pw(2,r3) = co(r3,cr(2,r3));
r4 = mem(r3,cr(2,r3));
}
ASSUME(creturn[2] >= cr(2,r3));
// call void @llvm.dbg.value(metadata i64 %1, metadata !69, metadata !DIExpression()), !dbg !112
// %conv4 = trunc i64 %1 to i32, !dbg !94
// call void @llvm.dbg.value(metadata i32 %conv4, metadata !66, metadata !DIExpression()), !dbg !104
// %tobool = icmp ne i32 %conv4, 0, !dbg !95
// br i1 %tobool, label %if.then, label %if.else, !dbg !97
old_cctrl = cctrl[2];
cctrl[2] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[2] >= old_cctrl);
ASSUME(cctrl[2] >= creg_r4);
ASSUME(cctrl[2] >= 0);
if((r4!=0)) {
goto T2BLOCK2;
} else {
goto T2BLOCK3;
}
T2BLOCK2:
// br label %lbl_LC00, !dbg !98
goto T2BLOCK4;
T2BLOCK3:
// br label %lbl_LC00, !dbg !99
goto T2BLOCK4;
T2BLOCK4:
// call void @llvm.dbg.label(metadata !102), !dbg !119
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 3), metadata !70, metadata !DIExpression()), !dbg !120
// call void @llvm.dbg.value(metadata i64 1, metadata !72, metadata !DIExpression()), !dbg !120
// store atomic i64 1, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 3) monotonic, align 8, !dbg !102
// ST: Guess
iw(2,0+3*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW
old_cw = cw(2,0+3*1);
cw(2,0+3*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM
// Check
ASSUME(active[iw(2,0+3*1)] == 2);
ASSUME(active[cw(2,0+3*1)] == 2);
ASSUME(sforbid(0+3*1,cw(2,0+3*1))== 0);
ASSUME(iw(2,0+3*1) >= 0);
ASSUME(iw(2,0+3*1) >= 0);
ASSUME(cw(2,0+3*1) >= iw(2,0+3*1));
ASSUME(cw(2,0+3*1) >= old_cw);
ASSUME(cw(2,0+3*1) >= cr(2,0+3*1));
ASSUME(cw(2,0+3*1) >= cl[2]);
ASSUME(cw(2,0+3*1) >= cisb[2]);
ASSUME(cw(2,0+3*1) >= cdy[2]);
ASSUME(cw(2,0+3*1) >= cdl[2]);
ASSUME(cw(2,0+3*1) >= cds[2]);
ASSUME(cw(2,0+3*1) >= cctrl[2]);
ASSUME(cw(2,0+3*1) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,0+3*1) = 1;
mem(0+3*1,cw(2,0+3*1)) = 1;
co(0+3*1,cw(2,0+3*1))+=1;
delta(0+3*1,cw(2,0+3*1)) = -1;
ASSUME(creturn[2] >= cw(2,0+3*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 3), metadata !74, metadata !DIExpression()), !dbg !122
// %2 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 3) monotonic, align 8, !dbg !104
// LD: Guess
old_cr = cr(2,0+3*1);
cr(2,0+3*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM
// Check
ASSUME(active[cr(2,0+3*1)] == 2);
ASSUME(cr(2,0+3*1) >= iw(2,0+3*1));
ASSUME(cr(2,0+3*1) >= 0);
ASSUME(cr(2,0+3*1) >= cdy[2]);
ASSUME(cr(2,0+3*1) >= cisb[2]);
ASSUME(cr(2,0+3*1) >= cdl[2]);
ASSUME(cr(2,0+3*1) >= cl[2]);
// Update
creg_r5 = cr(2,0+3*1);
crmax(2,0+3*1) = max(crmax(2,0+3*1),cr(2,0+3*1));
caddr[2] = max(caddr[2],0);
if(cr(2,0+3*1) < cw(2,0+3*1)) {
r5 = buff(2,0+3*1);
} else {
if(pw(2,0+3*1) != co(0+3*1,cr(2,0+3*1))) {
ASSUME(cr(2,0+3*1) >= old_cr);
}
pw(2,0+3*1) = co(0+3*1,cr(2,0+3*1));
r5 = mem(0+3*1,cr(2,0+3*1));
}
ASSUME(creturn[2] >= cr(2,0+3*1));
// call void @llvm.dbg.value(metadata i64 %2, metadata !76, metadata !DIExpression()), !dbg !122
// %conv8 = trunc i64 %2 to i32, !dbg !105
// call void @llvm.dbg.value(metadata i32 %conv8, metadata !73, metadata !DIExpression()), !dbg !104
// %tobool9 = icmp ne i32 %conv8, 0, !dbg !106
// br i1 %tobool9, label %if.then10, label %if.else11, !dbg !108
old_cctrl = cctrl[2];
cctrl[2] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[2] >= old_cctrl);
ASSUME(cctrl[2] >= creg_r5);
ASSUME(cctrl[2] >= 0);
if((r5!=0)) {
goto T2BLOCK5;
} else {
goto T2BLOCK6;
}
T2BLOCK5:
// br label %lbl_LC01, !dbg !109
goto T2BLOCK7;
T2BLOCK6:
// br label %lbl_LC01, !dbg !110
goto T2BLOCK7;
T2BLOCK7:
// call void @llvm.dbg.label(metadata !103), !dbg !130
// call void (...) @isb(), !dbg !112
// isb: Guess
cisb[2] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cisb[2] >= cdy[2]);
ASSUME(cisb[2] >= cctrl[2]);
ASSUME(cisb[2] >= caddr[2]);
ASSUME(creturn[2] >= cisb[2]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0), metadata !78, metadata !DIExpression()), !dbg !132
// %3 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !114
// LD: Guess
old_cr = cr(2,0);
cr(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM
// Check
ASSUME(active[cr(2,0)] == 2);
ASSUME(cr(2,0) >= iw(2,0));
ASSUME(cr(2,0) >= 0);
ASSUME(cr(2,0) >= cdy[2]);
ASSUME(cr(2,0) >= cisb[2]);
ASSUME(cr(2,0) >= cdl[2]);
ASSUME(cr(2,0) >= cl[2]);
// Update
creg_r6 = cr(2,0);
crmax(2,0) = max(crmax(2,0),cr(2,0));
caddr[2] = max(caddr[2],0);
if(cr(2,0) < cw(2,0)) {
r6 = buff(2,0);
} else {
if(pw(2,0) != co(0,cr(2,0))) {
ASSUME(cr(2,0) >= old_cr);
}
pw(2,0) = co(0,cr(2,0));
r6 = mem(0,cr(2,0));
}
ASSUME(creturn[2] >= cr(2,0));
// call void @llvm.dbg.value(metadata i64 %3, metadata !80, metadata !DIExpression()), !dbg !132
// %conv15 = trunc i64 %3 to i32, !dbg !115
// call void @llvm.dbg.value(metadata i32 %conv15, metadata !77, metadata !DIExpression()), !dbg !104
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0), metadata !82, metadata !DIExpression()), !dbg !135
// %4 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !117
// LD: Guess
old_cr = cr(2,0);
cr(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM
// Check
ASSUME(active[cr(2,0)] == 2);
ASSUME(cr(2,0) >= iw(2,0));
ASSUME(cr(2,0) >= 0);
ASSUME(cr(2,0) >= cdy[2]);
ASSUME(cr(2,0) >= cisb[2]);
ASSUME(cr(2,0) >= cdl[2]);
ASSUME(cr(2,0) >= cl[2]);
// Update
creg_r7 = cr(2,0);
crmax(2,0) = max(crmax(2,0),cr(2,0));
caddr[2] = max(caddr[2],0);
if(cr(2,0) < cw(2,0)) {
r7 = buff(2,0);
} else {
if(pw(2,0) != co(0,cr(2,0))) {
ASSUME(cr(2,0) >= old_cr);
}
pw(2,0) = co(0,cr(2,0));
r7 = mem(0,cr(2,0));
}
ASSUME(creturn[2] >= cr(2,0));
// call void @llvm.dbg.value(metadata i64 %4, metadata !84, metadata !DIExpression()), !dbg !135
// %conv19 = trunc i64 %4 to i32, !dbg !118
// call void @llvm.dbg.value(metadata i32 %conv19, metadata !81, metadata !DIExpression()), !dbg !104
// %cmp = icmp eq i32 %conv, 1, !dbg !119
// %conv20 = zext i1 %cmp to i32, !dbg !119
// call void @llvm.dbg.value(metadata i32 %conv20, metadata !85, metadata !DIExpression()), !dbg !104
// call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !86, metadata !DIExpression()), !dbg !139
// %5 = zext i32 %conv20 to i64
// call void @llvm.dbg.value(metadata i64 %5, metadata !88, metadata !DIExpression()), !dbg !139
// store atomic i64 %5, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !121
// ST: Guess
iw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW
old_cw = cw(2,4);
cw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM
// Check
ASSUME(active[iw(2,4)] == 2);
ASSUME(active[cw(2,4)] == 2);
ASSUME(sforbid(4,cw(2,4))== 0);
ASSUME(iw(2,4) >= max(creg_r0,0));
ASSUME(iw(2,4) >= 0);
ASSUME(cw(2,4) >= iw(2,4));
ASSUME(cw(2,4) >= old_cw);
ASSUME(cw(2,4) >= cr(2,4));
ASSUME(cw(2,4) >= cl[2]);
ASSUME(cw(2,4) >= cisb[2]);
ASSUME(cw(2,4) >= cdy[2]);
ASSUME(cw(2,4) >= cdl[2]);
ASSUME(cw(2,4) >= cds[2]);
ASSUME(cw(2,4) >= cctrl[2]);
ASSUME(cw(2,4) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,4) = (r0==1);
mem(4,cw(2,4)) = (r0==1);
co(4,cw(2,4))+=1;
delta(4,cw(2,4)) = -1;
ASSUME(creturn[2] >= cw(2,4));
// %cmp24 = icmp eq i32 %conv8, 1, !dbg !122
// %conv25 = zext i1 %cmp24 to i32, !dbg !122
// call void @llvm.dbg.value(metadata i32 %conv25, metadata !89, metadata !DIExpression()), !dbg !104
// call void @llvm.dbg.value(metadata i64* @atom_1_X7_1, metadata !90, metadata !DIExpression()), !dbg !142
// %6 = zext i32 %conv25 to i64
// call void @llvm.dbg.value(metadata i64 %6, metadata !92, metadata !DIExpression()), !dbg !142
// store atomic i64 %6, i64* @atom_1_X7_1 seq_cst, align 8, !dbg !124
// ST: Guess
iw(2,5) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW
old_cw = cw(2,5);
cw(2,5) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM
// Check
ASSUME(active[iw(2,5)] == 2);
ASSUME(active[cw(2,5)] == 2);
ASSUME(sforbid(5,cw(2,5))== 0);
ASSUME(iw(2,5) >= max(creg_r5,0));
ASSUME(iw(2,5) >= 0);
ASSUME(cw(2,5) >= iw(2,5));
ASSUME(cw(2,5) >= old_cw);
ASSUME(cw(2,5) >= cr(2,5));
ASSUME(cw(2,5) >= cl[2]);
ASSUME(cw(2,5) >= cisb[2]);
ASSUME(cw(2,5) >= cdy[2]);
ASSUME(cw(2,5) >= cdl[2]);
ASSUME(cw(2,5) >= cds[2]);
ASSUME(cw(2,5) >= cctrl[2]);
ASSUME(cw(2,5) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,5) = (r5==1);
mem(5,cw(2,5)) = (r5==1);
co(5,cw(2,5))+=1;
delta(5,cw(2,5)) = -1;
ASSUME(creturn[2] >= cw(2,5));
// %cmp29 = icmp eq i32 %conv15, 0, !dbg !125
// %conv30 = zext i1 %cmp29 to i32, !dbg !125
// call void @llvm.dbg.value(metadata i32 %conv30, metadata !93, metadata !DIExpression()), !dbg !104
// call void @llvm.dbg.value(metadata i64* @atom_1_X8_0, metadata !94, metadata !DIExpression()), !dbg !145
// %7 = zext i32 %conv30 to i64
// call void @llvm.dbg.value(metadata i64 %7, metadata !96, metadata !DIExpression()), !dbg !145
// store atomic i64 %7, i64* @atom_1_X8_0 seq_cst, align 8, !dbg !127
// ST: Guess
iw(2,6) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW
old_cw = cw(2,6);
cw(2,6) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM
// Check
ASSUME(active[iw(2,6)] == 2);
ASSUME(active[cw(2,6)] == 2);
ASSUME(sforbid(6,cw(2,6))== 0);
ASSUME(iw(2,6) >= max(creg_r6,0));
ASSUME(iw(2,6) >= 0);
ASSUME(cw(2,6) >= iw(2,6));
ASSUME(cw(2,6) >= old_cw);
ASSUME(cw(2,6) >= cr(2,6));
ASSUME(cw(2,6) >= cl[2]);
ASSUME(cw(2,6) >= cisb[2]);
ASSUME(cw(2,6) >= cdy[2]);
ASSUME(cw(2,6) >= cdl[2]);
ASSUME(cw(2,6) >= cds[2]);
ASSUME(cw(2,6) >= cctrl[2]);
ASSUME(cw(2,6) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,6) = (r6==0);
mem(6,cw(2,6)) = (r6==0);
co(6,cw(2,6))+=1;
delta(6,cw(2,6)) = -1;
ASSUME(creturn[2] >= cw(2,6));
// %cmp34 = icmp eq i32 %conv19, 1, !dbg !128
// %conv35 = zext i1 %cmp34 to i32, !dbg !128
// call void @llvm.dbg.value(metadata i32 %conv35, metadata !97, metadata !DIExpression()), !dbg !104
// call void @llvm.dbg.value(metadata i64* @atom_1_X10_1, metadata !98, metadata !DIExpression()), !dbg !148
// %8 = zext i32 %conv35 to i64
// call void @llvm.dbg.value(metadata i64 %8, metadata !100, metadata !DIExpression()), !dbg !148
// store atomic i64 %8, i64* @atom_1_X10_1 seq_cst, align 8, !dbg !130
// ST: Guess
iw(2,7) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW
old_cw = cw(2,7);
cw(2,7) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM
// Check
ASSUME(active[iw(2,7)] == 2);
ASSUME(active[cw(2,7)] == 2);
ASSUME(sforbid(7,cw(2,7))== 0);
ASSUME(iw(2,7) >= max(creg_r7,0));
ASSUME(iw(2,7) >= 0);
ASSUME(cw(2,7) >= iw(2,7));
ASSUME(cw(2,7) >= old_cw);
ASSUME(cw(2,7) >= cr(2,7));
ASSUME(cw(2,7) >= cl[2]);
ASSUME(cw(2,7) >= cisb[2]);
ASSUME(cw(2,7) >= cdy[2]);
ASSUME(cw(2,7) >= cdl[2]);
ASSUME(cw(2,7) >= cds[2]);
ASSUME(cw(2,7) >= cctrl[2]);
ASSUME(cw(2,7) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,7) = (r7==1);
mem(7,cw(2,7)) = (r7==1);
co(7,cw(2,7))+=1;
delta(7,cw(2,7)) = -1;
ASSUME(creturn[2] >= cw(2,7));
// ret i8* null, !dbg !131
ret_thread_2 = (- 1);
// Dumping thread 3
int ret_thread_3 = 0;
cdy[3] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[3] >= cstart[3]);
T3BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !153, metadata !DIExpression()), !dbg !158
// br label %label_3, !dbg !46
goto T3BLOCK1;
T3BLOCK1:
// call void @llvm.dbg.label(metadata !157), !dbg !160
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0), metadata !154, metadata !DIExpression()), !dbg !161
// call void @llvm.dbg.value(metadata i64 1, metadata !156, metadata !DIExpression()), !dbg !161
// store atomic i64 1, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !49
// ST: Guess
iw(3,0) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW
old_cw = cw(3,0);
cw(3,0) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM
// Check
ASSUME(active[iw(3,0)] == 3);
ASSUME(active[cw(3,0)] == 3);
ASSUME(sforbid(0,cw(3,0))== 0);
ASSUME(iw(3,0) >= 0);
ASSUME(iw(3,0) >= 0);
ASSUME(cw(3,0) >= iw(3,0));
ASSUME(cw(3,0) >= old_cw);
ASSUME(cw(3,0) >= cr(3,0));
ASSUME(cw(3,0) >= cl[3]);
ASSUME(cw(3,0) >= cisb[3]);
ASSUME(cw(3,0) >= cdy[3]);
ASSUME(cw(3,0) >= cdl[3]);
ASSUME(cw(3,0) >= cds[3]);
ASSUME(cw(3,0) >= cctrl[3]);
ASSUME(cw(3,0) >= caddr[3]);
// Update
caddr[3] = max(caddr[3],0);
buff(3,0) = 1;
mem(0,cw(3,0)) = 1;
co(0,cw(3,0))+=1;
delta(0,cw(3,0)) = -1;
ASSUME(creturn[3] >= cw(3,0));
// ret i8* null, !dbg !50
ret_thread_3 = (- 1);
// Dumping thread 0
int ret_thread_0 = 0;
cdy[0] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[0] >= cstart[0]);
T0BLOCK0:
// %thr0 = alloca i64, align 8
// %thr1 = alloca i64, align 8
// %thr2 = alloca i64, align 8
// call void @llvm.dbg.value(metadata i32 %argc, metadata !171, metadata !DIExpression()), !dbg !240
// call void @llvm.dbg.value(metadata i8** %argv, metadata !172, metadata !DIExpression()), !dbg !240
// %0 = bitcast i64* %thr0 to i8*, !dbg !114
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !114
// call void @llvm.dbg.declare(metadata i64* %thr0, metadata !173, metadata !DIExpression()), !dbg !242
// %1 = bitcast i64* %thr1 to i8*, !dbg !116
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !116
// call void @llvm.dbg.declare(metadata i64* %thr1, metadata !177, metadata !DIExpression()), !dbg !244
// %2 = bitcast i64* %thr2 to i8*, !dbg !118
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #7, !dbg !118
// call void @llvm.dbg.declare(metadata i64* %thr2, metadata !178, metadata !DIExpression()), !dbg !246
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 3), metadata !179, metadata !DIExpression()), !dbg !247
// call void @llvm.dbg.value(metadata i64 0, metadata !181, metadata !DIExpression()), !dbg !247
// store atomic i64 0, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 3) monotonic, align 8, !dbg !121
// ST: Guess
iw(0,0+3*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,0+3*1);
cw(0,0+3*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,0+3*1)] == 0);
ASSUME(active[cw(0,0+3*1)] == 0);
ASSUME(sforbid(0+3*1,cw(0,0+3*1))== 0);
ASSUME(iw(0,0+3*1) >= 0);
ASSUME(iw(0,0+3*1) >= 0);
ASSUME(cw(0,0+3*1) >= iw(0,0+3*1));
ASSUME(cw(0,0+3*1) >= old_cw);
ASSUME(cw(0,0+3*1) >= cr(0,0+3*1));
ASSUME(cw(0,0+3*1) >= cl[0]);
ASSUME(cw(0,0+3*1) >= cisb[0]);
ASSUME(cw(0,0+3*1) >= cdy[0]);
ASSUME(cw(0,0+3*1) >= cdl[0]);
ASSUME(cw(0,0+3*1) >= cds[0]);
ASSUME(cw(0,0+3*1) >= cctrl[0]);
ASSUME(cw(0,0+3*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+3*1) = 0;
mem(0+3*1,cw(0,0+3*1)) = 0;
co(0+3*1,cw(0,0+3*1))+=1;
delta(0+3*1,cw(0,0+3*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+3*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 2), metadata !182, metadata !DIExpression()), !dbg !249
// call void @llvm.dbg.value(metadata i64 0, metadata !184, metadata !DIExpression()), !dbg !249
// store atomic i64 0, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !123
// ST: Guess
iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,0+2*1);
cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,0+2*1)] == 0);
ASSUME(active[cw(0,0+2*1)] == 0);
ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(cw(0,0+2*1) >= iw(0,0+2*1));
ASSUME(cw(0,0+2*1) >= old_cw);
ASSUME(cw(0,0+2*1) >= cr(0,0+2*1));
ASSUME(cw(0,0+2*1) >= cl[0]);
ASSUME(cw(0,0+2*1) >= cisb[0]);
ASSUME(cw(0,0+2*1) >= cdy[0]);
ASSUME(cw(0,0+2*1) >= cdl[0]);
ASSUME(cw(0,0+2*1) >= cds[0]);
ASSUME(cw(0,0+2*1) >= cctrl[0]);
ASSUME(cw(0,0+2*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+2*1) = 0;
mem(0+2*1,cw(0,0+2*1)) = 0;
co(0+2*1,cw(0,0+2*1))+=1;
delta(0+2*1,cw(0,0+2*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+2*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1), metadata !185, metadata !DIExpression()), !dbg !251
// call void @llvm.dbg.value(metadata i64 0, metadata !187, metadata !DIExpression()), !dbg !251
// store atomic i64 0, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !125
// ST: Guess
iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,0+1*1);
cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,0+1*1)] == 0);
ASSUME(active[cw(0,0+1*1)] == 0);
ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(cw(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cw(0,0+1*1) >= old_cw);
ASSUME(cw(0,0+1*1) >= cr(0,0+1*1));
ASSUME(cw(0,0+1*1) >= cl[0]);
ASSUME(cw(0,0+1*1) >= cisb[0]);
ASSUME(cw(0,0+1*1) >= cdy[0]);
ASSUME(cw(0,0+1*1) >= cdl[0]);
ASSUME(cw(0,0+1*1) >= cds[0]);
ASSUME(cw(0,0+1*1) >= cctrl[0]);
ASSUME(cw(0,0+1*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+1*1) = 0;
mem(0+1*1,cw(0,0+1*1)) = 0;
co(0+1*1,cw(0,0+1*1))+=1;
delta(0+1*1,cw(0,0+1*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+1*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0), metadata !188, metadata !DIExpression()), !dbg !253
// call void @llvm.dbg.value(metadata i64 0, metadata !190, metadata !DIExpression()), !dbg !253
// store atomic i64 0, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !127
// ST: Guess
iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,0);
cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,0)] == 0);
ASSUME(active[cw(0,0)] == 0);
ASSUME(sforbid(0,cw(0,0))== 0);
ASSUME(iw(0,0) >= 0);
ASSUME(iw(0,0) >= 0);
ASSUME(cw(0,0) >= iw(0,0));
ASSUME(cw(0,0) >= old_cw);
ASSUME(cw(0,0) >= cr(0,0));
ASSUME(cw(0,0) >= cl[0]);
ASSUME(cw(0,0) >= cisb[0]);
ASSUME(cw(0,0) >= cdy[0]);
ASSUME(cw(0,0) >= cdl[0]);
ASSUME(cw(0,0) >= cds[0]);
ASSUME(cw(0,0) >= cctrl[0]);
ASSUME(cw(0,0) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0) = 0;
mem(0,cw(0,0)) = 0;
co(0,cw(0,0))+=1;
delta(0,cw(0,0)) = -1;
ASSUME(creturn[0] >= cw(0,0));
// call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !191, metadata !DIExpression()), !dbg !255
// call void @llvm.dbg.value(metadata i64 0, metadata !193, metadata !DIExpression()), !dbg !255
// store atomic i64 0, i64* @atom_1_X0_1 monotonic, align 8, !dbg !129
// ST: Guess
iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,4);
cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,4)] == 0);
ASSUME(active[cw(0,4)] == 0);
ASSUME(sforbid(4,cw(0,4))== 0);
ASSUME(iw(0,4) >= 0);
ASSUME(iw(0,4) >= 0);
ASSUME(cw(0,4) >= iw(0,4));
ASSUME(cw(0,4) >= old_cw);
ASSUME(cw(0,4) >= cr(0,4));
ASSUME(cw(0,4) >= cl[0]);
ASSUME(cw(0,4) >= cisb[0]);
ASSUME(cw(0,4) >= cdy[0]);
ASSUME(cw(0,4) >= cdl[0]);
ASSUME(cw(0,4) >= cds[0]);
ASSUME(cw(0,4) >= cctrl[0]);
ASSUME(cw(0,4) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,4) = 0;
mem(4,cw(0,4)) = 0;
co(4,cw(0,4))+=1;
delta(4,cw(0,4)) = -1;
ASSUME(creturn[0] >= cw(0,4));
// call void @llvm.dbg.value(metadata i64* @atom_1_X7_1, metadata !194, metadata !DIExpression()), !dbg !257
// call void @llvm.dbg.value(metadata i64 0, metadata !196, metadata !DIExpression()), !dbg !257
// store atomic i64 0, i64* @atom_1_X7_1 monotonic, align 8, !dbg !131
// ST: Guess
iw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,5);
cw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,5)] == 0);
ASSUME(active[cw(0,5)] == 0);
ASSUME(sforbid(5,cw(0,5))== 0);
ASSUME(iw(0,5) >= 0);
ASSUME(iw(0,5) >= 0);
ASSUME(cw(0,5) >= iw(0,5));
ASSUME(cw(0,5) >= old_cw);
ASSUME(cw(0,5) >= cr(0,5));
ASSUME(cw(0,5) >= cl[0]);
ASSUME(cw(0,5) >= cisb[0]);
ASSUME(cw(0,5) >= cdy[0]);
ASSUME(cw(0,5) >= cdl[0]);
ASSUME(cw(0,5) >= cds[0]);
ASSUME(cw(0,5) >= cctrl[0]);
ASSUME(cw(0,5) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,5) = 0;
mem(5,cw(0,5)) = 0;
co(5,cw(0,5))+=1;
delta(5,cw(0,5)) = -1;
ASSUME(creturn[0] >= cw(0,5));
// call void @llvm.dbg.value(metadata i64* @atom_1_X8_0, metadata !197, metadata !DIExpression()), !dbg !259
// call void @llvm.dbg.value(metadata i64 0, metadata !199, metadata !DIExpression()), !dbg !259
// store atomic i64 0, i64* @atom_1_X8_0 monotonic, align 8, !dbg !133
// ST: Guess
iw(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,6);
cw(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,6)] == 0);
ASSUME(active[cw(0,6)] == 0);
ASSUME(sforbid(6,cw(0,6))== 0);
ASSUME(iw(0,6) >= 0);
ASSUME(iw(0,6) >= 0);
ASSUME(cw(0,6) >= iw(0,6));
ASSUME(cw(0,6) >= old_cw);
ASSUME(cw(0,6) >= cr(0,6));
ASSUME(cw(0,6) >= cl[0]);
ASSUME(cw(0,6) >= cisb[0]);
ASSUME(cw(0,6) >= cdy[0]);
ASSUME(cw(0,6) >= cdl[0]);
ASSUME(cw(0,6) >= cds[0]);
ASSUME(cw(0,6) >= cctrl[0]);
ASSUME(cw(0,6) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,6) = 0;
mem(6,cw(0,6)) = 0;
co(6,cw(0,6))+=1;
delta(6,cw(0,6)) = -1;
ASSUME(creturn[0] >= cw(0,6));
// call void @llvm.dbg.value(metadata i64* @atom_1_X10_1, metadata !200, metadata !DIExpression()), !dbg !261
// call void @llvm.dbg.value(metadata i64 0, metadata !202, metadata !DIExpression()), !dbg !261
// store atomic i64 0, i64* @atom_1_X10_1 monotonic, align 8, !dbg !135
// ST: Guess
iw(0,7) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW
old_cw = cw(0,7);
cw(0,7) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM
// Check
ASSUME(active[iw(0,7)] == 0);
ASSUME(active[cw(0,7)] == 0);
ASSUME(sforbid(7,cw(0,7))== 0);
ASSUME(iw(0,7) >= 0);
ASSUME(iw(0,7) >= 0);
ASSUME(cw(0,7) >= iw(0,7));
ASSUME(cw(0,7) >= old_cw);
ASSUME(cw(0,7) >= cr(0,7));
ASSUME(cw(0,7) >= cl[0]);
ASSUME(cw(0,7) >= cisb[0]);
ASSUME(cw(0,7) >= cdy[0]);
ASSUME(cw(0,7) >= cdl[0]);
ASSUME(cw(0,7) >= cds[0]);
ASSUME(cw(0,7) >= cctrl[0]);
ASSUME(cw(0,7) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,7) = 0;
mem(7,cw(0,7)) = 0;
co(7,cw(0,7))+=1;
delta(7,cw(0,7)) = -1;
ASSUME(creturn[0] >= cw(0,7));
// %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !136
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,0+3));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,9+0));
ASSUME(cdy[0] >= cw(0,10+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cw(0,7+0));
ASSUME(cdy[0] >= cw(0,8+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,0+3));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,9+0));
ASSUME(cdy[0] >= cr(0,10+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(cdy[0] >= cr(0,7+0));
ASSUME(cdy[0] >= cr(0,8+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[1] >= cdy[0]);
// %call15 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !137
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,0+3));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,9+0));
ASSUME(cdy[0] >= cw(0,10+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cw(0,7+0));
ASSUME(cdy[0] >= cw(0,8+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,0+3));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,9+0));
ASSUME(cdy[0] >= cr(0,10+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(cdy[0] >= cr(0,7+0));
ASSUME(cdy[0] >= cr(0,8+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[2] >= cdy[0]);
// %call16 = call i32 @pthread_create(i64* noundef %thr2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t2, i8* noundef null) #7, !dbg !138
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,0+3));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,9+0));
ASSUME(cdy[0] >= cw(0,10+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cw(0,7+0));
ASSUME(cdy[0] >= cw(0,8+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,0+3));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,9+0));
ASSUME(cdy[0] >= cr(0,10+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(cdy[0] >= cr(0,7+0));
ASSUME(cdy[0] >= cr(0,8+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[3] >= cdy[0]);
// %3 = load i64, i64* %thr0, align 8, !dbg !139, !tbaa !140
// LD: Guess
old_cr = cr(0,8);
cr(0,8) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,8)] == 0);
ASSUME(cr(0,8) >= iw(0,8));
ASSUME(cr(0,8) >= 0);
ASSUME(cr(0,8) >= cdy[0]);
ASSUME(cr(0,8) >= cisb[0]);
ASSUME(cr(0,8) >= cdl[0]);
ASSUME(cr(0,8) >= cl[0]);
// Update
creg_r9 = cr(0,8);
crmax(0,8) = max(crmax(0,8),cr(0,8));
caddr[0] = max(caddr[0],0);
if(cr(0,8) < cw(0,8)) {
r9 = buff(0,8);
} else {
if(pw(0,8) != co(8,cr(0,8))) {
ASSUME(cr(0,8) >= old_cr);
}
pw(0,8) = co(8,cr(0,8));
r9 = mem(8,cr(0,8));
}
ASSUME(creturn[0] >= cr(0,8));
// %call17 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !144
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,0+3));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,9+0));
ASSUME(cdy[0] >= cw(0,10+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cw(0,7+0));
ASSUME(cdy[0] >= cw(0,8+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,0+3));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,9+0));
ASSUME(cdy[0] >= cr(0,10+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(cdy[0] >= cr(0,7+0));
ASSUME(cdy[0] >= cr(0,8+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[1]);
// %4 = load i64, i64* %thr1, align 8, !dbg !145, !tbaa !140
// LD: Guess
old_cr = cr(0,9);
cr(0,9) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,9)] == 0);
ASSUME(cr(0,9) >= iw(0,9));
ASSUME(cr(0,9) >= 0);
ASSUME(cr(0,9) >= cdy[0]);
ASSUME(cr(0,9) >= cisb[0]);
ASSUME(cr(0,9) >= cdl[0]);
ASSUME(cr(0,9) >= cl[0]);
// Update
creg_r10 = cr(0,9);
crmax(0,9) = max(crmax(0,9),cr(0,9));
caddr[0] = max(caddr[0],0);
if(cr(0,9) < cw(0,9)) {
r10 = buff(0,9);
} else {
if(pw(0,9) != co(9,cr(0,9))) {
ASSUME(cr(0,9) >= old_cr);
}
pw(0,9) = co(9,cr(0,9));
r10 = mem(9,cr(0,9));
}
ASSUME(creturn[0] >= cr(0,9));
// %call18 = call i32 @pthread_join(i64 noundef %4, i8** noundef null), !dbg !146
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,0+3));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,9+0));
ASSUME(cdy[0] >= cw(0,10+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cw(0,7+0));
ASSUME(cdy[0] >= cw(0,8+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,0+3));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,9+0));
ASSUME(cdy[0] >= cr(0,10+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(cdy[0] >= cr(0,7+0));
ASSUME(cdy[0] >= cr(0,8+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[2]);
// %5 = load i64, i64* %thr2, align 8, !dbg !147, !tbaa !140
// LD: Guess
old_cr = cr(0,10);
cr(0,10) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,10)] == 0);
ASSUME(cr(0,10) >= iw(0,10));
ASSUME(cr(0,10) >= 0);
ASSUME(cr(0,10) >= cdy[0]);
ASSUME(cr(0,10) >= cisb[0]);
ASSUME(cr(0,10) >= cdl[0]);
ASSUME(cr(0,10) >= cl[0]);
// Update
creg_r11 = cr(0,10);
crmax(0,10) = max(crmax(0,10),cr(0,10));
caddr[0] = max(caddr[0],0);
if(cr(0,10) < cw(0,10)) {
r11 = buff(0,10);
} else {
if(pw(0,10) != co(10,cr(0,10))) {
ASSUME(cr(0,10) >= old_cr);
}
pw(0,10) = co(10,cr(0,10));
r11 = mem(10,cr(0,10));
}
ASSUME(creturn[0] >= cr(0,10));
// %call19 = call i32 @pthread_join(i64 noundef %5, i8** noundef null), !dbg !148
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,0+3));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,9+0));
ASSUME(cdy[0] >= cw(0,10+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cw(0,7+0));
ASSUME(cdy[0] >= cw(0,8+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,0+3));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,9+0));
ASSUME(cdy[0] >= cr(0,10+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(cdy[0] >= cr(0,7+0));
ASSUME(cdy[0] >= cr(0,8+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[3]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 3), metadata !204, metadata !DIExpression()), !dbg !276
// %6 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 3) seq_cst, align 8, !dbg !150
// LD: Guess
old_cr = cr(0,0+3*1);
cr(0,0+3*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,0+3*1)] == 0);
ASSUME(cr(0,0+3*1) >= iw(0,0+3*1));
ASSUME(cr(0,0+3*1) >= 0);
ASSUME(cr(0,0+3*1) >= cdy[0]);
ASSUME(cr(0,0+3*1) >= cisb[0]);
ASSUME(cr(0,0+3*1) >= cdl[0]);
ASSUME(cr(0,0+3*1) >= cl[0]);
// Update
creg_r12 = cr(0,0+3*1);
crmax(0,0+3*1) = max(crmax(0,0+3*1),cr(0,0+3*1));
caddr[0] = max(caddr[0],0);
if(cr(0,0+3*1) < cw(0,0+3*1)) {
r12 = buff(0,0+3*1);
} else {
if(pw(0,0+3*1) != co(0+3*1,cr(0,0+3*1))) {
ASSUME(cr(0,0+3*1) >= old_cr);
}
pw(0,0+3*1) = co(0+3*1,cr(0,0+3*1));
r12 = mem(0+3*1,cr(0,0+3*1));
}
ASSUME(creturn[0] >= cr(0,0+3*1));
// call void @llvm.dbg.value(metadata i64 %6, metadata !206, metadata !DIExpression()), !dbg !276
// %conv = trunc i64 %6 to i32, !dbg !151
// call void @llvm.dbg.value(metadata i32 %conv, metadata !203, metadata !DIExpression()), !dbg !240
// %cmp = icmp eq i32 %conv, 1, !dbg !152
// %conv20 = zext i1 %cmp to i32, !dbg !152
// call void @llvm.dbg.value(metadata i32 %conv20, metadata !207, metadata !DIExpression()), !dbg !240
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0), metadata !209, metadata !DIExpression()), !dbg !280
// %7 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0) seq_cst, align 8, !dbg !154
// LD: Guess
old_cr = cr(0,0);
cr(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,0)] == 0);
ASSUME(cr(0,0) >= iw(0,0));
ASSUME(cr(0,0) >= 0);
ASSUME(cr(0,0) >= cdy[0]);
ASSUME(cr(0,0) >= cisb[0]);
ASSUME(cr(0,0) >= cdl[0]);
ASSUME(cr(0,0) >= cl[0]);
// Update
creg_r13 = cr(0,0);
crmax(0,0) = max(crmax(0,0),cr(0,0));
caddr[0] = max(caddr[0],0);
if(cr(0,0) < cw(0,0)) {
r13 = buff(0,0);
} else {
if(pw(0,0) != co(0,cr(0,0))) {
ASSUME(cr(0,0) >= old_cr);
}
pw(0,0) = co(0,cr(0,0));
r13 = mem(0,cr(0,0));
}
ASSUME(creturn[0] >= cr(0,0));
// call void @llvm.dbg.value(metadata i64 %7, metadata !211, metadata !DIExpression()), !dbg !280
// %conv24 = trunc i64 %7 to i32, !dbg !155
// call void @llvm.dbg.value(metadata i32 %conv24, metadata !208, metadata !DIExpression()), !dbg !240
// %cmp25 = icmp eq i32 %conv24, 2, !dbg !156
// %conv26 = zext i1 %cmp25 to i32, !dbg !156
// call void @llvm.dbg.value(metadata i32 %conv26, metadata !212, metadata !DIExpression()), !dbg !240
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1), metadata !214, metadata !DIExpression()), !dbg !284
// %8 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1) seq_cst, align 8, !dbg !158
// LD: Guess
old_cr = cr(0,0+1*1);
cr(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,0+1*1)] == 0);
ASSUME(cr(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cr(0,0+1*1) >= 0);
ASSUME(cr(0,0+1*1) >= cdy[0]);
ASSUME(cr(0,0+1*1) >= cisb[0]);
ASSUME(cr(0,0+1*1) >= cdl[0]);
ASSUME(cr(0,0+1*1) >= cl[0]);
// Update
creg_r14 = cr(0,0+1*1);
crmax(0,0+1*1) = max(crmax(0,0+1*1),cr(0,0+1*1));
caddr[0] = max(caddr[0],0);
if(cr(0,0+1*1) < cw(0,0+1*1)) {
r14 = buff(0,0+1*1);
} else {
if(pw(0,0+1*1) != co(0+1*1,cr(0,0+1*1))) {
ASSUME(cr(0,0+1*1) >= old_cr);
}
pw(0,0+1*1) = co(0+1*1,cr(0,0+1*1));
r14 = mem(0+1*1,cr(0,0+1*1));
}
ASSUME(creturn[0] >= cr(0,0+1*1));
// call void @llvm.dbg.value(metadata i64 %8, metadata !216, metadata !DIExpression()), !dbg !284
// %conv30 = trunc i64 %8 to i32, !dbg !159
// call void @llvm.dbg.value(metadata i32 %conv30, metadata !213, metadata !DIExpression()), !dbg !240
// %cmp31 = icmp eq i32 %conv30, 1, !dbg !160
// %conv32 = zext i1 %cmp31 to i32, !dbg !160
// call void @llvm.dbg.value(metadata i32 %conv32, metadata !217, metadata !DIExpression()), !dbg !240
// call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !219, metadata !DIExpression()), !dbg !288
// %9 = load atomic i64, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !162
// LD: Guess
old_cr = cr(0,4);
cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,4)] == 0);
ASSUME(cr(0,4) >= iw(0,4));
ASSUME(cr(0,4) >= 0);
ASSUME(cr(0,4) >= cdy[0]);
ASSUME(cr(0,4) >= cisb[0]);
ASSUME(cr(0,4) >= cdl[0]);
ASSUME(cr(0,4) >= cl[0]);
// Update
creg_r15 = cr(0,4);
crmax(0,4) = max(crmax(0,4),cr(0,4));
caddr[0] = max(caddr[0],0);
if(cr(0,4) < cw(0,4)) {
r15 = buff(0,4);
} else {
if(pw(0,4) != co(4,cr(0,4))) {
ASSUME(cr(0,4) >= old_cr);
}
pw(0,4) = co(4,cr(0,4));
r15 = mem(4,cr(0,4));
}
ASSUME(creturn[0] >= cr(0,4));
// call void @llvm.dbg.value(metadata i64 %9, metadata !221, metadata !DIExpression()), !dbg !288
// %conv36 = trunc i64 %9 to i32, !dbg !163
// call void @llvm.dbg.value(metadata i32 %conv36, metadata !218, metadata !DIExpression()), !dbg !240
// call void @llvm.dbg.value(metadata i64* @atom_1_X7_1, metadata !223, metadata !DIExpression()), !dbg !291
// %10 = load atomic i64, i64* @atom_1_X7_1 seq_cst, align 8, !dbg !165
// LD: Guess
old_cr = cr(0,5);
cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,5)] == 0);
ASSUME(cr(0,5) >= iw(0,5));
ASSUME(cr(0,5) >= 0);
ASSUME(cr(0,5) >= cdy[0]);
ASSUME(cr(0,5) >= cisb[0]);
ASSUME(cr(0,5) >= cdl[0]);
ASSUME(cr(0,5) >= cl[0]);
// Update
creg_r16 = cr(0,5);
crmax(0,5) = max(crmax(0,5),cr(0,5));
caddr[0] = max(caddr[0],0);
if(cr(0,5) < cw(0,5)) {
r16 = buff(0,5);
} else {
if(pw(0,5) != co(5,cr(0,5))) {
ASSUME(cr(0,5) >= old_cr);
}
pw(0,5) = co(5,cr(0,5));
r16 = mem(5,cr(0,5));
}
ASSUME(creturn[0] >= cr(0,5));
// call void @llvm.dbg.value(metadata i64 %10, metadata !225, metadata !DIExpression()), !dbg !291
// %conv40 = trunc i64 %10 to i32, !dbg !166
// call void @llvm.dbg.value(metadata i32 %conv40, metadata !222, metadata !DIExpression()), !dbg !240
// call void @llvm.dbg.value(metadata i64* @atom_1_X8_0, metadata !227, metadata !DIExpression()), !dbg !294
// %11 = load atomic i64, i64* @atom_1_X8_0 seq_cst, align 8, !dbg !168
// LD: Guess
old_cr = cr(0,6);
cr(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,6)] == 0);
ASSUME(cr(0,6) >= iw(0,6));
ASSUME(cr(0,6) >= 0);
ASSUME(cr(0,6) >= cdy[0]);
ASSUME(cr(0,6) >= cisb[0]);
ASSUME(cr(0,6) >= cdl[0]);
ASSUME(cr(0,6) >= cl[0]);
// Update
creg_r17 = cr(0,6);
crmax(0,6) = max(crmax(0,6),cr(0,6));
caddr[0] = max(caddr[0],0);
if(cr(0,6) < cw(0,6)) {
r17 = buff(0,6);
} else {
if(pw(0,6) != co(6,cr(0,6))) {
ASSUME(cr(0,6) >= old_cr);
}
pw(0,6) = co(6,cr(0,6));
r17 = mem(6,cr(0,6));
}
ASSUME(creturn[0] >= cr(0,6));
// call void @llvm.dbg.value(metadata i64 %11, metadata !229, metadata !DIExpression()), !dbg !294
// %conv44 = trunc i64 %11 to i32, !dbg !169
// call void @llvm.dbg.value(metadata i32 %conv44, metadata !226, metadata !DIExpression()), !dbg !240
// call void @llvm.dbg.value(metadata i64* @atom_1_X10_1, metadata !231, metadata !DIExpression()), !dbg !297
// %12 = load atomic i64, i64* @atom_1_X10_1 seq_cst, align 8, !dbg !171
// LD: Guess
old_cr = cr(0,7);
cr(0,7) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM
// Check
ASSUME(active[cr(0,7)] == 0);
ASSUME(cr(0,7) >= iw(0,7));
ASSUME(cr(0,7) >= 0);
ASSUME(cr(0,7) >= cdy[0]);
ASSUME(cr(0,7) >= cisb[0]);
ASSUME(cr(0,7) >= cdl[0]);
ASSUME(cr(0,7) >= cl[0]);
// Update
creg_r18 = cr(0,7);
crmax(0,7) = max(crmax(0,7),cr(0,7));
caddr[0] = max(caddr[0],0);
if(cr(0,7) < cw(0,7)) {
r18 = buff(0,7);
} else {
if(pw(0,7) != co(7,cr(0,7))) {
ASSUME(cr(0,7) >= old_cr);
}
pw(0,7) = co(7,cr(0,7));
r18 = mem(7,cr(0,7));
}
ASSUME(creturn[0] >= cr(0,7));
// call void @llvm.dbg.value(metadata i64 %12, metadata !233, metadata !DIExpression()), !dbg !297
// %conv48 = trunc i64 %12 to i32, !dbg !172
// call void @llvm.dbg.value(metadata i32 %conv48, metadata !230, metadata !DIExpression()), !dbg !240
// %and = and i32 %conv44, %conv48, !dbg !173
creg_r19 = max(creg_r17,creg_r18);
ASSUME(active[creg_r19] == 0);
r19 = r17 & r18;
// call void @llvm.dbg.value(metadata i32 %and, metadata !234, metadata !DIExpression()), !dbg !240
// %and49 = and i32 %conv40, %and, !dbg !174
creg_r20 = max(creg_r16,creg_r19);
ASSUME(active[creg_r20] == 0);
r20 = r16 & r19;
// call void @llvm.dbg.value(metadata i32 %and49, metadata !235, metadata !DIExpression()), !dbg !240
// %and50 = and i32 %conv36, %and49, !dbg !175
creg_r21 = max(creg_r15,creg_r20);
ASSUME(active[creg_r21] == 0);
r21 = r15 & r20;
// call void @llvm.dbg.value(metadata i32 %and50, metadata !236, metadata !DIExpression()), !dbg !240
// %and51 = and i32 %conv32, %and50, !dbg !176
creg_r22 = max(max(creg_r14,0),creg_r21);
ASSUME(active[creg_r22] == 0);
r22 = (r14==1) & r21;
// call void @llvm.dbg.value(metadata i32 %and51, metadata !237, metadata !DIExpression()), !dbg !240
// %and52 = and i32 %conv26, %and51, !dbg !177
creg_r23 = max(max(creg_r13,0),creg_r22);
ASSUME(active[creg_r23] == 0);
r23 = (r13==2) & r22;
// call void @llvm.dbg.value(metadata i32 %and52, metadata !238, metadata !DIExpression()), !dbg !240
// %and53 = and i32 %conv20, %and52, !dbg !178
creg_r24 = max(max(creg_r12,0),creg_r23);
ASSUME(active[creg_r24] == 0);
r24 = (r12==1) & r23;
// call void @llvm.dbg.value(metadata i32 %and53, metadata !239, metadata !DIExpression()), !dbg !240
// %cmp54 = icmp eq i32 %and53, 1, !dbg !179
// br i1 %cmp54, label %if.then, label %if.end, !dbg !181
old_cctrl = cctrl[0];
cctrl[0] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[0] >= old_cctrl);
ASSUME(cctrl[0] >= creg_r24);
ASSUME(cctrl[0] >= 0);
if((r24==1)) {
goto T0BLOCK1;
} else {
goto T0BLOCK2;
}
T0BLOCK1:
// call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([124 x i8], [124 x i8]* @.str.1, i64 0, i64 0), i32 noundef 97, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !182
// unreachable, !dbg !182
r25 = 1;
T0BLOCK2:
// %13 = bitcast i64* %thr2 to i8*, !dbg !185
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %13) #7, !dbg !185
// %14 = bitcast i64* %thr1 to i8*, !dbg !185
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %14) #7, !dbg !185
// %15 = bitcast i64* %thr0 to i8*, !dbg !185
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %15) #7, !dbg !185
// ret i32 0, !dbg !186
ret_thread_0 = 0;
ASSERT(r25== 0);
}
| [
"tuan-phong.ngo@it.uu.se"
] | tuan-phong.ngo@it.uu.se |
a76e79505b6a5b409a3e881ae0880be91bf1a41e | 1ae555d3088dc123836060371fc520bf0ff13e52 | /atcoder/atc001/b.cpp | feb74974c7aeeec85dbf3cf67b45dda353be3d28 | [] | no_license | knagakura/procon | a87b9a1717674aeb5ee3da0301d465e95c758fde | c6ac49dbaaa908ff13cb0d9af439efe5439ec691 | refs/heads/master | 2022-01-31T19:46:33.535685 | 2022-01-23T11:59:02 | 2022-01-23T11:59:02 | 161,764,993 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,264 | cpp | #include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end() //sort(all(vi S)) sort(all(string S))
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;
const int MOD = 1e9+7;
const int INF = 1e9;
struct UnionFind{
vector<int> Parent;
vector<int> sizes;
UnionFind(int n):Parent(n),sizes(n,1){ rep(i,n)Parent[i]=i; }
//find the root of x
int root(int x){
if(x!=Parent[x]){
Parent[x] = root(Parent[x]);
}
return Parent[x];
}
//merge x and y
void unite(int x,int y){
x = root(x);
y = root(y);
if(x == y) return;
if(sizes[x] < sizes[y]) swap(x, y);
Parent[y] = x;
sizes[x] += sizes[y];
}
bool same(int x,int y){ return root(x) == root(y); }
int size(int x){ return sizes[root(x)]; }
};
int main() {
int N,Q;
cin>>N>>Q;
vector<int> P(Q),A(Q),B(Q);
rep(i,Q){
cin>>P[i]>>A[i]>>B[i];
}
UnionFind uni(N);
rep(i,Q){
if(P[i]==0){
if(!(uni.same(A[i],B[i]))) uni.unite(A[i],B[i]);
}
else{
if(uni.same(A[i],B[i]))cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
return 0;
} | [
"ngkrkzy03@gmail.com"
] | ngkrkzy03@gmail.com |
36b78b5ea168fe14c20ec16a9f6b9c057dcf380d | 46b3a0aab4f2b166ecaa5b1f884fd59cb673d810 | /old/APinTest/APinTest.ino | 8e4acbb2dad3fd82c3f6d4924abaed1f47348748 | [] | no_license | denizsomer/arduino | fb69856c94aba421be2cf706b5c59b192d9b74f7 | cfc9cc54de34d81dbbd299fe3aa6387439d9e37b | refs/heads/master | 2021-01-25T08:54:26.684049 | 2015-08-13T10:14:41 | 2015-08-13T10:14:41 | 40,651,982 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 791 | ino | /*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led, l0=A0, li=A15;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
for (led = l0; led < li; led++){
pinMode(led, OUTPUT);
}
}
// the loop routine runs over and over again forever:
void loop() {
for (led = l0; led < li; led++) analogWrite(led, 100); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
for (led = l0; led < li; led++) analogWrite(led, 100); // turn the LED off by making the voltage LOW
delay(200);
}
| [
"denizsomer@gmail.com"
] | denizsomer@gmail.com |
9022f55515167cfb743432f3fe26a2d40e99a585 | 01878f3b1d7f044558a7759b8f92a8cf744ad567 | /include/Camera.h | 6d121280e0a0ee27cb31df244c6695afa7a1b724 | [] | no_license | KiraLd/Raytracing-cpp | 0f5ec33e7e34a158f705f4c90066279c2887bb32 | 096f32cd6c5963c266785b7a8e97b638ac3bf282 | refs/heads/master | 2021-01-25T05:21:47.842400 | 2015-01-13T16:35:02 | 2015-01-13T16:35:02 | 29,199,619 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 946 | h | #ifndef CAMERA_H
#define CAMERA_H
#include "Point.h"
class Camera
{
private:
Point o;
int f;
int res_x;
int res_y;
double pitch_x;
double pitch_y;
public:
Camera();
void setOrigine(int x, int y, int z);
void setFocale(int g);
void setRes(int x, int y);
void setPitch(double x, double y);
double getX();
double getY();
double getZ();
inline int getF()
{
return f;
}
inline double getPitchX()
{
return pitch_x;
}
inline double getPitchY()
{
return pitch_y;
}
inline int getResX()
{
return res_x;
}
inline int getResY()
{
return res_y;
}
inline Point* getOrigine()
{
return &o;
}
};
#endif // CAMERA_H
| [
"lucas.mohimont@hotmail.fr"
] | lucas.mohimont@hotmail.fr |
92d249d4b77c715e44dd2c7825f543a89276b1aa | 9f345095d2b65378d2d3a9ee0bf96e1f57d1e4c5 | /CODEFORCES-D/1151.cpp | b9705c397ad2d1c36aa868b1c0ad50dbc35b8b00 | [] | no_license | ritwizsinha/PROGRAMMING-SOLUTIONS | d28d840d190d144c432435ae3d2ea627b9ee4007 | ee087d2a61ad3f30a042b7667eace226a3e262be | refs/heads/master | 2020-06-18T13:59:41.255894 | 2019-12-07T12:29:49 | 2019-12-07T12:29:49 | 196,325,862 | 0 | 3 | null | 2019-10-04T20:09:47 | 2019-07-11T05:32:01 | C++ | UTF-8 | C++ | false | false | 974 | cpp | #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<chrono>
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define endl "\n"
#define int long long
#define forn(i,n) for(long long i = 0; i < long long (n); ++i)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace std::chrono;
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
int32_t main()
{
IOS
auto start = high_resolution_clock::now();
int n;
cin>>n;
vector< pair<int, int> > v1,v2;
for(int i=0;i<n;i++){
int a,b;
cin>>a>>b;
v1.push_back(make_pair(a,b));
v2.push_back(make_pair(a*i + b*(n-i-1),i));
}
sort(begin(v2),end(v2));
cout<<v2[0].first;
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
//cout << "Time taken by function: "<< duration.count() << " microseconds" << endl;
return 0;
} | [
"ritwizsinha0@gmail.com"
] | ritwizsinha0@gmail.com |
b5dd03cbcf9ebd30a36d3be6f515b32c7be678ed | 6c0a11f53eff7b31ee0c493524e69b003b5938d7 | /src.gfx/Threading/OgreBarrierPThreads.cpp | f8c3680fc26ad73a6b857982622258372eba0338 | [] | no_license | yangfengzzz/Sisy | d2a8a6c34cd24f2eb9ab11bf99c76c68032ccc25 | 1f9637bcdc31905a4fb28fe2b9446c1ed279a923 | refs/heads/master | 2023-02-02T20:16:19.307627 | 2020-03-26T02:03:15 | 2020-03-26T02:03:15 | 322,533,099 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,736 | cpp | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2014 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#include "OgreStableHeaders.h"
#include "OgreBarrier.h"
#include <errno.h>
namespace Ogre{
#if OGRE_CPU == OGRE_CPU_ARM
#define __dmb() asm volatile ( "dmb sy\n" ::: "cc" );
#endif
#if defined(ANDROID) || OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
typedef int pthread_barrierattr_t;
//-----------------------------------------------------------------------------------
int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, int count)
{
if(count == 0)
{
errno = EINVAL;
return -1;
}
if(pthread_mutex_init(&barrier->mutex, 0) < 0)
{
return -1;
}
if(pthread_cond_init(&barrier->cond, 0) < 0)
{
pthread_mutex_destroy(&barrier->mutex);
return -1;
}
barrier->tripCount = count;
barrier->count = 0;
return 0;
}
//-----------------------------------------------------------------------------------
int pthread_barrier_destroy(pthread_barrier_t *barrier)
{
pthread_cond_destroy(&barrier->cond);
pthread_mutex_destroy(&barrier->mutex);
return 0;
}
//-----------------------------------------------------------------------------------
int pthread_barrier_wait(pthread_barrier_t *barrier)
{
pthread_mutex_lock(&barrier->mutex);
++(barrier->count);
if(barrier->count >= barrier->tripCount)
{
barrier->count = 0;
pthread_cond_broadcast(&barrier->cond);
pthread_mutex_unlock(&barrier->mutex);
return 1;
}
else
{
pthread_cond_wait(&barrier->cond, &(barrier->mutex));
pthread_mutex_unlock(&barrier->mutex);
return 0;
}
}
//-----------------------------------------------------------------------------------
#endif
Barrier::Barrier( size_t threadCount )
{
#if OGRE_PLATFORM != OGRE_PLATFORM_EMSCRIPTEN
pthread_barrier_init( &mBarrier, 0, static_cast<int>(threadCount) );
#endif
}
//-----------------------------------------------------------------------------------
Barrier::~Barrier()
{
#if OGRE_PLATFORM != OGRE_PLATFORM_EMSCRIPTEN
pthread_barrier_destroy( &mBarrier );
#endif
}
//-----------------------------------------------------------------------------------
void Barrier::sync(void)
{
#if OGRE_PLATFORM != OGRE_PLATFORM_EMSCRIPTEN
pthread_barrier_wait( &mBarrier );
#endif
}
}
| [
"yangfengzzz@hotmail.com"
] | yangfengzzz@hotmail.com |
f4f4bb12c3135b02fc434e06e9c8ce015044eedf | 51e9012435503b693a7811301c6af4332033a1a3 | /COLLISION/COLLISION.cpp | 5eb40f805b8d3bdd14f87d6bbd09abb1bba0de10 | [] | no_license | phutruonnttn/CPP_Code_Giai_Thuat | e7e3312ae70cee9ade33994de0cc3a1f17fbf0f1 | 8081d346aa0348d1a6bef546036e5a498e7b2ee5 | refs/heads/master | 2020-07-02T04:29:51.910768 | 2019-08-09T07:16:37 | 2019-08-09T07:16:37 | 201,412,551 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,640 | cpp | #include <bits/stdc++.h>
#define nmax 100007
using namespace std;
struct data
{
long long x,y,t,h;
};
long long ans,n;
data q[nmax];
bool cmp1(data k, data l)
{
return k.x < l.x;
}
bool cmp2(data k, data l)
{
return k.y < l.y;
}
bool cmp3(data k, data l)
{
return k.t < l.t;
}
bool cmp4(data k, data l)
{
return k.h < l.h;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
freopen("COLLISION.inp","r",stdin);
freopen("COLLISION.out","w",stdout);
cin >> n;
for (long i=1; i<=n; i++)
{
cin >> q[i].x >> q[i].y;
q[i].h=q[i].x-q[i].y;
q[i].t=q[i].x+q[i].y;
}
sort(q+1,q+n+1,cmp1);
long long dem=1;
for (long i=2; i<=n; i++)
{
if (q[i].x==q[i-1].x) dem++;
else
{
ans+=(dem-1);
dem=1;
}
}
ans+=(dem-1);
sort(q+1,q+n+1,cmp2);
dem=1;
for (long i=2; i<=n; i++)
{
if (q[i].y==q[i-1].y) dem++;
else
{
ans+=(dem-1);
dem=1;
}
}
ans+=(dem-1);
sort(q+1,q+n+1,cmp3);
dem=1;
for (long i=2; i<=n; i++)
{
if (q[i].t==q[i-1].t) dem++;
else
{
ans+=(dem-1);
dem=1;
}
}
ans+=(dem-1);
sort(q+1,q+n+1,cmp4);
dem=1;
for (long i=2; i<=n; i++)
{
if (q[i].h==q[i-1].h) dem++;
else
{
ans+=(dem-1);
dem=1;
}
}
ans+=(dem-1);
cout << ans;
}
| [
"truongnguyen@MacBook-Pro-cua-TruongNP.local"
] | truongnguyen@MacBook-Pro-cua-TruongNP.local |
0da9fdefa5277760ebad40b1e4c267574a80035e | 59e1888edf73a084e536d8198a8fff77c7badf60 | /Merics/visqol-master/bazel-visqol-master/src/include/support_vector_regression_model.h | d6685541c4be1f06224cc148d9c5cf3d01d158ae | [
"Apache-2.0"
] | permissive | RigDas/RigDas | 03a41f6b9fd3bbd09085b18c844225f38bd26dc3 | 02d16f1e210e7d48caf96c8bb677e2c38650472d | refs/heads/main | 2023-08-23T10:51:27.599418 | 2021-10-19T12:23:01 | 2021-10-19T12:23:01 | 392,676,908 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,900 | h | /*
* Copyright 2019 Google LLC, Andrew Hines
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef VISQOL_INCLUDE_SUPPORTVECTORREGRESSIONMODEL_H
#define VISQOL_INCLUDE_SUPPORTVECTORREGRESSIONMODEL_H
#include <vector>
#include "file_path.h"
#include "machine_learning.h"
#include "absl/status/status.h"
#include "absl/synchronization/mutex.h"
#include "svm.h"
namespace Visqol {
/**
* This class represents a Support Vector Regression model. It utilises the
* LIBSVM library.
*/
class SupportVectorRegressionModel {
public:
/**
* The constructor for the SVR model.
*/
SupportVectorRegressionModel();
/**
* The deconstructor for the SVR model. Cleans up the LIBSVM allocated memory.
*/
~SupportVectorRegressionModel();
/**
* Initialize the SVR model using a model file.
*
* @param model_path The path to the SVR model file.
*
* @return An OK status if the model was successfully initialized with the
* model file. Else, an error status is returned.
*/
absl::Status Init(const FilePath &model_path);
/**
* Initialize the SVR model using vectors of observations and targets. These
* vectors are used to train the SVR model and save it for prediction usage.
*
* @param observations A vector of observations.
* @param targets A vector of targets.
*/
void Init(const std::vector<MlObservation> &observations,
const std::vector<MlTarget> &targets);
/**
* Using the SVR model, predict a quality value for the given observation.
*
* @param observation A single observation.
*
* @return The predicted value from the observation.
*/
double Predict(const MlObservation &observation) const;
private:
/**
* The svm model provided by the LIBSVM library.
*/
svm_model *model_;
/**
* Accessing the LibSVM external libraries for loading the model must be
* performed by one thread at a time. This mutex is used to guard this
* loading of the model file.
*/
static absl::Mutex load_model_mutex_;
/**
* Pointer to an array of pointers used by the model for training.
* As per the docs, this memory can't be freed while the model is used.
*/
svm_node **observations_ptr_;
/**
* Number of observations in the training data.
*/
size_t num_observations_;
};
} // namespace Visqol
#endif // VISQOL_INCLUDE_SUPPORTVECTORREGRESSIONMODEL_H
| [
"rdas@jabra.com"
] | rdas@jabra.com |
2a3001dde4cd3be50243f8ac12c832af072eb3b7 | 17fc74d16abf6efd6c02ad3299b55c85cf4940a7 | /quick_sort.cpp | 56b23aa8476a331234d5b12eacc412816b0d4e4a | [] | no_license | Funck-Felipe97/quicksort_omp | 3a66405e71d1535e8c63dbaaf38fbe378906ff43 | 9d047a83511c43933890a57cf0035c28e6f33507 | refs/heads/master | 2020-06-04T02:21:55.527966 | 2019-06-14T12:01:53 | 2019-06-14T12:01:53 | 191,832,656 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,047 | cpp | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <omp.h>
#define TAMANHO_VETOR 200000
#define NUMERO_THREADS 8
#define LIMITE_PARALELO 1000
void imprimir_vetor(int *vetor, int tamanho) {
for (int i = 0; i < tamanho; ++i) {
printf("%d ", vetor[i]);
}
}
void iniciar_vetor(int *vetor_sequencial, int *vetor_paralelo) {
for (int i = 0; i < TAMANHO_VETOR; ++i) {
vetor_sequencial[i] = rand() % 1000;
vetor_paralelo[i] = vetor_sequencial[i];
}
}
void quick_sequencial(int *vetor, int inicio, int fim) {
int pivo, aux, i, j, meio;
i = inicio;
j = fim;
meio = (int) ((i + j) / 2);
pivo = vetor[meio];
do {
while (vetor[i] < pivo) i = i + 1;
while (vetor[j] > pivo) j = j - 1;
if(i <= j) {
aux = vetor[i];
vetor[i] = vetor[j];
vetor[j] = aux;
i = i + 1;
j = j - 1;
}
} while(j > i);
if(inicio < j) quick_sequencial(vetor, inicio, j);
if(i < fim) quick_sequencial(vetor, i, fim);
}
void quick_paralelo(int *vetor, int inicio, int fim) {
int pivo, aux, i, j, meio;
i = inicio;
j = fim;
meio = (int) ((i + j) / 2);
pivo = vetor[meio];
do {
while (vetor[i] < pivo) i = i + 1;
while (vetor[j] > pivo) j = j - 1;
if(i <= j) {
aux = vetor[i];
vetor[i] = vetor[j];
vetor[j] = aux;
i = i + 1;
j = j - 1;
}
} while(j > i);
if (fim - inicio < LIMITE_PARALELO) {
if(inicio < j) quick_paralelo(vetor, inicio, j);
if(i < fim) quick_paralelo(vetor, i, fim);
} else {
#pragma omp task
{ if(inicio < j) quick_paralelo(vetor, inicio, j); }
#pragma omp task
{ if(i < fim) quick_paralelo(vetor, i, fim); }
}
}
void teste_sequencial(int *vetor_sequencial) {
clock_t tempo;
printf("\n10 primeiros numeros sequencial desordenados: ");
imprimir_vetor(vetor_sequencial, 10);
tempo = clock();
quick_sequencial(vetor_sequencial, 0, TAMANHO_VETOR - 1);
printf("\nTempo sequencial: (%f) segundos\n", (clock() - tempo) / (double)CLOCKS_PER_SEC);
printf("10 primeiros numeros sequencial ordenados: ");
imprimir_vetor(vetor_sequencial, 10);
}
void teste_paralelo(int *vetor_paralelo) {
clock_t tempo;
printf("\n\n10 primeiros numeros paralelos desordenados: ");
imprimir_vetor(vetor_paralelo, 10);
tempo = clock();
#pragma omp parallel num_threads(NUMERO_THREADS)
{
#pragma omp single nowait
{
quick_paralelo(vetor_paralelo, 0, TAMANHO_VETOR - 1);
printf("\nTempo paralelo: (%f) segundos\n", (clock() - tempo) / (double)CLOCKS_PER_SEC);
}
}
printf("10 primeiros numeros paralelos ordenados: ");
imprimir_vetor(vetor_paralelo, 10);
printf("\n");
}
int main() {
int vetor_sequencial[TAMANHO_VETOR];
int vetor_paralelo[TAMANHO_VETOR];
iniciar_vetor(vetor_sequencial, vetor_paralelo);
teste_sequencial(vetor_sequencial);
teste_paralelo(vetor_paralelo);
}
| [
"funck.felipe@hotmail.com"
] | funck.felipe@hotmail.com |
137d5d119bd68e93c47cf80c8adaf186cbd0d773 | 581444df24c3040de6a339887476267bc30772df | /follower/src/Ball3DPointRetriver.h | 298fea45c141ff38e91acec5de586dfedad77796 | [] | no_license | valegagge/my_appls | 8439a59c6edcb5e6b8cddd3fa8597e84958dbc53 | f5196516f0fcd1d689ab7ff0aa9d89633ac7c9e6 | refs/heads/master | 2022-07-02T18:50:49.531316 | 2022-06-07T08:41:57 | 2022-06-07T08:41:57 | 134,380,141 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 980 | h |
/******************************************************************************
* *
* Copyright (C) 2019 Fondazione Istituto Italiano di Tecnologia (IIT) *
* All Rights Reserved. *
* *
******************************************************************************/
/**
* @file Ball3DPointRetriver.h
* @authors: Valentina Gaggero <valentina.gaggero@iit.it>
*/
#ifndef BALL3DPOINTRETRIVER_H
#define BALL3DPOINTRETRIVER_H
#include "TargetRetriver.h"
namespace FollowerTarget
{
class Ball3DPointRetriver : public TargetRetriver
{
public:
Target_t getTarget(void);
Ball3DPointRetriver();
void getTargetPixelCoord(double &u, double &v);
private:
double m_ballPointU;
double m_ballPointV;
};
}
#endif
| [
"valentina.gaggero@iit.it"
] | valentina.gaggero@iit.it |
c29d14c1a9a964af19f37e3a5d88a618891abbd1 | 279395ac5d76346c0948e44921e9c29e3a6ba46a | /PersonalBudget/UsersFile.h | 02a9ea3d9203fd828df73874b82a8219ed9c2759 | [] | no_license | dariuszkrygier/PersonalBudget | 84b500a5b8386950d18da3e19e484b315f9b169d | 02b2923434c0b30dd4f9c57e6859e64f31abc070 | refs/heads/main | 2023-01-10T01:45:33.034551 | 2020-11-08T19:25:34 | 2020-11-08T19:25:34 | 308,001,365 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 494 | h | #ifndef USERSFILE_H
#define USERSFILE_H
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include "User.h"
#include "AuxiliaryMethods.h"
#include <stdio.h>
#include "Markup.h"
using namespace std;
class UsersFile {
const string usersFileName;
public:
UsersFile(string USERSFILENAME) : usersFileName (USERSFILENAME) {};
vector <User> loadUsersFromFile();
void saveUserToFile(User user);
void saveAllUsersToFile(vector <User> &users);
};
#endif
| [
"dariusz.krygier.programista@gmail.com"
] | dariusz.krygier.programista@gmail.com |
4a271559826bbc9023e817452bb05faf084030f0 | 1e1af8b5df62f5d535f4922d22b122af2c784141 | /src/comet/core/logger.h | 389191f24c6726f28c95abe8a31b1e7bb5260d12 | [
"MIT"
] | permissive | m4jr0/gameengine | 37e449c43f79ce2bc1ca9966c91f2980b6cd5787 | 5154b9728709e357c915cdc5ef4c64a842128f0f | refs/heads/master | 2023-07-12T22:04:59.694554 | 2023-05-16T09:35:28 | 2023-05-16T10:51:49 | 69,503,616 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,342 | h | // Copyright 2023 m4jr0. All Rights Reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
#ifndef COMET_COMET_CORE_LOGGER_H_
#define COMET_COMET_CORE_LOGGER_H_
#include "comet_precompile.h"
// If issues arise with current terminal, comment this line.
#define COMET_TERMINAL_COLORS
#define COMET_ASCII_PREFIX "\033["
#define COMET_ASCII_SUFFIX "m"
#define COMET_ASCII_ATTR_SUFFIX ";"
#define COMET_ASCII_EMPHASIS_ATTR "1" COMET_ASCII_ATTR_SUFFIX
#define COMET_ASCII_NORMAL_COL "0" // Default terminal color.
#define COMET_ASCII_INFO_COL COMET_ASCII_NORMAL_COL
#define COMET_ASCII_ERROR_COL "31" // Red color.
#define COMET_ASCII_WARNING_COL "33" // Yellow color.
#define COMET_ASCII_DEBUG_COL "90" // Dark gray color.
#ifdef COMET_TERMINAL_COLORS
#define COMET_ASCII_CATEGORY(COLOR) \
COMET_ASCII_PREFIX COMET_ASCII_EMPHASIS_ATTR COLOR COMET_ASCII_SUFFIX
#define COMET_ASCII(COLOR) COMET_ASCII_PREFIX COLOR COMET_ASCII_SUFFIX
#define COMET_ASCII_RESET COMET_ASCII(COMET_ASCII_NORMAL_COL)
#else
#define COMET_ASCII_CATEGORY(COLOR) ""
#define COMET_ASCII(COLOR) ""
#define COMET_ASCII_RESET ""
#endif // COMET_TERMINAL_COLORS
namespace comet {
enum class LoggerType {
Unknown = 0,
Global,
Core,
Event,
GameObject,
Input,
Physics,
Rendering,
Resource,
Time,
Utils
};
class Logger final {
public:
static Logger& Get(LoggerType);
Logger() = delete;
Logger(const Logger&) = delete;
Logger(Logger&&) = delete;
Logger& operator=(const Logger&) = delete;
Logger& operator=(Logger&&) = delete;
~Logger() = default;
template <typename... Targs>
void Error(const Targs&... args) const {
std::stringstream string_stream;
GetString(string_stream, args...);
std::cerr << COMET_ASCII_CATEGORY(COMET_ASCII_ERROR_COL) << "[ERROR]"
<< COMET_ASCII(COMET_ASCII_ERROR_COL) << " "
<< string_stream.str() << COMET_ASCII_RESET << '\n';
}
template <typename... Targs>
void Info(const Targs&... args) const {
std::stringstream string_stream;
GetString(string_stream, args...);
std::cout << COMET_ASCII_CATEGORY(COMET_ASCII_INFO_COL) << "[INFO]"
<< COMET_ASCII(COMET_ASCII_INFO_COL) << " " << string_stream.str()
<< COMET_ASCII_RESET << '\n';
}
template <typename... Targs>
void Debug(const Targs&... args) const {
std::stringstream string_stream;
GetString(string_stream, args...);
std::cout << COMET_ASCII_CATEGORY(COMET_ASCII_DEBUG_COL) << "[DEBUG]"
<< COMET_ASCII(COMET_ASCII_DEBUG_COL) << " "
<< string_stream.str() << COMET_ASCII_RESET << '\n';
}
template <typename... Targs>
void Warning(const Targs&... args) const {
std::stringstream string_stream;
GetString(string_stream, args...);
std::cout << COMET_ASCII_CATEGORY(COMET_ASCII_WARNING_COL) << "[WARNING]"
<< COMET_ASCII(COMET_ASCII_WARNING_COL) << " "
<< string_stream.str() << COMET_ASCII_RESET << '\n';
}
const LoggerType GetType() const { return type_; };
private:
explicit Logger(LoggerType logger_type);
template <typename T>
void GetString(std::stringstream& string_stream, const T& arg) const {
string_stream << arg;
}
template <typename T, typename... Targs>
void GetString(std::stringstream& string_stream, const T& arg,
const Targs&... args) const {
GetString(string_stream, arg);
GetString(string_stream, args...);
}
static std::shared_ptr<Logger> Generate(LoggerType logger_type);
static std::unordered_map<LoggerType, std::shared_ptr<Logger>> loggers_;
LoggerType type_{LoggerType::Unknown};
};
#ifndef COMET_DEBUG
#define COMET_LOG_ERROR(logger_type, ...)
#define COMET_LOG_INFO(logger_type, ...)
#define COMET_LOG_DEBUG(logger_type, ...)
#define COMET_LOG_WARNING(logger_type, ...)
#define COMET_LOG_GLOBAL_ERROR(...)
#define COMET_LOG_GLOBAL_INFO(...)
#define COMET_LOG_GLOBAL_DEBUG(...)
#define COMET_LOG_GLOBAL_WARNING(...)
#define COMET_LOG_CORE_ERROR(...)
#define COMET_LOG_CORE_INFO(...)
#define COMET_LOG_CORE_DEBUG(...)
#define COMET_LOG_CORE_WARNING(...)
#define COMET_LOG_EVENT_ERROR(...)
#define COMET_LOG_EVENT_INFO(...)
#define COMET_LOG_EVENT_DEBUG(...)
#define COMET_LOG_EVENT_WARNING(...)
#define COMET_LOG_ENTITY_ERROR(...)
#define COMET_LOG_ENTITY_INFO(...)
#define COMET_LOG_ENTITY_DEBUG(...)
#define COMET_LOG_ENTITY_WARNING(...)
#define COMET_LOG_INPUT_ERROR(...)
#define COMET_LOG_INPUT_INFO(...)
#define COMET_LOG_INPUT_DEBUG(...)
#define COMET_LOG_INPUT_WARNING(...)
#define COMET_LOG_PHYSICS_ERROR(...)
#define COMET_LOG_PHYSICS_INFO(...)
#define COMET_LOG_PHYSICS_DEBUG(...)
#define COMET_LOG_PHYSICS_WARNING(...)
#define COMET_LOG_RENDERING_ERROR(...)
#define COMET_LOG_RENDERING_INFO(...)
#define COMET_LOG_RENDERING_DEBUG(...)
#define COMET_LOG_RENDERING_WARNING(...)
#define COMET_LOG_RESOURCE_ERROR(...)
#define COMET_LOG_RESOURCE_INFO(...)
#define COMET_LOG_RESOURCE_DEBUG(...)
#define COMET_LOG_RESOURCE_WARNING(...)
#define COMET_LOG_TIME_ERROR(...)
#define COMET_LOG_TIME_INFO(...)
#define COMET_LOG_TIME_DEBUG(...)
#define COMET_LOG_TIME_WARNING(...)
#define COMET_LOG_UTILS_ERROR(...)
#define COMET_LOG_UTILS_INFO(...)
#define COMET_LOG_UTILS_DEBUG(...)
#define COMET_LOG_UTILS_WARNING(...)
#else
#define COMET_LOG_ERROR(logger_type, ...) \
comet::Logger::Get(logger_type).Error(__VA_ARGS__)
#define COMET_LOG_INFO(logger_type, ...) \
comet::Logger::Get(logger_type).Info(__VA_ARGS__)
#define COMET_LOG_DEBUG(logger_type, ...) \
comet::Logger::Get(logger_type).Debug(__VA_ARGS__)
#define COMET_LOG_WARNING(logger_type, ...) \
comet::Logger::Get(logger_type).Warning(__VA_ARGS__)
#define COMET_LOG_GLOBAL_ERROR(...) \
comet::Logger::Get(comet::LoggerType::Global).Error(__VA_ARGS__)
#define COMET_LOG_GLOBAL_INFO(...) \
comet::Logger::Get(comet::LoggerType::Global).Info(__VA_ARGS__)
#define COMET_LOG_GLOBAL_DEBUG(...) \
comet::Logger::Get(comet::LoggerType::Global).Debug(__VA_ARGS__)
#define COMET_LOG_GLOBAL_WARNING(...) \
comet::Logger::Get(comet::LoggerType::Global).Warning(__VA_ARGS__)
#define COMET_LOG_CORE_ERROR(...) \
comet::Logger::Get(comet::LoggerType::Core).Error(__VA_ARGS__)
#define COMET_LOG_CORE_INFO(...) \
comet::Logger::Get(comet::LoggerType::Core).Info(__VA_ARGS__)
#define COMET_LOG_CORE_DEBUG(...) \
comet::Logger::Get(comet::LoggerType::Core).Debug(__VA_ARGS__)
#define COMET_LOG_CORE_WARNING(...) \
comet::Logger::Get(comet::LoggerType::Core).Warning(__VA_ARGS__)
#define COMET_LOG_EVENT_ERROR(...) \
comet::Logger::Get(comet::LoggerType::Event).Error(__VA_ARGS__)
#define COMET_LOG_EVENT_INFO(...) \
comet::Logger::Get(comet::LoggerType::Event).Info(__VA_ARGS__)
#define COMET_LOG_EVENT_DEBUG(...) \
comet::Logger::Get(comet::LoggerType::Event).Debug(__VA_ARGS__)
#define COMET_LOG_EVENT_WARNING(...) \
comet::Logger::Get(comet::LoggerType::Event).Warning(__VA_ARGS__)
#define COMET_LOG_ENTITY_ERROR(...) \
comet::Logger::Get(comet::LoggerType::GameObject).Error(__VA_ARGS__)
#define COMET_LOG_ENTITY_INFO(...) \
comet::Logger::Get(comet::LoggerType::GameObject).Info(__VA_ARGS__)
#define COMET_LOG_ENTITY_DEBUG(...) \
comet::Logger::Get(comet::LoggerType::GameObject).Debug(__VA_ARGS__)
#define COMET_LOG_ENTITY_WARNING(...) \
comet::Logger::Get(comet::LoggerType::GameObject).Warning(__VA_ARGS__)
#define COMET_LOG_INPUT_ERROR(...) \
comet::Logger::Get(comet::LoggerType::Input).Error(__VA_ARGS__)
#define COMET_LOG_INPUT_INFO(...) \
comet::Logger::Get(comet::LoggerType::Input).Info(__VA_ARGS__)
#define COMET_LOG_INPUT_DEBUG(...) \
comet::Logger::Get(comet::LoggerType::Input).Debug(__VA_ARGS__)
#define COMET_LOG_INPUT_WARNING(...) \
comet::Logger::Get(comet::LoggerType::Input).Warning(__VA_ARGS__)
#define COMET_LOG_PHYSICS_ERROR(...) \
comet::Logger::Get(comet::LoggerType::Physics).Error(__VA_ARGS__)
#define COMET_LOG_PHYSICS_INFO(...) \
comet::Logger::Get(comet::LoggerType::Physics).Info(__VA_ARGS__)
#define COMET_LOG_PHYSICS_DEBUG(...) \
comet::Logger::Get(comet::LoggerType::Physics).Debug(__VA_ARGS__)
#define COMET_LOG_PHYSICS_WARNING(...) \
comet::Logger::Get(comet::LoggerType::Physics).Warning(__VA_ARGS__)
#define COMET_LOG_RENDERING_ERROR(...) \
comet::Logger::Get(comet::LoggerType::Rendering).Error(__VA_ARGS__)
#define COMET_LOG_RENDERING_INFO(...) \
comet::Logger::Get(comet::LoggerType::Rendering).Info(__VA_ARGS__)
#define COMET_LOG_RENDERING_DEBUG(...) \
comet::Logger::Get(comet::LoggerType::Rendering).Debug(__VA_ARGS__)
#define COMET_LOG_RENDERING_WARNING(...) \
comet::Logger::Get(comet::LoggerType::Rendering).Warning(__VA_ARGS__)
#define COMET_LOG_RESOURCE_ERROR(...) \
comet::Logger::Get(comet::LoggerType::Resource).Error(__VA_ARGS__)
#define COMET_LOG_RESOURCE_INFO(...) \
comet::Logger::Get(comet::LoggerType::Resource).Info(__VA_ARGS__)
#define COMET_LOG_RESOURCE_DEBUG(...) \
comet::Logger::Get(comet::LoggerType::Resource).Debug(__VA_ARGS__)
#define COMET_LOG_RESOURCE_WARNING(...) \
comet::Logger::Get(comet::LoggerType::Resource).Warning(__VA_ARGS__)
#define COMET_LOG_TIME_ERROR(...) \
comet::Logger::Get(comet::LoggerType::Time).Error(__VA_ARGS__)
#define COMET_LOG_TIME_INFO(...) \
comet::Logger::Get(comet::LoggerType::Time).Info(__VA_ARGS__)
#define COMET_LOG_TIME_DEBUG(...) \
comet::Logger::Get(comet::LoggerType::Time).Debug(__VA_ARGS__)
#define COMET_LOG_TIME_WARNING(...) \
comet::Logger::Get(comet::LoggerType::Time).Warning(__VA_ARGS__)
#define COMET_LOG_UTILS_ERROR(...) \
comet::Logger::Get(comet::LoggerType::Utils).Error(__VA_ARGS__)
#define COMET_LOG_UTILS_INFO(...) \
comet::Logger::Get(comet::LoggerType::Utils).Info(__VA_ARGS__)
#define COMET_LOG_UTILS_DEBUG(...) \
comet::Logger::Get(comet::LoggerType::Utils).Debug(__VA_ARGS__)
#define COMET_LOG_UTILS_WARNING(...) \
comet::Logger::Get(comet::LoggerType::Utils).Warning(__VA_ARGS__)
#endif // !COMET_DEBUG
} // namespace comet
#endif // COMET_COMET_CORE_LOGGER_H_
| [
"lowgravityisfun@gmail.com"
] | lowgravityisfun@gmail.com |
57fb26ba6527ef4df58c51dcecb15f9e0845fb6d | ab97a8915347c76d05d6690dbdbcaf23d7f0d1fd | /chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.h | cd3b7156e7d65b150f398e2c5ff90dbf7233d682 | [
"BSD-3-Clause"
] | permissive | laien529/chromium | c9eb243957faabf1b477939e3b681df77f083a9a | 3f767cdd5c82e9c78b910b022ffacddcb04d775a | refs/heads/master | 2022-11-28T00:28:58.669067 | 2020-08-20T08:37:31 | 2020-08-20T08:37:31 | 288,961,699 | 1 | 0 | BSD-3-Clause | 2020-08-20T09:21:57 | 2020-08-20T09:21:56 | null | UTF-8 | C++ | false | false | 7,713 | h | // Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_CONTAINER_IMPL_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_CONTAINER_IMPL_VIEW_H_
#include <string>
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "chrome/browser/ui/global_media_controls/media_notification_container_impl.h"
#include "chrome/browser/ui/views/global_media_controls/media_notification_audio_device_selector_view_delegate.h"
#include "chrome/browser/ui/views/global_media_controls/overlay_media_notification_view.h"
#include "components/media_message_center/media_notification_container.h"
#include "components/media_message_center/media_notification_view_impl.h"
#include "media/audio/audio_device_description.h"
#include "ui/views/animation/slide_out_controller_delegate.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/widget/unique_widget_ptr.h"
namespace media_message_center {
class MediaNotificationItem;
} // namespace media_message_center
namespace views {
class ImageButton;
class SlideOutController;
} // namespace views
class MediaNotificationAudioDeviceSelectorView;
class MediaNotificationContainerObserver;
class MediaNotificationService;
// MediaNotificationContainerImplView holds a media notification for display
// within the MediaDialogView. The media notification shows metadata for a media
// session and can control playback.
class MediaNotificationContainerImplView
: public views::Button,
public media_message_center::MediaNotificationContainer,
public MediaNotificationContainerImpl,
public MediaNotificationAudioDeviceSelectorViewDelegate,
public views::SlideOutControllerDelegate,
public views::ButtonListener,
public views::FocusChangeListener {
public:
MediaNotificationContainerImplView(
const std::string& id,
base::WeakPtr<media_message_center::MediaNotificationItem> item,
MediaNotificationService* service);
~MediaNotificationContainerImplView() override;
// views::Button:
void AddedToWidget() override;
void RemovedFromWidget() override;
bool OnMousePressed(const ui::MouseEvent& event) override;
bool OnMouseDragged(const ui::MouseEvent& event) override;
void OnMouseReleased(const ui::MouseEvent& event) override;
void OnMouseEntered(const ui::MouseEvent& event) override;
void OnMouseExited(const ui::MouseEvent& event) override;
// views::FocusChangeListener:
void OnWillChangeFocus(views::View* focused_before,
views::View* focused_now) override {}
void OnDidChangeFocus(views::View* focused_before,
views::View* focused_now) override;
// media_message_center::MediaNotificationContainer:
void OnExpanded(bool expanded) override;
void OnMediaSessionInfoChanged(
const media_session::mojom::MediaSessionInfoPtr& session_info) override;
void OnMediaSessionMetadataChanged(
const media_session::MediaMetadata& metadata) override;
void OnVisibleActionsChanged(
const base::flat_set<media_session::mojom::MediaSessionAction>& actions)
override;
void OnMediaArtworkChanged(const gfx::ImageSkia& image) override;
void OnColorsChanged(SkColor foreground, SkColor background) override;
void OnHeaderClicked() override;
// views::SlideOutControllerDelegate:
ui::Layer* GetSlideOutLayer() override;
void OnSlideStarted() override {}
void OnSlideChanged(bool in_progress) override {}
void OnSlideOut() override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// MediaNotificationContainerImpl:
void AddObserver(MediaNotificationContainerObserver* observer) override;
void RemoveObserver(MediaNotificationContainerObserver* observer) override;
// MediaNotificationAudioDeviceSelectorViewDelegate
// Called when an audio device has been selected for output.
void OnAudioSinkChosen(const std::string& sink_id) override;
void OnAudioDeviceSelectorViewSizeChanged() override;
// Sets up the notification to be ready to display in an overlay instead of
// the dialog.
void PopOut();
// Called when overlay notification is shown and setup |overlay_|.
void OnOverlayNotificationShown(OverlayMediaNotificationView* overlay);
const base::string16& GetTitle();
views::ImageButton* GetDismissButtonForTesting();
media_message_center::MediaNotificationViewImpl* view_for_testing() {
return view_;
}
bool is_playing_for_testing() { return is_playing_; }
bool is_expanded_for_testing() { return is_expanded_; }
views::Widget* drag_image_widget_for_testing() {
return drag_image_widget_.get();
}
private:
class DismissButton;
void UpdateDismissButtonIcon();
void UpdateDismissButtonBackground();
void UpdateDismissButtonVisibility();
void DismissNotification();
void CreateDragImageWidget();
// Updates the forced expanded state of |view_|.
void ForceExpandedState();
// Notify observers that we've been clicked.
void ContainerClicked();
// True if we should handle the given mouse event for dragging purposes.
bool ShouldHandleMouseEvent(const ui::MouseEvent& event, bool is_press);
void OnSizeChanged();
const std::string id_;
views::View* swipeable_container_ = nullptr;
base::string16 title_;
// Always "visible" so that it reserves space in the header so that the
// dismiss button can appear without forcing things to shift.
views::View* dismiss_button_placeholder_ = nullptr;
// Shows the colored circle background behind the dismiss button to give it
// proper contrast against the artwork. The background can't be on the dismiss
// button itself because it messes up the ink drop.
views::View* dismiss_button_container_ = nullptr;
DismissButton* dismiss_button_ = nullptr;
media_message_center::MediaNotificationViewImpl* view_ = nullptr;
MediaNotificationAudioDeviceSelectorView* audio_device_selector_view_ =
nullptr;
SkColor foreground_color_;
SkColor background_color_;
bool has_artwork_ = false;
bool has_many_actions_ = false;
// True if we've been dragged out of the dialog and into an overlay.
bool dragged_out_ = false;
// True if we're currently tracking a mouse drag. Used for dragging
// notifications out into an overlay notification, not for swiping to dismiss
// (see |slide_out_controller_| for swiping to dismiss).
bool is_mouse_pressed_ = false;
// The start point of a mouse drag. Used for dragging notifications out into
// an overlay notification, not for swiping to dismiss (see
// |slide_out_controller_| for swiping to dismiss).
gfx::Point initial_drag_location_;
// True if the current mouse press has been dragged enough to be considered a
// drag instead of a button click.
bool is_dragging_ = false;
bool is_playing_ = false;
bool is_expanded_ = false;
std::string audio_sink_id_ = media::AudioDeviceDescription::kDefaultDeviceId;
base::ObserverList<MediaNotificationContainerObserver> observers_;
// Handles gesture events for swiping to dismiss notifications.
std::unique_ptr<views::SlideOutController> slide_out_controller_;
OverlayMediaNotificationView* overlay_ = nullptr;
views::UniqueWidgetPtr drag_image_widget_;
MediaNotificationService* const service_;
DISALLOW_COPY_AND_ASSIGN(MediaNotificationContainerImplView);
};
#endif // CHROME_BROWSER_UI_VIEWS_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_CONTAINER_IMPL_VIEW_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
274944f8eb5b40761a9532f55e8c310cd8f676af | c475cd8531a94ffae69cc92371d41531dbbddb6c | /Projects/angelscript_2_32_0_sdk/angelscript/source/as_memory.cpp | db3b06f94eda05cadfdf305cdefd0d6dbfd13191 | [
"Apache-2.0",
"LicenseRef-scancode-free-unknown"
] | permissive | WolfireGames/overgrowth | 72d3dd29cbd7254337265c29f8de3e5c32400114 | 594a2a4f9da0855304ee8cd5335d042f8e954ce1 | refs/heads/main | 2023-08-15T19:36:56.156578 | 2023-05-17T08:17:53 | 2023-05-17T08:20:36 | 467,448,492 | 2,264 | 245 | Apache-2.0 | 2023-05-09T07:29:58 | 2022-03-08T09:38:54 | C++ | UTF-8 | C++ | false | false | 8,516 | cpp | /*
AngelCode Scripting Library
Copyright (c) 2003-2016 Andreas Jonsson
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
The original version of this library can be located at:
http://www.angelcode.com/angelscript/
Andreas Jonsson
andreas@angelcode.com
*/
//
// as_memory.cpp
//
// Overload the default memory management functions so that we
// can let the application decide how to do it.
//
#include <stdlib.h>
#if !defined(__APPLE__) && !defined(__SNC__) && !defined(__ghs__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
#include <malloc.h>
#endif
#include "as_config.h"
#include "as_memory.h"
#include "as_scriptnode.h"
#include "as_bytecode.h"
BEGIN_AS_NAMESPACE
#ifdef WIP_16BYTE_ALIGN
// TODO: Add support for 16byte aligned application types (e.g. __m128). The following is a list of things that needs to be implemented:
//
// ok - The script context must make sure to always allocate the local stack memory buffer on 16byte aligned boundaries (asCContext::ReserveStackSpace)
// ok - The engine must make sure to always allocate the memory for the script objects on 16byte aligned boundaries (asCScriptEngine::CallAlloc)
// ok - The application needs to inform a new flag when registering types that require 16byte alignment, e.g. asOBJ_APP_ALIGN16 (asCScriptEngine::RegisterObjectType)
// ok - The script object type must make sure to align member properties of these types correctly (asCObjectType::AddPropertyToClass)
// ok - Script global properties must allocate memory on 16byte boundaries if holding these types (asCGlobalProperty::AllocateMemory)
// TODO - The script compiler must make sure to allocate the local variables on 16byte boundaries (asCCompiler::AllocateVariable)
// TODO - The script compiler must add pad bytes on the stack for all function calls to guarantee that the stack position is 16byte aligned on entry in the called function (asCCompiler)
// TODO - The bytecode serializer must be capable of adjusting these pad bytes to guarantee platform independent saved bytecode. Remember that the registered type may not be 16byte aligned on all platforms (asCWriter & asCReader)
// TODO - The bytecode serializer must also be prepared to adjust the position of the local variables according to the need fro 16byte alignment (asCWriter & asCReader)
// TODO - The code for the native calling conventions must be adjusted for all platforms that should support 16byte aligned types (as_callfunc...)
// ok - When the context needs to grow the local stack memory it must copy the function arguments so that the stack entry position is 16byte aligned (asCContext::CallScriptFunction)
// TODO - When the context is prepared for a new call, it must set the initial stack position so the stack entry position is 16byte aligned (asCContext::Prepare)
//
// http://www.gamedev.net/topic/650555-alignment-requirements/
// TODO: Allow user to register its own aligned memory routines
// Wrappers for aligned allocations
void *debugAlignedMalloc(size_t size, size_t align, const char *file, int line)
{
void *mem = ((asALLOCFUNCDEBUG_t)userAlloc)(size + (align-1) + sizeof(void*), file, line);
char *amem = ((char*)mem) + sizeof(void*);
if( (uintptr_t)amem & (align - 1) )
amem += align - ((uintptr_t)amem & (align - 1));
((void**)amem)[-1] = mem;
return amem;
}
void *alignedMalloc(size_t size, size_t align)
{
void *mem = userAlloc(size + (align-1) + sizeof(void*));
char *amem = ((char*)mem) + sizeof(void*);
if( (uintptr_t)amem & (align - 1) )
amem += align - ((uintptr_t)amem & (align - 1));
((void**)amem)[-1] = mem;
return amem;
}
void alignedFree(void *mem)
{
userFree( ((void**)mem)[-1] );
}
bool isAligned(const void* const pointer, asUINT alignment)
{
return (uintptr_t(pointer) % alignment) == 0;
}
#endif
// By default we'll use the standard memory management functions
// Make sure these globals are initialized first. Otherwise the
// library may crash in case the application initializes the engine
// as a global variable.
#ifdef _MSC_VER
// MSVC let's us choose between a couple of different initialization orders.
#pragma warning(disable: 4073)
#pragma init_seg(lib)
asALLOCFUNC_t userAlloc = malloc;
asFREEFUNC_t userFree = free;
#ifdef WIP_16BYTE_ALIGN
#ifdef AS_DEBUG
asALLOCALIGNEDFUNC_t userAllocAligned = (asALLOCALIGNEDFUNC_t)debugAlignedMalloc;
#else
asALLOCALIGNEDFUNC_t userAllocAligned = alignedMalloc;
#endif
asFREEALIGNEDFUNC_t userFreeAligned = alignedFree;
#endif
#else
// Other compilers will just have to rely on luck.
asALLOCFUNC_t userAlloc = malloc;
asFREEFUNC_t userFree = free;
#ifdef WIP_16BYTE_ALIGN
asALLOCALIGNEDFUNC_t userAllocAligned = alignedMalloc;
asFREEALIGNEDFUNC_t userFreeAligned = alignedFree;
#endif
#endif
extern "C"
{
// interface
int asSetGlobalMemoryFunctions(asALLOCFUNC_t allocFunc, asFREEFUNC_t freeFunc)
{
// Clean-up thread local memory before changing the allocation routines to avoid
// potential problem with trying to free memory using a different allocation
// routine than used when allocating it.
asThreadCleanup();
userAlloc = allocFunc;
userFree = freeFunc;
return 0;
}
// interface
int asResetGlobalMemoryFunctions()
{
// Clean-up thread local memory before changing the allocation routines to avoid
// potential problem with trying to free memory using a different allocation
// routine than used when allocating it.
asThreadCleanup();
userAlloc = malloc;
userFree = free;
return 0;
}
// interface
void *asAllocMem(size_t size)
{
return asNEWARRAY(asBYTE, size);
}
// interface
void asFreeMem(void *mem)
{
asDELETEARRAY(mem);
}
} // extern "C"
asCMemoryMgr::asCMemoryMgr()
{
}
asCMemoryMgr::~asCMemoryMgr()
{
FreeUnusedMemory();
}
void asCMemoryMgr::FreeUnusedMemory()
{
// It's necessary to protect the scriptNodePool from multiple
// simultaneous accesses, as the parser is used by several methods
// that can be executed simultaneously.
ENTERCRITICALSECTION(cs);
int n;
for( n = 0; n < (signed)scriptNodePool.GetLength(); n++ )
userFree(scriptNodePool[n]);
scriptNodePool.Allocate(0, false);
LEAVECRITICALSECTION(cs);
// The engine already protects against multiple threads
// compiling scripts simultaneously so this pool doesn't have
// to be protected again.
for( n = 0; n < (signed)byteInstructionPool.GetLength(); n++ )
userFree(byteInstructionPool[n]);
byteInstructionPool.Allocate(0, false);
}
void *asCMemoryMgr::AllocScriptNode()
{
ENTERCRITICALSECTION(cs);
if( scriptNodePool.GetLength() )
{
void *tRet = scriptNodePool.PopLast();
LEAVECRITICALSECTION(cs);
return tRet;
}
LEAVECRITICALSECTION(cs);
#if defined(AS_DEBUG)
return ((asALLOCFUNCDEBUG_t)(userAlloc))(sizeof(asCScriptNode), __FILE__, __LINE__);
#else
return userAlloc(sizeof(asCScriptNode));
#endif
}
void asCMemoryMgr::FreeScriptNode(void *ptr)
{
ENTERCRITICALSECTION(cs);
// Pre allocate memory for the array to avoid slow growth
if( scriptNodePool.GetLength() == 0 )
scriptNodePool.Allocate(100, 0);
scriptNodePool.PushLast(ptr);
LEAVECRITICALSECTION(cs);
}
#ifndef AS_NO_COMPILER
void *asCMemoryMgr::AllocByteInstruction()
{
if( byteInstructionPool.GetLength() )
return byteInstructionPool.PopLast();
#if defined(AS_DEBUG)
return ((asALLOCFUNCDEBUG_t)(userAlloc))(sizeof(asCByteInstruction), __FILE__, __LINE__);
#else
return userAlloc(sizeof(asCByteInstruction));
#endif
}
void asCMemoryMgr::FreeByteInstruction(void *ptr)
{
// Pre allocate memory for the array to avoid slow growth
if( byteInstructionPool.GetLength() == 0 )
byteInstructionPool.Allocate(100, 0);
byteInstructionPool.PushLast(ptr);
}
#endif // AS_NO_COMPILER
END_AS_NAMESPACE
| [
"max@autious.net"
] | max@autious.net |
79b738e31a8ca7c9c03a0f1509a76fde92d0f73e | c9b8fc0894409d76d019dfa5d3033387dd684685 | /C09/PC9_03/PC9_03.cpp | 22da57139876647786434308c6d2437d73b0a087 | [] | no_license | nyccowgirl/Starting-Out | 3775f4d61801faec6ad726242e2d8fc761b612e6 | 78c8701628496172079562d2f6ad1914c1a697ab | refs/heads/main | 2023-01-01T03:58:55.277499 | 2020-10-26T03:27:40 | 2020-10-26T03:27:40 | 303,046,963 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,665 | cpp | /*
DROP LOWEST SCORE
Program illustrates modifies Test Scores #1 and drops the lowest test score, which is not
included in the average.
PC9_03.cpp
Starting Out/C09
Created by nyccowgirl on 10/4/20.
Copyright ยฉ 2020 nyccowgirl. All rights reserved.
*/
#include <iostream>
#include <iomanip>
using namespace std;
void getData(int *scores, int size);
void sortScores(int *scores, int size);
double calcAvg(const int *scores, int size);
void displayData(int *scores, int size);
int main(int argc, const char * argv[]) {
int numScores;
int *scores;
cout << "Enter number of scores: ";
cin >> numScores;
scores = new int[numScores];
getData(scores, numScores);
displayData(scores, numScores);
delete [] scores;
scores = nullptr;
return 0;
}
// Definition of function getData.
void getData(int *scores, int size) {
for (int x = 0; x < size; x++) {
do {
cout << "Enter score #" << (x + 1) << ": ";
cin >> *(scores + x);
if (*(scores + x) < 0) {
cout << "Invalid input: score cannot be less than 0." << endl;
}
} while (*(scores + x) < 0);
}
}
// Definition of function sortScores.
void sortScores(int *scores, int size) {
int minIdx, minScore;
for (int x = 0; x < (size - 1); x++) {
minIdx = x;
minScore = *(scores + x);
for (int y = (x + 1); y < size; y++) {
if (*(scores + y) < minScore) {
minScore = *(scores + y);
minIdx = y;
}
}
*(scores + minIdx) = *(scores + x);
*(scores + x) = minScore;
}
}
// Definition of function calcAvg.
double calcAvg(const int *scores, int size) {
double sum = 0;
for (int x = 1; x < size; x++) {
sum += *(scores + x);
}
return sum / ((size - 1) * 1.0);
}
void displayData(int *scores, int size) {
cout << "\nTEST SCORES" << endl;
cout << "------------------------------------------------------" << endl;
cout << "Scores in ascending order: ";
sortScores(scores, size);
for (int x = 1; x < size; x++) {
cout << *(scores + x) << " ";
}
cout << fixed << showpoint << setprecision(2);
cout << "\nAverage score: " << calcAvg(scores, size) << endl;
}
/*
Enter number of scores: 5
Enter score #1: 88
Enter score #2: 77
Enter score #3: 63
Enter score #4: 99
Enter score #5: 95
TEST SCORES
------------------------------------------------------
Scores in ascending order: 77 88 95 99
Average score: 89.75
*/
| [
"nyc_cowgirl@hotmail.com"
] | nyc_cowgirl@hotmail.com |
95a1dbd82192aa653f0de8c8089e75693606491b | ee50a370cde41389871e56f3f382ffda63bb037d | /macros/2HDM/thdm_BRs_f_sinB_A_tanB.cpp | 551279027fd480ddf7faf0a46b9a94a4565d4ccc | [] | no_license | pasmuss/SusHi-macros | f8b7f3b98311a45667209a84f0269ee17a3c1fdd | 36b9653ab7451cb7ed621bf732bc1af7309cf295 | refs/heads/master | 2020-06-14T00:13:00.126154 | 2019-07-02T09:33:37 | 2019-07-02T09:33:37 | 194,832,373 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,164 | cpp | #include <TH3F.h>
#include <TH3.h>
#include <TGraph.h>
#include <TFile.h>
#include "TSystem.h"
#include <TCanvas.h>
#include <TLegend.h>
#include <string>
#include <vector>
// xsection estimation for MSSM
#include "Analysis/MssmHbb/macros/signal/mssm_xs_tools.h"
#include "Analysis/MssmHbb/macros/signal/mssm_xs_tools.C"
#include "Analysis/MssmHbb/macros/Drawer/HbbStyle.cc"
// Tools
#include "Analysis/MssmHbb/interface/utilLib.h"
using namespace std;
const auto cmsswBase = static_cast<std::string>(gSystem->Getenv("CMSSW_BASE"));
void CompareBrs(const vector<double>&, const vector<double>&, const double& , const vector<string>&, const string&, const string&);
double MssmBr(mssm_xs_tools& my,
const double& mA,
const double& tanBeta);
double THDMBr(map<string,TH3F*>& f,
const double& mA,
const double& tanBeta,
const double& sinB_A,
const string& name);
void DrawGraphs(vector<TGraph>& graphs2HDM, const vector<string> &BRs, const double& sinB_A);
void GetTHDMHistos(TFile& name,map<string,TH3F*>&,const vector<string>&);
string boson = "A";
string mA = "900";
int main(){
HbbStyle style;
style.set(PRIVATE);
// Comparison should be done
// Histo with 2HDM results:
string thdm_production = "production_cosB_A_-1_1_tanB_0p5-100_COMBINATION"; //production_corseBins_cosB_A_-1_1_tanB_1-100 //
string thdm_type = "type2";
string thdm_fname = "/nfs/dust/cms/user/pasmuss/SusHiScaner/output/" + thdm_production + "/rootFiles/Histograms3D_" + thdm_type + "_mA_mH.root";
TFile f(thdm_fname.c_str(),"read");
// Define mass points:
vector<double> mAs{300,400,500,600,700,900,1100};
// Define tnaBeta points:
vector<double> tanBetas{10,20,30,40,50,60};
// Define sin(beta-alpha) points:
vector<double> sinB_As;
for(double i = -0.99; i <= 0.99; i+=0.1) sinB_As.push_back(i);
// Define types of BRs:
vector<string> BRs = {"br_" + boson + "ss","br_" + boson + "cc","br_" + boson + "bb","br_" + boson + "tt","br_" + boson + "tautau","br_" + boson + "Zh"};
// MSSM benchm,ark file
string mssm_bench = cmsswBase + "/src/Analysis/MssmHbb/macros/signal/mhmodp_mu200_13TeV.root";
CompareBrs(sinB_As,tanBetas,stoi(mA),BRs,thdm_fname,mssm_bench);
return 0;
}
void CompareBrs(const vector<double> &sinB_As, const vector<double> &tanBetas, const double&mA, const vector<string>& BRs, const string &thdm_fname,const string &mssm_benchmark){
// File for 2HDM scans:
map<string,TH3F*> thdm_map;
TFile f(thdm_fname.c_str(),"read");
GetTHDMHistos(f,thdm_map,BRs);
// Setup mssm_xs_tools:
mssm_xs_tools my(mssm_benchmark.c_str(),true,0);
// Setup mssm_xs_tools:
// Start mA, tan(beta) and sin(beta-alpha) loops:
for(const auto& tanBeta : tanBetas){
// Prepare output TGraphs
vector<TGraph> graphs2HDM(BRs.size());
vector<TGraph> graphsMSSM(BRs.size());
int i = 0;
for(const auto& BR : BRs){
TGraph& gr_2hdm = graphs2HDM.at(i);
TGraph& gr_mssm = graphsMSSM.at(i);
// Set number of points for TGraph
gr_2hdm.Set((int)sinB_As.size());
gr_mssm.Set((int)sinB_As.size());
++i;
int j =0;
for(const auto& sinB_A : sinB_As){
//Calcualte SigmaBr and fill TGraphs:
// gr_mssm.SetPoint(j,tanBeta,MssmBr(my,mA,tanBeta));
gr_2hdm.SetPoint(j,sinB_A,THDMBr(thdm_map,mA,tanBeta,sinB_A,BR));
++j;
}
}
DrawGraphs(graphs2HDM,BRs,tanBeta);
}
}
void DrawGraphs(vector<TGraph>& graphs2HDM, const vector<string> &BRs, const double& tanBeta){
// setup canvas
TCanvas can("can","can",800,600);
can.SetGrid();
double xmin, xmax,ymin,ymax;
xmin = 0.7;xmax = 0.93;
ymin = 0.3; ymax = 0.55;
if(tanBeta <= 20){
ymin = 0.6; ymax = 0.8;
}
if(boson == "H"){
xmin = 0.74; xmax = 0.94;
ymin = 0.75; ymax = 0.915;
if(tanBeta <= 30 ){
xmin = 0.21; xmax = 0.38;
ymin = 0.72; ymax = 0.915 ;
}
}
TLegend leg(xmin,ymin,xmax,ymax);
vector<int> colours = {1,3,2,4,6,9,12,28,46};
// Loop over the tanBetas
for (unsigned int i = 0; i != BRs.size(); ++i){
TGraph& thdm = graphs2HDM.at(i);
auto br = BRs.at(i);
//Cosmetics:
thdm.SetMarkerStyle(20 + i);
thdm.SetMarkerSize(1.04);
thdm.SetMarkerColor(colours.at(i));
thdm.SetLineColor(colours.at(i));
thdm.SetTitle( ("2HDM(tan#beta = " + to_string_with_precision(tanBeta,2) + ")" + ";cos(#beta-#alpha); BR").c_str());
leg.AddEntry(&thdm,("2HDM , " + br).c_str(),"pl");
if(i==0){
thdm.Draw("APL");
}
else thdm.Draw("PLsame");
if(i==0) thdm.GetYaxis()->SetRangeUser(0.00000001,1);
if(i==0) thdm.GetXaxis()->SetRangeUser(-1,1.);
can.SetLogy();
can.Update();
}
leg.Draw();
can.Print( (cmsswBase + "/src/Analysis/MssmHbb/macros/pictures/2HDM/" + boson + "_thdm_BRs_sinB_A_mA-" + mA + "_tanB-" + to_string_with_precision(tanBeta,2) + ".pdf").c_str() );
}
double THDMBr(map<string,TH3F*>& f,
const double& mA,
const double& tanBeta,
const double& sinB_A,
const string& name){
double BrAbb = f[name]->Interpolate(mA,tanBeta,sinB_A);
return BrAbb;
}
void GetTHDMHistos(TFile& f, map<string,TH3F*>& histos, const vector<string>& BRs){
CheckZombie(f);
for(const auto& br: BRs){
CheckZombieObjectInTFile(f,br);
histos[br] = (TH3F*) f.Get(br.c_str());
}
}
| [
"paul.asmuss@cern.ch"
] | paul.asmuss@cern.ch |
cfbfab911e201b585fccf4d7fddfb2a7af27206c | d92fc55174ac8424bfae07d00fa27224c7862aa6 | /interface/FJWrapper.h | a8d4bb427987edd7de5bd71dac730e5271ab94c4 | [
"CC0-1.0"
] | permissive | mverwe/diall | cfc5bf83adce405e84a20afc55641ea31c33e9cc | 22c110acc2dd71684dd1db3e6c384559f81cf513 | refs/heads/master | 2020-05-21T13:36:21.742391 | 2017-04-27T12:03:50 | 2017-04-27T12:03:50 | 47,253,784 | 0 | 2 | null | 2016-01-29T14:21:32 | 2015-12-02T10:24:18 | C++ | UTF-8 | C++ | false | false | 41,163 | h | #ifndef FJWrapper_H
#define FJWrapper_H
#include <vector>
#include <TString.h>
#include "FJ_includes.h"
#include "FJJetShape.h"
class FJWrapper
{
public:
FJWrapper(const char *name, const char *title);
virtual ~FJWrapper();
virtual void AddInputVector (Double_t px, Double_t py, Double_t pz, Double_t E, Int_t index = -99999);
virtual void AddInputVector (const fastjet::PseudoJet& vec, Int_t index = -99999);
virtual void AddInputVectors(const std::vector<fastjet::PseudoJet>& vecs, Int_t offsetIndex = -99999);
virtual void AddInputGhost (Double_t px, Double_t py, Double_t pz, Double_t E, Int_t index = -99999);
virtual const char *ClassName() const { return "FJWrapper"; }
virtual void Clear(const Option_t* /*opt*/ = "");
virtual void CopySettingsFrom (const FJWrapper& wrapper);
virtual void GetMedianAndSigma(Double_t& median, Double_t& sigma, Int_t remove = 0) const;
fastjet::ClusterSequenceArea* GetClusterSequence() const { return fClustSeq; }
fastjet::ClusterSequence* GetClusterSequenceSA() const { return fClustSeqSA; }
fastjet::ClusterSequenceActiveAreaExplicitGhosts* GetClusterSequenceGhosts() const { return fClustSeqActGhosts; }
const std::vector<fastjet::PseudoJet>& GetInputVectors() const { return fInputVectors; }
const std::vector<fastjet::PseudoJet>& GetInputGhosts() const { return fInputGhosts; }
const std::vector<fastjet::PseudoJet>& GetInclusiveJets() const { return fInclusiveJets; }
const std::vector<fastjet::PseudoJet>& GetFilteredJets() const { return fFilteredJets; }
std::vector<fastjet::PseudoJet> GetJetConstituents(UInt_t idx) const;
std::vector<fastjet::PseudoJet> GetFilteredJetConstituents(UInt_t idx) const;
Double_t GetMedianUsedForBgSubtraction() const { return fMedUsedForBgSub; }
const char* GetName() const { return fName; }
const char* GetTitle() const { return fTitle; }
Double_t GetJetArea (UInt_t idx) const;
fastjet::PseudoJet GetJetAreaVector (UInt_t idx) const;
Double_t GetFilteredJetArea (UInt_t idx) const;
fastjet::PseudoJet GetFilteredJetAreaVector(UInt_t idx) const;
Double_t GetJetSubtractedPt (UInt_t idx) const;
virtual std::vector<double> GetSubtractedJetsPts(Double_t median_pt = -1, Bool_t sorted = kFALSE);
Bool_t GetLegacyMode() { return fLegacyMode; }
Bool_t GetDoFilterArea() { return fDoFilterArea; }
const std::vector<fastjet::contrib::GenericSubtractorInfo> GetGenSubtractorInfoJetMass() const {return fGenSubtractorInfoJetMass ; }
const std::vector<fastjet::contrib::GenericSubtractorInfo> GetGenSubtractorInfoJetAngularity() const {return fGenSubtractorInfoJetAngularity ; }
const std::vector<fastjet::contrib::GenericSubtractorInfo> GetGenSubtractorInfoJetpTD() const {return fGenSubtractorInfoJetpTD ; }
const std::vector<fastjet::contrib::GenericSubtractorInfo> GetGenSubtractorInfoJetCircularity() const {return fGenSubtractorInfoJetCircularity ; }
const std::vector<fastjet::contrib::GenericSubtractorInfo> GetGenSubtractorInfoJetSigma2() const {return fGenSubtractorInfoJetSigma2 ; }
const std::vector<fastjet::contrib::GenericSubtractorInfo> GetGenSubtractorInfoJetConstituent() const {return fGenSubtractorInfoJetConstituent ; }
const std::vector<fastjet::contrib::GenericSubtractorInfo> GetGenSubtractorInfoJetLeSub() const {return fGenSubtractorInfoJetLeSub ; }
const std::vector<fastjet::PseudoJet> GetConstituentSubtrJets() const {return fConstituentSubtrJets ; }
virtual std::vector<double> GetGRNumerator() const { return fGRNumerator ; }
virtual std::vector<double> GetGRDenominator() const { return fGRDenominator ; }
virtual std::vector<double> GetGRNumeratorSub() const { return fGRNumeratorSub ; }
virtual std::vector<double> GetGRDenominatorSub() const { return fGRDenominatorSub ; }
virtual Int_t Run();
virtual Int_t Filter();
virtual Int_t DoGenericSubtractionJetMass();
virtual Int_t DoGenericSubtractionGR(Int_t ijet);
virtual Int_t DoGenericSubtractionJetAngularity();
virtual Int_t DoGenericSubtractionJetpTD();
virtual Int_t DoGenericSubtractionJetCircularity();
virtual Int_t DoGenericSubtractionJetSigma2();
virtual Int_t DoGenericSubtractionJetConstituent();
virtual Int_t DoGenericSubtractionJetLeSub();
virtual Int_t DoConstituentSubtraction();
void SetName(const char* name) { fName = name; }
void SetTitle(const char* title) { fTitle = title; }
void SetStrategy(const fastjet::Strategy &strat) { fStrategy = strat; }
void SetAlgorithm(const fastjet::JetAlgorithm &algor) { fAlgor = algor; }
void SetRecombScheme(const fastjet::RecombinationScheme &scheme) { fScheme = scheme; }
void SetAreaType(const fastjet::AreaType &atype) { fAreaType = atype; }
void SetNRepeats(Int_t nrepeat) { fNGhostRepeats = nrepeat; }
void SetGhostArea(Double_t gharea) { fGhostArea = gharea; }
void SetMaxRap(Double_t maxrap) { fMaxRap = maxrap; }
void SetR(Double_t r) { fR = r; }
void SetGridScatter(Double_t gridSc) { fGridScatter = gridSc; }
void SetKtScatter(Double_t ktSc) { fKtScatter = ktSc; }
void SetMeanGhostKt(Double_t meankt) { fMeanGhostKt = meankt; }
void SetPluginAlgor(Int_t plugin) { fPluginAlgor = plugin; }
void SetUseArea4Vector(Bool_t useA4v) { fUseArea4Vector = useA4v; }
void SetupAlgorithmfromOpt(const char *option);
void SetupAreaTypefromOpt(const char *option);
void SetupSchemefromOpt(const char *option);
void SetupStrategyfromOpt(const char *option);
void SetLegacyMode (Bool_t mode) { fLegacyMode ^= mode; }
void SetLegacyFJ();
void SetUseExternalBkg(Bool_t b, Double_t rho, Double_t rhom) { fUseExternalBkg = b; fRho = rho; fRhom = rhom;}
void SetRMaxAndStep(Double_t rmax, Double_t dr) {fRMax = rmax; fDRStep = dr; }
protected:
TString fName; //!
TString fTitle; //!
std::vector<fastjet::PseudoJet> fInputVectors; //!
std::vector<fastjet::PseudoJet> fInputGhosts; //!
std::vector<fastjet::PseudoJet> fInclusiveJets; //!
std::vector<fastjet::PseudoJet> fFilteredJets; //!
std::vector<double> fSubtractedJetsPt; //!
std::vector<fastjet::PseudoJet> fConstituentSubtrJets; //!
fastjet::AreaDefinition *fAreaDef; //!
fastjet::VoronoiAreaSpec *fVorAreaSpec; //!
fastjet::GhostedAreaSpec *fGhostedAreaSpec; //!
fastjet::JetDefinition *fJetDef; //!
fastjet::JetDefinition::Plugin *fPlugin; //!
fastjet::Selector *fRange; //!
fastjet::ClusterSequenceArea *fClustSeq; //!
fastjet::ClusterSequence *fClustSeqSA; //!
fastjet::ClusterSequenceActiveAreaExplicitGhosts *fClustSeqActGhosts; //!
fastjet::Strategy fStrategy; //!
fastjet::JetAlgorithm fAlgor; //!
fastjet::RecombinationScheme fScheme; //!
fastjet::AreaType fAreaType; //!
Int_t fNGhostRepeats; //!
Double_t fGhostArea; //!
Double_t fMaxRap; //!
Double_t fR; //!
// no setters for the moment - used default values in the constructor
Double_t fGridScatter; //!
Double_t fKtScatter; //!
Double_t fMeanGhostKt; //!
Int_t fPluginAlgor; //!
// extra parameters
Double_t fMedUsedForBgSub; //!
Bool_t fUseArea4Vector; //!
fastjet::JetMedianBackgroundEstimator *fBkrdEstimator; //!
//from contrib package
fastjet::contrib::GenericSubtractor *fGenSubtractor; //!
std::vector<fastjet::contrib::GenericSubtractorInfo> fGenSubtractorInfoJetMass; //!
std::vector<fastjet::contrib::GenericSubtractorInfo> fGenSubtractorInfoGRNum; //!
std::vector<fastjet::contrib::GenericSubtractorInfo> fGenSubtractorInfoGRDen; //!
std::vector<fastjet::contrib::GenericSubtractorInfo> fGenSubtractorInfoJetAngularity; //!
std::vector<fastjet::contrib::GenericSubtractorInfo> fGenSubtractorInfoJetpTD; //!
std::vector<fastjet::contrib::GenericSubtractorInfo> fGenSubtractorInfoJetCircularity; //!
std::vector<fastjet::contrib::GenericSubtractorInfo> fGenSubtractorInfoJetSigma2; //!
std::vector<fastjet::contrib::GenericSubtractorInfo> fGenSubtractorInfoJetConstituent; //!
std::vector<fastjet::contrib::GenericSubtractorInfo> fGenSubtractorInfoJetLeSub; //!
Bool_t fDoFilterArea; //!
Bool_t fLegacyMode; //!
Bool_t fUseExternalBkg; //!
Double_t fRho; // pT background density
Double_t fRhom; // mT background density
Double_t fRMax; //!
Double_t fDRStep; //!
std::vector<double> fGRNumerator; //!
std::vector<double> fGRDenominator; //!
std::vector<double> fGRNumeratorSub; //!
std::vector<double> fGRDenominatorSub; //!
virtual void SubtractBackground(const Double_t median_pt = -1);
private:
FJWrapper();
FJWrapper(const FJWrapper& wrapper);
FJWrapper& operator = (const FJWrapper& wrapper);
};
#endif
#ifdef FJWrapper_cc
#undef FJWrapper_cc
#if defined __GNUC__
#pragma GCC system_header
#endif
namespace fj = fastjet;
//_________________________________________________________________________________________________
FJWrapper::FJWrapper(const char *name, const char *title)
:
fName (name)
, fTitle (title)
, fInputVectors ( )
, fInputGhosts ( )
, fInclusiveJets ( )
, fFilteredJets ( )
, fSubtractedJetsPt ( )
, fConstituentSubtrJets ( )
, fAreaDef (0)
, fVorAreaSpec (0)
, fGhostedAreaSpec (0)
, fJetDef (0)
, fPlugin (0)
, fRange (0)
, fClustSeq (0)
, fClustSeqSA (0)
, fClustSeqActGhosts (0)
, fStrategy (fj::Best)
, fAlgor (fj::kt_algorithm)
, fScheme (fj::BIpt_scheme)
, fAreaType (fj::active_area)
, fNGhostRepeats (1)
, fGhostArea (0.005)
, fMaxRap (5.)
, fR (0.4)
, fGridScatter (1.0)
, fKtScatter (0.1)
, fMeanGhostKt (1e-100)
, fPluginAlgor (0)
, fMedUsedForBgSub (0)
, fUseArea4Vector (kFALSE)
, fBkrdEstimator (0)
, fGenSubtractor (0)
, fGenSubtractorInfoJetMass ( )
, fGenSubtractorInfoGRNum ( )
, fGenSubtractorInfoGRDen ( )
, fGenSubtractorInfoJetAngularity ( )
, fGenSubtractorInfoJetpTD ( )
, fGenSubtractorInfoJetCircularity( )
, fGenSubtractorInfoJetSigma2()
, fGenSubtractorInfoJetConstituent ( )
, fGenSubtractorInfoJetLeSub ( )
, fDoFilterArea (false)
, fLegacyMode (false)
, fUseExternalBkg (false)
, fRho (0)
, fRhom (0)
, fRMax(2.)
, fDRStep(0.04)
, fGRNumerator()
, fGRDenominator()
, fGRNumeratorSub()
, fGRDenominatorSub()
{
// Constructor.
}
//_________________________________________________________________________________________________
FJWrapper::~FJWrapper()
{
// Destructor.
if (fAreaDef) { delete fAreaDef; fAreaDef = NULL; }
if (fVorAreaSpec) { delete fVorAreaSpec; fVorAreaSpec = NULL; }
if (fGhostedAreaSpec) { delete fGhostedAreaSpec; fGhostedAreaSpec = NULL; }
if (fJetDef) { delete fJetDef; fJetDef = NULL; }
if (fPlugin) { delete fPlugin; fPlugin = NULL; }
if (fRange) { delete fRange; fRange = NULL; }
if (fClustSeq) { delete fClustSeq; fClustSeq = NULL; }
if (fClustSeqSA) { delete fClustSeqSA; fClustSeqSA = NULL; }
if (fClustSeqActGhosts) { delete fClustSeqActGhosts; fClustSeqActGhosts = NULL; }
if (fBkrdEstimator) { delete fBkrdEstimator; fBkrdEstimator = NULL; }
if (fGenSubtractor) { delete fGenSubtractor; fGenSubtractor = NULL; }
// if (fConstituentSubtractor) { delete fConstituentSubtractor; fConstituentSubtractor = NULL; }
}
//_________________________________________________________________________________________________
void FJWrapper::CopySettingsFrom(const FJWrapper& wrapper)
{
// Copy some settings.
// You very often want to keep most of the settings
// but change only the algorithm or R - do it after call to this function
fStrategy = wrapper.fStrategy;
fAlgor = wrapper.fAlgor;
fScheme = wrapper.fScheme;
fAreaType = wrapper.fAreaType;
fNGhostRepeats = wrapper.fNGhostRepeats;
fGhostArea = wrapper.fGhostArea;
fMaxRap = wrapper.fMaxRap;
fR = wrapper.fR;
fGridScatter = wrapper.fGridScatter;
fKtScatter = wrapper.fKtScatter;
fMeanGhostKt = wrapper.fMeanGhostKt;
fPluginAlgor = wrapper.fPluginAlgor;
fUseArea4Vector = wrapper.fUseArea4Vector;
fLegacyMode = wrapper.fLegacyMode;
fUseExternalBkg = wrapper.fUseExternalBkg;
fRho = wrapper.fRho;
fRhom = wrapper.fRhom;
}
//_________________________________________________________________________________________________
void FJWrapper::Clear(const Option_t */*opt*/)
{
// Simply clear the input vectors.
// Make sure done on every event if the instance is reused
// Reset the median to zero.
fInputVectors.clear();
fInputGhosts.clear();
fMedUsedForBgSub = 0;
// for the moment brute force delete everything
if (fAreaDef) { delete fAreaDef; fAreaDef = NULL; }
if (fVorAreaSpec) { delete fVorAreaSpec; fVorAreaSpec = NULL; }
if (fGhostedAreaSpec) { delete fGhostedAreaSpec; fGhostedAreaSpec = NULL; }
if (fJetDef) { delete fJetDef; fJetDef = NULL; }
if (fPlugin) { delete fPlugin; fPlugin = NULL; }
if (fRange) { delete fRange; fRange = NULL; }
if (fClustSeq) { delete fClustSeq; fClustSeq = NULL; }
if (fClustSeqSA) { delete fClustSeqSA; fClustSeqSA = NULL; }
if (fClustSeqActGhosts) { delete fClustSeqActGhosts; fClustSeqActGhosts = NULL; }
if (fBkrdEstimator) { delete fBkrdEstimator; fBkrdEstimator = NULL; }
if (fGenSubtractor) { delete fGenSubtractor; fGenSubtractor = NULL; }
// if (fConstituentSubtractor) { delete fConstituentSubtractor; fConstituentSubtractor = NULL; }
}
//_________________________________________________________________________________________________
void FJWrapper::AddInputVector(Double_t px, Double_t py, Double_t pz, Double_t E, Int_t index)
{
// Make the input pseudojet.
fastjet::PseudoJet inVec(px, py, pz, E);
if (index > -99999) {
inVec.set_user_index(index);
} else {
inVec.set_user_index(fInputVectors.size());
}
// add to the fj container of input vectors
fInputVectors.push_back(inVec);
}
//_________________________________________________________________________________________________
void FJWrapper::AddInputVector(const fj::PseudoJet& vec, Int_t index)
{
// Add an input pseudojet.
fj::PseudoJet inVec = vec;
if (index > -99999) {
inVec.set_user_index(index);
} else {
inVec.set_user_index(fInputVectors.size());
}
// add to the fj container of input vectors
fInputVectors.push_back(inVec);
}
//_________________________________________________________________________________________________
void FJWrapper::AddInputVectors(const std::vector<fj::PseudoJet>& vecs, Int_t offsetIndex)
{
// Add the input from vector of pseudojets.
for (UInt_t i = 0; i < vecs.size(); ++i) {
fj::PseudoJet inVec = vecs[i];
if (offsetIndex > -99999)
inVec.set_user_index(fInputVectors.size() + offsetIndex);
// add to the fj container of input vectors
fInputVectors.push_back(inVec);
}
}
//_________________________________________________________________________________________________
void FJWrapper::AddInputGhost(Double_t px, Double_t py, Double_t pz, Double_t E, Int_t index)
{
// Make the input pseudojet.
fastjet::PseudoJet inVec(px, py, pz, E);
if (index > -99999) {
inVec.set_user_index(index);
} else {
inVec.set_user_index(fInputGhosts.size());
}
// add to the fj container of input vectors
fInputGhosts.push_back(inVec);
if (!fDoFilterArea) fDoFilterArea = kTRUE;
}
//_________________________________________________________________________________________________
Double_t FJWrapper::GetJetArea(UInt_t idx) const
{
// Get the jet area.
Double_t retval = -1; // really wrong area..
if ( idx < fInclusiveJets.size() ) {
retval = fClustSeq->area(fInclusiveJets[idx]);
} else {
Printf("[e] ::GetJetArea wrong index: %d",idx);
}
return retval;
}
//_________________________________________________________________________________________________
Double_t FJWrapper::GetFilteredJetArea(UInt_t idx) const
{
// Get the filtered jet area.
Double_t retval = -1; // really wrong area..
if (fDoFilterArea && fClustSeqActGhosts && (idx<fFilteredJets.size())) {
retval = fClustSeqActGhosts->area(fFilteredJets[idx]);
} else {
Printf("[e] ::GetFilteredJetArea wrong index: %d",idx);
}
return retval;
}
//_________________________________________________________________________________________________
fastjet::PseudoJet FJWrapper::GetJetAreaVector(UInt_t idx) const
{
// Get the jet area as vector.
fastjet::PseudoJet retval;
if ( idx < fInclusiveJets.size() ) {
retval = fClustSeq->area_4vector(fInclusiveJets[idx]);
} else {
Printf("[e] ::GetJetArea wrong index: %d",idx);
}
return retval;
}
//_________________________________________________________________________________________________
fastjet::PseudoJet FJWrapper::GetFilteredJetAreaVector(UInt_t idx) const
{
// Get the jet area as vector.
fastjet::PseudoJet retval;
if (fDoFilterArea && fClustSeqActGhosts && (idx<fFilteredJets.size())) {
retval = fClustSeqActGhosts->area_4vector(fFilteredJets[idx]);
} else {
Printf("[e] ::GetFilteredJetArea wrong index: %d",idx);
}
return retval;
}
//_________________________________________________________________________________________________
std::vector<double> FJWrapper::GetSubtractedJetsPts(Double_t median_pt, Bool_t sorted)
{
// Get subtracted jets pTs, returns vector.
SubtractBackground(median_pt);
if (kTRUE == sorted) {
std::sort(fSubtractedJetsPt.begin(), fSubtractedJetsPt.begin());
}
return fSubtractedJetsPt;
}
//_________________________________________________________________________________________________
Double_t FJWrapper::GetJetSubtractedPt(UInt_t idx) const
{
// Get subtracted jets pTs, returns Double_t.
Double_t retval = -99999.; // really wrong pt..
if ( idx < fSubtractedJetsPt.size() ) {
retval = fSubtractedJetsPt[idx];
}
return retval;
}
//_________________________________________________________________________________________________
std::vector<fastjet::PseudoJet>
FJWrapper::GetJetConstituents(UInt_t idx) const
{
// Get jets constituents.
std::vector<fastjet::PseudoJet> retval;
if ( idx < fInclusiveJets.size() ) {
retval = fClustSeq->constituents(fInclusiveJets[idx]);
} else {
Printf("[e] ::GetJetConstituents wrong index: %d",idx);
}
return retval;
}
//_________________________________________________________________________________________________
std::vector<fastjet::PseudoJet>
FJWrapper::GetFilteredJetConstituents(UInt_t idx) const
{
// Get jets constituents.
std::vector<fastjet::PseudoJet> retval;
if ( idx < fFilteredJets.size() ) {
if (fClustSeqSA) retval = fClustSeqSA->constituents(fFilteredJets[idx]);
if (fClustSeqActGhosts) retval = fClustSeqActGhosts->constituents(fFilteredJets[idx]);
} else {
Printf("[e] ::GetFilteredJetConstituents wrong index: %d",idx);
}
return retval;
}
//_________________________________________________________________________________________________
void FJWrapper::GetMedianAndSigma(Double_t &median, Double_t &sigma, Int_t remove) const
{
// Get the median and sigma from fastjet.
// User can also do it on his own because the cluster sequence is exposed (via a getter)
if (!fClustSeq) {
Printf("[e] Run the jfinder first.");
return;
}
Double_t mean_area = 0;
try {
if(0 == remove) {
fClustSeq->get_median_rho_and_sigma(*fRange, fUseArea4Vector, median, sigma, mean_area);
} else {
std::vector<fastjet::PseudoJet> input_jets = sorted_by_pt(fClustSeq->inclusive_jets());
input_jets.erase(input_jets.begin(), input_jets.begin() + remove);
fClustSeq->get_median_rho_and_sigma(input_jets, *fRange, fUseArea4Vector, median, sigma, mean_area);
input_jets.clear();
}
} catch (fj::Error) {
Printf(" [w] FJ Exception caught.");
median = -1.;
sigma = -1;
}
}
//_________________________________________________________________________________________________
Int_t FJWrapper::Run()
{
// Run the actual jet finder.
if (fAreaType == fj::voronoi_area) {
// Rfact - check dependence - default is 1.
// NOTE: hardcoded variable!
fVorAreaSpec = new fj::VoronoiAreaSpec(1.);
fAreaDef = new fj::AreaDefinition(*fVorAreaSpec);
} else {
fGhostedAreaSpec = new fj::GhostedAreaSpec(fMaxRap,
fNGhostRepeats,
fGhostArea,
fGridScatter,
fKtScatter,
fMeanGhostKt);
fAreaDef = new fj::AreaDefinition(*fGhostedAreaSpec, fAreaType);
}
// this is acceptable by fastjet:
fRange = new fj::Selector(fj::SelectorAbsRapMax(fMaxRap - 0.95 * fR));
if (fAlgor == fj::plugin_algorithm) {
if (fPluginAlgor == 0) {
// SIS CONE ALGOR
// NOTE: hardcoded split parameter
Double_t overlap_threshold = 0.75; // NOTE: this actually splits a lot: thr/min(pt1,pt2)
fPlugin = new fj::SISConePlugin(fR,
overlap_threshold,
0, //search of stable cones - zero = until no more
1.0); // this should be seed effectively for proto jets
fJetDef = new fastjet::JetDefinition(fPlugin);
} else if (fPluginAlgor == 1) {
// CDF cone
// NOTE: hardcoded split parameter
Double_t overlap_threshold = 0.75; // NOTE: this actually splits a lot: thr/min(pt1,pt2)
fPlugin = new fj::CDFMidPointPlugin(fR,
overlap_threshold,
1.0, //search of stable cones - zero = until no more
1.0); // this should be seed effectively for proto jets
fJetDef = new fastjet::JetDefinition(fPlugin);
} else {
Printf("[e] Unrecognized plugin number!");
}
} else {
fJetDef = new fj::JetDefinition(fAlgor, fR, fScheme, fStrategy);
}
try {
fClustSeq = new fj::ClusterSequenceArea(fInputVectors, *fJetDef, *fAreaDef);
} catch (fj::Error) {
Printf(" [w] FJ Exception caught.");
return -1;
}
// FJ3 :: Define an JetMedianBackgroundEstimator just in case it will be used
fBkrdEstimator = new fj::JetMedianBackgroundEstimator(fj::SelectorAbsRapMax(fMaxRap));
if (fLegacyMode) { SetLegacyFJ(); } // for FJ 2.x even if fLegacyMode is set, SetLegacyFJ is dummy
// inclusive jets:
fInclusiveJets.clear();
fInclusiveJets = fClustSeq->inclusive_jets(0.0);
return 0;
}
//_________________________________________________________________________________________________
Int_t FJWrapper::Filter()
{
//
// FJWrapper::Filter
//
fJetDef = new fj::JetDefinition(fAlgor, fR, fScheme, fStrategy);
if (fDoFilterArea) {
if (fInputGhosts.size()>0) {
try {
fClustSeqActGhosts = new fj::ClusterSequenceActiveAreaExplicitGhosts(fInputVectors,
*fJetDef,
fInputGhosts,
fGhostArea);
} catch (fj::Error) {
Printf(" [w] FJ Exception caught.");
return -1;
}
fFilteredJets.clear();
fFilteredJets = fClustSeqActGhosts->inclusive_jets(0.0);
} else {
return -1;
}
} else {
try {
fClustSeqSA = new fastjet::ClusterSequence(fInputVectors, *fJetDef);
} catch (fj::Error) {
Printf(" [w] FJ Exception caught.");
return -1;
}
fFilteredJets.clear();
fFilteredJets = fClustSeqSA->inclusive_jets(0.0);
}
return 0;
}
//_________________________________________________________________________________________________
void FJWrapper::SetLegacyFJ()
{
// This methods enable legacy behaviour (FastJet 2.x) when AliROOT is compiled with FastJet 3.x
std::cout << "WARNING! Setting FastJet in legacy mode" << std::endl;
if (fGhostedAreaSpec) { fGhostedAreaSpec->set_fj2_placement(kTRUE); }
if (fBkrdEstimator) {
fBkrdEstimator->set_provide_fj2_sigma(kTRUE);
fBkrdEstimator->set_use_area_4vector(kFALSE);
}
}
//_________________________________________________________________________________________________
void FJWrapper::SubtractBackground(Double_t median_pt)
{
// Subtract the background (specify the value - see below the meaning).
// Negative argument means the bg will be determined with the current algorithm
// this is the default behavior. Zero is allowed
// Note: user may set the switch for area4vector based subtraction.
Double_t median = 0;
Double_t sigma = 0;
Double_t mean_area = 0;
// clear the subtracted jet pt's vector<double>
fSubtractedJetsPt.clear();
// check what was specified (default is -1)
if (median_pt < 0) {
try {
fClustSeq->get_median_rho_and_sigma(*fRange, fUseArea4Vector, median, sigma, mean_area);
}
catch (fj::Error) {
Printf(" [w] FJ Exception caught.");
median = -9999.;
sigma = -1;
fMedUsedForBgSub = median;
return;
}
fMedUsedForBgSub = median;
} else {
// we do not know the sigma in this case
sigma = -1;
if (0.0 == median_pt) {
fMedUsedForBgSub = 0.;
} else {
fMedUsedForBgSub = median_pt;
}
}
// subtract:
for (unsigned i = 0; i < fInclusiveJets.size(); i++) {
if ( fUseArea4Vector ) {
// subtract the background using the area4vector
fj::PseudoJet area4v = fClustSeq->area_4vector(fInclusiveJets[i]);
fj::PseudoJet jet_sub = fInclusiveJets[i] - area4v * fMedUsedForBgSub;
fSubtractedJetsPt.push_back(jet_sub.perp()); // here we put only the pt of the jet - note: this can be negative
} else {
// subtract the background using scalars
// fj::PseudoJet jet_sub = fInclusiveJets[i] - area * fMedUsedForBgSub_;
Double_t area = fClustSeq->area(fInclusiveJets[i]);
// standard subtraction
Double_t pt_sub = fInclusiveJets[i].perp() - fMedUsedForBgSub * area;
fSubtractedJetsPt.push_back(pt_sub); // here we put only the pt of the jet - note: this can be negative
}
}
}
//_________________________________________________________________________________________________
Int_t FJWrapper::DoGenericSubtractionJetMass() {
//Do generic subtraction for jet mass
if(fUseExternalBkg) fGenSubtractor = new fj::contrib::GenericSubtractor(fRho,fRhom);
else fGenSubtractor = new fj::contrib::GenericSubtractor(fBkrdEstimator);
// Define jet shape
FJJetShapeMass shapeMass;
// clear the generic subtractor info vector
fGenSubtractorInfoJetMass.clear();
for (unsigned i = 0; i < fInclusiveJets.size(); i++) {
fj::contrib::GenericSubtractorInfo info;
if(fInclusiveJets[i].perp()>1.e-4)
double subtracted_shape = (*fGenSubtractor)(shapeMass, fInclusiveJets[i], info);
fGenSubtractorInfoJetMass.push_back(info);
}
return 0;
}
//_________________________________________________________________________________________________
Int_t FJWrapper::DoGenericSubtractionGR(Int_t ijet) {
//Do generic subtraction for jet structure function
if(fUseExternalBkg) fGenSubtractor = new fj::contrib::GenericSubtractor(fRho,fRhom);
else fGenSubtractor = new fj::contrib::GenericSubtractor(fBkrdEstimator);
if(ijet>fInclusiveJets.size()) return 0;
fGRNumerator.clear();
fGRDenominator.clear();
fGRNumeratorSub.clear();
fGRDenominatorSub.clear();
// Define jet shape
for(Double_t r = 0.; r<fRMax; r+=fDRStep) {
FJJetShapeGRNum shapeGRNum(r,fDRStep);
FJJetShapeGRDen shapeGRDen(r,fDRStep);
// clear the generic subtractor info vector
fGenSubtractorInfoGRNum.clear();
fGenSubtractorInfoGRDen.clear();
fj::contrib::GenericSubtractorInfo infoNum;
fj::contrib::GenericSubtractorInfo infoDen;
if(fInclusiveJets[ijet].perp()>1.e-4) {
double sub_num = (*fGenSubtractor)(shapeGRNum, fInclusiveJets[ijet], infoNum);
double sub_den = (*fGenSubtractor)(shapeGRDen, fInclusiveJets[ijet], infoDen);
}
fGenSubtractorInfoGRNum.push_back(infoNum);
fGenSubtractorInfoGRDen.push_back(infoDen);
fGRNumerator.push_back(infoNum.unsubtracted());
fGRDenominator.push_back(infoDen.unsubtracted());
fGRNumeratorSub.push_back(infoNum.second_order_subtracted());
fGRDenominatorSub.push_back(infoDen.second_order_subtracted());
}
return 0;
}
//_________________________________________________________________________________________________
Int_t FJWrapper::DoGenericSubtractionJetAngularity() {
//Do generic subtraction for jet mass
if(fUseExternalBkg) fGenSubtractor = new fj::contrib::GenericSubtractor(fRho,fRhom);
else fGenSubtractor = new fj::contrib::GenericSubtractor(fBkrdEstimator);
// Define jet shape
FJJetShapeAngularity shapeAngularity;
// clear the generic subtractor info vector
fGenSubtractorInfoJetAngularity.clear();
for (unsigned i = 0; i < fInclusiveJets.size(); i++) {
fj::contrib::GenericSubtractorInfo infoAng;
if(fInclusiveJets[i].perp()>1.e-4)
double subtracted_shape = (*fGenSubtractor)(shapeAngularity, fInclusiveJets[i], infoAng);
fGenSubtractorInfoJetAngularity.push_back(infoAng);
}
return 0;
}
//_________________________________________________________________________________________________
Int_t FJWrapper::DoGenericSubtractionJetpTD() {
//Do generic subtraction for pTD
if(fUseExternalBkg) fGenSubtractor = new fj::contrib::GenericSubtractor(fRho,fRhom);
else fGenSubtractor = new fj::contrib::GenericSubtractor(fBkrdEstimator);
// Define jet shape
FJJetShapepTD shapepTD;
// clear the generic subtractor info vector
fGenSubtractorInfoJetpTD.clear();
for (unsigned i = 0; i < fInclusiveJets.size(); i++) {
fj::contrib::GenericSubtractorInfo infopTD;
if(fInclusiveJets[i].perp()>1.e-4)
double subtracted_shape = (*fGenSubtractor)(shapepTD, fInclusiveJets[i], infopTD);
fGenSubtractorInfoJetpTD.push_back(infopTD);
}
return 0;
}
//_________________________________________________________________________________________________
Int_t FJWrapper::DoGenericSubtractionJetCircularity() {
//Do generic subtraction for jet circularity
if(fUseExternalBkg) fGenSubtractor = new fj::contrib::GenericSubtractor(fRho,fRhom);
else fGenSubtractor = new fj::contrib::GenericSubtractor(fBkrdEstimator);
// Define jet shape
FJJetShapeCircularity shapecircularity;
// clear the generic subtractor info vector
fGenSubtractorInfoJetCircularity.clear();
for (unsigned i = 0; i < fInclusiveJets.size(); i++) {
fj::contrib::GenericSubtractorInfo infoCirc;
if(fInclusiveJets[i].perp()>1.e-4)
double subtracted_shape = (*fGenSubtractor)(shapecircularity, fInclusiveJets[i], infoCirc);
fGenSubtractorInfoJetCircularity.push_back(infoCirc);
}
return 0;
}
//_________________________________________________________________________________________________
Int_t FJWrapper::DoGenericSubtractionJetSigma2() {
//Do generic subtraction for jet sigma2
if(fUseExternalBkg) fGenSubtractor = new fj::contrib::GenericSubtractor(fRho,fRhom);
else fGenSubtractor = new fj::contrib::GenericSubtractor(fBkrdEstimator);
// Define jet shape
FJJetShapeSigma2 shapesigma2;
// clear the generic subtractor info vector
fGenSubtractorInfoJetSigma2.clear();
for (unsigned i = 0; i < fInclusiveJets.size(); i++) {
fj::contrib::GenericSubtractorInfo infoSigma;
if(fInclusiveJets[i].perp()>1.e-4)
double subtracted_shape = (*fGenSubtractor)(shapesigma2, fInclusiveJets[i], infoSigma);
fGenSubtractorInfoJetSigma2.push_back(infoSigma);
}
return 0;
}
//_________________________________________________________________________________________________
Int_t FJWrapper::DoGenericSubtractionJetConstituent() {
//Do generic subtraction for #constituents
if(fUseExternalBkg) fGenSubtractor = new fj::contrib::GenericSubtractor(fRho,fRhom);
else fGenSubtractor = new fj::contrib::GenericSubtractor(fBkrdEstimator);
// Define jet shape
FJJetShapeConstituent shapeconst;
// clear the generic subtractor info vector
fGenSubtractorInfoJetConstituent.clear();
for (unsigned i = 0; i < fInclusiveJets.size(); i++) {
fj::contrib::GenericSubtractorInfo infoConst;
if(fInclusiveJets[i].perp()>1.e-4)
double subtracted_shape = (*fGenSubtractor)(shapeconst, fInclusiveJets[i], infoConst);
fGenSubtractorInfoJetConstituent.push_back(infoConst);
}
return 0;
}
//_________________________________________________________________________________________________
Int_t FJWrapper::DoGenericSubtractionJetLeSub() {
//Do generic subtraction for leading-subleading constituent
if(fUseExternalBkg) fGenSubtractor = new fj::contrib::GenericSubtractor(fRho,fRhom);
else fGenSubtractor = new fj::contrib::GenericSubtractor(fBkrdEstimator);
// Define jet shape
FJJetShapeLeSub shapeLeSub;
// clear the generic subtractor info vector
fGenSubtractorInfoJetLeSub.clear();
for (unsigned i = 0; i < fInclusiveJets.size(); i++) {
fj::contrib::GenericSubtractorInfo infoLeSub;
if(fInclusiveJets[i].perp()>1.e-4)
double subtracted_shape = (*fGenSubtractor)(shapeLeSub, fInclusiveJets[i], infoLeSub);
fGenSubtractorInfoJetLeSub.push_back(infoLeSub);
}
return 0;
}
//_________________________________________________________________________________________________
Int_t FJWrapper::DoConstituentSubtraction() {
//Do constituent subtraction
fj::contrib::ConstituentSubtractor *subtractor;
if(fUseExternalBkg)
subtractor = new fj::contrib::ConstituentSubtractor(fRho,fRhom,0.,-1.);//kFALSE,kTRUE);
else subtractor = new fj::contrib::ConstituentSubtractor(fBkrdEstimator);
//clear constituent subtracted jets
fConstituentSubtrJets.clear();
for (unsigned i = 0; i < fInclusiveJets.size(); i++) {
fj::PseudoJet subtracted_jet(0.,0.,0.,0.);
if(fInclusiveJets[i].perp()>0.)
subtracted_jet = (*subtractor)(fInclusiveJets[i]);
fConstituentSubtrJets.push_back(subtracted_jet);
}
if(subtractor) {delete subtractor; subtractor = 0; }
return 0;
}
//_________________________________________________________________________________________________
void FJWrapper::SetupAlgorithmfromOpt(const char *option)
{
// Setup algorithm from char.
std::string opt(option);
if (!opt.compare("kt")) fAlgor = fj::kt_algorithm;
if (!opt.compare("antikt")) fAlgor = fj::antikt_algorithm;
if (!opt.compare("cambridge")) fAlgor = fj::cambridge_algorithm;
if (!opt.compare("genkt")) fAlgor = fj::genkt_algorithm;
if (!opt.compare("cambridge_passive")) fAlgor = fj::cambridge_for_passive_algorithm;
if (!opt.compare("genkt_passive")) fAlgor = fj::genkt_for_passive_algorithm;
if (!opt.compare("ee_kt")) fAlgor = fj::ee_kt_algorithm;
if (!opt.compare("ee_genkt")) fAlgor = fj::ee_genkt_algorithm;
if (!opt.compare("plugin")) fAlgor = fj::plugin_algorithm;
}
//_________________________________________________________________________________________________
void FJWrapper::SetupAreaTypefromOpt(const char *option)
{
// Setup area type from char.
std::string opt(option);
if (!opt.compare("active")) fAreaType = fj::active_area;
if (!opt.compare("invalid")) fAreaType = fj::invalid_area;
if (!opt.compare("active_area_explicit_ghosts")) fAreaType = fj::active_area_explicit_ghosts;
if (!opt.compare("one_ghost_passive")) fAreaType = fj::one_ghost_passive_area;
if (!opt.compare("passive")) fAreaType = fj::passive_area;
if (!opt.compare("voronoi")) fAreaType = fj::voronoi_area;
}
//_________________________________________________________________________________________________
void FJWrapper::SetupSchemefromOpt(const char *option)
{
//
// setup scheme from char
//
std::string opt(option);
if (!opt.compare("BIpt")) fScheme = fj::BIpt_scheme;
if (!opt.compare("BIpt2")) fScheme = fj::BIpt2_scheme;
if (!opt.compare("E")) fScheme = fj::E_scheme;
if (!opt.compare("pt")) fScheme = fj::pt_scheme;
if (!opt.compare("pt2")) fScheme = fj::pt2_scheme;
if (!opt.compare("Et")) fScheme = fj::Et_scheme;
if (!opt.compare("Et2")) fScheme = fj::Et2_scheme;
}
//_________________________________________________________________________________________________
void FJWrapper::SetupStrategyfromOpt(const char *option)
{
// Setup strategy from char.
std::string opt(option);
if (!opt.compare("Best")) fStrategy = fj::Best;
if (!opt.compare("N2MinHeapTiled")) fStrategy = fj::N2MinHeapTiled;
if (!opt.compare("N2Tiled")) fStrategy = fj::N2Tiled;
if (!opt.compare("N2PoorTiled")) fStrategy = fj::N2PoorTiled;
if (!opt.compare("N2Plain")) fStrategy = fj::N2Plain;
if (!opt.compare("N3Dumb")) fStrategy = fj::N3Dumb;
if (!opt.compare("NlnN")) fStrategy = fj::NlnN;
if (!opt.compare("NlnN3pi")) fStrategy = fj::NlnN3pi;
if (!opt.compare("NlnN4pi")) fStrategy = fj::NlnN4pi;
if (!opt.compare("NlnNCam4pi")) fStrategy = fj::NlnNCam4pi;
if (!opt.compare("NlnNCam2pi2R")) fStrategy = fj::NlnNCam2pi2R;
if (!opt.compare("NlnNCam")) fStrategy = fj::NlnNCam;
if (!opt.compare("plugin")) fStrategy = fj::plugin_strategy;
}
#endif
| [
"marta.verweij@cern.ch"
] | marta.verweij@cern.ch |
ecc0a6f99901954a4f2b4508c7723b1961e7b0ef | 425c08536358e484bb38c23e4c4ae52d488dde71 | /src/LZespolona.cpp | b48940d0f005e079f7ce9c1f5015dabe29f923e9 | [] | no_license | marsok98/PWr_Liczby_Zespolone | ac2798c690a48e2b9c65d90ed4cfb32516c314ec | d2c9cfdf69a99efac6b601870c068c0166c140b5 | refs/heads/master | 2022-08-21T17:55:41.469458 | 2020-03-07T21:58:02 | 2020-03-07T21:58:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,585 | cpp | #include "LZespolona.hh"
#include <iostream>
#include <iomanip>
using namespace std;
//Przeciazenie operatora przesuniecia bitowego pelniacego funkcje
//wyswietlenia liczby zespolonej
ostream & operator << (ostream & wyj, LZespolona Skl1)
{
wyj<<"("<<Skl1.re<<showpos<<Skl1.im<<"i)"<<noshowpos;
return wyj;
}
/*Obowiazujacy format liczby zespolonej:
'('Czesc rzeczywista Czesc urojona'i'')''*/
//Wczytanie liczby zespolonej z strumienia wejsciowego i zapisanie
istream & operator >> (istream & wej, LZespolona &Skl1) // jej w strukturze podanej przez uzytkownika
{
wczytaj_i_sprawdz_znak(wej,'('); //Sprawdzenie czy wczytany znak jest '('
wczytaj_sprawdz_zapisz_liczbe(wej,Skl1.re); //wczytanie czesci rzeczywistej
wczytaj_sprawdz_zapisz_liczbe(wej,Skl1.im);
wczytaj_i_sprawdz_znak(wej,'i');
wczytaj_i_sprawdz_znak(wej,')');
return wej;
}
double Modul2(LZespolona Skl1) //Funkcja wyliczajaca modul do kwadratu z danej liczby zespolonej
{
double Wynik = (Skl1.re * Skl1.re + Skl1.im * Skl1.im);
return Wynik;
}
//Wylicza sprzezenie liczby zespolonej
LZespolona Sprzezenie(LZespolona Skl1)
{
LZespolona Wynik;
Wynik.re = Skl1.re;
Wynik.im =-Skl1.im;
return Wynik;
}
LZespolona operator / (LZespolona Skl1, double dzielnik) //Realizuje dzielenie liczby zespolonej przez typ double
{
LZespolona Wynik;
if(dzielnik){ //Sprawdzenie czy dzielnik aby napewno jest rozny od zera
Wynik.re = Skl1.re / dzielnik;
Wynik.im = Skl1.im / dzielnik;
return Wynik;
}
else{
cerr<<"Nie mozna dzielic przez zero\n";
exit(0);
}
}
//Przeciazenie operatorow dzialan arytmetycznych
LZespolona operator + (LZespolona Skl1, LZespolona Skl2)
{
LZespolona Wynik;
Wynik.re = Skl1.re + Skl2.re;
Wynik.im = Skl1.im + Skl2.im;
return Wynik;
}
LZespolona operator - (LZespolona Skl1, LZespolona Skl2)
{
LZespolona Wynik;
Wynik.re = Skl1.re - Skl2.re;
Wynik.im = Skl1.im - Skl2.im;
return Wynik;
}
LZespolona operator * (LZespolona Skl1, LZespolona Skl2)
{
LZespolona Wynik;
Wynik.re=((Skl1.re * Skl2.re) - (Skl1.im * Skl2.im));
Wynik.im=((Skl2.im * Skl1.re) + (Skl1.im * Skl2.re));
return Wynik;
}
LZespolona operator / (LZespolona Skl1, LZespolona Skl2)
{
LZespolona Wynik;
LZespolona Licznik;
double Mianownik;
Licznik = Skl1 * Sprzezenie(Skl2);
Mianownik = Modul2(Skl2);
Wynik = Licznik / Mianownik; //wykorzystanie przeciazenie dla Lzespolona i liczby typu double
return Wynik;
}
bool operator == (LZespolona Prawidlowa, LZespolona Do_Porownania) //Przeciazenie dla operatora porownania
{
if(Prawidlowa.re == Do_Porownania.re && Prawidlowa.im == Do_Porownania.im) return true;
else return false;
}
/*Funkcja wczytujaca znak ze strumienia wej i sprawdzajaca czy znak jest znakiem prawidlowym
Jesli nie to ustawiamy na strumieniu wejsciowym failbit*/
istream & wczytaj_i_sprawdz_znak(istream &wej,char znak_prawidlowy)
{
char znak;
wej>>znak;
if(znak != znak_prawidlowy)
{
wej.setstate(ios::failbit);
return wej;
}
return wej;
}
//Funkcja wczytujaca ze strumienia wej liczbe typu double
istream & wczytaj_sprawdz_zapisz_liczbe(istream &wej, double &liczba)
{
double temp;
wej >> temp;
if(wej.fail()) //jesli zostalo wczytanego cos nieprawidlowego to zwroc strumien
return wej;
else
{
liczba = temp; //jesli wszystko ok to przypisz do liczby wartosc wczytana
return wej;
}
} | [
"mariusz6m@onet.pl"
] | mariusz6m@onet.pl |
feaa29c09a1867fc6f1521b53e393bd8497cc5e3 | 19907e496cfaf4d59030ff06a90dc7b14db939fc | /POC/oracle_dapp/node_modules/wrtc/third_party/webrtc/include/chromium/src/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h | 59eca58cb73549c4660195f4139e4921a245cdda | [
"BSD-2-Clause"
] | permissive | ATMatrix/demo | c10734441f21e24b89054842871a31fec19158e4 | e71a3421c75ccdeac14eafba38f31cf92d0b2354 | refs/heads/master | 2020-12-02T20:53:29.214857 | 2017-08-28T05:49:35 | 2017-08-28T05:49:35 | 96,223,899 | 8 | 4 | null | 2017-08-28T05:49:36 | 2017-07-04T13:59:26 | JavaScript | UTF-8 | C++ | false | false | 11,845 | h | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_COMPRESSION_STATS_H_
#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_COMPRESSION_STATS_H_
#include <stddef.h>
#include <stdint.h>
#include <map>
#include <string>
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h"
#include "components/data_reduction_proxy/core/browser/db_data_owner.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h"
#include "components/data_reduction_proxy/proto/data_store.pb.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_member.h"
#include "net/base/network_change_notifier.h"
class PrefService;
namespace base {
class ListValue;
class Value;
}
namespace data_reduction_proxy {
class DataReductionProxyService;
// Data reduction proxy delayed pref service reduces the number calls to pref
// service by storing prefs in memory and writing to the given PrefService after
// |delay| amount of time. If |delay| is zero, the delayed pref service writes
// directly to the PrefService and does not store the prefs in memory. All
// prefs must be stored and read on the UI thread.
class DataReductionProxyCompressionStats
: public net::NetworkChangeNotifier::ConnectionTypeObserver {
public:
typedef base::ScopedPtrHashMap<std::string, scoped_ptr<PerSiteDataUsage>>
SiteUsageMap;
// Collects and store data usage and compression statistics. Basic data usage
// stats are stored in browser preferences. More detailed stats broken down
// by site and internet type are stored in |DataReductionProxyStore|.
//
// To store basic stats, it constructs a data reduction proxy delayed pref
// service object using |pref_service|. Writes prefs to |pref_service| after
// |delay| and stores them in |pref_map_| and |list_pref_map| between writes.
// If |delay| is zero, writes directly to the PrefService and does not store
// in the maps.
DataReductionProxyCompressionStats(DataReductionProxyService* service,
PrefService* pref_service,
const base::TimeDelta& delay);
~DataReductionProxyCompressionStats() override;
// Records detailed data usage broken down by connection type and domain. Also
// records daily data savings statistics to prefs and reports data savings
// UMA. |compressed_size| and |original_size| are measured in bytes.
void UpdateContentLengths(int64_t compressed_size,
int64_t original_size,
bool data_reduction_proxy_enabled,
DataReductionProxyRequestType request_type,
const std::string& data_usage_host,
const std::string& mime_type);
// Creates a |Value| summary of the persistent state of the network session.
// The caller is responsible for deleting the returned value.
// Must be called on the UI thread.
base::Value* HistoricNetworkStatsInfoToValue();
// Returns the time in milliseconds since epoch that the last update was made
// to the daily original and received content lengths.
int64_t GetLastUpdateTime();
// Resets daily content length statistics.
void ResetStatistics();
// Clears all data saving statistics.
void ClearDataSavingStatistics();
// Returns a list of all the daily content lengths.
ContentLengthList GetDailyContentLengths(const char* pref_name);
// Returns aggregate received and original content lengths over the specified
// number of days, as well as the time these stats were last updated.
void GetContentLengths(unsigned int days,
int64_t* original_content_length,
int64_t* received_content_length,
int64_t* last_update_time);
// Calls |get_data_usage_callback| with full data usage history. In-memory
// data usage stats are flushed to storage before querying for full history.
// An empty vector will be returned if "data_usage_reporting.enabled" pref is
// not enabled or if called immediately after enabling the pref before
// in-memory stats could be initialized from storage. Data usage is sorted
// chronologically with the last entry corresponding to |base::Time::Now()|.
void GetHistoricalDataUsage(
const HistoricalDataUsageCallback& get_data_usage_callback);
// Deletes browsing history from storage and memory for the given time
// range. Currently, this method deletes all data usage for the given range.
void DeleteBrowsingHistory(const base::Time& start, const base::Time& end);
// Called by |net::NetworkChangeNotifier| when network type changes. Used to
// keep track of connection type for reporting data usage breakdown by
// connection type.
void OnConnectionTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) override;
// Callback from loading detailed data usage. Initializes in memory data
// structures used to collect data usage. |data_usage| contains the data usage
// for the last stored interval.
void OnCurrentDataUsageLoaded(scoped_ptr<DataUsageBucket> data_usage);
private:
// Enum to track the state of loading data usage from storage.
enum CurrentDataUsageLoadStatus { NOT_LOADED = 0, LOADING = 1, LOADED = 2 };
friend class DataReductionProxyCompressionStatsTest;
typedef std::map<const char*, int64_t> DataReductionProxyPrefMap;
typedef base::ScopedPtrHashMap<const char*, scoped_ptr<base::ListValue>>
DataReductionProxyListPrefMap;
class DailyContentLengthUpdate;
class DailyDataSavingUpdate;
// Loads all data_reduction_proxy::prefs into the |pref_map_| and
// |list_pref_map_|.
void Init();
// Gets the value of |pref| from the pref service and adds it to the
// |pref_map|.
void InitInt64Pref(const char* pref);
// Gets the value of |pref| from the pref service and adds it to the
// |list_pref_map|.
void InitListPref(const char* pref);
void OnUpdateContentLengths();
// Gets the int64_t pref at |pref_path| from the |DataReductionProxyPrefMap|.
int64_t GetInt64(const char* pref_path);
// Updates the pref value in the |DataReductionProxyPrefMap| map.
// The pref is later written to |pref service_|.
void SetInt64(const char* pref_path, int64_t pref_value);
// Increases the pref value in the |DataReductionProxyPrefMap| map.
// The pref is later written to |pref service_|.
void IncreaseInt64Pref(const char* pref_path, int64_t delta);
// Gets the pref list at |pref_path| from the |DataReductionProxyPrefMap|.
base::ListValue* GetList(const char* pref_path);
// Writes the prefs stored in |DataReductionProxyPrefMap| and
// |DataReductionProxyListPrefMap| to |pref_service|.
void WritePrefs();
// Starts a timer (if necessary) to write prefs in |kMinutesBetweenWrites| to
// the |pref_service|.
void DelayedWritePrefs();
// Copies the values at each index of |from_list| to the same index in
// |to_list|.
void TransferList(const base::ListValue& from_list,
base::ListValue* to_list);
// Records content length updates to prefs.
void RecordRequestSizePrefs(int64_t compressed_size,
int64_t original_size,
bool with_data_reduction_proxy_enabled,
DataReductionProxyRequestType request_type,
const std::string& mime_type,
const base::Time& now);
void IncrementDailyUmaPrefs(int64_t original_size,
int64_t received_size,
const char* original_size_pref,
const char* received_size_pref,
bool data_reduction_proxy_enabled,
const char* original_size_with_proxy_enabled_pref,
const char* recevied_size_with_proxy_enabled_pref,
bool via_data_reduction_proxy,
const char* original_size_via_proxy_pref,
const char* received_size_via_proxy_pref);
// Record UMA with data savings bytes and percent over the past
// |DataReductionProxy::kNumDaysInHistorySummary| days. These numbers
// are displayed to users as their data savings.
void RecordUserVisibleDataSavings();
// Record data usage and original size of request broken down by host. |time|
// is the time at which the data usage occurred. This method should be called
// in real time, so |time| is expected to be |Time::Now()|.
void RecordDataUsage(const std::string& data_usage_host,
int64_t original_request_size,
int64_t data_used,
const base::Time& time);
// Persists the in memory data usage information to storage and clears all
// in-memory data usage. Do not call this method unless |data_usage_loaded_|
// is |LOADED|.
void PersistDataUsage();
// Deletes all historical data usage from storage and memory. This method
// should not be called when |current_data_usage_load_status_| is |LOADING|.
void DeleteHistoricalDataUsage();
// Actual implementation of |GetHistoricalDataUsage|. This helper method
// explicitly passes |base::Time::Now()| to make testing easier.
void GetHistoricalDataUsageImpl(
const HistoricalDataUsageCallback& get_data_usage_callback,
const base::Time& now);
// Called when |prefs::kDataUsageReportingEnabled| pref values changes.
// Initializes data usage statistics in memory when pref is enabled and
// persists data usage to memory when pref is disabled.
void OnDataUsageReportingPrefChanged();
// Normalizes the hostname for data usage attribution. Returns a substring
// without the protocol.
// Example: "http://www.finance.google.com" -> "www.finance.google.com"
static std::string NormalizeHostname(const std::string& host);
DataReductionProxyService* service_;
PrefService* pref_service_;
const base::TimeDelta delay_;
DataReductionProxyPrefMap pref_map_;
DataReductionProxyListPrefMap list_pref_map_;
PrefChangeRegistrar pref_change_registrar_;
BooleanPrefMember data_usage_reporting_enabled_;
ConnectionType connection_type_;
// Maintains detailed data usage for current interval.
SiteUsageMap data_usage_map_;
// Time when |data_usage_map_| was last updated. Contains NULL time if
// |data_usage_map_| does not have any data. This could happen either because
// current data usage has not yet been loaded from storage, or because
// no data usage has ever been recorded.
base::Time data_usage_map_last_updated_;
// Tracks whether |data_usage_map_| has changes that have not yet been
// persisted to storage.
bool data_usage_map_is_dirty_;
// Tracks state of loading data usage from storage.
CurrentDataUsageLoadStatus current_data_usage_load_status_;
base::OneShotTimer pref_writer_timer_;
base::ThreadChecker thread_checker_;
base::WeakPtrFactory<DataReductionProxyCompressionStats> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(DataReductionProxyCompressionStats);
};
} // namespace data_reduction_proxy
#endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_COMPRESSION_STATS_H_
| [
"steven.jun.liu@qq.com"
] | steven.jun.liu@qq.com |
86e92884671d90ba1facffee8990a9fd5bc15434 | e92a8e7ba8dbad9339ba14db9a32a772e9415ac3 | /programmers/68935.cpp | a86f56a0a2299f335984a35a0939637ae3d44278 | [] | no_license | Lee-Jungyu/algorithm | ec3155a4424d97d12ab96d98f7a7f14589f8ec70 | 6a18758ba3d4ee55a6cfae33ed86258ddda9bc96 | refs/heads/master | 2021-08-06T15:28:06.919063 | 2021-07-14T12:49:37 | 2021-07-14T12:49:37 | 232,481,372 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 516 | cpp | #include <string>
#include <vector>
using namespace std;
string reverse_ternary(int num) {
string str = "";
while(num) {
str += (char)(num % 3 + '0');
num /= 3;
}
return str;
}
int ternary_to_decimal(string str) {
int n = 0;
for(int i = 0; i < str.length(); i++) {
n *= 3;
n += str[i] - '0';
}
return n;
}
int solution(int n) {
string str = reverse_ternary(n);
int answer = ternary_to_decimal(str);
return answer;
}
| [
"noreply@github.com"
] | noreply@github.com |
6ad8f85f239d2f8cfea72b07093eca1967fd08a6 | fa80d959c083575085f6a8ef3d44a9dd250c7fca | /sample_source/jaea_uoa_ros/src/SpiderROSArmController.cpp | e5b5dff2fd81525b28bcbda38e5aad7bf3e36130 | [
"BSD-2-Clause"
] | permissive | REL-UoA-JAEA-WRS-SIM/Workshop | 5ca65450ce3a24fb97a3f6b029d1ba1889db4fea | 0a244fae4018c135bf1ebe50a81737796ed4eb9c | refs/heads/master | 2021-08-08T10:18:46.856006 | 2021-03-19T00:51:25 | 2021-03-19T00:51:25 | 246,250,553 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,688 | cpp | /*
\author Fumiaki Abe
*/
#include <cnoid/SimpleController>
#include <cnoid/SharedJoystick>
#include <mutex>
#include <iostream>
#include <vector>
#include <cnoid/Body>
#include <cnoid/JointPath>
#include <cnoid/EigenUtil>
#include <unistd.h>
#include <ros/ros.h>
#include <ros/node_handle.h>
#include <std_msgs/String.h>
#include <sensor_msgs/Joy.h>
using namespace std;
using namespace cnoid;
class SpiderROSArmController : public SimpleController
{
ros::NodeHandle nh;
ros::Subscriber joystickSubscriber;
sensor_msgs::Joy latestJoystickState;
std::mutex joystickMutex;
Body* body;
Body* ioBody;
Link* ioFINGER1;
Link* ioFINGER2;
Link* ioFINGER3;
BodyPtr ikBody;
Link* ikWrist;
std::shared_ptr<cnoid::JointPath> baseToWrist;
Link::ActuationMode mainActuationMode;
Link::ActuationMode trackActuationMode;
double time;
double timeStep;
double waitTime;
struct JointInfo {
Link* joint;
double qref;
double qold;
double kp;
double kd;
};
vector<JointInfo> jointInfos;
vector<JointInfo> jointInfos2;
vector<Link*> tracks;
double trackVelocityRatio;
double kd_mainTrack;
double kd_subTrack;
vector<double> qprev_track;
struct JointSpec {
string name;
double kp_torque;
double kd_torque;
double kp_velocity;
};
enum { L_TRACK, R_TRACK, FL_SUB_TRACK, FR_SUB_TRACK, BL_SUB_TRACK, BR_SUB_TRACK, NUM_TRACKS };
enum { FR_FLIPPER, FL_FLIPPER, BR_FLIPPER, BL_FLIPPER, NUM_FLIPPERS };
enum { SHOULDER, ARM_HALF_1, ARM_HALF_2, FOREARM, WRIST_SPHERICAL_1, WRIST_SPHERICAL_2,
HAND_3FINGER, FINGER_PROXIMAL_1, FINGER_PROXIMAL_2, FINGER_PROXIMAL_3,NUM_JOINTS
};
sensor_msgs::Joy joystick;
SharedJoystickPtr sharedjoy;
int targetMode;
bool controlFlg;
public:
Matrix3d RotateX(double radian);
Matrix3d RotateY(double radian);
Matrix3d RotateZ(double radian);
virtual bool initialize(SimpleControllerIO* io) override;
bool initializeTracks(SimpleControllerIO* io);
bool initializeTracks(SimpleControllerIO* io, vector<string>& names);
bool initializeFlipperJoints(SimpleControllerIO* io);
bool initializeJoints(SimpleControllerIO* io, vector<JointSpec>& specs);
bool start();
bool initializeJoints(SimpleControllerIO* io, vector<JointSpec>& specs, const string& prefix);
virtual bool control() override;
void controlTracks();
double deg2rad(double degree);
double rad2deg(double radian);
void updateTargetJointAnglesBYInverseKinematicks();
int updateControlflg();
void setTrackTorque(int id, double dq_target, double kd);
void updateFlipperTargetPositions();
void controlJointsWithTorque();
void controlJointsWithVelocity();
void controlJointsWithPosition();
void joystickCallback(const sensor_msgs::Joy& msg);
};
Matrix3d SpiderROSArmController::RotateX(double radian)
{
Matrix3d rotX = MatrixXd::Zero(3,3);
rotX(0,0) = 1;
rotX(1,1) = cos(radian);
rotX(1,2) = -sin(radian);
rotX(2,1) = sin(radian);
rotX(2,2) = cos(radian);
return rotX;
}
Matrix3d SpiderROSArmController::RotateY(double radian)
{
Matrix3d rotY = MatrixXd::Zero(3,3);
rotY(0,0) = cos(radian);
rotY(0,2) = sin(radian);
rotY(1,1) = 1;
rotY(2,0) = -sin(radian);
rotY(2,2) = cos(radian);
return rotY;
}
Matrix3d SpiderROSArmController::RotateZ(double radian)
{
Matrix3d rotZ = MatrixXd::Zero(3,3);
rotZ(0,0) = cos(radian);
rotZ(0,1) = -sin(radian);
rotZ(1,0) = sin(radian);
rotZ(1,1) = cos(radian);
rotZ(2,2) = 1;
return rotZ;
}
bool SpiderROSArmController::initialize(SimpleControllerIO* io)
{
body = io->body();
ioBody = io->body();
timeStep = io->timeStep();
ikBody = ioBody->clone();
ikWrist = ikBody->link("HAND_3FINGER");
ioFINGER1 = ioBody->link("FINGER_PROXIMAL_1");
ioFINGER2 = ioBody->link("FINGER_PROXIMAL_2");
ioFINGER3 = ioBody->link("FINGER_PROXIMAL_3");
Link* base = ikBody->link("BASE");
baseToWrist = getCustomJointPath(ikBody, base, ikWrist);
base->p().setZero();
base->R().setIdentity();
mainActuationMode = Link::JOINT_TORQUE;
string prefix;
for(auto& option : io->options()){
if(option == "velocity"){
mainActuationMode = Link::JOINT_VELOCITY;
io->os() << "velocity mode" << endl;
} else if(option == "position"){
mainActuationMode = Link::JOINT_ANGLE;
io->os() << "position mode" << endl;
} else if(option == "torque"){
mainActuationMode = Link::JOINT_TORQUE;
io->os() << "torque mode" << endl;
} else {
prefix = option;
io->os() << "prefix: " << prefix << endl;
}
}
jointInfos2.clear();
if(!initializeTracks(io)){
return false;
}
if(!initializeFlipperJoints(io)){
return false;
}
jointInfos.clear();
const double P_GAIN_VELOCITY = 0.3;
vector<JointSpec> specs(NUM_JOINTS);
if(io->timeStep() < 0.02){
// P D P (vel)
specs[SHOULDER ] = { "SHOULDER", 1000.0, 100, P_GAIN_VELOCITY };
specs[ARM_HALF_1 ] = { "ARM_HALF_1", 1000.0, 100, P_GAIN_VELOCITY };
specs[ARM_HALF_2 ] = { "ARM_HALF_2", 600.0, 60, P_GAIN_VELOCITY };
specs[FOREARM ] = { "FOREARM", 600.0, 60, P_GAIN_VELOCITY };
specs[WRIST_SPHERICAL_1] = { "WRIST_SPHERICAL_1", 300.0, 30, P_GAIN_VELOCITY };
specs[WRIST_SPHERICAL_2] = { "WRIST_SPHERICAL_2", 300.0, 30, P_GAIN_VELOCITY };
specs[HAND_3FINGER ] = { "HAND_3FINGER", 250.0, 25, P_GAIN_VELOCITY };
specs[FINGER_PROXIMAL_1] = { "FINGER_PROXIMAL_1", 5, 3, P_GAIN_VELOCITY };
specs[FINGER_PROXIMAL_2] = { "FINGER_PROXIMAL_2", 5, 3, P_GAIN_VELOCITY };
specs[FINGER_PROXIMAL_3] = { "FINGER_PROXIMAL_3", 5, 3, P_GAIN_VELOCITY };
} else {
// P D P (vel)
specs[SHOULDER ] = { "SHOULDER", 400.0, 30, P_GAIN_VELOCITY };
specs[ARM_HALF_1 ] = { "ARM_HALF_1", 400.0, 30, P_GAIN_VELOCITY };
specs[ARM_HALF_2 ] = { "ARM_HALF_2", 150.0, 15, P_GAIN_VELOCITY };
specs[FOREARM ] = { "FOREARM", 150.0, 15, P_GAIN_VELOCITY };
specs[WRIST_SPHERICAL_1] = { "WRIST_SPHERICAL_1", 60.0, 5, P_GAIN_VELOCITY };
specs[WRIST_SPHERICAL_2] = { "WRIST_SPHERICAL_2", 60.0, 5, P_GAIN_VELOCITY };
specs[HAND_3FINGER ] = { "HAND_3FINGER", 60.0, 5, P_GAIN_VELOCITY };
specs[FINGER_PROXIMAL_1] = { "FINGER_PROXIMAL_1", 5, 0.5, P_GAIN_VELOCITY };
specs[FINGER_PROXIMAL_2] = { "FINGER_PROXIMAL_2", 5, 0.5, P_GAIN_VELOCITY };
specs[FINGER_PROXIMAL_3] = { "FINGER_PROXIMAL_3", 5, 0.5, P_GAIN_VELOCITY };
}
if(!initializeJoints(io, specs, prefix)){
return false;
}
baseToWrist->calcForwardKinematics();
time = 0.0;
timeStep = io->timeStep();
waitTime = io->currentTime();
sharedjoy = io->getOrCreateSharedObject<SharedJoystick>("joystick");
targetMode = sharedjoy->addMode();
joystickSubscriber = nh.subscribe("joy",1, &SpiderROSArmController::joystickCallback,this);
return true;
}
bool SpiderROSArmController::initializeTracks(SimpleControllerIO* io)
{
tracks.clear();
qprev_track.clear();
vector<string> trackNames = {
"L_TRACK", "R_TRACK", "FL_SUB_TRACK", "FR_SUB_TRACK", "BL_SUB_TRACK", "BR_SUB_TRACK" };
vector<string> wheelNames = {
"SPROCKET_L", "SPROCKET_R",
"SPROCKET_LF", "SPROCKET_RF", "SPROCKET_LR", "SPROCKET_RR" };
bool result;
if(body->link(wheelNames[0])){
if(mainActuationMode == Link::JOINT_TORQUE){
trackActuationMode = Link::JOINT_TORQUE;
trackVelocityRatio = 0.5;
kd_mainTrack = 8.0;
kd_subTrack = 1.5;
} else {
trackActuationMode= Link::JOINT_VELOCITY;
trackVelocityRatio = 4.0;
}
result = initializeTracks(io, wheelNames);
} else {
trackActuationMode = Link::JOINT_SURFACE_VELOCITY;
trackVelocityRatio = 0.5;
result = initializeTracks(io, trackNames);
}
return result;
}
bool SpiderROSArmController::initializeTracks(SimpleControllerIO* io, vector<string>& names)
{
for(auto& name : names){
auto link = body->link(name);
if(!link){
// io->os() << format("{0} of {1} is not found", name, body->name()) << endl;
return false;
}
link->setActuationMode( trackActuationMode);
io->enableOutput(link);
tracks.push_back(link);
qprev_track.push_back(link->q());
}
return true;
}
bool SpiderROSArmController::initializeFlipperJoints(SimpleControllerIO* io)
{
jointInfos2.clear();
vector<JointSpec> specs(NUM_FLIPPERS);
const double FLIPPER_P_GAIN_TORQUE = 800.0;
const double FLIPPER_D_GAIN_TORQUE = 20.0;
const double FLIPPER_P_GAIN_VELOCITY = 1.0;
specs[FR_FLIPPER] = { "FR_FLIPPER", FLIPPER_P_GAIN_TORQUE, FLIPPER_D_GAIN_TORQUE, FLIPPER_P_GAIN_VELOCITY };
specs[FL_FLIPPER] = { "FL_FLIPPER", FLIPPER_P_GAIN_TORQUE, FLIPPER_D_GAIN_TORQUE, FLIPPER_P_GAIN_VELOCITY };
specs[BR_FLIPPER] = { "BR_FLIPPER", FLIPPER_P_GAIN_TORQUE, FLIPPER_D_GAIN_TORQUE, FLIPPER_P_GAIN_VELOCITY };
specs[BL_FLIPPER] = { "BL_FLIPPER", FLIPPER_P_GAIN_TORQUE, FLIPPER_D_GAIN_TORQUE, FLIPPER_P_GAIN_VELOCITY };
return initializeJoints(io, specs);
}
bool SpiderROSArmController::start()
{
return true;
}
bool SpiderROSArmController::initializeJoints(SimpleControllerIO* io, vector<JointSpec>& specs, const string& prefix)
{
for(auto& spec : specs){
string name = prefix + spec.name;
auto joint = ioBody->link(name);
if(!joint){
return false;
}
else{
joint->setActuationMode(mainActuationMode);
io->enableIO(joint);
JointInfo info;
info.joint = joint;
info.qref = info.qold = joint->q();
if(mainActuationMode == Link::JOINT_VELOCITY){
info.kp = spec.kp_velocity;
}
else if(mainActuationMode == Link::JOINT_TORQUE){
info.kp = spec.kp_torque;
info.kd = spec.kd_torque;
}
jointInfos.push_back(info);
}
}
return true;
}
bool SpiderROSArmController::initializeJoints(SimpleControllerIO* io, vector<JointSpec>& specs)
{
for(auto& spec : specs){
auto joint = body->link(spec.name);
if(!joint){
//io->os() << format("{0} of {1} is not found", spec.name, body->name()) << endl;
return false;
}
joint->setActuationMode(mainActuationMode);
io->enableIO(joint);
JointInfo info;
info.joint = joint;
info.qref = info.qold = joint->q();
if(mainActuationMode == Link::JOINT_VELOCITY){
info.kp = spec.kp_velocity;
} else if(mainActuationMode == Link::JOINT_TORQUE){
info.kp = spec.kp_torque;
info.kd = spec.kd_torque;
}
jointInfos2.push_back(info);
}
return true;
}
bool SpiderROSArmController::control()
{
sharedjoy->updateState(targetMode);
{
std::lock_guard<std::mutex> lock(mutex);
joystick = latestJoystickState;
joystick.axes.resize(10, 0.0f);
joystick.buttons.resize(13, 0);
}
if(joystick.buttons[10] )
{
if((time - waitTime) > 100*timeStep){
waitTime = time;
if(!controlFlg){controlFlg=true;}
else{controlFlg=false;}
}
}
// if(joystick.buttons[10]){
// if(!controlFlg){controlFlg=true;}
// else{controlFlg=false;}
// }
if(controlFlg){
updateTargetJointAnglesBYInverseKinematicks();
}
else if(!controlFlg){
controlTracks();
updateFlipperTargetPositions();
}
else{}
switch(mainActuationMode){
case Link::JOINT_TORQUE:
controlJointsWithTorque();
break;
case Link::JOINT_VELOCITY:
controlJointsWithVelocity();
break;
case Link::JOINT_ANGLE:
controlJointsWithPosition();
break;
default:
break;
}
time += timeStep;
return true;
}
double SpiderROSArmController::deg2rad(double degree)
{
return (double) (degree * M_PI / 180.0);
}
double SpiderROSArmController::rad2deg(double radian)
{
return (double) (radian * 180.0/ M_PI);
}
void SpiderROSArmController::updateTargetJointAnglesBYInverseKinematicks()
{
// ๆ้ฆๅบงๆจ
baseToWrist->calcForwardKinematics();
Vector3d p = ikWrist->p();
Matrix3d R = ikWrist->R();
p(1) -= joystick.axes[0]/500;
p(0) -= joystick.axes[1]/500;
p(2) -= joystick.axes[3]/500;
if(joystick.buttons[5]){
R *= RotateX(deg2rad(-0.3));
}
if(joystick.buttons[4]){
R *= RotateX(deg2rad(0.3));
}
// ๆ้ฆใฎๆไฝ
if(joystick.buttons[1]){
R *= RotateY(deg2rad(0.3)) ;
}
if(joystick.buttons[2]){
R *= RotateY(deg2rad(-0.3));
}
if(joystick.buttons[0]){
R *= RotateZ(deg2rad(0.3));
}
if(joystick.buttons[3]){
R *= RotateZ(deg2rad(-0.3));
}
baseToWrist->calcInverseKinematics(p, R);
Vector3d rpy = rpyFromRot(ikWrist->attitude());
for(int i = 0; i <7; i++ )
{
Link* joint = baseToWrist->joint(i);
jointInfos[i].qref = joint->q();
}
double dq_fingerL = 0.0;
double ltL = joystick.axes[6];
dq_fingerL -= ltL;
//double
ltL = joystick.axes[7];
dq_fingerL += ltL;
for(int i = FINGER_PROXIMAL_1; i <= FINGER_PROXIMAL_3; ++i){
jointInfos[i].qref += 0.003*dq_fingerL;
}
}
void SpiderROSArmController::controlJointsWithTorque()
{
for(auto& info : jointInfos){
auto joint = info.joint;
double q = joint->q();
double dq = (q - info.qold) / timeStep;
joint->u() = info.kp * (info.qref - q) + info.kd * (0.0 - dq);
info.qold = q;
}
for(auto& info : jointInfos2){
auto joint = info.joint;
double q = joint->q();
double dq = (q - info.qold) / timeStep;
joint->u() = info.kp * (info.qref - q) + info.kd * (0.0 - dq);
info.qold = q;
}
}
void SpiderROSArmController::controlJointsWithVelocity()
{
for(auto& info : jointInfos){
auto joint = info.joint;
double q = joint->q();
joint->dq_target() = info.kp * (info.qref - q) / timeStep;
}
for(auto& info : jointInfos2){
auto joint = info.joint;
double q = joint->q();
joint->dq_target() = info.kp * (info.qref - q) / timeStep;
}
}
void SpiderROSArmController::controlJointsWithPosition()
{
for(auto& info : jointInfos){
info.joint->q_target() = info.qref;
}
for(auto& info : jointInfos2){
info.joint->q_target() = info.qref;
}
}
void SpiderROSArmController::joystickCallback(const sensor_msgs::Joy& msg)
{
std::lock_guard<std::mutex> lock(mutex);
latestJoystickState = msg;
}
void SpiderROSArmController::controlTracks()
{
double hpos = joystick.axes[0];
double vpos = -joystick.axes[1];
double dq_L = trackVelocityRatio * (vpos + 0.4 * hpos);
double dq_R = trackVelocityRatio * (vpos - 0.4 * hpos);
switch(trackActuationMode){
case Link::JOINT_VELOCITY:
case Link::JOINT_SURFACE_VELOCITY:
for(int i=0; i < 3; ++i){
tracks[i*2 ]->dq_target() = dq_L;
tracks[i*2+1]->dq_target() = dq_R;
}
break;
case Link::JOINT_TORQUE:
setTrackTorque(L_TRACK, dq_L, kd_mainTrack);
setTrackTorque(R_TRACK, dq_R, kd_mainTrack);
setTrackTorque(FL_SUB_TRACK, dq_L, kd_subTrack);
setTrackTorque(FR_SUB_TRACK, dq_R, kd_subTrack);
setTrackTorque(BL_SUB_TRACK, dq_L, kd_subTrack);
setTrackTorque(BR_SUB_TRACK, dq_R, kd_subTrack);
break;
default:
break;
}
}
void SpiderROSArmController::setTrackTorque(int id, double dq_target, double kd)
{
Link* axis = tracks[id];
double dq_current = (axis->q() - qprev_track[id]) / timeStep;
axis->u() = kd * (dq_target - dq_current);
qprev_track[id] = axis->q();
}
void SpiderROSArmController::updateFlipperTargetPositions()
{
static const double FLIPPER_GAIN = 0.1;
if(joystick.buttons[12]){
double qa = 0.0;
for(int i=0; i < NUM_FLIPPERS; ++i){
qa += jointInfos2[i].qref;
}
qa /= NUM_FLIPPERS;
double dqmax = timeStep * 0.5;
for(int i=0; i < NUM_FLIPPERS; ++i){
double dq = qa - jointInfos2[i].qref;
if(dq > dqmax){
dq = dqmax;
} else if(dq < -dqmax){
dq = -dqmax;
}
jointInfos2[i].qref += dq;
}
} else {
double pos = joystick.axes[3] * 5.0;
double dq = timeStep * FLIPPER_GAIN * pos;
bool FL = joystick.buttons[4];
bool FR = joystick.buttons[5];
bool BL = false;
bool BR = false;
if(joystick.axes[6] > 0){BL = true;}
else {BL = false;}
if(joystick.axes[7] > 0){BR = true;}
else {BR = false;}
if(!FL && !FR && !BL && !BR){
// Synchronize mode
jointInfos2[FR_FLIPPER].qref -= dq;
jointInfos2[FL_FLIPPER].qref -= dq;
jointInfos2[BR_FLIPPER].qref += dq;
jointInfos2[BL_FLIPPER].qref += dq;
} else {
if(FL){
jointInfos2[FL_FLIPPER].qref -= dq;
}
if(FR){
jointInfos2[FR_FLIPPER].qref -= dq;
}
if(BL){
jointInfos2[BL_FLIPPER].qref += dq;
}
if(BR){
jointInfos2[BR_FLIPPER].qref += dq;
}
}
}
}
CNOID_IMPLEMENT_SIMPLE_CONTROLLER_FACTORY(SpiderROSArmController)
| [
"naruse@u-aizu.ac.jp"
] | naruse@u-aizu.ac.jp |
83b90274890a6e3a0b3650e42213f2c44927e74d | 2f10f807d3307b83293a521da600c02623cdda82 | /deps/boost/win/debug/include/boost/fusion/view/filter_view/detail/size_impl.hpp | 03650646bc618da1e8b291740bcd50ee268f7b4f | [] | no_license | xpierrohk/dpt-rp1-cpp | 2ca4e377628363c3e9d41f88c8cbccc0fc2f1a1e | 643d053983fce3e6b099e2d3c9ab8387d0ea5a75 | refs/heads/master | 2021-05-23T08:19:48.823198 | 2019-07-26T17:35:28 | 2019-07-26T17:35:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 129 | hpp | version https://git-lfs.github.com/spec/v1
oid sha256:ec290bbb6a9c78c6986f66cf4a4b83ab01ce2760dd7eff006aca8f47b82bb529
size 1141
| [
"YLiLarry@gmail.com"
] | YLiLarry@gmail.com |
2847695cd7cb52d7efcb04b29afe049659caf942 | b4e6090a804c29b0fefcce025d683c9c2f02a42e | /PENGIRIM_LCD_BESAR_FIX.ino | eda27863929dc61b781c2a722ff1d6720fc31ab2 | [] | no_license | namitron/DIGITAL-PANEL-METER | 8d8926efdaf417b572bbfdf6c983b098801106de | f6c3a4c16584d9f24e6ff8ef9257af9bf7ce2033 | refs/heads/main | 2023-04-03T13:29:45.928259 | 2021-04-06T04:26:00 | 2021-04-06T04:26:00 | 355,054,256 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,514 | ino | #include <SoftwareSerial.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
SoftwareSerial espSerial(5, 6);
String str;
String str2;
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina219;
int c = 0;
int a = 0;
int b = 0;
int d = 0;
int e =0;
void(*reset_ulang) (void) = 0;//Perintah reset
void setup(){
Serial.begin(9600);
espSerial.begin(9600);
delay(2000);
while (!Serial) {
// will pause Zero, Leonardo, etc until serial console opens
delay(1);
}
uint32_t currentFrequency;
Serial.println("Hello!");
ina219.begin();
Serial.println("Measuring voltage and current with INA219 ...");
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextSize(3);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0,4);
display.print("mA: ");
display.setCursor(0,0);
display.display(); // actually display all of the
}
void loop()
{
float shuntvoltage = 0;
float busvoltage = 0;
float current_mA = 0;
float loadvoltage = 0;
shuntvoltage = ina219.getShuntVoltage_mV();
busvoltage = ina219.getBusVoltage_V();
current_mA = ina219.getCurrent_mA();
loadvoltage = busvoltage + (shuntvoltage / 1000);
int mA = current_mA ;
Serial.println(mA);
d = mA - d;
//Serial.print("Asli = ");
//Serial.println(mA);
//str2 = String(mA)+String(",")+String("*");
//espSerial.println(str2);
if (mA>5){
a = mA;
if (a>b /*&& d<2 && d>0*/){
b = a;
c = map(b, 0, 81, 0, 100);
Serial.println("Asli: ");
Serial.println(mA);
Serial.println("kebaca: ");
Serial.println(c);
str2 = String(c)+String(",")+String("*");
espSerial.println(str2);
// Serial.println("asli: ");
//Serial.println(mA);
/* display.setTextSize(3);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0,4);
display.print("mA: ");
display.setTextSize(3);
display.setTextColor(SSD1306_WHITE);
display.setCursor(60,4);
display.print(c);
display.setCursor(0,0);
display.display();
display.clearDisplay();*/
}
//delay(5000);
//reset_ulang();
}
/* if (a>b && d<2 && d>0)
{
b = a;
c = map(b, 0, 38, 0, 100);
Serial.println("kebaca: ");
Serial.println(c);
} */
/*
if(micros() >= voltageLastSample + 1000 )
{
voltageSampleRead = (analogRead(mA)-512)+ voltageOffset1;
voltageSampleSum = voltageSampleSum + sq(voltageSampleRead) ;
voltageSampleCount = voltageSampleCount + 1;
voltageLastSample = micros() ;
}
if(voltageSampleCount == 1)
{
display.setTextSize(3);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0,4);
display.print("mA: ");
display.setTextSize(3);
display.setTextColor(SSD1306_WHITE);
display.setCursor(60,4);
display.print(c);
//Serial.println(mA);
display.setCursor(0,0);
display.display();
display.clearDisplay();
voltageSampleSum =0;
voltageSampleCount =0;
}
*/
}
| [
"noreply@github.com"
] | noreply@github.com |
5f58d662134d4cbf65a50354f21a0904f8732055 | 36e117a24ee3003be11d0e65fec1fcff7bfe61e0 | /findclincchargedlg.cpp | 7ab642f036a5d1b724b96945ad127097a34e3cc5 | [] | no_license | xuebeibei/HIS1.12 | 5bd01ac03f98f5d9a62ab5416b256933dcc57af8 | d6d68bbafe366a312eb97966364c46b332315137 | refs/heads/master | 2021-01-01T05:24:25.565484 | 2016-05-23T11:37:32 | 2016-05-23T11:37:32 | 58,366,054 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,603 | cpp | #include "findclincchargedlg.h"
FindClincChargeDlg::FindClincChargeDlg(QWidget *parent) :
QDialog(parent)
{
m_strId = g_strNull;
create();
init();
setMyLayout();
}
FindClincChargeDlg::~FindClincChargeDlg()
{
}
QString FindClincChargeDlg::getId()
{
return m_strId;
}
void FindClincChargeDlg::create()
{
m_chargeNumLabel = new QLabel(g_strClincChargeNumLabel);
m_chargeNumEdit = new QLineEdit();
m_chargeNumLabel->setBuddy(m_chargeNumEdit);
m_nameLabel = new QLabel(g_strNameLabel);
m_nameEdit = new QLineEdit();
m_nameLabel->setBuddy(m_nameEdit);
m_genderLabel = new QLabel(g_strGenderLabel);
m_genderComboBox = new QComboBox;
m_genderComboBox->addItem(g_strMan);
m_genderComboBox->addItem(g_strWoman);
m_findButton = new QToolButton;
m_findButton->setIcon(QIcon(g_strIconPath + "find.png"));
connect(m_findButton, SIGNAL(clicked()), this, SLOT(find()));
m_resultsTableView = new QTableView;
m_resultsModel = new QStandardItemModel;
m_resultsTableView->setModel(m_resultsModel);
m_resultsTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
m_resultsTableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
connect(m_resultsTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(choise()));
m_choiseButton = new QPushButton(g_strChoiseButton);
connect(m_choiseButton, SIGNAL(clicked()), this, SLOT(choise()));
m_cancelButton = new QPushButton(g_strCancelButton);
connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(close()));
}
void FindClincChargeDlg::setMyLayout()
{
QHBoxLayout *topLayout = new QHBoxLayout;
topLayout->addWidget(m_chargeNumLabel);
topLayout->addWidget(m_chargeNumEdit);
topLayout->addWidget(m_nameLabel);
topLayout->addWidget(m_nameEdit);
topLayout->addWidget(m_genderLabel);
topLayout->addWidget(m_genderComboBox);
topLayout->addStretch();
topLayout->addWidget(m_findButton);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
bottomLayout->addWidget(m_choiseButton);
bottomLayout->addWidget(m_cancelButton);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(topLayout);
mainLayout->addWidget(m_resultsTableView);
mainLayout->addLayout(bottomLayout);
setLayout(mainLayout);
}
void FindClincChargeDlg::init()
{
m_chargeNumEdit->setText(g_strNull);
m_nameEdit->setText(g_strNull);
m_genderComboBox->setCurrentIndex(man);
initTable();
}
void FindClincChargeDlg::initTable()
{
m_resultsModel->clear();
m_resultsModel->setHorizontalHeaderItem(0,new QStandardItem(QObject::tr("ๆถ่ดนๅๅท")));
m_resultsModel->setHorizontalHeaderItem(1,new QStandardItem(QObject::tr("ๆถ้ด")));
m_resultsModel->setHorizontalHeaderItem(2,new QStandardItem(QObject::tr("ๅงๅ")));
m_resultsModel->setHorizontalHeaderItem(3,new QStandardItem(QObject::tr("็งๅฎค")));
m_resultsModel->setHorizontalHeaderItem(4,new QStandardItem(QObject::tr("ๅป็")));
m_resultsModel->setItem(0, 3, NULL);
}
void FindClincChargeDlg::find()
{
initTable();
QString strId = m_chargeNumEdit->text();
QString strName = m_nameEdit->text();
Gender eGender = (Gender)m_genderComboBox->currentIndex();
QSqlTableModel *model = new QSqlTableModel;
model->setTable(g_strClinicCharge);
QString strSql = "" , strTemp = "";
strTemp = "Gender = " + QString::number((int)eGender);
strSql += strTemp;
if(!strId.isEmpty())
{
strTemp = " and ID = \'" + strId + "\'";
strSql += strTemp;
}
if(!strName.isEmpty())
{
strTemp = " and Name = \'" + strName + "\'";
strSql += strTemp;
}
model->setFilter(strSql);
model->select();
for(int i = 0; i < model->rowCount();i++)
{
QSqlRecord record = model->record(i);
m_resultsModel->setItem(i,0,new QStandardItem(record.value("ID").toString()));
m_resultsModel->setItem(i,1,new QStandardItem(record.value("Time").toString()));
m_resultsModel->setItem(i,2,new QStandardItem(record.value("Name").toString()));
m_resultsModel->setItem(i,3,new QStandardItem(record.value("Department").toString()));
m_resultsModel->setItem(i,4,new QStandardItem(record.value("Doctor").toString()));
}
}
void FindClincChargeDlg::choise()
{
QModelIndex index = m_resultsTableView->currentIndex();
if(index.isValid())
{
QStandardItem *item = m_resultsModel->item(index.row(),0);
m_strId = item->text();
close();
}
}
| [
"xuebei@seimun.com"
] | xuebei@seimun.com |
21873a3f001ced8a7e6ef74f4ab736fa3259dafc | abbcbc47870c0d49f9aedbe50e7a1e10ba3165d5 | /src/Lcd/LcdInterface.h | 27f25abf61c1f97675e0590926623d1083759585 | [] | no_license | ghost7/gameboyC | 4c999891809f9ea9b799e5909487b2f69c08eb85 | fba672bb4ace0cdf9f5d48fcf94cbf632b1d962b | refs/heads/master | 2020-06-09T05:16:02.625035 | 2012-07-17T17:31:55 | 2012-07-17T17:31:55 | 3,037,999 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,021 | h | #ifndef _LCD_INTERFACE_
#define _LCD_INTERFACE_
#include <stdint.h>
/**
* This defines the LCD screen of the game boy.
*/
class LcdInterface
{
public:
/**
* Initialize the LCD with an array of pixels. The LCD will "draw" on these
* pixels
*
* @param pixels 160x144 array of pixels.
*/
virtual void init(uint32_t* pixels) = 0;
/**
* Advance all LCD timings by a given amount of cycles.
*
* @paran cycles Number of cycles to advance by.
*/
virtual void step(int cycles) = 0;
/**
* Notifies the client code that the LCD is dirty. This means that the LCD
* has modified the array of pixels and the screen can be updated.
*
* @return True if the screen should be updated, false otherwise.
*/
virtual bool isDirty() = 0;
/**
* After the client has updated the screen, this function should be called
* to notify the LCD that it is no longer in a dirty state.
*/
virtual void clean() = 0;
};
#endif
| [
"ghost7dev@gmail.com"
] | ghost7dev@gmail.com |
afebbe7f3fc49081676f1a7880c315e0faca2e22 | f5e46fc1f26506245dfc3f6bf170bc03067e4e80 | /swea_4014.cpp | 5bf13f5d358e97a324e7a1d2cc31fc5e14072cb1 | [] | no_license | 0ul/Alg | 110cc926224c564afc1c2b2e48b6185ede3b8cb8 | 3510e060c7c88cfc3a4c76627ee9fb06ad79ce18 | refs/heads/master | 2020-03-28T18:34:09.444001 | 2018-11-02T07:09:00 | 2018-11-02T07:09:00 | 148,892,168 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 2,797 | cpp | // 4014 ํ์ฃผ๋ก ๊ฑด์ค
#include <cstdio>
#include <vector>
using namespace std;
int T, N, X, ans;
vector<vector<int>> map; //์
๋ ฅ ์ ์ฅ
vector<vector<int>> v, v1; //๊ฒฝ์ฌ๋ก ๊ฑด์คํ๋์ง ์๋์ง
bool visit(int i, int j, int type, int dir) { // type ๊ฐ๋ก์ธ๋ก dir ์ค๋ฅด๋ง ๋ด๋ฆฌ๋ง
int idx = 0;
if (type == 0 && dir == 0) { //๊ฐ๋ก ๊ฒ์ฌํ๋๋ฐ ์ค๋ฅด๋ง
while (idx < X) {
if (j - idx < 0)
return false;
if (v[i][j - idx] == 1)
return false;
idx++;
}
idx = 0;
while (idx < X) {
v[i][j - idx] = 1;
idx++;
}
return true;
}
else if (type == 0 && dir == 1) { //๊ฐ๋ก ๊ฒ์ฌํ๋๋ฐ ๋ด๋ฆฌ๋ง
while (idx < X) {
if (j + idx >= N)
return false;
if (v[i][j + idx] == 1)
return false;
idx++;
}
idx = 0;
while (idx < X) {
v[i][j + idx] = 1;
idx++;
}
return true;
}
else if (type == 1 && dir == 0) { //์ธ๋ก ๊ฒ์ฌํ๋๋ฐ ์ค๋ฅด๋ง
while (idx < X) {
if (j - idx < 0)
return false;
if (v1[j - idx][i] == 1)
return false;
idx++;
}
idx = 0;
while (idx < X) {
v1[j - idx][i] = 1;
idx++;
}
return true;
}
else {
while (idx < X) {
if (j + idx >= N)
return false;
if (v1[j + idx][i] == 1)
return false;
idx++;
}
idx = 0;
while (idx < X) {
v1[j + idx][i] = 1;
idx++;
}
return true;
}
}
void chk(int type) { //type 0:๊ฐ๋ก๊ฒ์ฌ 1:์ธ๋ก๊ฒ์ฌ
int can;
if (type == 0) {
for (int i = 0; i < N; i++) {
can = 1;
for (int j = 0; j < N - 1; j++) {
if (map[i][j] == map[i][j + 1])
continue;
if (map[i][j] + 1 == map[i][j + 1]) { //์ค๋ฅด๋ง
if (!visit(i, j, 0, 0)) {
can = 0;
break;
}
}
else if (map[i][j] - 1 == map[i][j + 1]) { // ๋ด๋ฆฌ๋ง
if (!visit(i, j + 1, 0, 1)) {
can = 0;
break;
}
}
else {
can = 0;
break;
}
}
if (can == 1)
ans++;
}
}
else {
for (int i = 0; i < N; i++) {
can = 1;
for (int j = 0; j < N - 1; j++) {
if (map[j][i] == map[j + 1][i])
continue;
if (map[j][i] + 1 == map[j + 1][i]) { //์ค๋ฅด๋ง
if (!visit(i, j, 1, 0)) {
can = 0;
break;
}
}
else if (map[j][i] - 1 == map[j + 1][i]) { // ๋ด๋ฆฌ๋ง
if (!visit(i, j + 1, 1, 1)) {
can = 0;
break;
}
}
else {
can = 0;
break;
}
}
if (can == 1)
ans++;
}
}
}
int main() {
scanf("%d", &T);
for (int tc = 1; tc <= T; tc++) {
map.clear(); v.clear(); v1.clear();
scanf("%d%d", &N, &X);
for (int i = 0; i < N; i++) {
vector<int> tmp(N);
map.push_back(tmp);
v.push_back(tmp);
v1.push_back(tmp);
for (int j = 0; j < N; j++) {
scanf("%d", &map[i][j]);
}
}
ans = 0;
chk(0);
chk(1);
printf("#%d %d\n", tc, ans);
}
return 0;
} | [
"benrtt@naver.com"
] | benrtt@naver.com |
ea22dc456fda6487daf62fee428d704b8d0cde47 | 6ed471f36e5188f77dc61cca24daa41496a6d4a0 | /SDK/ProjFireBall_functions.cpp | e6ef1f9871f2fb1692808bcc45219691cfafc2fe | [] | no_license | zH4x-SDK/zARKSotF-SDK | 77bfaf9b4b9b6a41951ee18db88f826dd720c367 | 714730f4bb79c07d065181caf360d168761223f6 | refs/heads/main | 2023-07-16T22:33:15.140456 | 2021-08-27T13:40:06 | 2021-08-27T13:40:06 | 400,521,086 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,319 | cpp |
#include "../SDK.h"
// Name: ARKSotF, Version: 178.8.0
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------
// Function ProjFireBall.ProjFireBall_C.UserConstructionScript
// ()
void AProjFireBall_C::UserConstructionScript()
{
static auto fn = UObject::FindObject<UFunction>("Function ProjFireBall.ProjFireBall_C.UserConstructionScript");
AProjFireBall_C_UserConstructionScript_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function ProjFireBall.ProjFireBall_C.ExecuteUbergraph_ProjFireBall
// ()
// Parameters:
// int EntryPoint (Parm, ZeroConstructor, IsPlainOldData)
void AProjFireBall_C::ExecuteUbergraph_ProjFireBall(int EntryPoint)
{
static auto fn = UObject::FindObject<UFunction>("Function ProjFireBall.ProjFireBall_C.ExecuteUbergraph_ProjFireBall");
AProjFireBall_C_ExecuteUbergraph_ProjFireBall_Params params;
params.EntryPoint = EntryPoint;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"zp2kshield@gmail.com"
] | zp2kshield@gmail.com |
e0b508ab34929bbd62dd2aac5d89528a42fac830 | f23e6027b98ce89ccdf946bbc0aaa8d90ac54ce5 | /src/erhe/graphics/erhe_graphics/gl_context_provider.cpp | 2c03ba337c0b9de248bfadc49651ca809096416f | [
"MIT",
"Zlib",
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] | permissive | tksuoran/erhe | 8476cba96d73d4636aad2a40daaa707fd00b112f | d8a3393113aac273fe2446894f287d9a7889e0a7 | refs/heads/main | 2023-09-04T11:06:39.665543 | 2023-09-02T16:15:32 | 2023-09-02T16:15:32 | 363,416,834 | 412 | 45 | NOASSERTION | 2023-07-15T11:06:09 | 2021-05-01T13:29:16 | C++ | UTF-8 | C++ | false | false | 4,372 | cpp | #include "erhe_graphics/graphics_log.hpp"
#include "erhe_graphics/gl_context_provider.hpp"
#include "erhe_graphics/opengl_state_tracker.hpp"
#include "erhe_profile/profile.hpp"
#include "erhe_verify/verify.hpp"
#include "erhe_window/window.hpp"
#include <functional>
namespace erhe::graphics {
Gl_context_provider::Gl_context_provider(
erhe::graphics::Instance& graphics_instance,
OpenGL_state_tracker& opengl_state_tracker
)
: m_graphics_instance {graphics_instance}
, m_opengl_state_tracker{opengl_state_tracker}
, m_main_thread_id {std::this_thread::get_id()}
{
}
void Gl_context_provider::provide_worker_contexts(
erhe::window::Context_window* main_window,
std::function<bool()> worker_contexts_still_needed_callback
)
{
ERHE_PROFILE_FUNCTION();
log_context->info("Starting to provide worked GL contexts");
ERHE_VERIFY(m_main_thread_id == std::this_thread::get_id());
m_main_window = main_window;
{
ERHE_PROFILE_SCOPE("main_window->clear_current()");
main_window->clear_current();
}
auto max_count = std::min(std::thread::hardware_concurrency(), 8u);
for (auto end = max_count, i = 0u; i < end; ++i) {
ERHE_PROFILE_SCOPE("Worker context");
if (!worker_contexts_still_needed_callback()) {
ERHE_PROFILE_MESSAGE_LITERAL("No more GL worker thread contexts needed");
log_context->info("No more GL worker thread contexts needed");
break;
}
ERHE_PROFILE_MESSAGE_LITERAL("Creating another GL worker thread context");
auto context = std::make_shared<erhe::window::Context_window>(main_window);
m_contexts.push_back(context);
context->clear_current();
Gl_worker_context context_wrapper{
static_cast<int>(i),
context.get()
};
m_worker_context_pool.enqueue(context_wrapper);
m_condition_variable.notify_one();
}
ERHE_PROFILE_MESSAGE_LITERAL("Done creating GL worker thread contexts");
log_context->info("Done creating GL worker thread contexts");
{
ERHE_PROFILE_SCOPE("main_window->make_current()");
main_window->make_current();
}
}
auto Gl_context_provider::acquire_gl_context() -> Gl_worker_context
{
ERHE_PROFILE_COLOR("acquire_gl_context", 0x444444);
if (std::this_thread::get_id() == m_main_thread_id) {
log_context->trace("acquire_gl_context() called from main thread - immediate return");
return {};
}
Gl_worker_context context;
while (!m_worker_context_pool.try_dequeue(context)) {
log_context->trace("Waiting for available GL context");
//ERHE_PROFILE_MESSAGE_LITERAL("Waiting for available GL context");
std::unique_lock<std::mutex> lock(m_mutex);
m_condition_variable.wait(lock);
}
//const std::string text = fmt::format("Got GL context {}", context.id);
log_context->trace("Got GL context {}", context.id);
//ERHE_PROFILE_MESSAGE(text.c_str(), text.length());
//ZoneValue(context.id);
ERHE_VERIFY(context.context != nullptr);
context.context->make_current();
log_context->trace("Made current GL context {}", context.id);
return context;
}
void Gl_context_provider::release_gl_context(Gl_worker_context context)
{
ERHE_PROFILE_FUNCTION();
if (std::this_thread::get_id() == m_main_thread_id) {
ERHE_VERIFY(context.id == 0);
ERHE_VERIFY(context.context == nullptr);
return;
}
ERHE_VERIFY(context.context != nullptr);
log_context->trace("Releasing GL context {}", context.id);
//const std::string text = fmt::format("Releasing GL context {}", context.id);
//ERHE_PROFILE_MESSAGE(text.c_str(), text.length());
//ZoneValue(context.id);
m_opengl_state_tracker.on_thread_exit();
context.context->clear_current();
m_worker_context_pool.enqueue(context);
m_condition_variable.notify_one();
log_context->trace("Released GL context {}", context.id);
}
Scoped_gl_context::Scoped_gl_context(Gl_context_provider& context_provider)
: m_context_provider{context_provider}
, m_context{context_provider.acquire_gl_context()}
{
}
Scoped_gl_context::~Scoped_gl_context() noexcept
{
ERHE_PROFILE_FUNCTION();
m_context_provider.release_gl_context(m_context);
}
} // namespace erhe::graphics
| [
"tksuoran@gmail.com"
] | tksuoran@gmail.com |
d3ffb6f90cf51137fc7c33b8af13cffd87f32f08 | c9c1d8784a0905e21247076a8b70fc4ebb475184 | /Trees_Graphs/dijkstra.cpp | 92489799e2a1dbbd6121627e7a22a6a1ced13a64 | [] | no_license | kirito-udit/competitive-programming-library | f1aab402161bfd5d20968eaa202fda7a42fbff96 | 794f59553ff4bb703b06e03427c8b3e092350131 | refs/heads/master | 2023-08-14T01:38:54.865618 | 2021-09-29T17:39:50 | 2021-09-29T17:39:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 582 | cpp | void solve(vector<vector<pair<int,ll>>>& g, vector<ll>& d, vector<int>& p, int s) {
int n = g.size();
priority_queue<pair<ll,int> , vector<pair<ll,int>>, greater<pair<ll,int>>> dijkstra;
d[s] = 0; dijkstra.push({d[s],s});
while(!dijkstra.empty()) {
auto [l, node] = dijkstra.top(); dijkstra.pop();
if(l != d[node]) continue;
for(auto [to, len] : g[node]) {
if(d[node] + len < d[to]) {
d[to] = d[node] + len;
p[to] = node;
dijkstra.push({d[to],to});
}
}
}
}
| [
"diptarag1@gmail.com"
] | diptarag1@gmail.com |
ee3e2fd883206078485bc7a55abc93c45f722157 | 70599f0ea828564278b33ba46966c4b32ac78d56 | /src/qt/kts/prunnable.h | e3318d6167f76b03801cb678f92d6e371c132fa4 | [
"MIT"
] | permissive | klimatas/klimatas-core | 9b4c95a93ca4f6e42d98df7f4ff4ea2864f9ba7f | 7421ecd2ba1a88dcc15a1dc95f66e82e398cfe90 | refs/heads/master | 2022-05-21T01:05:07.481022 | 2022-03-29T15:40:42 | 2022-03-29T15:40:42 | 167,570,221 | 8 | 25 | MIT | 2022-03-29T15:40:43 | 2019-01-25T15:38:30 | C++ | UTF-8 | C++ | false | false | 461 | h | // Copyright (c) 2019 The PIVX developers
// Copyright (c) 2020 The Klimatas developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef KTS_CORE_NEW_GUI_PRUNNABLE_H
#define KTS_CORE_NEW_GUI_PRUNNABLE_H
class Runnable {
public:
virtual void run(int type) = 0;
virtual void onError(QString error, int type) = 0;
};
#endif //KTS_CORE_NEW_GUI_PRUNNABLE_H
| [
"m.vanamstel@dutchcrypto.works"
] | m.vanamstel@dutchcrypto.works |
118ce0d6103e7b4da8100fc9954ad447e0b5a585 | 7a7addc0e81bbd75fcb4912195adaf3032b2c24d | /Other/Algorithms/Graph Algorithms/Bellman Ford.cpp | 335252d55de2a0f139c669ae5d9a08207b8ee8d7 | [] | no_license | saribekyan/competitive-programming | 6e492ee0c1550fc4bab538a965e4825609cfbda2 | eeae87c2c40d85680b97a5d5f27e4dfbc02437e7 | refs/heads/master | 2021-05-04T03:07:22.576203 | 2019-04-06T14:55:55 | 2019-04-06T14:55:55 | 120,372,197 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 500 | cpp | #include <stdio.h>
int d[1000];
int edge[10000][3];
int main()
{
int n, m, s, p, q, i, j;
scanf("%d%d%d", &n, &m, &s);
for (i = 0; i < m; i++)
scanf("%d%d%d", edge[i], edge[i]+1, edge[i]+2);
for (i = 0; i < n; i++)
d[i] = 123456789;
d[s] = 0;
for (i = 0; i < n-1; i++)
for (j = 0; j < m; j++)
if (d[edge[j][1]] > d[edge[j][0]]+edge[j][2])
d[edge[j][1]] = d[edge[j][0]]+edge[j][2];
for (i = 0; i < n; i++)
printf("%d ", d[i]);
putchar('\n');
return 0;
}
| [
"shaykshe@gmail.com"
] | shaykshe@gmail.com |
42feb5d48e3ebe427f896209a6a8bcacac3ed5b8 | 3b9b4049a8e7d38b49e07bb752780b2f1d792851 | /src/third_party/webrtc/modules/audio_coding/neteq/nack_tracker_unittest.cc | e5c0c3bc4d0463e0a8907c58fc8b0b24556a6de9 | [
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-google-patent-license-webrtc",
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown",
"MS-LPL",
"LicenseRef-scancode-takuy... | permissive | webosce/chromium53 | f8e745e91363586aee9620c609aacf15b3261540 | 9171447efcf0bb393d41d1dc877c7c13c46d8e38 | refs/heads/webosce | 2020-03-26T23:08:14.416858 | 2018-08-23T08:35:17 | 2018-09-20T14:25:18 | 145,513,343 | 0 | 2 | Apache-2.0 | 2019-08-21T22:44:55 | 2018-08-21T05:52:31 | null | UTF-8 | C++ | false | false | 18,294 | cc | /*
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/modules/audio_coding/neteq/nack_tracker.h"
#include <stdint.h>
#include <algorithm>
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/typedefs.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
namespace webrtc {
namespace {
const int kNackThreshold = 3;
const int kSampleRateHz = 16000;
const int kPacketSizeMs = 30;
const uint32_t kTimestampIncrement = 480; // 30 ms.
const int64_t kShortRoundTripTimeMs = 1;
bool IsNackListCorrect(const std::vector<uint16_t>& nack_list,
const uint16_t* lost_sequence_numbers,
size_t num_lost_packets) {
if (nack_list.size() != num_lost_packets)
return false;
if (num_lost_packets == 0)
return true;
for (size_t k = 0; k < nack_list.size(); ++k) {
int seq_num = nack_list[k];
bool seq_num_matched = false;
for (size_t n = 0; n < num_lost_packets; ++n) {
if (seq_num == lost_sequence_numbers[n]) {
seq_num_matched = true;
break;
}
}
if (!seq_num_matched)
return false;
}
return true;
}
} // namespace
TEST(NackTrackerTest, EmptyListWhenNoPacketLoss) {
std::unique_ptr<NackTracker> nack(NackTracker::Create(kNackThreshold));
nack->UpdateSampleRate(kSampleRateHz);
int seq_num = 1;
uint32_t timestamp = 0;
std::vector<uint16_t> nack_list;
for (int n = 0; n < 100; n++) {
nack->UpdateLastReceivedPacket(seq_num, timestamp);
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
seq_num++;
timestamp += kTimestampIncrement;
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(nack_list.empty());
}
}
TEST(NackTrackerTest, NoNackIfReorderWithinNackThreshold) {
std::unique_ptr<NackTracker> nack(NackTracker::Create(kNackThreshold));
nack->UpdateSampleRate(kSampleRateHz);
int seq_num = 1;
uint32_t timestamp = 0;
std::vector<uint16_t> nack_list;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(nack_list.empty());
int num_late_packets = kNackThreshold + 1;
// Push in reverse order
while (num_late_packets > 0) {
nack->UpdateLastReceivedPacket(
seq_num + num_late_packets,
timestamp + num_late_packets * kTimestampIncrement);
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(nack_list.empty());
num_late_packets--;
}
}
TEST(NackTrackerTest, LatePacketsMovedToNackThenNackListDoesNotChange) {
const uint16_t kSequenceNumberLostPackets[] = {2, 3, 4, 5, 6, 7, 8, 9};
static const int kNumAllLostPackets = sizeof(kSequenceNumberLostPackets) /
sizeof(kSequenceNumberLostPackets[0]);
for (int k = 0; k < 2; k++) { // Two iteration with/without wrap around.
std::unique_ptr<NackTracker> nack(NackTracker::Create(kNackThreshold));
nack->UpdateSampleRate(kSampleRateHz);
uint16_t sequence_num_lost_packets[kNumAllLostPackets];
for (int n = 0; n < kNumAllLostPackets; n++) {
sequence_num_lost_packets[n] =
kSequenceNumberLostPackets[n] +
k * 65531; // Have wrap around in sequence numbers for |k == 1|.
}
uint16_t seq_num = sequence_num_lost_packets[0] - 1;
uint32_t timestamp = 0;
std::vector<uint16_t> nack_list;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(nack_list.empty());
seq_num = sequence_num_lost_packets[kNumAllLostPackets - 1] + 1;
timestamp += kTimestampIncrement * (kNumAllLostPackets + 1);
int num_lost_packets = std::max(0, kNumAllLostPackets - kNackThreshold);
for (int n = 0; n < kNackThreshold + 1; ++n) {
nack->UpdateLastReceivedPacket(seq_num, timestamp);
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(IsNackListCorrect(nack_list, sequence_num_lost_packets,
num_lost_packets));
seq_num++;
timestamp += kTimestampIncrement;
num_lost_packets++;
}
for (int n = 0; n < 100; ++n) {
nack->UpdateLastReceivedPacket(seq_num, timestamp);
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(IsNackListCorrect(nack_list, sequence_num_lost_packets,
kNumAllLostPackets));
seq_num++;
timestamp += kTimestampIncrement;
}
}
}
TEST(NackTrackerTest, ArrivedPacketsAreRemovedFromNackList) {
const uint16_t kSequenceNumberLostPackets[] = {2, 3, 4, 5, 6, 7, 8, 9};
static const int kNumAllLostPackets = sizeof(kSequenceNumberLostPackets) /
sizeof(kSequenceNumberLostPackets[0]);
for (int k = 0; k < 2; ++k) { // Two iteration with/without wrap around.
std::unique_ptr<NackTracker> nack(NackTracker::Create(kNackThreshold));
nack->UpdateSampleRate(kSampleRateHz);
uint16_t sequence_num_lost_packets[kNumAllLostPackets];
for (int n = 0; n < kNumAllLostPackets; ++n) {
sequence_num_lost_packets[n] = kSequenceNumberLostPackets[n] +
k * 65531; // Wrap around for |k == 1|.
}
uint16_t seq_num = sequence_num_lost_packets[0] - 1;
uint32_t timestamp = 0;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
std::vector<uint16_t> nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(nack_list.empty());
size_t index_retransmitted_rtp = 0;
uint32_t timestamp_retransmitted_rtp = timestamp + kTimestampIncrement;
seq_num = sequence_num_lost_packets[kNumAllLostPackets - 1] + 1;
timestamp += kTimestampIncrement * (kNumAllLostPackets + 1);
size_t num_lost_packets = std::max(0, kNumAllLostPackets - kNackThreshold);
for (int n = 0; n < kNumAllLostPackets; ++n) {
// Number of lost packets does not change for the first
// |kNackThreshold + 1| packets, one is added to the list and one is
// removed. Thereafter, the list shrinks every iteration.
if (n >= kNackThreshold + 1)
num_lost_packets--;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(IsNackListCorrect(
nack_list, &sequence_num_lost_packets[index_retransmitted_rtp],
num_lost_packets));
seq_num++;
timestamp += kTimestampIncrement;
// Retransmission of a lost RTP.
nack->UpdateLastReceivedPacket(
sequence_num_lost_packets[index_retransmitted_rtp],
timestamp_retransmitted_rtp);
index_retransmitted_rtp++;
timestamp_retransmitted_rtp += kTimestampIncrement;
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(IsNackListCorrect(
nack_list, &sequence_num_lost_packets[index_retransmitted_rtp],
num_lost_packets - 1)); // One less lost packet in the list.
}
ASSERT_TRUE(nack_list.empty());
}
}
// Assess if estimation of timestamps and time-to-play is correct. Introduce all
// combinations that timestamps and sequence numbers might have wrap around.
TEST(NackTrackerTest, EstimateTimestampAndTimeToPlay) {
const uint16_t kLostPackets[] = {2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15};
static const int kNumAllLostPackets =
sizeof(kLostPackets) / sizeof(kLostPackets[0]);
for (int k = 0; k < 4; ++k) {
std::unique_ptr<NackTracker> nack(NackTracker::Create(kNackThreshold));
nack->UpdateSampleRate(kSampleRateHz);
// Sequence number wrap around if |k| is 2 or 3;
int seq_num_offset = (k < 2) ? 0 : 65531;
// Timestamp wrap around if |k| is 1 or 3.
uint32_t timestamp_offset =
(k & 0x1) ? static_cast<uint32_t>(0xffffffff) - 6 : 0;
uint32_t timestamp_lost_packets[kNumAllLostPackets];
uint16_t seq_num_lost_packets[kNumAllLostPackets];
for (int n = 0; n < kNumAllLostPackets; ++n) {
timestamp_lost_packets[n] =
timestamp_offset + kLostPackets[n] * kTimestampIncrement;
seq_num_lost_packets[n] = seq_num_offset + kLostPackets[n];
}
// We and to push two packets before lost burst starts.
uint16_t seq_num = seq_num_lost_packets[0] - 2;
uint32_t timestamp = timestamp_lost_packets[0] - 2 * kTimestampIncrement;
const uint16_t first_seq_num = seq_num;
const uint32_t first_timestamp = timestamp;
// Two consecutive packets to have a correct estimate of timestamp increase.
nack->UpdateLastReceivedPacket(seq_num, timestamp);
seq_num++;
timestamp += kTimestampIncrement;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
// A packet after the last one which is supposed to be lost.
seq_num = seq_num_lost_packets[kNumAllLostPackets - 1] + 1;
timestamp =
timestamp_lost_packets[kNumAllLostPackets - 1] + kTimestampIncrement;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
NackTracker::NackList nack_list = nack->GetNackList();
EXPECT_EQ(static_cast<size_t>(kNumAllLostPackets), nack_list.size());
// Pretend the first packet is decoded.
nack->UpdateLastDecodedPacket(first_seq_num, first_timestamp);
nack_list = nack->GetNackList();
NackTracker::NackList::iterator it = nack_list.begin();
while (it != nack_list.end()) {
seq_num = it->first - seq_num_offset;
int index = seq_num - kLostPackets[0];
EXPECT_EQ(timestamp_lost_packets[index], it->second.estimated_timestamp);
EXPECT_EQ((index + 2) * kPacketSizeMs, it->second.time_to_play_ms);
++it;
}
// Pretend 10 ms is passed, and we had pulled audio from NetEq, it still
// reports the same sequence number as decoded, time-to-play should be
// updated by 10 ms.
nack->UpdateLastDecodedPacket(first_seq_num, first_timestamp);
nack_list = nack->GetNackList();
it = nack_list.begin();
while (it != nack_list.end()) {
seq_num = it->first - seq_num_offset;
int index = seq_num - kLostPackets[0];
EXPECT_EQ((index + 2) * kPacketSizeMs - 10, it->second.time_to_play_ms);
++it;
}
}
}
TEST(NackTrackerTest,
MissingPacketsPriorToLastDecodedRtpShouldNotBeInNackList) {
for (int m = 0; m < 2; ++m) {
uint16_t seq_num_offset = (m == 0) ? 0 : 65531; // Wrap around if |m| is 1.
std::unique_ptr<NackTracker> nack(NackTracker::Create(kNackThreshold));
nack->UpdateSampleRate(kSampleRateHz);
// Two consecutive packets to have a correct estimate of timestamp increase.
uint16_t seq_num = 0;
nack->UpdateLastReceivedPacket(seq_num_offset + seq_num,
seq_num * kTimestampIncrement);
seq_num++;
nack->UpdateLastReceivedPacket(seq_num_offset + seq_num,
seq_num * kTimestampIncrement);
// Skip 10 packets (larger than NACK threshold).
const int kNumLostPackets = 10;
seq_num += kNumLostPackets + 1;
nack->UpdateLastReceivedPacket(seq_num_offset + seq_num,
seq_num * kTimestampIncrement);
const size_t kExpectedListSize = kNumLostPackets - kNackThreshold;
std::vector<uint16_t> nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_EQ(kExpectedListSize, nack_list.size());
for (int k = 0; k < 2; ++k) {
// Decoding of the first and the second arrived packets.
for (int n = 0; n < kPacketSizeMs / 10; ++n) {
nack->UpdateLastDecodedPacket(seq_num_offset + k,
k * kTimestampIncrement);
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_EQ(kExpectedListSize, nack_list.size());
}
}
// Decoding of the last received packet.
nack->UpdateLastDecodedPacket(seq_num + seq_num_offset,
seq_num * kTimestampIncrement);
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(nack_list.empty());
// Make sure list of late packets is also empty. To check that, push few
// packets, if the late list is not empty its content will pop up in NACK
// list.
for (int n = 0; n < kNackThreshold + 10; ++n) {
seq_num++;
nack->UpdateLastReceivedPacket(seq_num_offset + seq_num,
seq_num * kTimestampIncrement);
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(nack_list.empty());
}
}
}
TEST(NackTrackerTest, Reset) {
std::unique_ptr<NackTracker> nack(NackTracker::Create(kNackThreshold));
nack->UpdateSampleRate(kSampleRateHz);
// Two consecutive packets to have a correct estimate of timestamp increase.
uint16_t seq_num = 0;
nack->UpdateLastReceivedPacket(seq_num, seq_num * kTimestampIncrement);
seq_num++;
nack->UpdateLastReceivedPacket(seq_num, seq_num * kTimestampIncrement);
// Skip 10 packets (larger than NACK threshold).
const int kNumLostPackets = 10;
seq_num += kNumLostPackets + 1;
nack->UpdateLastReceivedPacket(seq_num, seq_num * kTimestampIncrement);
const size_t kExpectedListSize = kNumLostPackets - kNackThreshold;
std::vector<uint16_t> nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_EQ(kExpectedListSize, nack_list.size());
nack->Reset();
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(nack_list.empty());
}
TEST(NackTrackerTest, ListSizeAppliedFromBeginning) {
const size_t kNackListSize = 10;
for (int m = 0; m < 2; ++m) {
uint16_t seq_num_offset = (m == 0) ? 0 : 65525; // Wrap around if |m| is 1.
std::unique_ptr<NackTracker> nack(NackTracker::Create(kNackThreshold));
nack->UpdateSampleRate(kSampleRateHz);
nack->SetMaxNackListSize(kNackListSize);
uint16_t seq_num = seq_num_offset;
uint32_t timestamp = 0x12345678;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
// Packet lost more than NACK-list size limit.
uint16_t num_lost_packets = kNackThreshold + kNackListSize + 5;
seq_num += num_lost_packets + 1;
timestamp += (num_lost_packets + 1) * kTimestampIncrement;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
std::vector<uint16_t> nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_EQ(kNackListSize - kNackThreshold, nack_list.size());
}
}
TEST(NackTrackerTest, ChangeOfListSizeAppliedAndOldElementsRemoved) {
const size_t kNackListSize = 10;
for (int m = 0; m < 2; ++m) {
uint16_t seq_num_offset = (m == 0) ? 0 : 65525; // Wrap around if |m| is 1.
std::unique_ptr<NackTracker> nack(NackTracker::Create(kNackThreshold));
nack->UpdateSampleRate(kSampleRateHz);
uint16_t seq_num = seq_num_offset;
uint32_t timestamp = 0x87654321;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
// Packet lost more than NACK-list size limit.
uint16_t num_lost_packets = kNackThreshold + kNackListSize + 5;
std::unique_ptr<uint16_t[]> seq_num_lost(new uint16_t[num_lost_packets]);
for (int n = 0; n < num_lost_packets; ++n) {
seq_num_lost[n] = ++seq_num;
}
++seq_num;
timestamp += (num_lost_packets + 1) * kTimestampIncrement;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
size_t expected_size = num_lost_packets - kNackThreshold;
std::vector<uint16_t> nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_EQ(expected_size, nack_list.size());
nack->SetMaxNackListSize(kNackListSize);
expected_size = kNackListSize - kNackThreshold;
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(IsNackListCorrect(
nack_list, &seq_num_lost[num_lost_packets - kNackListSize],
expected_size));
// NACK list does not change size but the content is changing. The oldest
// element is removed and one from late list is inserted.
size_t n;
for (n = 1; n <= static_cast<size_t>(kNackThreshold); ++n) {
++seq_num;
timestamp += kTimestampIncrement;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(IsNackListCorrect(
nack_list, &seq_num_lost[num_lost_packets - kNackListSize + n],
expected_size));
}
// NACK list should shrink.
for (; n < kNackListSize; ++n) {
++seq_num;
timestamp += kTimestampIncrement;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
--expected_size;
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(IsNackListCorrect(
nack_list, &seq_num_lost[num_lost_packets - kNackListSize + n],
expected_size));
}
// After this packet, NACK list should be empty.
++seq_num;
timestamp += kTimestampIncrement;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
nack_list = nack->GetNackList(kShortRoundTripTimeMs);
EXPECT_TRUE(nack_list.empty());
}
}
TEST(NackTrackerTest, RoudTripTimeIsApplied) {
const int kNackListSize = 200;
std::unique_ptr<NackTracker> nack(NackTracker::Create(kNackThreshold));
nack->UpdateSampleRate(kSampleRateHz);
nack->SetMaxNackListSize(kNackListSize);
uint16_t seq_num = 0;
uint32_t timestamp = 0x87654321;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
// Packet lost more than NACK-list size limit.
uint16_t kNumLostPackets = kNackThreshold + 5;
seq_num += (1 + kNumLostPackets);
timestamp += (1 + kNumLostPackets) * kTimestampIncrement;
nack->UpdateLastReceivedPacket(seq_num, timestamp);
// Expected time-to-play are:
// kPacketSizeMs - 10, 2*kPacketSizeMs - 10, 3*kPacketSizeMs - 10, ...
//
// sequence number: 1, 2, 3, 4, 5
// time-to-play: 20, 50, 80, 110, 140
//
std::vector<uint16_t> nack_list = nack->GetNackList(100);
ASSERT_EQ(2u, nack_list.size());
EXPECT_EQ(4, nack_list[0]);
EXPECT_EQ(5, nack_list[1]);
}
} // namespace webrtc
| [
"changhyeok.bae@lge.com"
] | changhyeok.bae@lge.com |
64b85dcea4bf41f420084a66a0b7a4a46965e81d | 58c4e7756a9ebdf8fcd36cee6206f78e0ac49784 | /nar3ncesorting.cpp | ed2853fc3146bf9270dea154bd8aa7ae05a5362b | [] | no_license | nar3nce/Projects-cpp | 3f4cdf70dfc5f2fda35eb231372b8a2ca28398b9 | 9d99ce76c9c8fd11e5ee495d139db9d0fd00cdfa | refs/heads/master | 2023-02-25T15:08:08.253076 | 2021-02-05T02:25:41 | 2021-02-05T02:25:41 | 336,140,549 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,804 | cpp | #include<iostream.h>
#include<conio.h>
//qsort components
void quick_sort(int[],int,int);
int partition(int[],int,int);
void quick_sort(int a[],int l,int u)
{
int j;
if(l<u)
{
j=partition(a,l,u);
quick_sort(a,l,j-1);
quick_sort(a,j+1,u);
}
}
int partition(int a[],int l,int u)
{
int v,i,j,temp;
v=a[l];
i=l;
j=u+1;
do
{
do
i++;
while(a[i]<v&&i<=u);
do
j--;
while(v<a[j]);
if(i<j)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}while(i<j);
a[l]=a[j];
a[j]=v;
return(j);
}
//end
void bsort()
{
int n, i, arr[50], j, temp;
cout<<"Enter total number of elements : ";
cin>>n;
cout<<"Enter "<<n<<" numbers : ";
for(i=0; i<n; i++)
{
cin>>arr[i];
}
for(i=0; i<(n-1); i++)
{
for(j=0; j<(n-i-1); j++)
{
if(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
cout<<"Array after sorting : ";
for(i=0; i<n; i++)
{
cout<<arr[i]<<" ";
}
}
void isort()
{
int size, arr[50], i, j, temp;
cout<<"Enter Array Size : ";
cin>>size;
cout<<"Enter Array Elements : ";
for(i=0; i<size; i++)
{
cin>>arr[i];
}
for(i=1; i<size; i++)
{
temp=arr[i];
j=i-1;
while((temp<arr[j]) && (j>=0))
{
arr[j+1]=arr[j];
j=j-1;
}
arr[j+1]=temp;
}
cout<<"Array after sorting : ";
for(i=0; i<size; i++)
{
cout<<arr[i]<<" ";
}
}
void selsort()
{
int size, arr[50], i, j, temp;
cout<<"Enter Array Size : ";
cin>>size;
cout<<"Enter Array Elements : ";
for(i=0; i<size; i++)
{
cin>>arr[i];
}
for(i=0; i<size; i++)
{
for(j=i+1; j<size; j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
cout<<"Now the Array after sorting is : ";
for(i=0; i<size; i++)
{
cout<<arr[i]<<" ";
}
}
void main()
{
clrscr();
int yes, sort;
do{
cout<<"Please Select Sorting Algorithm \n1 = quick sort\n2 = bubble sort\n3 = insert sort\n4 = selection sort\n";
cin>>sort;
if(sort == 1)
{
int a[50],n,i;
cout<<"Enter Array Size : ";
cin>>n;
cout<<"Enter Array Elements : ";
for(i=0;i<n;i++)
cin>>a[i];
quick_sort(a,0,n-1);
cout<<"\nArray after sorting : ";
for(i=0;i<n;i++)
cout<<a[i]<<" ";
}
else if (sort == 2)
{
bsort();
}
else if (sort == 3)
{
isort();
}
else if (sort == 4)
{
selsort();
}
else
{
cout<<"Invalid input";
}
cout<<"\nThank you for using! Enter 1 to try again, enter any number to exit : ";
cin>>yes;
}
while(yes == 1);
cout<<"\nThankYou for using my program!";
getch();
} | [
"nar3nce@gmail.com"
] | nar3nce@gmail.com |
a996e96ca6b87f73310e73ef665a954a442290aa | 0fc6eadc8811a6990e0bd41e9a23bf698e738c88 | /cf/502/d.cpp | cafc8fc4b964c36485a4b675cdac14945e1edeaf | [] | no_license | bossxu/acm | f88ee672736709f75739522d7e0f000ac86a31de | 871f8096086e53aadaf48cd098267dfbe6b51e19 | refs/heads/master | 2018-12-27T22:20:27.307185 | 2018-12-20T04:41:51 | 2018-12-20T04:41:51 | 108,379,456 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,586 | cpp | #include<bits/stdc++.h>
using namespace std;
#define clr(shu,x) memset(shu,x,sizeof(shu))
#define INF 0x3f3f3f3f
#define pi acos(-1)
#define loge exp(1)
#define ll long long
#define pb push_back
const int mod = 1e9+7;
const double eps = 1e-6;
int cha[4200][120];
int shu[4200][4200];
int num[4200];
int val[20];
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//freopen("in.txt","r",stdin);
int n,m,q;
while(cin>>n>>m>>q)
{
clr(num,0);
clr(shu,0);
clr(cha,0);
for(int i = 0;i<n;i++)
{
cin>>val[i];
}
for(int i = 1;i<=m;i++)
{
string s;
cin>>s;
//cout<<s<<endl;
int ans = 0;
for(int i = 0;i<n;i++)
{
ans = ans*2+s[i]-'0';
}
//cout<<ans<<endl;
num[ans]++;
}
for(int i = 0;i<(1<<n);i++)
{
for(int j = 0;j<(1<<n);j++)
{
if(num[j]==0) continue;
int a = i,b = j;
int op = 0;
for(int k = n-1;k>=0;k--)
{
if(a%2 == b%2) op += val[k];
a>>=1;b>>=1;
}
shu[i][j] = min(op,101);
}
}
//cout<<"hello"<<endl;
for(int i = 0;i<(1<<n);i++)
{
for(int j = 0;j<(1<<n);j++)
{
cha[i][shu[i][j]]+=num[j];
}
for(int j = 1;j<=100;j++)
{
cha[i][j] += cha[i][j-1];
}
}
for(int i = 1;i<=q;i++)
{
string s;
int k;
cin>>s>>k;
int ans = 0;
for(int i = 0;i<n;i++)
{
ans = ans*2+s[i]-'0';
}
cout<<cha[ans][k]<<endl;
}
}
return 0;
}
| [
"[756753676@qq.com]"
] | [756753676@qq.com] |
e0de9109b79e006dfd3233cd6b5f1eca995a4b5a | d6c7ef2ca0ada0e742545571d817ca48694e304f | /fix64.h | ac6d26e46b783e45ba907cf853457fb40d158083 | [] | no_license | kingking888/android_elf_fix | e0325ac6d1550b25c3088bea48b423184773898a | daef5e7e7a0698df0c9397b0b22940b6819faf30 | refs/heads/master | 2023-06-02T19:37:13.423673 | 2021-06-16T09:02:15 | 2021-06-16T09:02:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,225 | h | #pragma once
#include <fstream>
#include <string>
#include "elf.h"
#include <fstream>
using namespace std;
#define SHN_UNDEF 0
#define NOTE_GNU_BUILD_ID 1
#define HASH 2
#define GNU_HASH 3
#define DYNSYM 4
#define DYNSTR 5
#define GNU_VERSION 6
#define GNU_VERSION_R 7
#define RELA_DYN 8
#define RELA_PLT 9
#define PLT 10
#define TEXT 11
#define RODATA 12
#define EH_FRAME_HDR 13
#define EH_FRAME 14
#define GCC_EXCEPT_TABLE 15
#define NOTE_ANDROID_IDENT 16
#define INIT_ARRAY 17
#define FINI_ARRAY 18
#define DATA_REL_RO 19
#define DYNAMIC 20
#define GOT 21
#define DATA 22
#define BSS 23
#define COMMENT 24
#define SHSTRTAB 25
#define NOTE_GNU_PROPERTY 26
#define NUM 27
void fix_arm64(ifstream& ifs, ofstream& ofs);
void fix_arm64_section_table(Elf64_Ehdr* p_Ehdr, Elf64_Phdr** p_Phdr, Elf64_Shdr** p_Shdr, ifstream& ifs);
void get_program_table_arm64(ifstream& ifs, char* buffer, Elf64_Ehdr* p_Ehdr);
void get_elf_header_arm64(ifstream& ifs, char* buffer);
void move_arm64_section_table(ifstream &ifs, ifstream &ifs0, ofstream& ofs);
void get_elf_section_header_table(ifstream& ifs, char* buffer, Elf64_Ehdr* p_Ehdr);
void copy_elf_shstr_arm64(Elf64_Ehdr* p_Ehdr, Elf64_Shdr** p_Shdr, ifstream& ifs0, ofstream& ofs);
| [
"alex@DESKTOP-PSP4RV0"
] | alex@DESKTOP-PSP4RV0 |
faa89559a50d84dfe5230a0e6c2fe0d389ad7a24 | 62eff5e046a5ad087e28165d8a9b74188c1fa0e0 | /gauss.cpp | 9aa265451c80802bed2c48cb09011f347f6a744b | [] | no_license | Maj333/test | c27c703b8a39ee6e10f369386f0a08d80a432c13 | 6122c445bf2159d32955cf1ba96d283bc05a6604 | refs/heads/master | 2020-06-22T07:20:21.595125 | 2017-04-08T19:03:36 | 2017-04-08T19:03:36 | 74,598,257 | 0 | 0 | null | null | null | null | WINDOWS-1250 | C++ | false | false | 7,461 | cpp | //Rozwiazywanie ukladu rownan liniowych metoda Gaussa
//www.algorytm.org
#include <iostream>
#include <fstream>
#include <algorithm> // swap
#include <cstddef> // size_t
using std::swap;
// a[r][c]
// r - liczba wierszy
// c - liczba kolumnhjkhjkh
template<typename Number> void printMatrix(const Number** a, const std::size_t r, const std::size_t c) {
if(a == nullptr) {
return;
}
for(std::size_t ir = 0; ir < r; ++ir) {
if(a[ir] != nullptr) {
for(std::size_t ic = 0; ic < c; ++ic) {
std::cout << a[ir][ic];
if(ic + 1 < c) {
std::cout << " ";
}
}
}
std::cout << std::endl;
}
}
// x[n]
template<typename Number> void swapElements(Number* x, const std::size_t n, const std::size_t a, const std::size_t b) {
if(x == nullptr) {
return;
}
if(a >= n || b >= n) {
return;
}
swap(x[a], x[b]);
}
// a = a + bx
// a[n]
// b[n]
template<typename Number> void addMultiply(Number* a, const Number* b, const std::size_t n, const Number& x) {
if(a == nullptr || b == nullptr) {
return;
}
for(std::size_t i = 0; i < n; ++i) {
a[i] += b[i] * x;
}
}
enum LinearEquationsSystemSolutionsCount {
LESSC_NoSolutions = 0,
LESSC_UniqueSolution,
LESSC_InfinitelyManySolutions
};
enum LinearEquationsSolverException {
LESE_NullPointer,
LESE_MemAllocError
};
// ax = b
// a - macierz NxN gdzie piwrewszy indeks to numer wiersza/rรณwnania a drugi indeks to numer kolumny/zmiennej
// b - wektor
// x - wynik - wektor zmiennych
// a[n][n]
// b[n]
// x[n]
template<typename Number> LinearEquationsSystemSolutionsCount solveLinearEquationsSystem(
Number** a, Number* b, Number* x, const std::size_t n) {
std::size_t* rowsPerm = new std::size_t[n];
std::size_t* colsPerm = new std::size_t[n];
// Sprawdลบ czy alokacja pamiฤci powiodลa siฤ.
if(rowsPerm == nullptr) {
throw LESE_MemAllocError;
}
if(colsPerm == nullptr) {
delete[] rowsPerm;
throw LESE_MemAllocError;
}
// Sprawdลบ czy nie ma zerowych wskaลบnikรณw.
if(a == nullptr) {
delete[] rowsPerm;
delete[] colsPerm;
throw LESE_NullPointer;
}
for(std::size_t r = 0; r < n; ++r) {
if(a[r] == nullptr) {
delete[] rowsPerm;
delete[] colsPerm;
throw LESE_NullPointer;
}
}
// Wartoลci poczฤ
tkowe w wektorach permutacji
for(std::size_t i = 0; i < n; ++i) {
rowsPerm[i] = i;
colsPerm[i] = i;
}
// Eliminacja Gaussa
for(std::size_t i = 0; i < n; ++i) {
// Znajdลบ niezerowy element macierzy.
bool nonZeroFound = false;
for(std::size_t r = i; r < n; ++r) {
for(std::size_t c = i; c < n; ++c) {
if(a[rowsPerm[r]][colsPerm[c]] != Number(0)) {
swapElements<std::size_t>(rowsPerm, n, r, i);
swapElements<std::size_t>(colsPerm, n, c, i);
nonZeroFound = true;
break;
}
}
if(nonZeroFound) {
break;
}
}
if(!nonZeroFound) {
// Zakoลcz eliminacjฤ Gaussa poniewaลผ pozostaลa czฤลฤ macierzy jest zerowa.
break;
}
// Wyzeruj kolumnฤ.
if(i + 1 < n) {
for(std::size_t r = i + 1; r < n; ++r) {
if(a[rowsPerm[r]][colsPerm[i]] != Number(0)) {
Number q = -(a[rowsPerm[r]][colsPerm[i]]) / (a[rowsPerm[i]][colsPerm[i]]);
addMultiply<Number>(a[rowsPerm[r]], a[rowsPerm[i]], n, q);
b[rowsPerm[r]] += b[rowsPerm[i]] * q;
}
}
}
}
// Wyznacz rozwiฤ
zania.
LinearEquationsSystemSolutionsCount result;
bool infSol = false, resultDefined = false;
for(std::size_t i_1 = n; i_1 > 0; --i_1) {
std::size_t i = i_1 - 1;
Number b_s = b[rowsPerm[i]];
for(std::size_t j = i + 1; j < n; ++j) {
b_s -= a[rowsPerm[i]][colsPerm[j]] * x[colsPerm[j]];
}
const Number& a_ii = a[rowsPerm[i]][colsPerm[i]];
if(a_ii == Number(0)) {
if(b_s == Number(0)) {
infSol = true;
} else {
result = LESSC_NoSolutions;
resultDefined = true;
break;
}
} else if(!infSol) {
x[colsPerm[i]] = b_s / a_ii;
}
}
if(!resultDefined) {
if(infSol) {
result = LESSC_InfinitelyManySolutions;
} else {
result = LESSC_UniqueSolution;
}
}
delete[] rowsPerm;
delete[] colsPerm;
return result;
}
// wynik - tablica[r][c]
template<typename T> T** create2DArray(const std::size_t r, const std::size_t c) {
T** tmp = new T*[r];
if(tmp == nullptr) {
return nullptr;
}
for(std::size_t i = 0; i < r; ++i) {
tmp[i] = new T[c];
if(tmp[i] == nullptr) {
for(std::size_t j = 0; j < i; ++j) {
delete[] tmp[j];
}
delete[] tmp;
return nullptr;
}
}
return tmp;
}
// a[r][]
template<typename T> void destroy2DArray(T** a, const std::size_t r) {
if(a != nullptr) {
for(std::size_t i = 0; i < r; ++i) {
if(a[i] != nullptr) {
delete[] a[i];
}
}
delete[] a;
}
}
// ax = b
// n - liczba rรณwnaล/zmiennych
// a_ij - element macierzy w i-tym wierszy i j-tej kolumnie
// b_i - i-ty element wektora
// Format wejลcia:
// n
// a_11 a_12 ... a_1n
// ...
// a_n1 a_n2 ... a_nn
// b_1 b_2 ... b_n
template<typename Number> bool loadEquations(std::istream& input, Number**& a, Number*& b, std::size_t& n) {
input >> n;
if(!input) {
return false;
}
input.ignore();
b = new Number[n];
if(b == nullptr) {
return false;
}
a = create2DArray<Number>(n, n);
if(a == nullptr) {
delete[] b;
return false;
}
for(std::size_t r = 0; r < n; ++r) {
for(std::size_t c = 0; c < n; ++c) {
input >> a[r][c];
if(!input) {
destroy2DArray(a, n);
delete[] b;
return false;
}
input.ignore();
}
}
for(std::size_t i = 0; i < n; ++i) {
input >> b[i];
if(!input) {
destroy2DArray(a, n);
delete[] b;
return false;
}
input.ignore();
}
return true;
};
int main(int, char**) {
// Ukลad rรณwnan NxN
double** a = nullptr; // Lewa strona
double* b = nullptr; // Prawa strona
double* x = nullptr; // Wektor zmiennych
std::size_t n; // Liczba rรณwnaล/zmiennych
std::ifstream input("input.txt");
if(!input.is_open()) {
std::cout << "Nie udalo sie otworzyc pliku." << std::endl;
getchar();
return 0;
}
if(!loadEquations(input, a, b, n)) {
std::cout << "Nie udalo sie wczytac ukladu rownan." << std::endl;
getchar();
return 0;
}
input.close();
x = new double[n];
if(x == nullptr) {
std::cout << "Wystapil blad podczas alokacji pamieci." << std::endl;
destroy2DArray(a, n);
delete[] b;
getchar();
return 0;
}
std::cout << "Obliczanie..." << std::endl;
LinearEquationsSystemSolutionsCount result;
try {
result = solveLinearEquationsSystem(a, b, x, n);
} catch(LinearEquationsSolverException e) {
std::cout << "Wystapil blad: ";
switch(e) {
case LESE_MemAllocError:
std::cout << "Blad alokacji pamieci.";
break;
case LESE_NullPointer:
std::cout << "Zerowy wskaznik w danych wejsciowych.";
break;
default:
std::cout << "Nieznany blad.";
break;
}
destroy2DArray(a, n);
delete[] b;
delete[] x;
getchar();
return 0;
} catch(...) {
std::cout << "Wystapil nieznany blad.";
destroy2DArray(a, n);
delete[] b;
delete[] x;
getchar();
return 0;
}
std::cout << "Zakonczono obliczanie." << std::endl;
if(result == LESSC_UniqueSolution) {
std::cout << "Jedno rozwiazanie:" << std::endl;
printMatrix((const double**)(&x), 1, n);
} else if(result == LESSC_InfinitelyManySolutions) {
std::cout << "Nieskonczenie wiele rozwiazan." << std::endl;
} else {
std::cout << "Brak rozwiazan." << std::endl;
}
destroy2DArray(a, n);
delete[] b;
delete[] x;
getchar();
return 0;
}
| [
"juleczek1"
] | juleczek1 |
87a227279179d41e29e074508a8b11a1a3916dd6 | 0b5f5a38bb3f43ded62b9c1e4f710f882b1155c5 | /owCore/UtilsConvert.cpp | 2419c2a095fd506bc5d516113d32f863ec58b67a | [
"Apache-2.0"
] | permissive | xuebai5/OpenWow | a3c41d984cebe4dc34e9e3d0530363da4106bb61 | 97b2738862ce0244fd5b708f4dc3f05db7491f8b | refs/heads/master | 2020-04-26T23:16:26.733576 | 2019-03-03T12:41:04 | 2019-03-03T12:41:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,937 | cpp | #include "stdafx.h"
#include "Utils.h"
std::string Utils::ToString(const type_info& type, void* value)
{
std::stringstream stream;
if (type == typeid(bool))
stream << *((bool*)value);
else if (type == typeid(int))
stream << *((int*)value);
else if (type == typeid(unsigned int))
stream << *((unsigned int*)value);
else if (type == typeid(short))
stream << *((short*)value);
else if (type == typeid(unsigned short))
stream << *((unsigned short*)value);
else if (type == typeid(char))
stream << *((char*)value);
else if (type == typeid(unsigned char))
stream << *((unsigned char*)value);
else if (type == typeid(float))
stream << *((float*)value);
else if (type == typeid(double))
stream << *((double*)value);
else if (type == typeid(std::string))
return (std::string&)*((std::string *)value);
else
{
Log::Error("UtilsParsing: a required type is not defined!");
return "";
}
return stream.str();
}
bool Utils::ToBool(cstring _string)
{
std::string _str = _string;
Trim(_str);
transform(_str.begin(), _str.end(), _str.begin(), ::tolower);
if (_str == "true") return true;
if (_str == "1") return true;
if (_str == "false") return false;
if (_str == "0") return false;
return false;
}
// My types
vec2 Utils::ToPoint(std::string& _string)
{
float _x = popFirstFloat(_string);
float _y = popFirstFloat(_string);
return vec2(_x, _y);
}
vec3 Utils::ToVector3(std::string& _string)
{
float _x = popFirstFloat(_string);
float _y = popFirstFloat(_string);
float _z = popFirstFloat(_string);
return vec3(_x, _y, _z);
}
Color Utils::ToColorFromName(std::string& _string)
{
ToLower(_string);
if (_string == "empty")
return COLOR_EMPTY;
else if (_string == "black")
return COLOR_BLACK;
else if (_string == "darkgray")
return COLOR_DARKGRAY;
else if (_string == "gray")
return COLOR_GRAY;
else if (_string == "lightgray")
return COLOR_LIGHTGRAY;
else if (_string == "white")
return COLOR_WHITE;
else if (_string == "red")
return COLOR_RED;
else if (_string == "green")
return COLOR_GREEN;
else if (_string == "blue")
return COLOR_BLUE;
else if (_string == "lightblue")
return COLOR_LIGHTBLUE;
else if (_string == "pink")
return COLOR_PINK;
else if (_string == "yellow")
return COLOR_YELLOW;
else
return COLOR_EMPTY;
}
Color Utils::ToColorFromRGB(std::string& _string)
{
Color c;
c.red = static_cast<float>(popFirstFloat(_string)) / 255.0f;
c.green = static_cast<float>(popFirstFloat(_string)) / 255.0f;
c.blue = static_cast<float>(popFirstFloat(_string)) / 255.0f;
c.alpha = 1.0;
return c;
}
Color Utils::ToColorFromRGBA(std::string& _string)
{
Color c;
c.red = static_cast<float>(popFirstFloat(_string)) / 255.0f;
c.green = static_cast<float>(popFirstFloat(_string)) / 255.0f;
c.blue = static_cast<float>(popFirstFloat(_string)) / 255.0f;
c.alpha = static_cast<float>(popFirstInt(_string)) / 255.0f;
return c;
}
TextAlignW Utils::ToTextAlignW(std::string& _string)
{
ToLower(_string);
if (_string == "left")
return TextAlignW::TEXT_ALIGNW_LEFT;
else if (_string == "center")
return TextAlignW::TEXT_ALIGNW_CENTER;
else if (_string == "right")
return TextAlignW::TEXT_ALIGNW_RIGHT;
else
return TextAlignW::TEXT_ALIGNW_LEFT;
}
TextAlignH Utils::ToTextAlignH(std::string& _string)
{
ToLower(_string);
if (_string == "top")
return TextAlignH::TEXT_ALIGNH_TOP;
else if (_string == "center")
return TextAlignH::TEXT_ALIGNH_CENTER;
else if (_string == "bottom")
return TextAlignH::TEXT_ALIGNH_BOTTOM;
// Default
else
return TextAlignH::TEXT_ALIGNH_BOTTOM;
}
InputMode Utils::ToInputMode(std::string& _string)
{
ToLower(_string);
if (_string == "any")
return InputMode::MODE_ANY;
else if (_string == "characters")
return InputMode::MODE_CHARACTERS;
else if (_string == "numbers")
return InputMode::MODE_NUMBERS;
// Default
else
return InputMode::MODE_ANY;
}
| [
"alexstenfard@gmail.com"
] | alexstenfard@gmail.com |
99088d34f51a472e38009df09a5bb7bd00bfb04d | dcd772f567ef8a8a1173a9f437cd68f211fb9362 | /crow/contrib/include/boost/math/tools/detail/rational_horner3_16.hpp | b1c89774f8e0048a6d22b1d8b9515cca66c3aa02 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause",
"BSD-3-Clause",
"BSL-1.0"
] | permissive | idaholab/raven | 39cdce98ad916c638399232cdc01a9be00e200a2 | 2b16e7aa3325fe84cab2477947a951414c635381 | refs/heads/devel | 2023-08-31T08:40:16.653099 | 2023-08-29T16:21:51 | 2023-08-29T16:21:51 | 85,989,537 | 201 | 126 | Apache-2.0 | 2023-09-13T21:55:43 | 2017-03-23T19:29:27 | C++ | UTF-8 | C++ | false | false | 26,543 | hpp | // (C) Copyright John Maddock 2007.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// This file is machine generated, do not edit by hand
// Polynomial evaluation using second order Horners rule
#ifndef BOOST_MATH_TOOLS_RAT_EVAL_16_HPP
#define BOOST_MATH_TOOLS_RAT_EVAL_16_HPP
namespace boost{ namespace math{ namespace tools{ namespace detail{
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*)
{
return static_cast<V>(0);
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*)
{
return static_cast<V>(a[0]) / static_cast<V>(b[0]);
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*)
{
return static_cast<V>((a[1] * x + a[0]) / (b[1] * x + b[0]));
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*)
{
return static_cast<V>(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0]));
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*)
{
return static_cast<V>((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0]));
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*)
{
if(x <= 1)
{
V x2 = x * x;
V t[4];
t[0] = a[4] * x2 + a[2];
t[1] = a[3] * x2 + a[1];
t[2] = b[4] * x2 + b[2];
t[3] = b[3] * x2 + b[1];
t[0] *= x2;
t[2] *= x2;
t[0] += static_cast<V>(a[0]);
t[2] += static_cast<V>(b[0]);
t[1] *= x;
t[3] *= x;
return (t[0] + t[1]) / (t[2] + t[3]);
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
V t[4];
t[0] = a[0] * z2 + a[2];
t[1] = a[1] * z2 + a[3];
t[2] = b[0] * z2 + b[2];
t[3] = b[1] * z2 + b[3];
t[0] *= z2;
t[2] *= z2;
t[0] += static_cast<V>(a[4]);
t[2] += static_cast<V>(b[4]);
t[1] *= z;
t[3] *= z;
return (t[0] + t[1]) / (t[2] + t[3]);
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*)
{
if(x <= 1)
{
V x2 = x * x;
V t[4];
t[0] = a[5] * x2 + a[3];
t[1] = a[4] * x2 + a[2];
t[2] = b[5] * x2 + b[3];
t[3] = b[4] * x2 + b[2];
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[1]);
t[1] += static_cast<V>(a[0]);
t[2] += static_cast<V>(b[1]);
t[3] += static_cast<V>(b[0]);
t[0] *= x;
t[2] *= x;
return (t[0] + t[1]) / (t[2] + t[3]);
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
V t[4];
t[0] = a[0] * z2 + a[2];
t[1] = a[1] * z2 + a[3];
t[2] = b[0] * z2 + b[2];
t[3] = b[1] * z2 + b[3];
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[5]);
t[0] *= z;
t[2] *= z;
return (t[0] + t[1]) / (t[2] + t[3]);
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*)
{
if(x <= 1)
{
V x2 = x * x;
V t[4];
t[0] = a[6] * x2 + a[4];
t[1] = a[5] * x2 + a[3];
t[2] = b[6] * x2 + b[4];
t[3] = b[5] * x2 + b[3];
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[2]);
t[1] += static_cast<V>(a[1]);
t[2] += static_cast<V>(b[2]);
t[3] += static_cast<V>(b[1]);
t[0] *= x2;
t[2] *= x2;
t[0] += static_cast<V>(a[0]);
t[2] += static_cast<V>(b[0]);
t[1] *= x;
t[3] *= x;
return (t[0] + t[1]) / (t[2] + t[3]);
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
V t[4];
t[0] = a[0] * z2 + a[2];
t[1] = a[1] * z2 + a[3];
t[2] = b[0] * z2 + b[2];
t[3] = b[1] * z2 + b[3];
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[5]);
t[0] *= z2;
t[2] *= z2;
t[0] += static_cast<V>(a[6]);
t[2] += static_cast<V>(b[6]);
t[1] *= z;
t[3] *= z;
return (t[0] + t[1]) / (t[2] + t[3]);
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*)
{
if(x <= 1)
{
V x2 = x * x;
V t[4];
t[0] = a[7] * x2 + a[5];
t[1] = a[6] * x2 + a[4];
t[2] = b[7] * x2 + b[5];
t[3] = b[6] * x2 + b[4];
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[3]);
t[1] += static_cast<V>(a[2]);
t[2] += static_cast<V>(b[3]);
t[3] += static_cast<V>(b[2]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[1]);
t[1] += static_cast<V>(a[0]);
t[2] += static_cast<V>(b[1]);
t[3] += static_cast<V>(b[0]);
t[0] *= x;
t[2] *= x;
return (t[0] + t[1]) / (t[2] + t[3]);
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
V t[4];
t[0] = a[0] * z2 + a[2];
t[1] = a[1] * z2 + a[3];
t[2] = b[0] * z2 + b[2];
t[3] = b[1] * z2 + b[3];
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[5]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[6]);
t[1] += static_cast<V>(a[7]);
t[2] += static_cast<V>(b[6]);
t[3] += static_cast<V>(b[7]);
t[0] *= z;
t[2] *= z;
return (t[0] + t[1]) / (t[2] + t[3]);
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*)
{
if(x <= 1)
{
V x2 = x * x;
V t[4];
t[0] = a[8] * x2 + a[6];
t[1] = a[7] * x2 + a[5];
t[2] = b[8] * x2 + b[6];
t[3] = b[7] * x2 + b[5];
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[3]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[3]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[2]);
t[1] += static_cast<V>(a[1]);
t[2] += static_cast<V>(b[2]);
t[3] += static_cast<V>(b[1]);
t[0] *= x2;
t[2] *= x2;
t[0] += static_cast<V>(a[0]);
t[2] += static_cast<V>(b[0]);
t[1] *= x;
t[3] *= x;
return (t[0] + t[1]) / (t[2] + t[3]);
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
V t[4];
t[0] = a[0] * z2 + a[2];
t[1] = a[1] * z2 + a[3];
t[2] = b[0] * z2 + b[2];
t[3] = b[1] * z2 + b[3];
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[5]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[6]);
t[1] += static_cast<V>(a[7]);
t[2] += static_cast<V>(b[6]);
t[3] += static_cast<V>(b[7]);
t[0] *= z2;
t[2] *= z2;
t[0] += static_cast<V>(a[8]);
t[2] += static_cast<V>(b[8]);
t[1] *= z;
t[3] *= z;
return (t[0] + t[1]) / (t[2] + t[3]);
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*)
{
if(x <= 1)
{
V x2 = x * x;
V t[4];
t[0] = a[9] * x2 + a[7];
t[1] = a[8] * x2 + a[6];
t[2] = b[9] * x2 + b[7];
t[3] = b[8] * x2 + b[6];
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[5]);
t[1] += static_cast<V>(a[4]);
t[2] += static_cast<V>(b[5]);
t[3] += static_cast<V>(b[4]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[3]);
t[1] += static_cast<V>(a[2]);
t[2] += static_cast<V>(b[3]);
t[3] += static_cast<V>(b[2]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[1]);
t[1] += static_cast<V>(a[0]);
t[2] += static_cast<V>(b[1]);
t[3] += static_cast<V>(b[0]);
t[0] *= x;
t[2] *= x;
return (t[0] + t[1]) / (t[2] + t[3]);
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
V t[4];
t[0] = a[0] * z2 + a[2];
t[1] = a[1] * z2 + a[3];
t[2] = b[0] * z2 + b[2];
t[3] = b[1] * z2 + b[3];
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[5]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[6]);
t[1] += static_cast<V>(a[7]);
t[2] += static_cast<V>(b[6]);
t[3] += static_cast<V>(b[7]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[8]);
t[1] += static_cast<V>(a[9]);
t[2] += static_cast<V>(b[8]);
t[3] += static_cast<V>(b[9]);
t[0] *= z;
t[2] *= z;
return (t[0] + t[1]) / (t[2] + t[3]);
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*)
{
if(x <= 1)
{
V x2 = x * x;
V t[4];
t[0] = a[10] * x2 + a[8];
t[1] = a[9] * x2 + a[7];
t[2] = b[10] * x2 + b[8];
t[3] = b[9] * x2 + b[7];
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[6]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[6]);
t[3] += static_cast<V>(b[5]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[3]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[3]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[2]);
t[1] += static_cast<V>(a[1]);
t[2] += static_cast<V>(b[2]);
t[3] += static_cast<V>(b[1]);
t[0] *= x2;
t[2] *= x2;
t[0] += static_cast<V>(a[0]);
t[2] += static_cast<V>(b[0]);
t[1] *= x;
t[3] *= x;
return (t[0] + t[1]) / (t[2] + t[3]);
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
V t[4];
t[0] = a[0] * z2 + a[2];
t[1] = a[1] * z2 + a[3];
t[2] = b[0] * z2 + b[2];
t[3] = b[1] * z2 + b[3];
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[5]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[6]);
t[1] += static_cast<V>(a[7]);
t[2] += static_cast<V>(b[6]);
t[3] += static_cast<V>(b[7]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[8]);
t[1] += static_cast<V>(a[9]);
t[2] += static_cast<V>(b[8]);
t[3] += static_cast<V>(b[9]);
t[0] *= z2;
t[2] *= z2;
t[0] += static_cast<V>(a[10]);
t[2] += static_cast<V>(b[10]);
t[1] *= z;
t[3] *= z;
return (t[0] + t[1]) / (t[2] + t[3]);
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*)
{
if(x <= 1)
{
V x2 = x * x;
V t[4];
t[0] = a[11] * x2 + a[9];
t[1] = a[10] * x2 + a[8];
t[2] = b[11] * x2 + b[9];
t[3] = b[10] * x2 + b[8];
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[7]);
t[1] += static_cast<V>(a[6]);
t[2] += static_cast<V>(b[7]);
t[3] += static_cast<V>(b[6]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[5]);
t[1] += static_cast<V>(a[4]);
t[2] += static_cast<V>(b[5]);
t[3] += static_cast<V>(b[4]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[3]);
t[1] += static_cast<V>(a[2]);
t[2] += static_cast<V>(b[3]);
t[3] += static_cast<V>(b[2]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[1]);
t[1] += static_cast<V>(a[0]);
t[2] += static_cast<V>(b[1]);
t[3] += static_cast<V>(b[0]);
t[0] *= x;
t[2] *= x;
return (t[0] + t[1]) / (t[2] + t[3]);
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
V t[4];
t[0] = a[0] * z2 + a[2];
t[1] = a[1] * z2 + a[3];
t[2] = b[0] * z2 + b[2];
t[3] = b[1] * z2 + b[3];
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[5]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[6]);
t[1] += static_cast<V>(a[7]);
t[2] += static_cast<V>(b[6]);
t[3] += static_cast<V>(b[7]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[8]);
t[1] += static_cast<V>(a[9]);
t[2] += static_cast<V>(b[8]);
t[3] += static_cast<V>(b[9]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[10]);
t[1] += static_cast<V>(a[11]);
t[2] += static_cast<V>(b[10]);
t[3] += static_cast<V>(b[11]);
t[0] *= z;
t[2] *= z;
return (t[0] + t[1]) / (t[2] + t[3]);
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*)
{
if(x <= 1)
{
V x2 = x * x;
V t[4];
t[0] = a[12] * x2 + a[10];
t[1] = a[11] * x2 + a[9];
t[2] = b[12] * x2 + b[10];
t[3] = b[11] * x2 + b[9];
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[8]);
t[1] += static_cast<V>(a[7]);
t[2] += static_cast<V>(b[8]);
t[3] += static_cast<V>(b[7]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[6]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[6]);
t[3] += static_cast<V>(b[5]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[3]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[3]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[2]);
t[1] += static_cast<V>(a[1]);
t[2] += static_cast<V>(b[2]);
t[3] += static_cast<V>(b[1]);
t[0] *= x2;
t[2] *= x2;
t[0] += static_cast<V>(a[0]);
t[2] += static_cast<V>(b[0]);
t[1] *= x;
t[3] *= x;
return (t[0] + t[1]) / (t[2] + t[3]);
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
V t[4];
t[0] = a[0] * z2 + a[2];
t[1] = a[1] * z2 + a[3];
t[2] = b[0] * z2 + b[2];
t[3] = b[1] * z2 + b[3];
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[5]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[6]);
t[1] += static_cast<V>(a[7]);
t[2] += static_cast<V>(b[6]);
t[3] += static_cast<V>(b[7]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[8]);
t[1] += static_cast<V>(a[9]);
t[2] += static_cast<V>(b[8]);
t[3] += static_cast<V>(b[9]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[10]);
t[1] += static_cast<V>(a[11]);
t[2] += static_cast<V>(b[10]);
t[3] += static_cast<V>(b[11]);
t[0] *= z2;
t[2] *= z2;
t[0] += static_cast<V>(a[12]);
t[2] += static_cast<V>(b[12]);
t[1] *= z;
t[3] *= z;
return (t[0] + t[1]) / (t[2] + t[3]);
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*)
{
if(x <= 1)
{
V x2 = x * x;
V t[4];
t[0] = a[13] * x2 + a[11];
t[1] = a[12] * x2 + a[10];
t[2] = b[13] * x2 + b[11];
t[3] = b[12] * x2 + b[10];
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[9]);
t[1] += static_cast<V>(a[8]);
t[2] += static_cast<V>(b[9]);
t[3] += static_cast<V>(b[8]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[7]);
t[1] += static_cast<V>(a[6]);
t[2] += static_cast<V>(b[7]);
t[3] += static_cast<V>(b[6]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[5]);
t[1] += static_cast<V>(a[4]);
t[2] += static_cast<V>(b[5]);
t[3] += static_cast<V>(b[4]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[3]);
t[1] += static_cast<V>(a[2]);
t[2] += static_cast<V>(b[3]);
t[3] += static_cast<V>(b[2]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[1]);
t[1] += static_cast<V>(a[0]);
t[2] += static_cast<V>(b[1]);
t[3] += static_cast<V>(b[0]);
t[0] *= x;
t[2] *= x;
return (t[0] + t[1]) / (t[2] + t[3]);
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
V t[4];
t[0] = a[0] * z2 + a[2];
t[1] = a[1] * z2 + a[3];
t[2] = b[0] * z2 + b[2];
t[3] = b[1] * z2 + b[3];
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[5]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[6]);
t[1] += static_cast<V>(a[7]);
t[2] += static_cast<V>(b[6]);
t[3] += static_cast<V>(b[7]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[8]);
t[1] += static_cast<V>(a[9]);
t[2] += static_cast<V>(b[8]);
t[3] += static_cast<V>(b[9]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[10]);
t[1] += static_cast<V>(a[11]);
t[2] += static_cast<V>(b[10]);
t[3] += static_cast<V>(b[11]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[12]);
t[1] += static_cast<V>(a[13]);
t[2] += static_cast<V>(b[12]);
t[3] += static_cast<V>(b[13]);
t[0] *= z;
t[2] *= z;
return (t[0] + t[1]) / (t[2] + t[3]);
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*)
{
if(x <= 1)
{
V x2 = x * x;
V t[4];
t[0] = a[14] * x2 + a[12];
t[1] = a[13] * x2 + a[11];
t[2] = b[14] * x2 + b[12];
t[3] = b[13] * x2 + b[11];
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[10]);
t[1] += static_cast<V>(a[9]);
t[2] += static_cast<V>(b[10]);
t[3] += static_cast<V>(b[9]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[8]);
t[1] += static_cast<V>(a[7]);
t[2] += static_cast<V>(b[8]);
t[3] += static_cast<V>(b[7]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[6]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[6]);
t[3] += static_cast<V>(b[5]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[3]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[3]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[2]);
t[1] += static_cast<V>(a[1]);
t[2] += static_cast<V>(b[2]);
t[3] += static_cast<V>(b[1]);
t[0] *= x2;
t[2] *= x2;
t[0] += static_cast<V>(a[0]);
t[2] += static_cast<V>(b[0]);
t[1] *= x;
t[3] *= x;
return (t[0] + t[1]) / (t[2] + t[3]);
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
V t[4];
t[0] = a[0] * z2 + a[2];
t[1] = a[1] * z2 + a[3];
t[2] = b[0] * z2 + b[2];
t[3] = b[1] * z2 + b[3];
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[5]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[6]);
t[1] += static_cast<V>(a[7]);
t[2] += static_cast<V>(b[6]);
t[3] += static_cast<V>(b[7]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[8]);
t[1] += static_cast<V>(a[9]);
t[2] += static_cast<V>(b[8]);
t[3] += static_cast<V>(b[9]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[10]);
t[1] += static_cast<V>(a[11]);
t[2] += static_cast<V>(b[10]);
t[3] += static_cast<V>(b[11]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[12]);
t[1] += static_cast<V>(a[13]);
t[2] += static_cast<V>(b[12]);
t[3] += static_cast<V>(b[13]);
t[0] *= z2;
t[2] *= z2;
t[0] += static_cast<V>(a[14]);
t[2] += static_cast<V>(b[14]);
t[1] *= z;
t[3] *= z;
return (t[0] + t[1]) / (t[2] + t[3]);
}
}
template <class T, class U, class V>
inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*)
{
if(x <= 1)
{
V x2 = x * x;
V t[4];
t[0] = a[15] * x2 + a[13];
t[1] = a[14] * x2 + a[12];
t[2] = b[15] * x2 + b[13];
t[3] = b[14] * x2 + b[12];
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[11]);
t[1] += static_cast<V>(a[10]);
t[2] += static_cast<V>(b[11]);
t[3] += static_cast<V>(b[10]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[9]);
t[1] += static_cast<V>(a[8]);
t[2] += static_cast<V>(b[9]);
t[3] += static_cast<V>(b[8]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[7]);
t[1] += static_cast<V>(a[6]);
t[2] += static_cast<V>(b[7]);
t[3] += static_cast<V>(b[6]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[5]);
t[1] += static_cast<V>(a[4]);
t[2] += static_cast<V>(b[5]);
t[3] += static_cast<V>(b[4]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[3]);
t[1] += static_cast<V>(a[2]);
t[2] += static_cast<V>(b[3]);
t[3] += static_cast<V>(b[2]);
t[0] *= x2;
t[1] *= x2;
t[2] *= x2;
t[3] *= x2;
t[0] += static_cast<V>(a[1]);
t[1] += static_cast<V>(a[0]);
t[2] += static_cast<V>(b[1]);
t[3] += static_cast<V>(b[0]);
t[0] *= x;
t[2] *= x;
return (t[0] + t[1]) / (t[2] + t[3]);
}
else
{
V z = 1 / x;
V z2 = 1 / (x * x);
V t[4];
t[0] = a[0] * z2 + a[2];
t[1] = a[1] * z2 + a[3];
t[2] = b[0] * z2 + b[2];
t[3] = b[1] * z2 + b[3];
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[5]);
t[2] += static_cast<V>(b[4]);
t[3] += static_cast<V>(b[5]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[6]);
t[1] += static_cast<V>(a[7]);
t[2] += static_cast<V>(b[6]);
t[3] += static_cast<V>(b[7]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[8]);
t[1] += static_cast<V>(a[9]);
t[2] += static_cast<V>(b[8]);
t[3] += static_cast<V>(b[9]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[10]);
t[1] += static_cast<V>(a[11]);
t[2] += static_cast<V>(b[10]);
t[3] += static_cast<V>(b[11]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[12]);
t[1] += static_cast<V>(a[13]);
t[2] += static_cast<V>(b[12]);
t[3] += static_cast<V>(b[13]);
t[0] *= z2;
t[1] *= z2;
t[2] *= z2;
t[3] *= z2;
t[0] += static_cast<V>(a[14]);
t[1] += static_cast<V>(a[15]);
t[2] += static_cast<V>(b[14]);
t[3] += static_cast<V>(b[15]);
t[0] *= z;
t[2] *= z;
return (t[0] + t[1]) / (t[2] + t[3]);
}
}
}}}} // namespaces
#endif // include guard
| [
"codypermann@gmail.com"
] | codypermann@gmail.com |
333cbe59e535e581ba581212a462218a0c762b3c | 5a5326e1a51a03c795e44182919ad3176a3f35f5 | /OpenGL_Two/OpenGL_Two/Source/Transform.h | 57864d1cc16fee4591a49105f550f83ba99125d7 | [] | no_license | LeeviPaa/OpenGL_Graphical-Engine | 40785a5654301ecf1afab29eb0e32f281d19ac0b | 3362b08d61d9c788a2f5dbcd766bc167e8d6d05f | refs/heads/master | 2020-04-11T15:58:59.941030 | 2019-01-08T16:28:17 | 2019-01-08T16:28:17 | 161,909,528 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 137 | h | #pragma once
#include <glm/glm.hpp>
#include <glm/ext.hpp>
enum SPACE
{
LOCAL,
GLOBAL
};
class Transform
{
public:
Transform();
};
| [
"lpkknn@gmail.com"
] | lpkknn@gmail.com |
816f088d466925c556196a84d382ecaed136f2d9 | 9706185cdc3de124dd5893d0064af977aa62aac1 | /LabHelper.cpp | 63362127c43352b8cc875cd96f026f1c4464f9b7 | [] | no_license | Slavjan/winAPI_noteBook | 689b65e02d299b695c2416a20a833873fe9c1e67 | 7f38e85ad14b3af8735e19096d35d75cabeef0aa | refs/heads/master | 2021-01-19T07:29:22.496786 | 2017-04-07T13:38:39 | 2017-04-07T13:38:39 | 87,544,946 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 458 | cpp | #include "labhelper.h"
// ะธะฝะธัะธะฐะปะธะทะธัะพะฒะฐัั ััะฐัะธัะตัะบะธะต ะฟะตัะตะผะตะฝะฝัะต ะฝัะถะฝะพ ะฒ .cpp ัะฐะนะปะฐั
// ะฝะฐัะธะฝะฐะตะผ ั id = 10000
int PairIdComponent::count = 10000;
std::string LabHelper::IntToString( int value )
{
std::stringstream ss;
ss << value;
return ss.str();
}
int LabHelper::StrToInt( std::string str )
{
return atoi( str.c_str() );
}
LabHelper::LabHelper()
{
} | [
"Yaroslav Khaidayev"
] | Yaroslav Khaidayev |
5a80f328c6447917d5d740cc88c6822c2f8f791d | a57b410453b962d7f128753a33ca8a880d4d0a35 | /Graphs/Heap.hpp | 1766c12f2f775b1be2d5cc85ae7aca90e1e25745 | [] | no_license | DaniloVlad/Data-Structures-and-Algorithms | bac09783352cffb1ca3655b6275173e8a6371bed | 948115e23f349e32f5dea5e12e84bdb7ca9bbd68 | refs/heads/master | 2021-05-22T21:33:05.942172 | 2020-04-04T21:52:59 | 2020-04-04T21:52:59 | 253,105,495 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 558 | hpp | #ifndef _Heap
#define _Heap
#include <iostream>
#include <math.h>
using namespace std;
class Heap {
public:
Heap(float keys[], int n);
bool in_heap(int id);
float min_key();
int min_id();
float key(int id);
void delete_min();
void decrease_key(int id, float new_key);
bool is_empty();
void print();
private:
//keys stores the values of the heap in original order
float *keys;
//heap of indices of keys
int *heap;
int length;
};
#endif | [
"danilo.vladicic@gmail.com"
] | danilo.vladicic@gmail.com |
ae3d0a131afefafce024850303c95b2bb1508280 | 7b49c6aced0e672cc7636a4fb5eeee7694f28cdc | /project/source/system/object/3d/SkeltalMesh.h | 2099c927b6b39a72865ea259469b6a322de1f595 | [] | no_license | TomohiroYuki/YukitterFramework | f57b3231deaeba86ac2e97d2cadb27a187cc6b49 | 50efa6d32005c89d1164894e4a239300573d7e7b | refs/heads/master | 2020-03-30T07:47:56.342747 | 2018-09-30T13:16:43 | 2018-09-30T13:16:43 | 150,967,310 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,321 | h | #pragma once
#include "source\system\object\primitive\Primitive.h"
#define MAX_BONE_INFLUENCES 4
struct SkeltalMeshVertexData
{
DirectX::XMFLOAT3 pos;
DirectX::XMFLOAT3 normal;
DirectX::XMFLOAT2 texcoord;
FLOAT bone_weights[MAX_BONE_INFLUENCES] = { 1, 0, 0, 0 };
INT bone_indices[MAX_BONE_INFLUENCES] = {};
};
class SkeltalMesh :public YQ3DBase
{
public:
SkeltalMesh(const char* file_name);
~SkeltalMesh() {};
private:
public:
struct bone
{
DirectX::XMFLOAT4X4 transform;
};
typedef std::vector<bone> skeletal;
struct skeletal_animation : public std::vector<skeletal>
{
float sampling_time = 1 / 24.0f;
float animation_tick = 0.0f;
};
struct Mesh
{
Microsoft::WRL::ComPtr<ID3D11Buffer> vertex_buffer;
Microsoft::WRL::ComPtr<ID3D11Buffer> index_buffer;
std::vector<Subset> subsets;
DirectX::XMFLOAT4X4 global_transform = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
// UNIT.22
std::vector<SkeltalMesh::bone> skeletal;
};
public:
DirectX::XMFLOAT4X4 coordinate_conversion = { 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1 };
std::vector<Mesh> meshes;
bool CreateBuffer(SkeltalMeshVertexData* v, int v_num, unsigned int* indicies, int ind_num, ID3D11Buffer** v_buffer, ID3D11Buffer** i_buffer);
void Render(DirectX::XMFLOAT3 pos, float angle, float scale);
}; | [
"rohimotokiyu@gmail.com"
] | rohimotokiyu@gmail.com |
548ac951dc319e451747c1c28fdbd31ab04a7c8d | 69828fb743c4b7a5eadb0052696920bf39576235 | /comtut/exeserver/addressobject.h | ad776711978b402936a001146fcd857ee92f237f | [] | no_license | praseedpai/COMTutorial1999 | 913caf9deca8611ab1c10cf21914f60d32371849 | 1dbe34a864a9aa0d4b975da8d55fc4ace9608845 | refs/heads/master | 2022-06-30T00:22:46.412251 | 2020-05-06T05:09:39 | 2020-05-06T05:09:39 | 261,657,657 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,195 | h | /* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 5.01.0164 */
/* at Wed Apr 21 19:02:41 1999
*/
/* Compiler settings for addressobject.idl:
Os (OptLev=s), W1, Zp8, env=Win32, ms_ext, c_ext
error checks: allocation ref bounds_check enum stub_data
*/
//@@MIDL_FILE_HEADING( )
/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 440
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif // __RPCNDR_H_VERSION__
#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif /*COM_NO_WINDOWS_H*/
#ifndef __addressobject_h__
#define __addressobject_h__
#ifdef __cplusplus
extern "C"{
#endif
/* Forward Declarations */
#ifndef __IAddress_FWD_DEFINED__
#define __IAddress_FWD_DEFINED__
typedef interface IAddress IAddress;
#endif /* __IAddress_FWD_DEFINED__ */
#ifndef __IAddressList_FWD_DEFINED__
#define __IAddressList_FWD_DEFINED__
typedef interface IAddressList IAddressList;
#endif /* __IAddressList_FWD_DEFINED__ */
#ifndef __Address_FWD_DEFINED__
#define __Address_FWD_DEFINED__
#ifdef __cplusplus
typedef class Address Address;
#else
typedef struct Address Address;
#endif /* __cplusplus */
#endif /* __Address_FWD_DEFINED__ */
#ifndef __AddressList_FWD_DEFINED__
#define __AddressList_FWD_DEFINED__
#ifdef __cplusplus
typedef class AddressList AddressList;
#else
typedef struct AddressList AddressList;
#endif /* __cplusplus */
#endif /* __AddressList_FWD_DEFINED__ */
/* header files for imported files */
#include "unknwn.h"
void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t);
void __RPC_USER MIDL_user_free( void __RPC_FAR * );
#ifndef __IAddress_INTERFACE_DEFINED__
#define __IAddress_INTERFACE_DEFINED__
/* interface IAddress */
/* [helpstring][uuid][object] */
EXTERN_C const IID IID_IAddress;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("3BF36EF1-F3B3-11d2-A4E3-0040056DF87F")
IAddress : public IUnknown
{
public:
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetName(
/* [out][in] */ LPSTR __MIDL_0000) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetName(
/* [in] */ LPSTR __MIDL_0001) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetAddress1(
/* [out][in] */ LPSTR __MIDL_0002) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetAddress1(
/* [in] */ LPSTR __MIDL_0003) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetAddress2(
/* [out][in] */ LPSTR __MIDL_0004) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetAddress2(
/* [in] */ LPSTR __MIDL_0005) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetCity(
/* [out][in] */ LPSTR __MIDL_0006) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetCity(
/* [in] */ LPSTR __MIDL_0007) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetState(
/* [out][in] */ LPSTR __MIDL_0008) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetState(
/* [in] */ LPSTR __MIDL_0009) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetCountry(
/* [out][in] */ LPSTR __MIDL_0010) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetCountry(
/* [in] */ LPSTR __MIDL_0011) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE GetPinCode(
/* [out][in] */ LPSTR __MIDL_0012) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE SetPinCode(
/* [in] */ LPSTR __MIDL_0013) = 0;
};
#else /* C style interface */
typedef struct IAddressVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
IAddress __RPC_FAR * This,
/* [in] */ REFIID riid,
/* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
IAddress __RPC_FAR * This);
ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
IAddress __RPC_FAR * This);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetName )(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0000);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetName )(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0001);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetAddress1 )(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0002);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetAddress1 )(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0003);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetAddress2 )(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0004);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetAddress2 )(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0005);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetCity )(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0006);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetCity )(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0007);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetState )(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0008);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetState )(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0009);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetCountry )(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0010);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetCountry )(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0011);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetPinCode )(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0012);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetPinCode )(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0013);
END_INTERFACE
} IAddressVtbl;
interface IAddress
{
CONST_VTBL struct IAddressVtbl __RPC_FAR *lpVtbl;
};
#ifdef COBJMACROS
#define IAddress_QueryInterface(This,riid,ppvObject) \
(This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
#define IAddress_AddRef(This) \
(This)->lpVtbl -> AddRef(This)
#define IAddress_Release(This) \
(This)->lpVtbl -> Release(This)
#define IAddress_GetName(This,__MIDL_0000) \
(This)->lpVtbl -> GetName(This,__MIDL_0000)
#define IAddress_SetName(This,__MIDL_0001) \
(This)->lpVtbl -> SetName(This,__MIDL_0001)
#define IAddress_GetAddress1(This,__MIDL_0002) \
(This)->lpVtbl -> GetAddress1(This,__MIDL_0002)
#define IAddress_SetAddress1(This,__MIDL_0003) \
(This)->lpVtbl -> SetAddress1(This,__MIDL_0003)
#define IAddress_GetAddress2(This,__MIDL_0004) \
(This)->lpVtbl -> GetAddress2(This,__MIDL_0004)
#define IAddress_SetAddress2(This,__MIDL_0005) \
(This)->lpVtbl -> SetAddress2(This,__MIDL_0005)
#define IAddress_GetCity(This,__MIDL_0006) \
(This)->lpVtbl -> GetCity(This,__MIDL_0006)
#define IAddress_SetCity(This,__MIDL_0007) \
(This)->lpVtbl -> SetCity(This,__MIDL_0007)
#define IAddress_GetState(This,__MIDL_0008) \
(This)->lpVtbl -> GetState(This,__MIDL_0008)
#define IAddress_SetState(This,__MIDL_0009) \
(This)->lpVtbl -> SetState(This,__MIDL_0009)
#define IAddress_GetCountry(This,__MIDL_0010) \
(This)->lpVtbl -> GetCountry(This,__MIDL_0010)
#define IAddress_SetCountry(This,__MIDL_0011) \
(This)->lpVtbl -> SetCountry(This,__MIDL_0011)
#define IAddress_GetPinCode(This,__MIDL_0012) \
(This)->lpVtbl -> GetPinCode(This,__MIDL_0012)
#define IAddress_SetPinCode(This,__MIDL_0013) \
(This)->lpVtbl -> SetPinCode(This,__MIDL_0013)
#endif /* COBJMACROS */
#endif /* C style interface */
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_GetName_Proxy(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0000);
void __RPC_STUB IAddress_GetName_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_SetName_Proxy(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0001);
void __RPC_STUB IAddress_SetName_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_GetAddress1_Proxy(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0002);
void __RPC_STUB IAddress_GetAddress1_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_SetAddress1_Proxy(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0003);
void __RPC_STUB IAddress_SetAddress1_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_GetAddress2_Proxy(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0004);
void __RPC_STUB IAddress_GetAddress2_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_SetAddress2_Proxy(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0005);
void __RPC_STUB IAddress_SetAddress2_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_GetCity_Proxy(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0006);
void __RPC_STUB IAddress_GetCity_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_SetCity_Proxy(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0007);
void __RPC_STUB IAddress_SetCity_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_GetState_Proxy(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0008);
void __RPC_STUB IAddress_GetState_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_SetState_Proxy(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0009);
void __RPC_STUB IAddress_SetState_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_GetCountry_Proxy(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0010);
void __RPC_STUB IAddress_GetCountry_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_SetCountry_Proxy(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0011);
void __RPC_STUB IAddress_SetCountry_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_GetPinCode_Proxy(
IAddress __RPC_FAR * This,
/* [out][in] */ LPSTR __MIDL_0012);
void __RPC_STUB IAddress_GetPinCode_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IAddress_SetPinCode_Proxy(
IAddress __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0013);
void __RPC_STUB IAddress_SetPinCode_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
#endif /* __IAddress_INTERFACE_DEFINED__ */
#ifndef __IAddressList_INTERFACE_DEFINED__
#define __IAddressList_INTERFACE_DEFINED__
/* interface IAddressList */
/* [helpstring][uuid][object] */
EXTERN_C const IID IID_IAddressList;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("5664CF91-F3B3-11d2-A4E3-0040056DF87F")
IAddressList : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE MoveFirst( void) = 0;
virtual HRESULT STDMETHODCALLTYPE MoveLast( void) = 0;
virtual HRESULT STDMETHODCALLTYPE MoveNext( void) = 0;
virtual HRESULT STDMETHODCALLTYPE MovePrevious( void) = 0;
virtual HRESULT STDMETHODCALLTYPE Eof( void) = 0;
virtual HRESULT STDMETHODCALLTYPE Bof( void) = 0;
virtual HRESULT STDMETHODCALLTYPE GetData(
/* [out] */ IAddress __RPC_FAR *__RPC_FAR *__MIDL_0014) = 0;
virtual HRESULT STDMETHODCALLTYPE Add(
IAddress __RPC_FAR *__MIDL_0015) = 0;
virtual HRESULT STDMETHODCALLTYPE Write(
/* [in] */ LPSTR __MIDL_0016) = 0;
virtual HRESULT STDMETHODCALLTYPE Open(
/* [in] */ LPSTR __MIDL_0017) = 0;
};
#else /* C style interface */
typedef struct IAddressListVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
IAddressList __RPC_FAR * This,
/* [in] */ REFIID riid,
/* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
IAddressList __RPC_FAR * This);
ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
IAddressList __RPC_FAR * This);
HRESULT ( STDMETHODCALLTYPE __RPC_FAR *MoveFirst )(
IAddressList __RPC_FAR * This);
HRESULT ( STDMETHODCALLTYPE __RPC_FAR *MoveLast )(
IAddressList __RPC_FAR * This);
HRESULT ( STDMETHODCALLTYPE __RPC_FAR *MoveNext )(
IAddressList __RPC_FAR * This);
HRESULT ( STDMETHODCALLTYPE __RPC_FAR *MovePrevious )(
IAddressList __RPC_FAR * This);
HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Eof )(
IAddressList __RPC_FAR * This);
HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Bof )(
IAddressList __RPC_FAR * This);
HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetData )(
IAddressList __RPC_FAR * This,
/* [out] */ IAddress __RPC_FAR *__RPC_FAR *__MIDL_0014);
HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Add )(
IAddressList __RPC_FAR * This,
IAddress __RPC_FAR *__MIDL_0015);
HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Write )(
IAddressList __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0016);
HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Open )(
IAddressList __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0017);
END_INTERFACE
} IAddressListVtbl;
interface IAddressList
{
CONST_VTBL struct IAddressListVtbl __RPC_FAR *lpVtbl;
};
#ifdef COBJMACROS
#define IAddressList_QueryInterface(This,riid,ppvObject) \
(This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
#define IAddressList_AddRef(This) \
(This)->lpVtbl -> AddRef(This)
#define IAddressList_Release(This) \
(This)->lpVtbl -> Release(This)
#define IAddressList_MoveFirst(This) \
(This)->lpVtbl -> MoveFirst(This)
#define IAddressList_MoveLast(This) \
(This)->lpVtbl -> MoveLast(This)
#define IAddressList_MoveNext(This) \
(This)->lpVtbl -> MoveNext(This)
#define IAddressList_MovePrevious(This) \
(This)->lpVtbl -> MovePrevious(This)
#define IAddressList_Eof(This) \
(This)->lpVtbl -> Eof(This)
#define IAddressList_Bof(This) \
(This)->lpVtbl -> Bof(This)
#define IAddressList_GetData(This,__MIDL_0014) \
(This)->lpVtbl -> GetData(This,__MIDL_0014)
#define IAddressList_Add(This,__MIDL_0015) \
(This)->lpVtbl -> Add(This,__MIDL_0015)
#define IAddressList_Write(This,__MIDL_0016) \
(This)->lpVtbl -> Write(This,__MIDL_0016)
#define IAddressList_Open(This,__MIDL_0017) \
(This)->lpVtbl -> Open(This,__MIDL_0017)
#endif /* COBJMACROS */
#endif /* C style interface */
HRESULT STDMETHODCALLTYPE IAddressList_MoveFirst_Proxy(
IAddressList __RPC_FAR * This);
void __RPC_STUB IAddressList_MoveFirst_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
HRESULT STDMETHODCALLTYPE IAddressList_MoveLast_Proxy(
IAddressList __RPC_FAR * This);
void __RPC_STUB IAddressList_MoveLast_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
HRESULT STDMETHODCALLTYPE IAddressList_MoveNext_Proxy(
IAddressList __RPC_FAR * This);
void __RPC_STUB IAddressList_MoveNext_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
HRESULT STDMETHODCALLTYPE IAddressList_MovePrevious_Proxy(
IAddressList __RPC_FAR * This);
void __RPC_STUB IAddressList_MovePrevious_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
HRESULT STDMETHODCALLTYPE IAddressList_Eof_Proxy(
IAddressList __RPC_FAR * This);
void __RPC_STUB IAddressList_Eof_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
HRESULT STDMETHODCALLTYPE IAddressList_Bof_Proxy(
IAddressList __RPC_FAR * This);
void __RPC_STUB IAddressList_Bof_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
HRESULT STDMETHODCALLTYPE IAddressList_GetData_Proxy(
IAddressList __RPC_FAR * This,
/* [out] */ IAddress __RPC_FAR *__RPC_FAR *__MIDL_0014);
void __RPC_STUB IAddressList_GetData_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
HRESULT STDMETHODCALLTYPE IAddressList_Add_Proxy(
IAddressList __RPC_FAR * This,
IAddress __RPC_FAR *__MIDL_0015);
void __RPC_STUB IAddressList_Add_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
HRESULT STDMETHODCALLTYPE IAddressList_Write_Proxy(
IAddressList __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0016);
void __RPC_STUB IAddressList_Write_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
HRESULT STDMETHODCALLTYPE IAddressList_Open_Proxy(
IAddressList __RPC_FAR * This,
/* [in] */ LPSTR __MIDL_0017);
void __RPC_STUB IAddressList_Open_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
#endif /* __IAddressList_INTERFACE_DEFINED__ */
#ifndef __Addressobject_LIBRARY_DEFINED__
#define __Addressobject_LIBRARY_DEFINED__
/* library Addressobject */
/* [version][helpstring][uuid] */
EXTERN_C const IID LIBID_Addressobject;
EXTERN_C const CLSID CLSID_Address;
#ifdef __cplusplus
class DECLSPEC_UUID("E49E4821-F3B3-11d2-A4E3-0040056DF87F")
Address;
#endif
EXTERN_C const CLSID CLSID_AddressList;
#ifdef __cplusplus
class DECLSPEC_UUID("14EF50C1-F3BA-11d2-A4E3-0040056DF87F")
AddressList;
#endif
#endif /* __Addressobject_LIBRARY_DEFINED__ */
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif
| [
"praseedp@gmail.com"
] | praseedp@gmail.com |
5b0e92cc3f092ed9d790d53bd46b95aa5b60b4d9 | 30cd1a7af92fb1243c33f9b8dde445c29118bd1a | /third_party/allwpilib_2016/wpilibc/Athena/src/ADXL362.cpp | 3c70b9b20f1a05aeb6969977448ab26cef394d13 | [
"BSD-2-Clause"
] | permissive | FRC1296/CheezyDriver2016 | 3907a34fd5f8ccd2c90ab1042782106c0947c0cb | 4aa95b16bb63137250d2ad2529b03b2bd56c78c0 | refs/heads/master | 2016-08-12T23:22:00.077919 | 2016-03-19T05:56:18 | 2016-03-19T05:56:18 | 51,854,487 | 2 | 0 | null | 2016-02-29T10:10:27 | 2016-02-16T17:27:07 | C++ | UTF-8 | C++ | false | false | 4,867 | cpp | /*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.
*/
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#include "ADXL362.h"
#include "DigitalInput.h"
#include "DigitalOutput.h"
#include "DriverStation.h"
#include "LiveWindow/LiveWindow.h"
static uint8_t kRegWrite = 0x0A;
static uint8_t kRegRead = 0x0B;
static uint8_t kPartIdRegister = 0x02;
static uint8_t kDataRegister = 0x0E;
static uint8_t kFilterCtlRegister = 0x2C;
static uint8_t kPowerCtlRegister = 0x2D;
//static uint8_t kFilterCtl_Range2G = 0x00;
//static uint8_t kFilterCtl_Range4G = 0x40;
//static uint8_t kFilterCtl_Range8G = 0x80;
static uint8_t kFilterCtl_ODR_100Hz = 0x03;
static uint8_t kPowerCtl_UltraLowNoise = 0x20;
//static uint8_t kPowerCtl_AutoSleep = 0x04;
static uint8_t kPowerCtl_Measure = 0x02;
/**
* Constructor. Uses the onboard CS1.
*
* @param range The range (+ or -) that the accelerometer will measure.
*/
ADXL362::ADXL362(Range range) : ADXL362(SPI::Port::kOnboardCS1, range) {}
/**
* Constructor.
*
* @param port The SPI port the accelerometer is attached to
* @param range The range (+ or -) that the accelerometer will measure.
*/
ADXL362::ADXL362(SPI::Port port, Range range) : m_spi(port) {
m_spi.SetClockRate(3000000);
m_spi.SetMSBFirst();
m_spi.SetSampleDataOnFalling();
m_spi.SetClockActiveLow();
m_spi.SetChipSelectActiveLow();
// Validate the part ID
uint8_t commands[3];
commands[0] = kRegRead;
commands[1] = kPartIdRegister;
commands[2] = 0;
m_spi.Transaction(commands, commands, 3);
if (commands[2] != 0xF2) {
DriverStation::ReportError("could not find ADXL362");
m_gsPerLSB = 0.0;
return;
}
SetRange(range);
// Turn on the measurements
commands[0] = kRegWrite;
commands[1] = kPowerCtlRegister;
commands[2] = kPowerCtl_Measure | kPowerCtl_UltraLowNoise;
m_spi.Write(commands, 3);
HALReport(HALUsageReporting::kResourceType_ADXL362, port);
LiveWindow::GetInstance()->AddSensor("ADXL362", port, this);
}
/** {@inheritdoc} */
void ADXL362::SetRange(Range range) {
if (m_gsPerLSB == 0.0) return;
uint8_t commands[3];
switch (range) {
case kRange_2G:
m_gsPerLSB = 0.001;
break;
case kRange_4G:
m_gsPerLSB = 0.002;
break;
case kRange_8G:
case kRange_16G: // 16G not supported; treat as 8G
m_gsPerLSB = 0.004;
break;
}
// Specify the data format to read
commands[0] = kRegWrite;
commands[1] = kFilterCtlRegister;
commands[2] = kFilterCtl_ODR_100Hz | (uint8_t)((range & 0x03) << 6);
m_spi.Write(commands, 3);
}
/** {@inheritdoc} */
double ADXL362::GetX() { return GetAcceleration(kAxis_X); }
/** {@inheritdoc} */
double ADXL362::GetY() { return GetAcceleration(kAxis_Y); }
/** {@inheritdoc} */
double ADXL362::GetZ() { return GetAcceleration(kAxis_Z); }
/**
* Get the acceleration of one axis in Gs.
*
* @param axis The axis to read from.
* @return Acceleration of the ADXL362 in Gs.
*/
double ADXL362::GetAcceleration(ADXL362::Axes axis) {
if (m_gsPerLSB == 0.0) return 0.0;
uint8_t buffer[4];
uint8_t command[4] = {0, 0, 0, 0};
command[0] = kRegRead;
command[1] = kDataRegister + (uint8_t)axis;
m_spi.Transaction(command, buffer, 4);
// Sensor is little endian... swap bytes
int16_t rawAccel = buffer[3] << 8 | buffer[2];
return rawAccel * m_gsPerLSB;
}
/**
* Get the acceleration of all axes in Gs.
*
* @return An object containing the acceleration measured on each axis of the
* ADXL362 in Gs.
*/
ADXL362::AllAxes ADXL362::GetAccelerations() {
AllAxes data = AllAxes();
if (m_gsPerLSB == 0.0) {
data.XAxis = data.YAxis = data.ZAxis = 0.0;
return data;
}
uint8_t dataBuffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
int16_t rawData[3];
// Select the data address.
dataBuffer[0] = kRegRead;
dataBuffer[1] = kDataRegister;
m_spi.Transaction(dataBuffer, dataBuffer, 8);
for (int32_t i = 0; i < 3; i++) {
// Sensor is little endian... swap bytes
rawData[i] = dataBuffer[i * 2 + 3] << 8 | dataBuffer[i * 2 + 2];
}
data.XAxis = rawData[0] * m_gsPerLSB;
data.YAxis = rawData[1] * m_gsPerLSB;
data.ZAxis = rawData[2] * m_gsPerLSB;
return data;
}
std::string ADXL362::GetSmartDashboardType() const {
return "3AxisAccelerometer";
}
void ADXL362::InitTable(std::shared_ptr<ITable> subtable) {
m_table = subtable;
UpdateTable();
}
void ADXL362::UpdateTable() {
if (m_table != nullptr) {
m_table->PutNumber("X", GetX());
m_table->PutNumber("Y", GetY());
m_table->PutNumber("Z", GetZ());
}
}
std::shared_ptr<ITable> ADXL362::GetTable() const { return m_table; }
| [
"tkb@cheezy.usfluidtech.com"
] | tkb@cheezy.usfluidtech.com |
61bb95d3a4e2fdc8a240bf49dc8197c26e2da7b3 | d9b4514134ee811c705009d05fd21a291a311c54 | /day9/exam9/stdafx.cpp | 3bf00e8f01fda19502b81a99279c535e34323391 | [] | no_license | akemflem1/example | eb2967b2abf85adaf988b227f1a87a0e7468005f | 4904b5e61618154cd7f169a5a6c5a15e5cac8a9c | refs/heads/master | 2020-04-05T13:04:52.555992 | 2017-07-18T07:11:02 | 2017-07-18T07:11:02 | 95,063,396 | 1 | 0 | null | null | null | null | UHC | C++ | false | false | 323 | cpp | // stdafx.cpp : ํ์ค ํฌํจ ํ์ผ๋ง ๋ค์ด ์๋ ์์ค ํ์ผ์
๋๋ค.
// exam9.pch๋ ๋ฏธ๋ฆฌ ์ปดํ์ผ๋ ํค๋๊ฐ ๋ฉ๋๋ค.
// stdafx.obj์๋ ๋ฏธ๋ฆฌ ์ปดํ์ผ๋ ํ์ ์ ๋ณด๊ฐ ํฌํจ๋ฉ๋๋ค.
#include "stdafx.h"
// TODO: ํ์ํ ์ถ๊ฐ ํค๋๋
// ์ด ํ์ผ์ด ์๋ STDAFX.H์์ ์ฐธ์กฐํฉ๋๋ค.
| [
"qhsghks6465@hanmail.net"
] | qhsghks6465@hanmail.net |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.