Project

General

Profile

Feature #357

Constructor for vectors? CoCoAVector

Added by Anna Maria Bigatti about 11 years ago. Updated over 4 years ago.

Status:
Rejected
Priority:
Normal
Category:
New Function
Target version:
Start date:
24 May 2013
Due date:
% Done:

100%

Estimated time:
4.01 h
Spent time:

Description

Writing vectors in C++ is very tedious (is there something in C++11?)
It would be handy to have a vector constructor with 0 to 4 elements (especially for RingElem), something like VectorCtor(a,b,c), returning a std::vector<RingElem> containing a,b,c.

final: called CoCoAVector(a,b,c,d)


Related issues

Related to CoCoALib - Feature #312: LongRange(a,b) returning vector of long a..b (included)Closed2013-02-14

Related to CoCoA-5 - Design #83: C++11 compatibility questionsIn Progress2012-01-26

Related to CoCoALib - Feature #966: New function or explain: first and last for a vector?Closed2016-11-10

Related to CoCoALib - Feature #1332: New function: vector of RingElem from string -- in CoCoALibClosed2019-10-08

Related to CoCoALib - Design #1414: Make class RingElemVector?In Progress2020-02-12

History

#1 Updated by John Abbott about 11 years ago

Yes, I believe C++11 makes it easier to construct std::vector values. I don't recall all the details.

Do we want to invest in a temporary solution until CoCoA switches to C++11?

#2 Updated by Anna Maria Bigatti about 11 years ago

it would be handy even though I don't know how many times we would use it (we had implemented the similar constructor for ideals, which removed the urgency)

#3 Updated by Anna Maria Bigatti over 10 years ago

  • Target version changed from CoCoALib-0.99534 Seoul14 to CoCoALib-0.99532

#4 Updated by Anna Maria Bigatti over 10 years ago

  • Target version changed from CoCoALib-0.99532 to CoCoALib-0.99533 Easter14

#5 Updated by Anna Maria Bigatti about 10 years ago

  • Target version changed from CoCoALib-0.99533 Easter14 to CoCoALib-0.99534 Seoul14

#6 Updated by John Abbott almost 10 years ago

  • Target version changed from CoCoALib-0.99534 Seoul14 to CoCoALib-1.0

#7 Updated by John Abbott about 8 years ago

  • Related to Design #83: C++11 compatibility questions added

#8 Updated by Anna Maria Bigatti about 8 years ago

  • Related to Feature #877: Easier syntax to make a PRINCIPAL ideal? added

#9 Updated by Anna Maria Bigatti about 8 years ago

  • Related to deleted (Feature #877: Easier syntax to make a PRINCIPAL ideal?)

#10 Updated by Anna Maria Bigatti about 8 years ago

We have these (for short lists)

  ideal::ideal(ConstRefRingElem r1)
  ideal::ideal(ConstRefRingElem r1, ConstRefRingElem r2)
  ideal::ideal(ConstRefRingElem r1, ConstRefRingElem r2, ConstRefRingElem r3)
  ideal::ideal(ConstRefRingElem r1, ConstRefRingElem r2, ConstRefRingElem r3, ConstRefRingElem r4)
  inline std::vector<T> CoCoAVector(const T& a)
  inline std::vector<T> CoCoAVector(const T& a,const T& b)
  inline std::vector<T> CoCoAVector(const T& a,const T& b,const T& c)
  inline std::vector<T> CoCoAVector(const T& a,const T& b,const T& c,const T& d)

#11 Updated by Anna Maria Bigatti over 7 years ago

  • Subject changed from constructor for vectors? to Constructor for vectors? CoCoAVector
  • Description updated (diff)
  • Status changed from New to Feedback
  • Assignee set to Anna Maria Bigatti
  • Target version changed from CoCoALib-1.0 to CoCoALib-0.99550 spring 2017
  • % Done changed from 0 to 90
  • Estimated time set to 1.05 h

This was done (up to 4 args): 2014/12/02

#12 Updated by Anna Maria Bigatti over 7 years ago

  • Related to Feature #966: New function or explain: first and last for a vector? added

#13 Updated by John Abbott over 7 years ago

It seems to me that this will be covered by the "braced constructor" for C++ vectors that appeared in C++11.

What might be more interesting is a constructor for "homogeneous" vectors of RingElem, by which I mean that all elements are in the same ring. Presumably one could also have an empty vector of elements of a given ring -- this would even have a well-defined sum!

#14 Updated by John Abbott about 7 years ago

The example use in ex-RingHom4.C did not work properly:

 vector<RingElem> v = CoCoAVector(zero(Fp), one(Fp));

The problem is that CoCoAVector returns a vector<RingElemAlias>.

The following is trickier still:

  vector<RingElem> v = CoCoAVector(one(Fp), RingElem(Fp,2));

because args are now of type RingElemAlias and RingElem.

Not sure how to fix this in a nice way.

#15 Updated by John Abbott about 7 years ago

Anna, can we postpone this to the next release?

I think that the problem I mentioned in comment 14 means that this is not yet properly ready for "public use".

#16 Updated by Anna Maria Bigatti about 7 years ago

  • Target version changed from CoCoALib-0.99550 spring 2017 to CoCoALib-0.99560

#17 Updated by John Abbott over 6 years ago

  • Target version changed from CoCoALib-0.99560 to CoCoALib-0.99600

I'm postponing again. We need to discuss this: the design does not convince me, and I hope that when we switch to C++11 the problem will be solved by C++ itself.

#18 Updated by Anna Maria Bigatti almost 6 years ago

  • Target version changed from CoCoALib-0.99600 to CoCoALib-0.99650 November 2019

#19 Updated by John Abbott about 5 years ago

  • Target version changed from CoCoALib-0.99650 November 2019 to CoCoALib-0.99700

#20 Updated by Anna Maria Bigatti over 4 years ago

  • Related to Feature #1332: New function: vector of RingElem from string -- in CoCoALib added

#21 Updated by Anna Maria Bigatti over 4 years ago

Re-reading the comments I think it's not worth it.

I went through all the code and removed all calls to CoCoAVector.
Using, when possible, the {...} C++ syntax, or RingElems.

So now I suggest Reject

#22 Updated by John Abbott over 4 years ago

Recalling part of my comment 13:
One aspect we could implement, which C++ does not, is the notion of "list of elems of ring R" (i.e. we state in advance the ring in which the elems will lie).

If we think this idea is worth discussing, maybe it should be made into a separate issue?

#23 Updated by Anna Maria Bigatti over 4 years ago

John Abbott wrote:

Recalling part of my comment 13:
One aspect we could implement, which C++ does not, is the notion of "list of elems of ring R" (i.e. we state in advance the ring in which the elems will lie).

If we think this idea is worth discussing, maybe it should be made into a separate issue?

Separate issue. In fact I had started (and abandoned) something along these lines.
One reason why I wanted this constructor was to make vector of integers for selecting rows and columns in submat.

For documentation, I add this snippet about vectors of RingElem:

    auto v = RingElems(RingQQt(2), "1/2, 1.4, t[1]*t[2]");
    cout << v << endl;

    v = {v[1], v[2]};
    cout << v << endl;

#24 Updated by Anna Maria Bigatti over 4 years ago

  • Status changed from Feedback to Rejected
  • % Done changed from 90 to 100
  • Estimated time changed from 1.05 h to 4.01 h

Discussed in person, and agreed to reject it.

#25 Updated by Anna Maria Bigatti over 4 years ago

Also available in: Atom PDF