Giter Site home page Giter Site logo

Comments (3)

romeric avatar romeric commented on June 1, 2024

This should be already possible if you compile with -DFASTOR_ZERO_INITIALISE flag.

from fastor.

Giuseppe499 avatar Giuseppe499 commented on June 1, 2024

I tried to add the flag -DFASTOR_ZERO_INITIALISE using the cmake command target_link_options(Fastor INTERFACE -DFASTOR_ZERO_INITIALISE) but i still can't initialize a constexpr Tensor<>.
My CMake file is:

cmake_minimum_required(VERSION 3.22)
project(RungeKutta)

set(CMAKE_CXX_STANDARD 14)

add_subdirectory(Fastor)
target_link_options(Fastor INTERFACE -DFASTOR_ZERO_INITIALISE)

add_executable(RungeKutta main.cpp Methods/LobattoIIIC.cpp)
target_link_libraries(RungeKutta Fastor)

and my main.cpp is:

#include <iostream>
#include "Fastor/Fastor/Fastor.h"

using namespace Fastor;

constexpr Tensor<double, 3, 3> A = {
        {1/6, -1/3, 1/6},
        {1/6, 5/12, -1/12},
        {1/6, 2/3, 1/6}
};

int main() {
    Tensor<double,2,2> A, B;
    A.iota();
    B.iota();
    Tensor<double,2,2> C = A%B;
    print("C", C);

    std::cout << "Hello, World!" << std::endl;
    std::cout << 1/6 << std::endl;
    return 0;
}

When i compile using CMake i get this error:

error: call to non-‘constexpr’ function ‘Fastor::Tensor<T, Rest>::Tensor(const std::initializer_list<std::initializer_list<U> >&) [with U = int; typename std::enable_if<is_primitive_v_<U>, bool>::type <anonymous> = false; T = double; long unsigned int ...Rest = {3, 3}]’

from fastor.

romeric avatar romeric commented on June 1, 2024

Just fixed in 6d7216f. Please download the latest copy of Fastor.

Note that, this is a road less tested (certain expressions cannot really be assigned using constexpr) so if you experience further problems open a new issue. I am closing this one.

from fastor.

Related Issues (20)

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.