Project

General

Profile

Feature #1008

square function

Added by John Abbott about 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
New Function
Start date:
12 Feb 2017
Due date:
% Done:

100%

Estimated time:
1.01 h
Spent time:

Description

In utils.H there is a fn called square defined only for double. It used only in ApproxPts.C.

I am sure that it is inappropriate to have that fn, so have moved it to ApproxPts.C.

Do we want to have a square function?


Related issues

Related to CoCoALib - Design #1147: mySquare and myPowerSmallExpNew2018-01-17

History

#1 Updated by John Abbott about 7 years ago

A search for square showed that there had been a square function for RingElem, but that it was removed (presumably with the idea that a user should call power with second arg equal to 2). I note that the fn square for RingElem called a special member fn mySquare (which may sometimes be faster than myMul on two copies of the arg).

If we do put a general square fn somewhere, it should probably be a template fn:

template <typename T>
T square(const T& a)
{ return a*a; }

However, this defn would not use the mem fn RingBase::mySquare.

#2 Updated by John Abbott about 7 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

So far we have not really felt the need for a square function in CoCoALib (presumably).

So maybe it does not make much sense to create one... yet another function for the user to learn!

Is square(x) that much easier to read/comprehend than power(x,2)?

#3 Updated by Anna Maria Bigatti about 7 years ago

If we had a square we should document how it differs from power(x,2). So I think we'd better not.
If we have mySquare, that should be called by power(x,2).

In short: mySquare make sense, square does not (IMHO)

#4 Updated by John Abbott about 7 years ago

  • Subject changed from square fuction to square function
  • Status changed from In Progress to Resolved
  • Assignee set to John Abbott
  • % Done changed from 10 to 80

OK, then we agree to eliminate the function square. It will disappear the next time I do a check in (later today?)

#5 Updated by John Abbott about 7 years ago

  • Status changed from Resolved to Feedback
  • % Done changed from 80 to 90

All tests pass. I have now checked in the change. ==> feedback

#6 Updated by John Abbott about 7 years ago

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

#7 Updated by John Abbott about 7 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100

The solution is: we do not define a square function. Use power(...,2) instead!

#8 Updated by Anna Maria Bigatti almost 7 years ago

  • Estimated time set to 1.01 h

#9 Updated by John Abbott over 6 years ago

  • Related to Design #1147: mySquare and myPowerSmallExp added

Also available in: Atom PDF