Coder Social home page Coder Social logo

mbsim-env / fmatvec Goto Github PK

View Code? Open in Web Editor NEW
9.0 10.0 4.0 1.63 MB

A fast vector/matrix library

Home Page: https://www.mbsim-env.de

License: GNU Lesser General Public License v2.1

C++ 96.47% Makefile 0.47% M4 0.19% Python 0.79% CMake 2.08%
lapack matrices atlas vector blas matrix-library c-plus-plus linear-algebra matrix

fmatvec's People

Contributors

foerg avatar friedrichatgc avatar greengary avatar kiliangrundl avatar rolandzander avatar tsschindler avatar wangzhanrock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fmatvec's Issues

Problem with the transpose of SymMat

I'm using a symmatric matrix to perform a rotation of a 6x6 stiffness matrix like this:

SqrMat3 rotateY = BasicRotAIKy(phi);
SymMat randomRotationMatrix (6,EYE);
for (unsigned ri=0;ri<=2;ri++){
	for (unsigned rj=0;rj<=i;rj++){
		randomRotationMatrix(ri,rj) = rotateY(ri,rj);
		randomRotationMatrix(ri+3,rj+3) = rotateY(ri,rj);
		}
	}

SymMat rotatedStiffness(6,INIT,0.0);
rotatedStiffness = trans(randomRotationMatrix) * stiffnessMatrix * randomRotationMatrix;

This is a rather old code of mine: I've been using it this way for three years now, but when I compile against fmatvec commit 3c41097 I get the following error:

/usr/local/include/fmatvec/linear_algebra.h:1391:78: error: ‘const class fmatvec::Matrix<fmatvec::Symmetric, fmatvec::Ref, fmatvec::Ref, double>’ has no member named ‘T’
 1391 |   Matrix<Type,Col,Row,AT> trans(const Matrix<Type,Row,Col,AT> &A) { return A.T(); }
      |                                                                            ~~^

Is this a bug or the transpose of symmetric matrices is not currently supported?

MSVC compile error C3066: there are multiple ways ... and "and"

Trying to get #5 done, I spotted an interesting, not trivial compile(er) error. Only MSVC (in all versions) complains about this, gcc and clang have no problem.

Problem:
linear_algebra_double.cc(782) and linear_algebra_double.cc(891) raise error C3066. The called function operator()(const Range<Var,Var> &I) const is declared both in class Vector<Ref,AT> and
Matrix<General,Ref,Ref,AT> (with different return types). Vector derived from Matrix. Both functions are not virtual. The root cause is the using Matrix<General, Ref, Ref, AT>::operator(); in vector.h, which pulls function name operator() into Vector. MSVC now complains about multiple possible ways that an object of this type can be called with these arguments... I am not convinced, that this is really a bug in MSVC. Anyway, this should be fixed (for MSVC or in general)

Potential Fix:

#ifdef _MSC_VER
	  AT* operator()() { return Matrix<General, Ref, Ref, AT>::operator()(); }
	  const AT* operator()() const { return Matrix<General, Ref, Ref, AT>::operator()(); }
#else
	  using Matrix<General, Ref, Ref, AT>::operator();
#endif

Here is a reproducer that can be used to play around e.g. with godbolt or whatever platofrm

template <class Type, class Row, class Col, class XT>
class TestA {};

template <class XT>
class TestA<float, float, float, XT>
{
public:
  float operator()(const int &I) const { return 1.0f; }
};

template <class XT>
class TestB : public TestA<float, float, float, XT>
{
public:
  double operator()(const int &I) const { return 1.0; }
  using TestA<float, float, float, XT>::operator();
};

void failMSVC(int num) {
	TestB<double> b;
	b(2);
}

cmake build gcc

I have seen the cmake branch here, which started in 2015 and which is based on cmake 2.x (as far as I have seen). With this issue, I want to push for a sound, maintained cmake build.

I would like to see (and implement) the following:

  • cmake build using cmake >= 3.10 (e.g. using target_include_directories instead of include_directories)
  • drop in replacement for current autoconf/configure process, remove dependencies to autoconf intermediate artifacts (config.h.in-cmake)
  • setup cmake build process to be platform neutral (allow for future MSVC build)
  • beside make, ninja should be a supported generator

Remarks:

  • Centos 7 ships with cmake 2.8, and installing cmake 3.x via RPM caused me some headache; but setting up cmake from source code works perfectly (in my docker image) - so this should not be an issue.
  • FIND_PACKAGE(LAPACK) was not working, if LAPACK had been installed from source using configure/make/make install. It turned out to be a problem of case -> FIND_PACKAGE(lapack) works.

create docker build images

I see two use cases for docker images within fmatvec project:

  1. Continuous integration
  2. Very concise, declarative way to describe prerequisites for building the software.

I admit, that I do not have enough insights into the current build process to decide, whether docker makes sense (or if it is even already in use).
But imho, it would definitely lower the bar for new users/contributors. Even if not using docker itself, the Dockerfile can be used as blueprint on how to setup a working build environment.
I have prepared two files at the moment, one targets debian:buster, the other target centos7.

If you think docker images make sense, I can share the Dockerfiles I have already created in my private fork of this project.

Support Windows using MSVC

Based on preparation made in isse #4 , the library shall be usable on Windows using MSVC toolchain. Target would be MSVC++ 14.1 _MSC_VER == 1910 (Visual Studio 2017 version 15.0; support for Visual Studio < 2015 would require more refactorintg, see this Microsoft document.

Todos:

  • fix compile errors (not that many)
  • align compiler settings
  • extend cmake script to support MSVC
  • if using dll, all static variables have to be checked thoroughly for portability

Remarks:

  • Linux build creates a shared library (so), the equivalent for Windows would be a dll;
    • Because of the extensive use of templates, the dll might be anemic
    • Because of Microsoft's weird name mangling, a linker lib would be part of the package in addition to dll and headers
    • Maybe it would simplify the usage, if just a static lib + header would make the interface?
    • a static lib would avoid the need for any means (likely a macro) to inject " __declspec(dllexport)" for functions exported by the Windows dll.

=> issue to be discussed!

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.