kandi background
Explore Kits

spack | flexible package manager that supports multiple versions | Build Tool library

 by   spack Python Version: v0.17.2 License: Non-SPDX

 by   spack Python Version: v0.17.2 License: Non-SPDX

Download this library from

kandi X-RAY | spack Summary

spack is a Python library typically used in Utilities, Build Tool applications. spack has high support. However spack has 289 bugs, it has 2 vulnerabilities, it build file is not available and it has a Non-SPDX License. You can download it from GitHub, GitLab.
Spack is a multi-platform package manager that builds and installs multiple versions and configurations of software. It works on Linux, macOS, and many supercomputers. Spack is non-destructive: installing a new version of a package does not break existing installations, so many configurations of the same package can coexist. Spack offers a simple "spec" syntax that allows users to specify versions and configuration options. Package files are written in pure Python, and specs allow package authors to write a single script for many different builds of the same package. With Spack, you can build your software all the ways you want to. See the Feature Overview for examples and highlights.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • spack has a highly active ecosystem.
  • It has 2620 star(s) with 1587 fork(s). There are 100 watchers for this library.
  • There were 1 major release(s) in the last 6 months.
  • There are 1803 open issues and 4398 have been closed. On average issues are closed in 176 days. There are 610 open pull requests and 0 closed requests.
  • It has a negative sentiment in the developer community.
  • The latest version of spack is v0.17.2
spack Support
Best in #Build Tool
Average in #Build Tool
spack Support
Best in #Build Tool
Average in #Build Tool

quality kandi Quality

  • spack has 289 bugs (234 blocker, 0 critical, 47 major, 8 minor) and 7667 code smells.
spack Quality
Best in #Build Tool
Average in #Build Tool
spack Quality
Best in #Build Tool
Average in #Build Tool

securitySecurity

  • spack has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • spack code analysis shows 2 unresolved vulnerabilities (0 blocker, 2 critical, 0 major, 0 minor).
  • There are 3424 security hotspots that need review.
spack Security
Best in #Build Tool
Average in #Build Tool
spack Security
Best in #Build Tool
Average in #Build Tool

license License

  • spack has a Non-SPDX License.
  • Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.
spack License
Best in #Build Tool
Average in #Build Tool
spack License
Best in #Build Tool
Average in #Build Tool

buildReuse

  • spack releases are available to install and integrate.
  • spack has no build file. You will be need to create the build yourself to build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • spack saves you 238596 person hours of effort in developing the same functionality from scratch.
  • It has 234727 lines of code, 14763 functions and 5860 files.
  • It has low code complexity. Code complexity directly impacts maintainability of the code.
spack Reuse
Best in #Build Tool
Average in #Build Tool
spack Reuse
Best in #Build Tool
Average in #Build Tool
Top functions reviewed by kandi - BETA

kandi has reviewed spack and discovered the below as its top functions. This is intended to give you an instant insight into spack implemented functionality, and help decide if they suit your requirements.

  • Generate gitlab - ci_ci_cii .
  • Executes ci rebuild .
  • Parses the given argument strings for known arguments .
  • Write the buildfile configuration .
  • Create a host configuration file .
  • Parse the version number from the given path .
  • Create the host configuration file .
  • Replies a pipeline yaml file .
  • Builds a tar archive
  • Checks the installation of VTK - M .

spack Key Features

A flexible package manager that supports multiple versions, configurations, platforms, and compilers.

default

copy iconCopydownload iconDownload
$ git clone -c feature.manyFiles=true https://github.com/spack/spack.git
$ cd spack/bin
$ ./spack install zlib

Replacing variable from vars/main.yml into ansible inventory

copy iconCopydownload iconDownload
shell> cat playbook.yml
---
- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    BASE_SERVERIP: 192.168.10
    PACKAGE_SERVER: "{{ BASE_SERVERIP }}.2"
  tasks:
    - add_host:
        hostname: "{{ PACKAGE_SERVER }}"
        groups: package_server

- name: Use group package_server
  hosts: package_server
  gather_facts: false
  tasks:
    - debug:
        msg: Creating package dir
shell> ansible-playbook playbook.yml

PLAY [Create group package_server] **************************************

TASK [add_host] *********************************************************
changed: [localhost]

PLAY [Use group package_server] *****************************************

TASK [debug] ************************************************************
ok: [192.168.10.2] => 
  msg: Creating package dir

PLAY RECAP **************************************************************
192.168.10.2: ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0   
localhost   : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 
- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    clients: "{{ ['192.168.10']|
                 product(range(3,6))|
                 map('join', '.')|
                 list }}"
  tasks:
    - debug:
        var: clients
    - add_host:
        hostname: "{{ item }}"
        groups: package_server
      loop: "{{ clients }}"
clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.10.5
    c:
      A: [192]
      B: [168]
      C: [10, 12]
      D: [3, 5]
    clients: "{{ range(c.A.0, c.A.1|d(c.A.0 + 1))|
                 product(range(c.B.0, c.B.1|d(c.B.0 + 1)))|map('flatten')|
                 product(range(c.C.0, c.C.1|d(c.C.0 + 1)))|map('flatten')|
                 product(range(c.D.0, c.D.1|d(c.D.0 + 1)))|map('flatten')|
                 map('join', '.')|list }}"
clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.11.3
  - 192.168.11.4
-----------------------
shell> cat playbook.yml
---
- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    BASE_SERVERIP: 192.168.10
    PACKAGE_SERVER: "{{ BASE_SERVERIP }}.2"
  tasks:
    - add_host:
        hostname: "{{ PACKAGE_SERVER }}"
        groups: package_server

- name: Use group package_server
  hosts: package_server
  gather_facts: false
  tasks:
    - debug:
        msg: Creating package dir
shell> ansible-playbook playbook.yml

PLAY [Create group package_server] **************************************

TASK [add_host] *********************************************************
changed: [localhost]

PLAY [Use group package_server] *****************************************

TASK [debug] ************************************************************
ok: [192.168.10.2] => 
  msg: Creating package dir

PLAY RECAP **************************************************************
192.168.10.2: ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0   
localhost   : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 
- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    clients: "{{ ['192.168.10']|
                 product(range(3,6))|
                 map('join', '.')|
                 list }}"
  tasks:
    - debug:
        var: clients
    - add_host:
        hostname: "{{ item }}"
        groups: package_server
      loop: "{{ clients }}"
clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.10.5
    c:
      A: [192]
      B: [168]
      C: [10, 12]
      D: [3, 5]
    clients: "{{ range(c.A.0, c.A.1|d(c.A.0 + 1))|
                 product(range(c.B.0, c.B.1|d(c.B.0 + 1)))|map('flatten')|
                 product(range(c.C.0, c.C.1|d(c.C.0 + 1)))|map('flatten')|
                 product(range(c.D.0, c.D.1|d(c.D.0 + 1)))|map('flatten')|
                 map('join', '.')|list }}"
clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.11.3
  - 192.168.11.4
-----------------------
shell> cat playbook.yml
---
- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    BASE_SERVERIP: 192.168.10
    PACKAGE_SERVER: "{{ BASE_SERVERIP }}.2"
  tasks:
    - add_host:
        hostname: "{{ PACKAGE_SERVER }}"
        groups: package_server

- name: Use group package_server
  hosts: package_server
  gather_facts: false
  tasks:
    - debug:
        msg: Creating package dir
shell> ansible-playbook playbook.yml

PLAY [Create group package_server] **************************************

TASK [add_host] *********************************************************
changed: [localhost]

PLAY [Use group package_server] *****************************************

TASK [debug] ************************************************************
ok: [192.168.10.2] => 
  msg: Creating package dir

PLAY RECAP **************************************************************
192.168.10.2: ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0   
localhost   : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 
- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    clients: "{{ ['192.168.10']|
                 product(range(3,6))|
                 map('join', '.')|
                 list }}"
  tasks:
    - debug:
        var: clients
    - add_host:
        hostname: "{{ item }}"
        groups: package_server
      loop: "{{ clients }}"
clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.10.5
    c:
      A: [192]
      B: [168]
      C: [10, 12]
      D: [3, 5]
    clients: "{{ range(c.A.0, c.A.1|d(c.A.0 + 1))|
                 product(range(c.B.0, c.B.1|d(c.B.0 + 1)))|map('flatten')|
                 product(range(c.C.0, c.C.1|d(c.C.0 + 1)))|map('flatten')|
                 product(range(c.D.0, c.D.1|d(c.D.0 + 1)))|map('flatten')|
                 map('join', '.')|list }}"
clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.11.3
  - 192.168.11.4
-----------------------
shell> cat playbook.yml
---
- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    BASE_SERVERIP: 192.168.10
    PACKAGE_SERVER: "{{ BASE_SERVERIP }}.2"
  tasks:
    - add_host:
        hostname: "{{ PACKAGE_SERVER }}"
        groups: package_server

- name: Use group package_server
  hosts: package_server
  gather_facts: false
  tasks:
    - debug:
        msg: Creating package dir
shell> ansible-playbook playbook.yml

PLAY [Create group package_server] **************************************

TASK [add_host] *********************************************************
changed: [localhost]

PLAY [Use group package_server] *****************************************

TASK [debug] ************************************************************
ok: [192.168.10.2] => 
  msg: Creating package dir

PLAY RECAP **************************************************************
192.168.10.2: ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0   
localhost   : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 
- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    clients: "{{ ['192.168.10']|
                 product(range(3,6))|
                 map('join', '.')|
                 list }}"
  tasks:
    - debug:
        var: clients
    - add_host:
        hostname: "{{ item }}"
        groups: package_server
      loop: "{{ clients }}"
clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.10.5
    c:
      A: [192]
      B: [168]
      C: [10, 12]
      D: [3, 5]
    clients: "{{ range(c.A.0, c.A.1|d(c.A.0 + 1))|
                 product(range(c.B.0, c.B.1|d(c.B.0 + 1)))|map('flatten')|
                 product(range(c.C.0, c.C.1|d(c.C.0 + 1)))|map('flatten')|
                 product(range(c.D.0, c.D.1|d(c.D.0 + 1)))|map('flatten')|
                 map('join', '.')|list }}"
clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.11.3
  - 192.168.11.4
-----------------------
shell> cat playbook.yml
---
- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    BASE_SERVERIP: 192.168.10
    PACKAGE_SERVER: "{{ BASE_SERVERIP }}.2"
  tasks:
    - add_host:
        hostname: "{{ PACKAGE_SERVER }}"
        groups: package_server

- name: Use group package_server
  hosts: package_server
  gather_facts: false
  tasks:
    - debug:
        msg: Creating package dir
shell> ansible-playbook playbook.yml

PLAY [Create group package_server] **************************************

TASK [add_host] *********************************************************
changed: [localhost]

PLAY [Use group package_server] *****************************************

TASK [debug] ************************************************************
ok: [192.168.10.2] => 
  msg: Creating package dir

PLAY RECAP **************************************************************
192.168.10.2: ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0   
localhost   : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 
- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    clients: "{{ ['192.168.10']|
                 product(range(3,6))|
                 map('join', '.')|
                 list }}"
  tasks:
    - debug:
        var: clients
    - add_host:
        hostname: "{{ item }}"
        groups: package_server
      loop: "{{ clients }}"
clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.10.5
    c:
      A: [192]
      B: [168]
      C: [10, 12]
      D: [3, 5]
    clients: "{{ range(c.A.0, c.A.1|d(c.A.0 + 1))|
                 product(range(c.B.0, c.B.1|d(c.B.0 + 1)))|map('flatten')|
                 product(range(c.C.0, c.C.1|d(c.C.0 + 1)))|map('flatten')|
                 product(range(c.D.0, c.D.1|d(c.D.0 + 1)))|map('flatten')|
                 map('join', '.')|list }}"
clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.11.3
  - 192.168.11.4
-----------------------
shell> cat playbook.yml
---
- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    BASE_SERVERIP: 192.168.10
    PACKAGE_SERVER: "{{ BASE_SERVERIP }}.2"
  tasks:
    - add_host:
        hostname: "{{ PACKAGE_SERVER }}"
        groups: package_server

- name: Use group package_server
  hosts: package_server
  gather_facts: false
  tasks:
    - debug:
        msg: Creating package dir
shell> ansible-playbook playbook.yml

PLAY [Create group package_server] **************************************

TASK [add_host] *********************************************************
changed: [localhost]

PLAY [Use group package_server] *****************************************

TASK [debug] ************************************************************
ok: [192.168.10.2] => 
  msg: Creating package dir

PLAY RECAP **************************************************************
192.168.10.2: ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0   
localhost   : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 
- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    clients: "{{ ['192.168.10']|
                 product(range(3,6))|
                 map('join', '.')|
                 list }}"
  tasks:
    - debug:
        var: clients
    - add_host:
        hostname: "{{ item }}"
        groups: package_server
      loop: "{{ clients }}"
clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.10.5
    c:
      A: [192]
      B: [168]
      C: [10, 12]
      D: [3, 5]
    clients: "{{ range(c.A.0, c.A.1|d(c.A.0 + 1))|
                 product(range(c.B.0, c.B.1|d(c.B.0 + 1)))|map('flatten')|
                 product(range(c.C.0, c.C.1|d(c.C.0 + 1)))|map('flatten')|
                 product(range(c.D.0, c.D.1|d(c.D.0 + 1)))|map('flatten')|
                 map('join', '.')|list }}"
clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.11.3
  - 192.168.11.4

Why does `gcc -ffast-math` disable the correct result of `isnan()` and `isinf()`?

copy iconCopydownload iconDownload
  printf("This should be a NaN: %.6e\n", sqrtf(-1.f));
  printf("This should be inf: %.6e\n", 1.f/0.f);
  printf("isnan failed?\n");
  printf("isinf failed?\n");

How can I find hpcviewer in order to visualize trace data generated by hpcrun?

copy iconCopydownload iconDownload
spack load hpctoolkit 
hpcviewer hpctoolkit-"name_of_exec"-database
-----------------------
spack load hpctoolkit 
hpcviewer hpctoolkit-"name_of_exec"-database

How can I make the C++ compiler support template for STL?

copy iconCopydownload iconDownload
compilers:
- compiler:
        spec: gcc@7.5.0
        paths:
          cc: /usr/bin/gcc-7
          cxx: null
          f77: /usr/bin/gfortran-7
          fc: /usr/bin/gfortran-7
        flags: {}
        operating_system: ubuntu20.04
        target: x86_64
        modules: []
        environment: {}
        extra_rpaths: []

- compiler:
    spec: gcc@9.3.0
    paths:
      cc: /usr/bin/gcc-9
      cxx: /usr/bin/g++-9
      f77: /usr/bin/gfortran-9
      fc: /usr/bin/gfortran-9
    flags: {}
    operating_system: ubuntu20.04
    target: x86_64
    modules: []
    environment: {}
    extra_rpaths: []

Change version of gcc which does not support compiling C++ programs using the compilers.yaml file

copy iconCopydownload iconDownload
spack compiler list 
-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0    gcc@10.2.0
cd ~/.spack/linux
emacs compilers.yaml & 
    compilers:
    - compiler:
            spec: gcc@10.2.0
            paths:
              cc: /usr/bin/gcc-10
              cxx: null
              f77: /usr/bin/gfortran-10
              fc: /usr/bin/gfortran-10
            flags: {}
            operating_system: ubuntu20.04
            target: x86_64
            modules: []
            environment: {}
            extra_rpaths: []

    - compiler:
        spec: gcc@9.3.0
        paths:
          cc: /usr/bin/gcc-9
          cxx: null
          f77: /usr/bin/gfortran-9
          fc: /usr/bin/gfortran-9
        flags: {}
        operating_system: ubuntu20.04
        target: x86_64
        modules: []
        environment: {}
        extra_rpaths: []
-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0
spack install hpctoolkit 
-----------------------
spack compiler list 
-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0    gcc@10.2.0
cd ~/.spack/linux
emacs compilers.yaml & 
    compilers:
    - compiler:
            spec: gcc@10.2.0
            paths:
              cc: /usr/bin/gcc-10
              cxx: null
              f77: /usr/bin/gfortran-10
              fc: /usr/bin/gfortran-10
            flags: {}
            operating_system: ubuntu20.04
            target: x86_64
            modules: []
            environment: {}
            extra_rpaths: []

    - compiler:
        spec: gcc@9.3.0
        paths:
          cc: /usr/bin/gcc-9
          cxx: null
          f77: /usr/bin/gfortran-9
          fc: /usr/bin/gfortran-9
        flags: {}
        operating_system: ubuntu20.04
        target: x86_64
        modules: []
        environment: {}
        extra_rpaths: []
-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0
spack install hpctoolkit 
-----------------------
spack compiler list 
-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0    gcc@10.2.0
cd ~/.spack/linux
emacs compilers.yaml & 
    compilers:
    - compiler:
            spec: gcc@10.2.0
            paths:
              cc: /usr/bin/gcc-10
              cxx: null
              f77: /usr/bin/gfortran-10
              fc: /usr/bin/gfortran-10
            flags: {}
            operating_system: ubuntu20.04
            target: x86_64
            modules: []
            environment: {}
            extra_rpaths: []

    - compiler:
        spec: gcc@9.3.0
        paths:
          cc: /usr/bin/gcc-9
          cxx: null
          f77: /usr/bin/gfortran-9
          fc: /usr/bin/gfortran-9
        flags: {}
        operating_system: ubuntu20.04
        target: x86_64
        modules: []
        environment: {}
        extra_rpaths: []
-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0
spack install hpctoolkit 
-----------------------
spack compiler list 
-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0    gcc@10.2.0
cd ~/.spack/linux
emacs compilers.yaml & 
    compilers:
    - compiler:
            spec: gcc@10.2.0
            paths:
              cc: /usr/bin/gcc-10
              cxx: null
              f77: /usr/bin/gfortran-10
              fc: /usr/bin/gfortran-10
            flags: {}
            operating_system: ubuntu20.04
            target: x86_64
            modules: []
            environment: {}
            extra_rpaths: []

    - compiler:
        spec: gcc@9.3.0
        paths:
          cc: /usr/bin/gcc-9
          cxx: null
          f77: /usr/bin/gfortran-9
          fc: /usr/bin/gfortran-9
        flags: {}
        operating_system: ubuntu20.04
        target: x86_64
        modules: []
        environment: {}
        extra_rpaths: []
-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0
spack install hpctoolkit 
-----------------------
spack compiler list 
-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0    gcc@10.2.0
cd ~/.spack/linux
emacs compilers.yaml & 
    compilers:
    - compiler:
            spec: gcc@10.2.0
            paths:
              cc: /usr/bin/gcc-10
              cxx: null
              f77: /usr/bin/gfortran-10
              fc: /usr/bin/gfortran-10
            flags: {}
            operating_system: ubuntu20.04
            target: x86_64
            modules: []
            environment: {}
            extra_rpaths: []

    - compiler:
        spec: gcc@9.3.0
        paths:
          cc: /usr/bin/gcc-9
          cxx: null
          f77: /usr/bin/gfortran-9
          fc: /usr/bin/gfortran-9
        flags: {}
        operating_system: ubuntu20.04
        target: x86_64
        modules: []
        environment: {}
        extra_rpaths: []
-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0
spack install hpctoolkit 
-----------------------
spack compiler list 
-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0    gcc@10.2.0
cd ~/.spack/linux
emacs compilers.yaml & 
    compilers:
    - compiler:
            spec: gcc@10.2.0
            paths:
              cc: /usr/bin/gcc-10
              cxx: null
              f77: /usr/bin/gfortran-10
              fc: /usr/bin/gfortran-10
            flags: {}
            operating_system: ubuntu20.04
            target: x86_64
            modules: []
            environment: {}
            extra_rpaths: []

    - compiler:
        spec: gcc@9.3.0
        paths:
          cc: /usr/bin/gcc-9
          cxx: null
          f77: /usr/bin/gfortran-9
          fc: /usr/bin/gfortran-9
        flags: {}
        operating_system: ubuntu20.04
        target: x86_64
        modules: []
        environment: {}
        extra_rpaths: []
-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0
spack install hpctoolkit 

How do I install and use PNGwriter to write PNG image files?

copy iconCopydownload iconDownload
    # For bash/zsh/sh
    $ . spack/share/spack/setup-env.sh
    
    # For tcsh/csh
    $ source spack/share/spack/setup-env.csh
    
    # For fish
    $ . spack/share/spack/setup-env.fish
    spack install pngwriter
    spack load pngwriter
    g++ example.cpp -o example `freetype-config --cflags` -I/usr/local/include  -L/usr/local/lib -lPNGwriter -lpng -lz -lfreetype
-----------------------
    # For bash/zsh/sh
    $ . spack/share/spack/setup-env.sh
    
    # For tcsh/csh
    $ source spack/share/spack/setup-env.csh
    
    # For fish
    $ . spack/share/spack/setup-env.fish
    spack install pngwriter
    spack load pngwriter
    g++ example.cpp -o example `freetype-config --cflags` -I/usr/local/include  -L/usr/local/lib -lPNGwriter -lpng -lz -lfreetype
-----------------------
    # For bash/zsh/sh
    $ . spack/share/spack/setup-env.sh
    
    # For tcsh/csh
    $ source spack/share/spack/setup-env.csh
    
    # For fish
    $ . spack/share/spack/setup-env.fish
    spack install pngwriter
    spack load pngwriter
    g++ example.cpp -o example `freetype-config --cflags` -I/usr/local/include  -L/usr/local/lib -lPNGwriter -lpng -lz -lfreetype
-----------------------
    # For bash/zsh/sh
    $ . spack/share/spack/setup-env.sh
    
    # For tcsh/csh
    $ source spack/share/spack/setup-env.csh
    
    # For fish
    $ . spack/share/spack/setup-env.fish
    spack install pngwriter
    spack load pngwriter
    g++ example.cpp -o example `freetype-config --cflags` -I/usr/local/include  -L/usr/local/lib -lPNGwriter -lpng -lz -lfreetype

How to run Popper on HPC without sudo rights

copy iconCopydownload iconDownload
 ~/popper/bin/popper run --engine singularity --file wf.yml --config popper_config.yml 1
resource_manager:
  name: slurm
  options:
    "1": # The default step ID is a number and needs quotes here.
      nodes: 1
      mem-per-cpu: 10 # MB
      ntasks: 1
      partition: test
      time: "00:01:00"
FATAL:   could not use fakeroot: no mapping entry found in /etc/subuid
-----------------------
 ~/popper/bin/popper run --engine singularity --file wf.yml --config popper_config.yml 1
resource_manager:
  name: slurm
  options:
    "1": # The default step ID is a number and needs quotes here.
      nodes: 1
      mem-per-cpu: 10 # MB
      ntasks: 1
      partition: test
      time: "00:01:00"
FATAL:   could not use fakeroot: no mapping entry found in /etc/subuid
-----------------------
 ~/popper/bin/popper run --engine singularity --file wf.yml --config popper_config.yml 1
resource_manager:
  name: slurm
  options:
    "1": # The default step ID is a number and needs quotes here.
      nodes: 1
      mem-per-cpu: 10 # MB
      ntasks: 1
      partition: test
      time: "00:01:00"
FATAL:   could not use fakeroot: no mapping entry found in /etc/subuid

Compilation working on my Mac but not on the cluster (Linux)

copy iconCopydownload iconDownload
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <array>  


using Integer=long;
using Real=double;



template <typename T, std::size_t>
using getTypeSequence = T;



template <typename, typename>
class TensorBase;

template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
{
protected:
    std::array<T, sizeof...(Is)> values{};
    static const std::size_t Size = sizeof...(Is);

public:
    constexpr TensorBase (getTypeSequence<T, Is> ... vals)
    : values{{vals...}}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> const & a)
    : values{a}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> && a)
    : values{std::move(a)}
    {}

    // TensorBase(std::initializer_list<T> a)
    // {
    //     assert(a.size() == Size);
    //     std::copy(std::begin(a), std::end(a), std::begin(values));
    // }

    constexpr TensorBase () = default;

    ~TensorBase() = default;

    constexpr TensorBase (TensorBase const &) = default;
    constexpr TensorBase (TensorBase &&) = default;

    constexpr TensorBase & operator= (TensorBase const &) = default;
    constexpr TensorBase & operator= (TensorBase &&) = default;
};


template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
{
public:
    static constexpr Integer Rows=Rows_;
    static constexpr Integer Cols=Cols_;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }
    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }
    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }
};





template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer,1>> 
{
public:
    static constexpr Integer Rows=1;
    static constexpr Integer Cols=1;
    using T= Real;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer,Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }

    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }

    inline constexpr T &operator[](const Integer i)
    {
        assert(i < Rows);
        return values[i];
    }

    inline constexpr const T &operator[](const Integer i)const
    {
        assert(i < Rows);
        return values[i];
    }


    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }


};

int main(int argc, char *argv[])
{
constexpr Matrix<Real,1,1> mat{1.0};


std::cout<<"it works"<<std::endl;
static_assert(mat(0,0)==1.0);



return 0;
}
template <typename T, Integer ... Is>
class TensorBase<T, std::index_sequence<Is...>>
template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_index_sequence<Rows_*Cols_>> 
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_index_sequence<1>> 
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer, 1>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
inline constexpr T &operator()(const Integer i)const
inline constexpr const T &operator()(const Integer i)const
-----------------------
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <array>  


using Integer=long;
using Real=double;



template <typename T, std::size_t>
using getTypeSequence = T;



template <typename, typename>
class TensorBase;

template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
{
protected:
    std::array<T, sizeof...(Is)> values{};
    static const std::size_t Size = sizeof...(Is);

public:
    constexpr TensorBase (getTypeSequence<T, Is> ... vals)
    : values{{vals...}}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> const & a)
    : values{a}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> && a)
    : values{std::move(a)}
    {}

    // TensorBase(std::initializer_list<T> a)
    // {
    //     assert(a.size() == Size);
    //     std::copy(std::begin(a), std::end(a), std::begin(values));
    // }

    constexpr TensorBase () = default;

    ~TensorBase() = default;

    constexpr TensorBase (TensorBase const &) = default;
    constexpr TensorBase (TensorBase &&) = default;

    constexpr TensorBase & operator= (TensorBase const &) = default;
    constexpr TensorBase & operator= (TensorBase &&) = default;
};


template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
{
public:
    static constexpr Integer Rows=Rows_;
    static constexpr Integer Cols=Cols_;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }
    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }
    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }
};





template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer,1>> 
{
public:
    static constexpr Integer Rows=1;
    static constexpr Integer Cols=1;
    using T= Real;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer,Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }

    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }

    inline constexpr T &operator[](const Integer i)
    {
        assert(i < Rows);
        return values[i];
    }

    inline constexpr const T &operator[](const Integer i)const
    {
        assert(i < Rows);
        return values[i];
    }


    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }


};

int main(int argc, char *argv[])
{
constexpr Matrix<Real,1,1> mat{1.0};


std::cout<<"it works"<<std::endl;
static_assert(mat(0,0)==1.0);



return 0;
}
template <typename T, Integer ... Is>
class TensorBase<T, std::index_sequence<Is...>>
template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_index_sequence<Rows_*Cols_>> 
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_index_sequence<1>> 
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer, 1>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
inline constexpr T &operator()(const Integer i)const
inline constexpr const T &operator()(const Integer i)const
-----------------------
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <array>  


using Integer=long;
using Real=double;



template <typename T, std::size_t>
using getTypeSequence = T;



template <typename, typename>
class TensorBase;

template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
{
protected:
    std::array<T, sizeof...(Is)> values{};
    static const std::size_t Size = sizeof...(Is);

public:
    constexpr TensorBase (getTypeSequence<T, Is> ... vals)
    : values{{vals...}}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> const & a)
    : values{a}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> && a)
    : values{std::move(a)}
    {}

    // TensorBase(std::initializer_list<T> a)
    // {
    //     assert(a.size() == Size);
    //     std::copy(std::begin(a), std::end(a), std::begin(values));
    // }

    constexpr TensorBase () = default;

    ~TensorBase() = default;

    constexpr TensorBase (TensorBase const &) = default;
    constexpr TensorBase (TensorBase &&) = default;

    constexpr TensorBase & operator= (TensorBase const &) = default;
    constexpr TensorBase & operator= (TensorBase &&) = default;
};


template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
{
public:
    static constexpr Integer Rows=Rows_;
    static constexpr Integer Cols=Cols_;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }
    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }
    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }
};





template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer,1>> 
{
public:
    static constexpr Integer Rows=1;
    static constexpr Integer Cols=1;
    using T= Real;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer,Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }

    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }

    inline constexpr T &operator[](const Integer i)
    {
        assert(i < Rows);
        return values[i];
    }

    inline constexpr const T &operator[](const Integer i)const
    {
        assert(i < Rows);
        return values[i];
    }


    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }


};

int main(int argc, char *argv[])
{
constexpr Matrix<Real,1,1> mat{1.0};


std::cout<<"it works"<<std::endl;
static_assert(mat(0,0)==1.0);



return 0;
}
template <typename T, Integer ... Is>
class TensorBase<T, std::index_sequence<Is...>>
template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_index_sequence<Rows_*Cols_>> 
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_index_sequence<1>> 
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer, 1>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
inline constexpr T &operator()(const Integer i)const
inline constexpr const T &operator()(const Integer i)const
-----------------------
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <array>  


using Integer=long;
using Real=double;



template <typename T, std::size_t>
using getTypeSequence = T;



template <typename, typename>
class TensorBase;

template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
{
protected:
    std::array<T, sizeof...(Is)> values{};
    static const std::size_t Size = sizeof...(Is);

public:
    constexpr TensorBase (getTypeSequence<T, Is> ... vals)
    : values{{vals...}}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> const & a)
    : values{a}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> && a)
    : values{std::move(a)}
    {}

    // TensorBase(std::initializer_list<T> a)
    // {
    //     assert(a.size() == Size);
    //     std::copy(std::begin(a), std::end(a), std::begin(values));
    // }

    constexpr TensorBase () = default;

    ~TensorBase() = default;

    constexpr TensorBase (TensorBase const &) = default;
    constexpr TensorBase (TensorBase &&) = default;

    constexpr TensorBase & operator= (TensorBase const &) = default;
    constexpr TensorBase & operator= (TensorBase &&) = default;
};


template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
{
public:
    static constexpr Integer Rows=Rows_;
    static constexpr Integer Cols=Cols_;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }
    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }
    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }
};





template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer,1>> 
{
public:
    static constexpr Integer Rows=1;
    static constexpr Integer Cols=1;
    using T= Real;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer,Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }

    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }

    inline constexpr T &operator[](const Integer i)
    {
        assert(i < Rows);
        return values[i];
    }

    inline constexpr const T &operator[](const Integer i)const
    {
        assert(i < Rows);
        return values[i];
    }


    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }


};

int main(int argc, char *argv[])
{
constexpr Matrix<Real,1,1> mat{1.0};


std::cout<<"it works"<<std::endl;
static_assert(mat(0,0)==1.0);



return 0;
}
template <typename T, Integer ... Is>
class TensorBase<T, std::index_sequence<Is...>>
template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_index_sequence<Rows_*Cols_>> 
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_index_sequence<1>> 
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer, 1>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
inline constexpr T &operator()(const Integer i)const
inline constexpr const T &operator()(const Integer i)const
-----------------------
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <array>  


using Integer=long;
using Real=double;



template <typename T, std::size_t>
using getTypeSequence = T;



template <typename, typename>
class TensorBase;

template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
{
protected:
    std::array<T, sizeof...(Is)> values{};
    static const std::size_t Size = sizeof...(Is);

public:
    constexpr TensorBase (getTypeSequence<T, Is> ... vals)
    : values{{vals...}}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> const & a)
    : values{a}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> && a)
    : values{std::move(a)}
    {}

    // TensorBase(std::initializer_list<T> a)
    // {
    //     assert(a.size() == Size);
    //     std::copy(std::begin(a), std::end(a), std::begin(values));
    // }

    constexpr TensorBase () = default;

    ~TensorBase() = default;

    constexpr TensorBase (TensorBase const &) = default;
    constexpr TensorBase (TensorBase &&) = default;

    constexpr TensorBase & operator= (TensorBase const &) = default;
    constexpr TensorBase & operator= (TensorBase &&) = default;
};


template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
{
public:
    static constexpr Integer Rows=Rows_;
    static constexpr Integer Cols=Cols_;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }
    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }
    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }
};





template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer,1>> 
{
public:
    static constexpr Integer Rows=1;
    static constexpr Integer Cols=1;
    using T= Real;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer,Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }

    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }

    inline constexpr T &operator[](const Integer i)
    {
        assert(i < Rows);
        return values[i];
    }

    inline constexpr const T &operator[](const Integer i)const
    {
        assert(i < Rows);
        return values[i];
    }


    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }


};

int main(int argc, char *argv[])
{
constexpr Matrix<Real,1,1> mat{1.0};


std::cout<<"it works"<<std::endl;
static_assert(mat(0,0)==1.0);



return 0;
}
template <typename T, Integer ... Is>
class TensorBase<T, std::index_sequence<Is...>>
template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_index_sequence<Rows_*Cols_>> 
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_index_sequence<1>> 
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer, 1>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
inline constexpr T &operator()(const Integer i)const
inline constexpr const T &operator()(const Integer i)const
-----------------------
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <array>  


using Integer=long;
using Real=double;



template <typename T, std::size_t>
using getTypeSequence = T;



template <typename, typename>
class TensorBase;

template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
{
protected:
    std::array<T, sizeof...(Is)> values{};
    static const std::size_t Size = sizeof...(Is);

public:
    constexpr TensorBase (getTypeSequence<T, Is> ... vals)
    : values{{vals...}}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> const & a)
    : values{a}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> && a)
    : values{std::move(a)}
    {}

    // TensorBase(std::initializer_list<T> a)
    // {
    //     assert(a.size() == Size);
    //     std::copy(std::begin(a), std::end(a), std::begin(values));
    // }

    constexpr TensorBase () = default;

    ~TensorBase() = default;

    constexpr TensorBase (TensorBase const &) = default;
    constexpr TensorBase (TensorBase &&) = default;

    constexpr TensorBase & operator= (TensorBase const &) = default;
    constexpr TensorBase & operator= (TensorBase &&) = default;
};


template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
{
public:
    static constexpr Integer Rows=Rows_;
    static constexpr Integer Cols=Cols_;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }
    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }
    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }
};





template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer,1>> 
{
public:
    static constexpr Integer Rows=1;
    static constexpr Integer Cols=1;
    using T= Real;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer,Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }

    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }

    inline constexpr T &operator[](const Integer i)
    {
        assert(i < Rows);
        return values[i];
    }

    inline constexpr const T &operator[](const Integer i)const
    {
        assert(i < Rows);
        return values[i];
    }


    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }


};

int main(int argc, char *argv[])
{
constexpr Matrix<Real,1,1> mat{1.0};


std::cout<<"it works"<<std::endl;
static_assert(mat(0,0)==1.0);



return 0;
}
template <typename T, Integer ... Is>
class TensorBase<T, std::index_sequence<Is...>>
template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_index_sequence<Rows_*Cols_>> 
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_index_sequence<1>> 
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer, 1>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
inline constexpr T &operator()(const Integer i)const
inline constexpr const T &operator()(const Integer i)const
-----------------------
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <array>  


using Integer=long;
using Real=double;



template <typename T, std::size_t>
using getTypeSequence = T;



template <typename, typename>
class TensorBase;

template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
{
protected:
    std::array<T, sizeof...(Is)> values{};
    static const std::size_t Size = sizeof...(Is);

public:
    constexpr TensorBase (getTypeSequence<T, Is> ... vals)
    : values{{vals...}}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> const & a)
    : values{a}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> && a)
    : values{std::move(a)}
    {}

    // TensorBase(std::initializer_list<T> a)
    // {
    //     assert(a.size() == Size);
    //     std::copy(std::begin(a), std::end(a), std::begin(values));
    // }

    constexpr TensorBase () = default;

    ~TensorBase() = default;

    constexpr TensorBase (TensorBase const &) = default;
    constexpr TensorBase (TensorBase &&) = default;

    constexpr TensorBase & operator= (TensorBase const &) = default;
    constexpr TensorBase & operator= (TensorBase &&) = default;
};


template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
{
public:
    static constexpr Integer Rows=Rows_;
    static constexpr Integer Cols=Cols_;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }
    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }
    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }
};





template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer,1>> 
{
public:
    static constexpr Integer Rows=1;
    static constexpr Integer Cols=1;
    using T= Real;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer,Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }

    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }

    inline constexpr T &operator[](const Integer i)
    {
        assert(i < Rows);
        return values[i];
    }

    inline constexpr const T &operator[](const Integer i)const
    {
        assert(i < Rows);
        return values[i];
    }


    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }


};

int main(int argc, char *argv[])
{
constexpr Matrix<Real,1,1> mat{1.0};


std::cout<<"it works"<<std::endl;
static_assert(mat(0,0)==1.0);



return 0;
}
template <typename T, Integer ... Is>
class TensorBase<T, std::index_sequence<Is...>>
template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_index_sequence<Rows_*Cols_>> 
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_index_sequence<1>> 
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer, 1>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
inline constexpr T &operator()(const Integer i)const
inline constexpr const T &operator()(const Integer i)const
-----------------------
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <array>  


using Integer=long;
using Real=double;



template <typename T, std::size_t>
using getTypeSequence = T;



template <typename, typename>
class TensorBase;

template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
{
protected:
    std::array<T, sizeof...(Is)> values{};
    static const std::size_t Size = sizeof...(Is);

public:
    constexpr TensorBase (getTypeSequence<T, Is> ... vals)
    : values{{vals...}}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> const & a)
    : values{a}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> && a)
    : values{std::move(a)}
    {}

    // TensorBase(std::initializer_list<T> a)
    // {
    //     assert(a.size() == Size);
    //     std::copy(std::begin(a), std::end(a), std::begin(values));
    // }

    constexpr TensorBase () = default;

    ~TensorBase() = default;

    constexpr TensorBase (TensorBase const &) = default;
    constexpr TensorBase (TensorBase &&) = default;

    constexpr TensorBase & operator= (TensorBase const &) = default;
    constexpr TensorBase & operator= (TensorBase &&) = default;
};


template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
{
public:
    static constexpr Integer Rows=Rows_;
    static constexpr Integer Cols=Cols_;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }
    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }
    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }
};





template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer,1>> 
{
public:
    static constexpr Integer Rows=1;
    static constexpr Integer Cols=1;
    using T= Real;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer,Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }

    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }

    inline constexpr T &operator[](const Integer i)
    {
        assert(i < Rows);
        return values[i];
    }

    inline constexpr const T &operator[](const Integer i)const
    {
        assert(i < Rows);
        return values[i];
    }


    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }


};

int main(int argc, char *argv[])
{
constexpr Matrix<Real,1,1> mat{1.0};


std::cout<<"it works"<<std::endl;
static_assert(mat(0,0)==1.0);



return 0;
}
template <typename T, Integer ... Is>
class TensorBase<T, std::index_sequence<Is...>>
template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_index_sequence<Rows_*Cols_>> 
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_index_sequence<1>> 
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer, 1>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
inline constexpr T &operator()(const Integer i)const
inline constexpr const T &operator()(const Integer i)const
-----------------------
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <array>  


using Integer=long;
using Real=double;



template <typename T, std::size_t>
using getTypeSequence = T;



template <typename, typename>
class TensorBase;

template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
{
protected:
    std::array<T, sizeof...(Is)> values{};
    static const std::size_t Size = sizeof...(Is);

public:
    constexpr TensorBase (getTypeSequence<T, Is> ... vals)
    : values{{vals...}}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> const & a)
    : values{a}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> && a)
    : values{std::move(a)}
    {}

    // TensorBase(std::initializer_list<T> a)
    // {
    //     assert(a.size() == Size);
    //     std::copy(std::begin(a), std::end(a), std::begin(values));
    // }

    constexpr TensorBase () = default;

    ~TensorBase() = default;

    constexpr TensorBase (TensorBase const &) = default;
    constexpr TensorBase (TensorBase &&) = default;

    constexpr TensorBase & operator= (TensorBase const &) = default;
    constexpr TensorBase & operator= (TensorBase &&) = default;
};


template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
{
public:
    static constexpr Integer Rows=Rows_;
    static constexpr Integer Cols=Cols_;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }
    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }
    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }
};





template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer,1>> 
{
public:
    static constexpr Integer Rows=1;
    static constexpr Integer Cols=1;
    using T= Real;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer,Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }

    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }

    inline constexpr T &operator[](const Integer i)
    {
        assert(i < Rows);
        return values[i];
    }

    inline constexpr const T &operator[](const Integer i)const
    {
        assert(i < Rows);
        return values[i];
    }


    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }


};

int main(int argc, char *argv[])
{
constexpr Matrix<Real,1,1> mat{1.0};


std::cout<<"it works"<<std::endl;
static_assert(mat(0,0)==1.0);



return 0;
}
template <typename T, Integer ... Is>
class TensorBase<T, std::index_sequence<Is...>>
template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_index_sequence<Rows_*Cols_>> 
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_index_sequence<1>> 
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer, 1>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
inline constexpr T &operator()(const Integer i)const
inline constexpr const T &operator()(const Integer i)const
-----------------------
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <array>  


using Integer=long;
using Real=double;



template <typename T, std::size_t>
using getTypeSequence = T;



template <typename, typename>
class TensorBase;

template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
{
protected:
    std::array<T, sizeof...(Is)> values{};
    static const std::size_t Size = sizeof...(Is);

public:
    constexpr TensorBase (getTypeSequence<T, Is> ... vals)
    : values{{vals...}}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> const & a)
    : values{a}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> && a)
    : values{std::move(a)}
    {}

    // TensorBase(std::initializer_list<T> a)
    // {
    //     assert(a.size() == Size);
    //     std::copy(std::begin(a), std::end(a), std::begin(values));
    // }

    constexpr TensorBase () = default;

    ~TensorBase() = default;

    constexpr TensorBase (TensorBase const &) = default;
    constexpr TensorBase (TensorBase &&) = default;

    constexpr TensorBase & operator= (TensorBase const &) = default;
    constexpr TensorBase & operator= (TensorBase &&) = default;
};


template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
{
public:
    static constexpr Integer Rows=Rows_;
    static constexpr Integer Cols=Cols_;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }
    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }
    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }
};





template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer,1>> 
{
public:
    static constexpr Integer Rows=1;
    static constexpr Integer Cols=1;
    using T= Real;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer,Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }

    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }

    inline constexpr T &operator[](const Integer i)
    {
        assert(i < Rows);
        return values[i];
    }

    inline constexpr const T &operator[](const Integer i)const
    {
        assert(i < Rows);
        return values[i];
    }


    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }


};

int main(int argc, char *argv[])
{
constexpr Matrix<Real,1,1> mat{1.0};


std::cout<<"it works"<<std::endl;
static_assert(mat(0,0)==1.0);



return 0;
}
template <typename T, Integer ... Is>
class TensorBase<T, std::index_sequence<Is...>>
template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_index_sequence<Rows_*Cols_>> 
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_index_sequence<1>> 
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer, 1>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
inline constexpr T &operator()(const Integer i)const
inline constexpr const T &operator()(const Integer i)const
-----------------------
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <array>  


using Integer=long;
using Real=double;



template <typename T, std::size_t>
using getTypeSequence = T;



template <typename, typename>
class TensorBase;

template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
{
protected:
    std::array<T, sizeof...(Is)> values{};
    static const std::size_t Size = sizeof...(Is);

public:
    constexpr TensorBase (getTypeSequence<T, Is> ... vals)
    : values{{vals...}}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> const & a)
    : values{a}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> && a)
    : values{std::move(a)}
    {}

    // TensorBase(std::initializer_list<T> a)
    // {
    //     assert(a.size() == Size);
    //     std::copy(std::begin(a), std::end(a), std::begin(values));
    // }

    constexpr TensorBase () = default;

    ~TensorBase() = default;

    constexpr TensorBase (TensorBase const &) = default;
    constexpr TensorBase (TensorBase &&) = default;

    constexpr TensorBase & operator= (TensorBase const &) = default;
    constexpr TensorBase & operator= (TensorBase &&) = default;
};


template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
{
public:
    static constexpr Integer Rows=Rows_;
    static constexpr Integer Cols=Cols_;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }
    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }
    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }
};





template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer,1>> 
{
public:
    static constexpr Integer Rows=1;
    static constexpr Integer Cols=1;
    using T= Real;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer,Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }

    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }

    inline constexpr T &operator[](const Integer i)
    {
        assert(i < Rows);
        return values[i];
    }

    inline constexpr const T &operator[](const Integer i)const
    {
        assert(i < Rows);
        return values[i];
    }


    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }


};

int main(int argc, char *argv[])
{
constexpr Matrix<Real,1,1> mat{1.0};


std::cout<<"it works"<<std::endl;
static_assert(mat(0,0)==1.0);



return 0;
}
template <typename T, Integer ... Is>
class TensorBase<T, std::index_sequence<Is...>>
template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_index_sequence<Rows_*Cols_>> 
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_index_sequence<1>> 
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer, 1>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
inline constexpr T &operator()(const Integer i)const
inline constexpr const T &operator()(const Integer i)const
-----------------------
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <array>  


using Integer=long;
using Real=double;



template <typename T, std::size_t>
using getTypeSequence = T;



template <typename, typename>
class TensorBase;

template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
{
protected:
    std::array<T, sizeof...(Is)> values{};
    static const std::size_t Size = sizeof...(Is);

public:
    constexpr TensorBase (getTypeSequence<T, Is> ... vals)
    : values{{vals...}}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> const & a)
    : values{a}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> && a)
    : values{std::move(a)}
    {}

    // TensorBase(std::initializer_list<T> a)
    // {
    //     assert(a.size() == Size);
    //     std::copy(std::begin(a), std::end(a), std::begin(values));
    // }

    constexpr TensorBase () = default;

    ~TensorBase() = default;

    constexpr TensorBase (TensorBase const &) = default;
    constexpr TensorBase (TensorBase &&) = default;

    constexpr TensorBase & operator= (TensorBase const &) = default;
    constexpr TensorBase & operator= (TensorBase &&) = default;
};


template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
{
public:
    static constexpr Integer Rows=Rows_;
    static constexpr Integer Cols=Cols_;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }
    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }
    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }
};





template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer,1>> 
{
public:
    static constexpr Integer Rows=1;
    static constexpr Integer Cols=1;
    using T= Real;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer,Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }

    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }

    inline constexpr T &operator[](const Integer i)
    {
        assert(i < Rows);
        return values[i];
    }

    inline constexpr const T &operator[](const Integer i)const
    {
        assert(i < Rows);
        return values[i];
    }


    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }


};

int main(int argc, char *argv[])
{
constexpr Matrix<Real,1,1> mat{1.0};


std::cout<<"it works"<<std::endl;
static_assert(mat(0,0)==1.0);



return 0;
}
template <typename T, Integer ... Is>
class TensorBase<T, std::index_sequence<Is...>>
template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_index_sequence<Rows_*Cols_>> 
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_index_sequence<1>> 
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer, 1>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
inline constexpr T &operator()(const Integer i)const
inline constexpr const T &operator()(const Integer i)const
-----------------------
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <array>  


using Integer=long;
using Real=double;



template <typename T, std::size_t>
using getTypeSequence = T;



template <typename, typename>
class TensorBase;

template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
{
protected:
    std::array<T, sizeof...(Is)> values{};
    static const std::size_t Size = sizeof...(Is);

public:
    constexpr TensorBase (getTypeSequence<T, Is> ... vals)
    : values{{vals...}}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> const & a)
    : values{a}
    {}

    constexpr TensorBase (std::array<T, sizeof...(Is)> && a)
    : values{std::move(a)}
    {}

    // TensorBase(std::initializer_list<T> a)
    // {
    //     assert(a.size() == Size);
    //     std::copy(std::begin(a), std::end(a), std::begin(values));
    // }

    constexpr TensorBase () = default;

    ~TensorBase() = default;

    constexpr TensorBase (TensorBase const &) = default;
    constexpr TensorBase (TensorBase &&) = default;

    constexpr TensorBase & operator= (TensorBase const &) = default;
    constexpr TensorBase & operator= (TensorBase &&) = default;
};


template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
{
public:
    static constexpr Integer Rows=Rows_;
    static constexpr Integer Cols=Cols_;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }
    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }
    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }
};





template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer,1>> 
{
public:
    static constexpr Integer Rows=1;
    static constexpr Integer Cols=1;
    using T= Real;
    using type= Matrix<T,Rows,Cols>;
    using subtype=T;
    using MB = TensorBase<T, std::make_integer_sequence<Integer,Rows*Cols>>;
    using MB::MB;
    using MB::values;
    static constexpr Integer NonZeroRow=NonZeroRow_;
    inline constexpr static Integer rows() { return Rows; }
    inline constexpr static Integer cols() { return Cols; }

    inline constexpr std::array<T,Rows*Cols> &operator()()
    {
        return values;
    }

    inline constexpr const std::array<T,Rows*Cols> &operator()()const
    {
        return values;
    }

    inline constexpr T &operator[](const Integer i)
    {
        assert(i < Rows);
        return values[i];
    }

    inline constexpr const T &operator[](const Integer i)const
    {
        assert(i < Rows);
        return values[i];
    }


    // access matrix direclty by using I*Col+J index
    inline constexpr T &operator()(const Integer i)
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr const T &operator()(const Integer i)const
    {
        assert(i < Rows*Cols);
        return values[i];
    }

    inline constexpr T &operator()(const Integer i, const Integer j)
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }

    inline constexpr const T &operator()(const Integer i, const Integer j) const
    {
        assert(i < Rows);
        assert(j < Cols);
        return values[i*cols() + j];
    }


};

int main(int argc, char *argv[])
{
constexpr Matrix<Real,1,1> mat{1.0};


std::cout<<"it works"<<std::endl;
static_assert(mat(0,0)==1.0);



return 0;
}
template <typename T, Integer ... Is>
class TensorBase<T, std::index_sequence<Is...>>
template <typename T, Integer ... Is>
class TensorBase<T, std::integer_sequence<Integer, Is...>>
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_index_sequence<Rows_*Cols_>> 
template<typename T, Integer Rows_, Integer Cols_,Integer NonZeroRow_=-1>
class Matrix: public TensorBase<T, std::make_integer_sequence<Integer, Rows_*Cols_>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_index_sequence<1>> 
template<Integer NonZeroRow_>
class Matrix<Real,1,1,NonZeroRow_>: public TensorBase<Real, std::make_integer_sequence<Integer, 1>> 
using MB = TensorBase<T, std::make_index_sequence<Rows*Cols>>;
using MB = TensorBase<T, std::make_integer_sequence<Integer, Rows*Cols>>;
inline constexpr T &operator()(const Integer i)const
inline constexpr const T &operator()(const Integer i)const

Community Discussions

Trending Discussions on spack
  • Replacing variable from vars/main.yml into ansible inventory
  • How can I run a command in a shell script function that requires access to the current shell instance?
  • How do I get the correct $PATHs for remote Python Fabric Access?
  • Why does `gcc -ffast-math` disable the correct result of `isnan()` and `isinf()`?
  • How can I find hpcviewer in order to visualize trace data generated by hpcrun?
  • How can I make the C++ compiler support template for STL?
  • Change version of gcc which does not support compiling C++ programs using the compilers.yaml file
  • How should I fix the configure.yaml file?
  • How do I install and use PNGwriter to write PNG image files?
  • How to run Popper on HPC without sudo rights
Trending Discussions on spack

QUESTION

Replacing variable from vars/main.yml into ansible inventory

Asked 2022-Mar-01 at 08:26

I am moving a lot of old scripts used to configure a computer room into ansible, and it really has improved the workflow. Currently, there I have several playbooks, and I need to share a common config among them. But in one task I have faced a problem: I need a hostname/ip to be a variable in the inventory. I have read a lot of tutorials and docs and maybe I am dumb or very tired, but I have not found yet a solution after many hours, it seems that it is not possible. Dynamics inventories, group_vars and so on look similar but actually are different from what I require here. I have created a mwe to easy showing the case. This mwe is a subset but the main idea remains: vars inside vars/main.yml are going to be shared among various playbooks (easy) and inventories (the question here). Thanks in advance.

  • ansible.cfg:
[ssh_connection]
pipelining = True
control_path = /tmp/ansible-ssh-%%h-%%p-%%r

[defaults]
interpreter_python = python3
  • inventory (ini format, also tried yaml)
[master]
192.168.10.1 ansible_connection=local

[package_clients]
192.168.10.[3:29]

[package_server]
{{PACKAGE_SERVER}} # <--- This var commes from vars/main.yml
  • site.yaml:
---
- name: Configuring package server (exports spack packages)
  hosts: package_server
  gather_facts: false
  vars_files:
    - vars/main.yml
  tasks:

  - name: Printing package server name
    debug:
      msg: "PACKAGE_SERVER  variable -> {{PACKAGE_SERVER}}"

  - name: Creating package dir (this throws an error sin PACKAGE_SERVER is not replaced in inventory)
    file:
      path: /packages
      state: directory
  • vars/main.yml
# Server internal ip
BASE_SERVERIP: '192.168.10'
# Package Server: Simply shares a directory with spack and packages
PACKAGE_SERVER: '{{BASE_SERVERIP}}.2'

When I run this as

ansible-playbook -i inventory site.yml --check

I get the following error:

PLAY [Configuring package server (exports spack packages)] *******************************************************************************************
TASK [Printing package server name] ******************************************************************************************************************
ok: [{{PACKAGE_SERVER}}] => {    "msg": "PACKAGE_SERVER  variable -> 192.168.10.2"
}
TASK [Creating package dir (this throws an error sin PACKAGE_SERVER is not replaced in inventory)] ***************************************************fatal: [{{PACKAGE_SERVER}}]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname {{package_server}}: Name or service not known", "unreachable": true}
PLAY RECAP *******************************************************************************************************************************************
{{PACKAGE_SERVER}}         : ok=1    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0   

ANSWER

Answered 2022-Mar-01 at 08:26

Use the module add_host and create new group package_server in the first play. Then use it in the second play. For example

shell> cat playbook.yml
---
- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    BASE_SERVERIP: 192.168.10
    PACKAGE_SERVER: "{{ BASE_SERVERIP }}.2"
  tasks:
    - add_host:
        hostname: "{{ PACKAGE_SERVER }}"
        groups: package_server

- name: Use group package_server
  hosts: package_server
  gather_facts: false
  tasks:
    - debug:
        msg: Creating package dir

gives

shell> ansible-playbook playbook.yml

PLAY [Create group package_server] **************************************

TASK [add_host] *********************************************************
changed: [localhost]

PLAY [Use group package_server] *****************************************

TASK [debug] ************************************************************
ok: [192.168.10.2] => 
  msg: Creating package dir

PLAY RECAP **************************************************************
192.168.10.2: ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0   
localhost   : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 

List of hosts

If you want to add more hosts to the group create a list. The expansion of slices, e.g. 192.168.10.[3:6], works only in the inventory. Use filters to declare such range in a list, e.g.

- name: Create group package_server
  hosts: localhost
  gather_facts: false
  vars:
    clients: "{{ ['192.168.10']|
                 product(range(3,6))|
                 map('join', '.')|
                 list }}"
  tasks:
    - debug:
        var: clients
    - add_host:
        hostname: "{{ item }}"
        groups: package_server
      loop: "{{ clients }}"

creates the list below and add the hosts into the group package_server

clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.10.5

Any octet can be declared as a sequence, e.g.

    c:
      A: [192]
      B: [168]
      C: [10, 12]
      D: [3, 5]
    clients: "{{ range(c.A.0, c.A.1|d(c.A.0 + 1))|
                 product(range(c.B.0, c.B.1|d(c.B.0 + 1)))|map('flatten')|
                 product(range(c.C.0, c.C.1|d(c.C.0 + 1)))|map('flatten')|
                 product(range(c.D.0, c.D.1|d(c.D.0 + 1)))|map('flatten')|
                 map('join', '.')|list }}"

gives

clients:
  - 192.168.10.3
  - 192.168.10.4
  - 192.168.11.3
  - 192.168.11.4

Source https://stackoverflow.com/questions/71285957

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install spack

You can download it from GitHub, GitLab.
You can use spack like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

Support

Full documentation is available, or run spack help or spack help --all. For a cheat sheet on Spack syntax, run spack help --spec.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Compare Build Tool Libraries with Highest Support
Compare Build Tool Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.