Giter VIP home page Giter VIP logo

ycmatrix's Introduction

YCMatrix

YCMatrix

Build Status DOI Carthage compatible

A flexible Matrix library for Objective-C and Swift, that interfaces BLAS, LAPACK and vDSP functions via the Accelerate Framework.

YCMatrix is available for MacOS (10.7+), as well as iOS (8.0+).

Getting started

Adding the framework to your project

Import the project in your workspace, or open the framework project in XCode, build and import the product.

.. or alternatively, just drag+drop the files (.h and .m) that you want to your project, presto.

Importing

YCMatrix defines a module so in newer versions of XCode, you can simply import the framework with:

@include YCMatrix;

Alternatively, you can do:

#import "YCMatrix/YCMatrix.h"

Dependencies

YCMatrix has no dependencies other than system frameworks (namely Foundation.framework and Accelerate.framework).

Importing/Using with CocoaPods (no longer supported)

Unfortunately Cocoapods is no longer supported as of 0.6.8. The decision to end Cocoapods support is related to the increasing time needed for debugging related to Cocoapods support (e.g. Xcode/OS updates, addition of C++ etc.). Dropping Cocoapods support will allow for more time spent to developing the project. We recommend Carthage for managing your project's dependencies. You may easily include YCMatrix in your cartfile as follows:

github "yconst/YCMatrix"

In addition, YCMatrix can be easily included manually into an Xcode project, by copying header and implementation files (and optionally creating a new target).

Usage

Naming Conventions

Methods that result in a new Matrix instance are usually prefixed with "matrixFrom", e.g. -matrixFromSubtraction: . Methods that change the receiver in-place do not have the prefix. In some cases, such as matrix-matrix multiplication, the prefix is not included in the method name, even though it is obvious that the result of the operation is a new Matrix instance.

Example

The snippet below is a basic example of matrix multiplication. It also shows how you can easily create matrices with predefined values.

@include YCMatrix;

Matrix *I = [Matrix identityOfRows:3 columns:3]; // 3x3 Identity
Matrix *C = [Matrix matrixOfRows:3 columns:3 value:2]; // 3x3 filled with 2s
Matrix *S = [I matrixByAddition:C]; // Outputs a new matrix
NSLog(@"Result:\n%@", S);

// Result:
// 3.0  2.0  2.0
// 2.0  3.0  2.0
// 2.0  2.0  3.0

What's in there?

The Framework functionality is split into four files: The base class definition, and three categories:

  • Matrix.h : YCMatrix class definition and basic operations.
  • Matrix+Advanced.h : Interface to more advanced LAPACK functions.
  • Matrix+Manipulate.h : Functions for manipulating rows/columns etc.
  • Matrix+Map.h : Functions for linearly mapping matrices.

In addition, there is a file that implements functionality related to NSArrays containing Matrices.

Please refer to the docs for a complete overview of the functionality contained in each of the categories.

In addition, YCMatrix comes with many unit tests included. Tests are divided in six files:

  • YCMatrixTests : General Matrix-related tests.
  • YCMatrixAdvancedTests : Tests related to higher-level operations (decompositions, inverses etc.).
  • YCMatrixManipulateTests : Tests related to matrix manipulation operations.
  • YCMatrixMapTests : Tests related to linear mapping operations.
  • YCMatrixNSArrayTests : Tests related to NSArray categories.
  • YCMatrixPerformanceTests: Tests for measuring performance of various operations.

Performance

YCMatrix has been built from the ground up with performance in mind. vDSP, BLAS and LAPACK are being used extensively throughout the framework. In addition, care has been given in memory allocation during initialization and copying.

The test file YCMatrixPerformanceTests.m contains some benchmarks using different addition/subtraction implementations (vDSP, BLAS, and pure C).

License

YCMatrix

Copyright (c) 2013 - 2016 Ioannis (Yannis) Chatzikonstantinou. All rights reserved. http://yconst.com

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.

Acknowledgments

This software relies on the following copyrighted material, the use of which is hereby acknowledged.


soboldata.h and sobolseq.c Part of the NLOpt Software

Copyright (c) 2007 Massachusetts Institute of Technology

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.


haltondata.cpp

Copyright (c) 2012 Leonhard Gruenschloss ([email protected])

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.


Routine for computing the Singular Value Decomposition of column-major matrix A using LAPACK

Author: Luke Lonergan Date: 5/31/08 License: Use pfreely

ycmatrix's People

Contributors

alexsosn avatar readmecritic avatar yconst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ycmatrix's Issues

Pod install issue

Undefined symbols for architecture x86_64:
  "std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
      std::__1::vector<std::__1::vector<unsigned short, std::__1::allocator<unsigned short> >, std::__1::allocator<std::__1::vector<unsigned short, std::__1::allocator<unsigned short> > > >::allocate(unsigned long) in libYCMatrix.a(HaltonInterface.o)
      std::__1::vector<unsigned short, std::__1::allocator<unsigned short> >::__append(unsigned long) in libYCMatrix.a(HaltonInterface.o)
  "std::terminate()", referenced from:
      ___clang_call_terminate in libYCMatrix.a(HaltonInterface.o)
  "operator delete(void*)", referenced from:
      std::__1::__vector_base<std::__1::vector<unsigned short, std::__1::allocator<unsigned short> >, std::__1::allocator<std::__1::vector<unsigned short, std::__1::allocator<unsigned short> > > >::~__vector_base() in libYCMatrix.a(HaltonInterface.o)
      std::__1::__vector_base<unsigned short, std::__1::allocator<unsigned short> >::~__vector_base() in libYCMatrix.a(HaltonInterface.o)
      std::__1::__split_buffer<unsigned short, std::__1::allocator<unsigned short>&>::~__split_buffer() in libYCMatrix.a(HaltonInterface.o)
  "operator new(unsigned long)", referenced from:
      std::__1::vector<std::__1::vector<unsigned short, std::__1::allocator<unsigned short> >, std::__1::allocator<std::__1::vector<unsigned short, std::__1::allocator<unsigned short> > > >::allocate(unsigned long) in libYCMatrix.a(HaltonInterface.o)
      std::__1::__split_buffer<unsigned short, std::__1::allocator<unsigned short>&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator<unsigned short>&) in libYCMatrix.a(HaltonInterface.o)
  "___cxa_begin_catch", referenced from:
      ___clang_call_terminate in libYCMatrix.a(HaltonInterface.o)
  "___gxx_personality_v0", referenced from:
      +[HaltonInterface sampleWithDimension:count:] in libYCMatrix.a(HaltonInterface.o)
      Halton_sampler::init_faure() in libYCMatrix.a(HaltonInterface.o)
      std::__1::vector<unsigned short, std::__1::allocator<unsigned short> >::resize(unsigned long) in libYCMatrix.a(HaltonInterface.o)
      std::__1::vector<std::__1::vector<unsigned short, std::__1::allocator<unsigned short> >, std::__1::allocator<std::__1::vector<unsigned short, std::__1::allocator<unsigned short> > > >::vector(unsigned long) in libYCMatrix.a(HaltonInterface.o)
      std::__1::vector<unsigned short, std::__1::allocator<unsigned short> >::__append(unsigned long) in libYCMatrix.a(HaltonInterface.o)
      Dwarf Exception Unwind Info (__eh_frame) in libYCMatrix.a(HaltonInterface.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)




I am getting a build error in iOS 9.2 ? just when installing the pod

Finding inverse?

Is there a method to find the inverse of a matrix? Could not find one in the documentation

eigenValuesAndEigenVectors not working

Created an matrix as such:

[0, 4 8, 12
1, 5, 9, 13
2, 6, 10, 14
3, 7, 11, 15]

The output returned from eigenValuesAndEigenVectors is incorrect. eigenValues, however, returns the correct output.

setPolyToPoly

Does YCMatrix have a method that is the same as the setPolyToPoly method on Android?
https://developer.android.com/reference/android/graphics/Matrix

I tried to look at each file in the repo but couldn't find it. To be short, I want to implement the same thing as Android's Matrix.setPolyToPoly on iOS. Apple's Core Graphics doesn't seem to have a similar method. That's why I searched and ended up finding with this repo.

Thank you in advance.

Removing Column Doesn't Work

- (Matrix *)removeColumn:(int)rowNumber doesn't seem work good. Wrong answers when using it.

Returns zeros after first row:

double test[16] = {
        16.0, 2.0,  3.0,  13.0,
        5.0,  11.0, 10.0, 8.0,
        9.0,  7.0,  6.0,  12.0,
        4.0,  14.0, 15.0, 0.05
    };

    Matrix *mainMatrix = [Matrix matrixFromArray:test Rows:4 Columns:4];
    CleanNSLog(@"%@", mainMatrix);
    Matrix *resultMatrix = [mainMatrix removeColumn:1];
    CleanNSLog(@"%@", resultMatrix);

Logger

    16.000000   2.000000    3.000000    13.000000
    5.000000    11.000000   10.000000   8.000000
    9.000000    7.000000    6.000000    12.000000
    4.000000    14.000000   15.000000   0.050000


    16.000000   3.000000    13.000000
    0.000000    0.000000    0.000000
    0.000000    0.000000    0.000000
    0.000000    0.000000    0.000000

Shuffling rows isn't working correctly

When I try shuffling rows, it messes up by putting values in different columns. I want to shuffle rows, but keep every value within their respective columns.

Here's an example.

Unshuffled:

1.000000    10.000000   100.000000  1000.000000 10000.000000
2.000000    20.000000   200.000000  2000.000000 20000.000000
3.000000    30.000000   300.000000  3000.000000 30000.000000
4.000000    40.000000   400.000000  4000.000000 40000.000000

Shuffled (Both in place shuffling and out-of-place):

300.000000  3000.000000 30000.000000    4.000000    40.000000
10.000000   100.000000  1000.000000 1.000000    2.000000
20.000000   200.000000  10000.000000    20000.000000    3.000000
30.000000   2000.000000 400.000000  4000.000000 40000.000000

Expected Result:

4.000000    40.000000   400.000000  4000.000000 40000.000000
1.000000    10.000000   100.000000  1000.000000 10000.000000
3.000000    30.000000   300.000000  3000.000000 30000.000000
2.000000    20.000000   200.000000  2000.000000 20000.000000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.