New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Bug 1391 - Feature Request: Allow custom DenseBase plugins to use IOFormat
Summary: Feature Request: Allow custom DenseBase plugins to use IOFormat
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.5 (future version)
Hardware: All All
: Normal Feature Request
Assignee: Kunal Tyagi
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-10 08:28 UTC by Kunal Tyagi
Modified: 2017-02-18 07:53 UTC (History)
4 users (show)



Attachments
Moved DenseBase dependencies to DenseBase.h (8.36 KB, patch)
2017-02-11 19:59 UTC, Kunal Tyagi
no flags Details | Diff

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

Note You need to log in before you can comment on or make changes to this bug.