This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 1391

Summary: Feature Request: Allow custom DenseBase plugins to use IOFormat
Product: Eigen Reporter: Kunal Tyagi <kunal.tyagi.3.1994>
Component: Core - generalAssignee: Kunal Tyagi <kunal.tyagi.3.1994>
Status: RESOLVED FIXED    
Severity: Feature Request CC: chtz, gael.guennebaud, jacob.benoit.1, kunal.tyagi.3.1994
Priority: Normal    
Version: 3.5 (future version)   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Moved DenseBase dependencies to DenseBase.h none

Description Kunal Tyagi 2017-02-10 08:28:35 UTC
Create plugins which enable the following behavior:

-- file a.h
#define EIGEN_DENSEBASE_PLUGIN "b.h"

-- file b.h
std::ostream& write(std::ostream& stream_) const
{
    const int FullPrecision = -2;  // required since it does not exist
    IOFormat outFormat(FullPrecision, 0, " ", " ", "", "", " ", " ");

    stream_ << this->size() << this->format(outFormat);
    return stream_;
}

-- expected
No compilation errors

-- error on compilation
error: variable has incomplete type 'Eigen::IOFormat'
    IOFormat outFormat(FullPrecision, 0, " ", " ", "", "", " ", " ");
             ^
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:221:8: note: forward declaration of 'Eigen::IOFormat'
struct IOFormat;

-- resolution
Split IO.h file into 2 parts, one containing IOFormat, WithFormat and related files indep of DenseBase and the other dependent on DenseBase.
Move #include "src/Core/IO.h" to before #include "src/Core/DenseBase.h" and include the newly split file later (or merge it with DenseBase.h)

Should I go ahead and start working on a patch?

-- compilation details (cmake)
set (FLAGS "-std=c++14 -Wall -Wextra -Wformat=2 -Werror")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG ${FLAGS}")
set (CMAKE_BUILD_TYPE Debug) #RelWithDebInfo

-- compiler details
$ c++ -v
clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/5.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/6.0.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.0.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.0.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda
Comment 1 Gael Guennebaud 2017-02-11 10:14:30 UTC
Yes feel free to propose a patch, thought I think such feature would better be implemented as free functions.
Comment 2 Kunal Tyagi 2017-02-11 17:03:45 UTC
This is similar to the ```WithFormat<Derived> format(const IOFormat&)``` member of DenseBase. The only difference is that the function would be fully defined inside DenseBase.h, unlike ```format``` function which is defined after full declaration of required classes.
Comment 3 Kunal Tyagi 2017-02-11 19:59:45 UTC
Created attachment 775 [details]
Moved DenseBase dependencies to DenseBase.h

Basic idea implemented as simply as possible
Comment 4 Gael Guennebaud 2017-02-13 10:52:34 UTC
Thank you for the patch. I applied a simple one, though:

https://bitbucket.org/eigen/eigen/commits/9735da81dd79/  (default)
https://bitbucket.org/eigen/eigen/commits/9107b18da7b6/  (3.3)
Comment 5 Kunal Tyagi 2017-02-14 22:29:19 UTC
Thanks a lot.
Any idea when will the change be released as a Ubuntu package update?
```
$ uname -a
Linux alien 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

$ dpkg -l | grep libeigen -i
ii  libeigen3-dev                                               3.3~beta1-2                                           all          lightweight C++ template library for linear algebra
```
Comment 6 Gael Guennebaud 2017-02-17 13:28:07 UTC
I've no idea about ubuntu's packaging!!
Comment 7 Kunal Tyagi 2017-02-18 07:53:37 UTC
As per [Launchpad](https://launchpad.net/ubuntu/xenial/+source/eigen3/+changelog), the last update to Eigen3 in Ubuntu 16.04 was in Jan 2016 for the following commit on 2016-01-09 **0db197c** Bug 1144: fix regression in x=y+A*x (aliasing), and move evaluator_traits::AssumeAliasing to evaluator_assume_aliasing.

There have been hundreds of updates after than. Can a update be scheduled because I don't want to deal with weird issues when I compile our code, with different parts compiling with different versions?

Bitbucket link to commit: https://bitbucket.org/eigen/eigen/commits/0db197c797c3891768bd8d74fcf85279680942a5
Comment 8 Nobody 2019-12-04 16:48:44 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1391.