diff --git a/AttractorKernel.cpp b/AttractorKernel.cpp index 302e216..7460e92 100644 --- a/AttractorKernel.cpp +++ b/AttractorKernel.cpp @@ -53,6 +53,8 @@ void AttractorKernel::dealloc(){ #pragma mark - #pragma mark parameters +// NOTE: inlining these functions (with the keyword inline) improves performance by at most 1% (tested) + double & AttractorKernel::operator[](const unsigned int index){ return parameters[index]; } diff --git a/AttractorKernel.hpp b/AttractorKernel.hpp index 6d0b03c..8ee008f 100644 --- a/AttractorKernel.hpp +++ b/AttractorKernel.hpp @@ -12,18 +12,19 @@ private: void dealloc(); protected: - - // stuff used by subclasses - AttractorKernel(const unsigned int dimension, const unsigned int numberOfParameters); - void reallocParameters(const unsigned int numberOfParameters); - - unsigned int numberOfParameters; + + // biggest type first, this will reduce sizeof(AttractorKernel) + // size is now 40 (when the unsigned int are in front, it was 48) double * parameters; - - unsigned int dimension; double * vectorNew; double * vectorOld; + unsigned int numberOfParameters; + unsigned int dimension; + + // stuff used by subclasses + AttractorKernel(const unsigned int dimension, const unsigned int numberOfParameters); + void reallocParameters(const unsigned int numberOfParameters); public: @@ -37,6 +38,9 @@ public: // getter functions for teh resulta (can't be used as setters) double const * vector() const; +// double const * vector() const{ +// return vectorNew; +// } double const * previousVector() const; unsigned int getDimension() const; diff --git a/AwesomeAttractor.xcodeproj/project.pbxproj b/AwesomeAttractor.xcodeproj/project.pbxproj new file mode 100644 index 0000000..57e2370 --- /dev/null +++ b/AwesomeAttractor.xcodeproj/project.pbxproj @@ -0,0 +1,324 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + 4231201A11A4948B00C2F8D1 /* Attractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4231200411A4948B00C2F8D1 /* Attractor.cpp */; }; + 4231201B11A4948B00C2F8D1 /* Canvas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4231200711A4948B00C2F8D1 /* Canvas.cpp */; }; + 4231202211A4948B00C2F8D1 /* Projector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4231201811A4948B00C2F8D1 /* Projector.cpp */; }; + 4271C3E8120D743D00D64B9A /* AttractorKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4271C3E7120D743D00D64B9A /* AttractorKernel.cpp */; }; + 429CA8FF11E75C70005E35C2 /* libpng.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 429CA8FE11E75C70005E35C2 /* libpng.dylib */; }; + 429CA96B11E75E89005E35C2 /* Logistic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 429CA94E11E75E89005E35C2 /* Logistic.cpp */; }; + 429CA97111E75E89005E35C2 /* pngwriter.cc in Sources */ = {isa = PBXBuildFile; fileRef = 429CA95A11E75E89005E35C2 /* pngwriter.cc */; }; + 429CA97311E75E89005E35C2 /* stf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 429CA96411E75E89005E35C2 /* stf.cpp */; }; + 42C3029B11F3AA6A00DCCC1D /* Lorenz3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 429CA95011E75E89005E35C2 /* Lorenz3D.cpp */; }; + 42C3029C11F3AA7100DCCC1D /* Polynomial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 429CA95211E75E89005E35C2 /* Polynomial.cpp */; }; + 42C3029D11F3AA7100DCCC1D /* PolynomialA3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 429CA95411E75E89005E35C2 /* PolynomialA3D.cpp */; }; + 42C3029E11F3AA7100DCCC1D /* Unravel3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 429CA95611E75E89005E35C2 /* Unravel3D.cpp */; }; + 8DD76F650486A84900D96B5E /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* main.cpp */; settings = {ATTRIBUTES = (); }; }; + 8DD76F6A0486A84900D96B5E /* AwesomeAttractor.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859E8B029090EE04C91782 /* AwesomeAttractor.1 */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 8DD76F690486A84900D96B5E /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + 8DD76F6A0486A84900D96B5E /* AwesomeAttractor.1 in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 08FB7796FE84155DC02AAC07 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + 4231200411A4948B00C2F8D1 /* Attractor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Attractor.cpp; sourceTree = ""; }; + 4231200511A4948B00C2F8D1 /* Attractor.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Attractor.hpp; sourceTree = ""; }; + 4231200611A4948B00C2F8D1 /* AttractorKernel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AttractorKernel.hpp; sourceTree = ""; }; + 4231200711A4948B00C2F8D1 /* Canvas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Canvas.cpp; sourceTree = ""; }; + 4231200811A4948B00C2F8D1 /* Canvas.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Canvas.hpp; sourceTree = ""; }; + 4231200911A4948B00C2F8D1 /* defines.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = defines.hpp; sourceTree = ""; }; + 4231201711A4948B00C2F8D1 /* myMath.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = myMath.hpp; sourceTree = ""; }; + 4231201811A4948B00C2F8D1 /* Projector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Projector.cpp; sourceTree = ""; }; + 4231201911A4948B00C2F8D1 /* Projector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Projector.hpp; sourceTree = ""; }; + 4271C3E7120D743D00D64B9A /* AttractorKernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AttractorKernel.cpp; sourceTree = ""; }; + 429CA8FE11E75C70005E35C2 /* libpng.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libpng.dylib; path = /Developer/SDKs/MacOSX10.6.sdk/usr/X11/lib/libpng.dylib; sourceTree = ""; }; + 429CA94E11E75E89005E35C2 /* Logistic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Logistic.cpp; sourceTree = ""; }; + 429CA94F11E75E89005E35C2 /* Logistic.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Logistic.hpp; sourceTree = ""; }; + 429CA95011E75E89005E35C2 /* Lorenz3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Lorenz3D.cpp; sourceTree = ""; }; + 429CA95111E75E89005E35C2 /* Lorenz3D.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Lorenz3D.hpp; sourceTree = ""; }; + 429CA95211E75E89005E35C2 /* Polynomial.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Polynomial.cpp; sourceTree = ""; }; + 429CA95311E75E89005E35C2 /* Polynomial.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Polynomial.hpp; sourceTree = ""; }; + 429CA95411E75E89005E35C2 /* PolynomialA3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolynomialA3D.cpp; sourceTree = ""; }; + 429CA95511E75E89005E35C2 /* PolynomialA3D.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PolynomialA3D.hpp; sourceTree = ""; }; + 429CA95611E75E89005E35C2 /* Unravel3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Unravel3D.cpp; sourceTree = ""; }; + 429CA95711E75E89005E35C2 /* Unravel3D.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Unravel3D.hpp; sourceTree = ""; }; + 429CA95A11E75E89005E35C2 /* pngwriter.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pngwriter.cc; sourceTree = ""; }; + 429CA95B11E75E89005E35C2 /* pngwriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pngwriter.h; sourceTree = ""; }; + 429CA96411E75E89005E35C2 /* stf.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stf.cpp; sourceTree = ""; }; + 429CA96511E75E89005E35C2 /* stf.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = stf.hpp; sourceTree = ""; }; + 8DD76F6C0486A84900D96B5E /* AwesomeAttractor */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = AwesomeAttractor; sourceTree = BUILT_PRODUCTS_DIR; }; + C6859E8B029090EE04C91782 /* AwesomeAttractor.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = AwesomeAttractor.1; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8DD76F660486A84900D96B5E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 429CA8FF11E75C70005E35C2 /* libpng.dylib in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 08FB7794FE84155DC02AAC07 /* AwesomeAttractor */ = { + isa = PBXGroup; + children = ( + 08FB7795FE84155DC02AAC07 /* Source */, + C6859E8C029090F304C91782 /* Documentation */, + 1AB674ADFE9D54B511CA2CBB /* Products */, + 429CA8FE11E75C70005E35C2 /* libpng.dylib */, + ); + name = AwesomeAttractor; + sourceTree = ""; + }; + 08FB7795FE84155DC02AAC07 /* Source */ = { + isa = PBXGroup; + children = ( + 4271C3E7120D743D00D64B9A /* AttractorKernel.cpp */, + 4231200611A4948B00C2F8D1 /* AttractorKernel.hpp */, + 429CA94B11E75E89005E35C2 /* kernels */, + 429CA95811E75E89005E35C2 /* pngwriter */, + 429CA95C11E75E89005E35C2 /* stfu */, + 4231200411A4948B00C2F8D1 /* Attractor.cpp */, + 4231200511A4948B00C2F8D1 /* Attractor.hpp */, + 4231200711A4948B00C2F8D1 /* Canvas.cpp */, + 4231200811A4948B00C2F8D1 /* Canvas.hpp */, + 4231200911A4948B00C2F8D1 /* defines.hpp */, + 4231201711A4948B00C2F8D1 /* myMath.hpp */, + 4231201811A4948B00C2F8D1 /* Projector.cpp */, + 4231201911A4948B00C2F8D1 /* Projector.hpp */, + 08FB7796FE84155DC02AAC07 /* main.cpp */, + ); + name = Source; + sourceTree = ""; + }; + 1AB674ADFE9D54B511CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8DD76F6C0486A84900D96B5E /* AwesomeAttractor */, + ); + name = Products; + sourceTree = ""; + }; + 429CA94B11E75E89005E35C2 /* kernels */ = { + isa = PBXGroup; + children = ( + 429CA94E11E75E89005E35C2 /* Logistic.cpp */, + 429CA94F11E75E89005E35C2 /* Logistic.hpp */, + 429CA95011E75E89005E35C2 /* Lorenz3D.cpp */, + 429CA95111E75E89005E35C2 /* Lorenz3D.hpp */, + 429CA95211E75E89005E35C2 /* Polynomial.cpp */, + 429CA95311E75E89005E35C2 /* Polynomial.hpp */, + 429CA95411E75E89005E35C2 /* PolynomialA3D.cpp */, + 429CA95511E75E89005E35C2 /* PolynomialA3D.hpp */, + 429CA95611E75E89005E35C2 /* Unravel3D.cpp */, + 429CA95711E75E89005E35C2 /* Unravel3D.hpp */, + ); + path = kernels; + sourceTree = ""; + }; + 429CA95811E75E89005E35C2 /* pngwriter */ = { + isa = PBXGroup; + children = ( + 429CA95A11E75E89005E35C2 /* pngwriter.cc */, + 429CA95B11E75E89005E35C2 /* pngwriter.h */, + ); + path = pngwriter; + sourceTree = ""; + }; + 429CA95C11E75E89005E35C2 /* stfu */ = { + isa = PBXGroup; + children = ( + 429CA96411E75E89005E35C2 /* stf.cpp */, + 429CA96511E75E89005E35C2 /* stf.hpp */, + ); + path = stfu; + sourceTree = ""; + }; + C6859E8C029090F304C91782 /* Documentation */ = { + isa = PBXGroup; + children = ( + C6859E8B029090EE04C91782 /* AwesomeAttractor.1 */, + ); + name = Documentation; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8DD76F620486A84900D96B5E /* AwesomeAttractor */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB923108733DC60010E9CD /* Build configuration list for PBXNativeTarget "AwesomeAttractor" */; + buildPhases = ( + 8DD76F640486A84900D96B5E /* Sources */, + 8DD76F660486A84900D96B5E /* Frameworks */, + 8DD76F690486A84900D96B5E /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = AwesomeAttractor; + productInstallPath = "$(HOME)/bin"; + productName = AwesomeAttractor; + productReference = 8DD76F6C0486A84900D96B5E /* AwesomeAttractor */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 08FB7793FE84155DC02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "AwesomeAttractor" */; + compatibilityVersion = "Xcode 3.1"; + hasScannedForEncodings = 1; + mainGroup = 08FB7794FE84155DC02AAC07 /* AwesomeAttractor */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8DD76F620486A84900D96B5E /* AwesomeAttractor */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 8DD76F640486A84900D96B5E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8DD76F650486A84900D96B5E /* main.cpp in Sources */, + 4231201A11A4948B00C2F8D1 /* Attractor.cpp in Sources */, + 4231201B11A4948B00C2F8D1 /* Canvas.cpp in Sources */, + 4231202211A4948B00C2F8D1 /* Projector.cpp in Sources */, + 429CA96B11E75E89005E35C2 /* Logistic.cpp in Sources */, + 429CA97111E75E89005E35C2 /* pngwriter.cc in Sources */, + 429CA97311E75E89005E35C2 /* stf.cpp in Sources */, + 42C3029B11F3AA6A00DCCC1D /* Lorenz3D.cpp in Sources */, + 42C3029C11F3AA7100DCCC1D /* Polynomial.cpp in Sources */, + 42C3029D11F3AA7100DCCC1D /* PolynomialA3D.cpp in Sources */, + 42C3029E11F3AA7100DCCC1D /* Unravel3D.cpp in Sources */, + 4271C3E8120D743D00D64B9A /* AttractorKernel.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1DEB923208733DC60010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + HEADER_SEARCH_PATHS = "\"$(SDKROOT)/usr/X11/include\""; + INSTALL_PATH = /usr/local/bin; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SDKROOT)/usr/X11/lib\"", + ); + PRODUCT_NAME = AwesomeAttractor; + }; + name = Debug; + }; + 1DEB923308733DC60010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_FAST_MATH = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 2; + HEADER_SEARCH_PATHS = "\"$(SDKROOT)/usr/X11/include\""; + INSTALL_PATH = /usr/local/bin; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SDKROOT)/usr/X11/lib\"", + ); + PRODUCT_NAME = AwesomeAttractor; + }; + name = Release; + }; + 1DEB923608733DC60010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + ONLY_ACTIVE_ARCH = YES; + PREBINDING = NO; + SDKROOT = macosx10.6; + }; + name = Debug; + }; + 1DEB923708733DC60010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_AUTO_VECTORIZATION = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = YES; + GCC_ENABLE_SSE3_EXTENSIONS = YES; + GCC_ENABLE_SSE41_EXTENSIONS = YES; + GCC_ENABLE_SSE42_EXTENSIONS = YES; + GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS = YES; + GCC_MODEL_TUNING = ""; + GCC_OPTIMIZATION_LEVEL = 3; + GCC_UNROLL_LOOPS = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; + PREBINDING = NO; + SDKROOT = macosx10.6; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB923108733DC60010E9CD /* Build configuration list for PBXNativeTarget "AwesomeAttractor" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB923208733DC60010E9CD /* Debug */, + 1DEB923308733DC60010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "AwesomeAttractor" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB923608733DC60010E9CD /* Debug */, + 1DEB923708733DC60010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; +} diff --git a/defines.hpp b/defines.hpp index aff37f6..c680322 100644 --- a/defines.hpp +++ b/defines.hpp @@ -1,7 +1,7 @@ //TODO: do this with files -#define ATTRACTOR_FILE "attractors/testPolynomial.stf" +#define ATTRACTOR_FILE "attractors/testUnravel.stf" #ifdef UNI_BUILD #warning Building for the RU, are you sure? diff --git a/main.cpp b/main.cpp index d36dc63..2a1d75a 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,5 @@ #include #include -using namespace std; #include "Attractor.hpp" #include "Canvas.hpp" @@ -9,6 +8,7 @@ using namespace std; #include "defines.hpp" int main(int argc, char *argv[]) { + clock_t start, end; double totalTime, totalIterations; @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) { } system("clear"); myAttractor.output(); - cout << j << "% done" << endl; + std::cout << j << "% done" << std::endl; } end = clock();