[sc-dev] Formation of Matrix formula

2010-08-13 Thread rashi dhing
Hi !! Can you tell me where exactly is the matrix fomula formed (i.e) where
are the curly brackets added to
form the matrix formula. Is it done by the edit engine ??

Thanks a ton !

Rashi


Re: [sc-dev] Add a new Calc spreadsheet function

2010-08-13 Thread Eike Rathke
Hi Marina,

On Thursday, 2010-08-12 15:13:24 +0200, Marina Plakalovic wrote:

 Working with ranges inside the functions is not the issue, but registering
 function is.

I'm not sure I understand what you mean with registering. Are you
referring to parclass.cxx?

 I followed steps described in
 http://wiki.services.openoffice.org/wiki/Calc/Implementation/Spreadsheet_Functions,
 and it seems that some additional changes must be made for functions that
 take range as a parameter.

I just added some details to
http://wiki.services.openoffice.org/wiki/Calc/Implementation/Spreadsheet_Functions#The_not_so_easy_case_of_non-scalar_arguments
and hope that helps. If not, please ask your questions ;-)

  Eike

-- 
 OOo Calc core developer. Number formatter stricken i18n transpositionizer.
 Signature key 0x87F8D412 : 2F58 5236 DB02 F335 8304  7D6C 65C9 F9B5 87F8 D412
 OpenOffice.org Engineering at Oracle: http://blogs.sun.com/GullFOSS
 --
 Please don't send mail to the old e...@sun.com account that I used for mailing
 lists, it phased out. Use eike.rat...@oracle.com instead. Thanks.


pgpK3g0Ufjxfh.pgp
Description: PGP signature


Re: [sc-dev] Changing values in matrix which is parameter

2010-08-13 Thread Eike Rathke
Hi Regina,

On Thursday, 2010-08-12 16:38:33 +0200, Regina Henschel wrote:

 The current implementation avoids to copy the matrices X or Y,
 although that would ease and shorten the code. I thought there must
 be a reason for that and tried to avoid it too. I hesitate to copy X
 or Y, because they might have a huge number of lines.

Indeed.

 I will try only using new matrices for products like X'X as it is
 done in the current implementation. That will result in a lot of
 nearly identical multiplication methods, but I think, that is better
 than copying the matrices.

To avoid both, having overly complicated code and copying large
matrices, we could introduce a const/non-const flag in ScMatrix,
defaulted to const and set to non-const by GetNewMat(), but to const
again when stored in ScFormulaResult. The usual case is that a matrix
was constructed from a range reference by the interpreter and not as
a const array or formula cell result. Then having
a ScMatrix::CloneIfConst() method could just return the current matrix
if non-const and would have to actually clone only in rare const cases.

Just an idea..

  Eike

-- 
 OOo Calc core developer. Number formatter stricken i18n transpositionizer.
 Signature key 0x87F8D412 : 2F58 5236 DB02 F335 8304  7D6C 65C9 F9B5 87F8 D412
 OpenOffice.org Engineering at Oracle: http://blogs.sun.com/GullFOSS
 --
 Please don't send mail to the old e...@sun.com account that I used for mailing
 lists, it phased out. Use eike.rat...@oracle.com instead. Thanks.


pgpJuyt4EM9bD.pgp
Description: PGP signature


Re: [sc-dev] Formation of Matrix formula

2010-08-13 Thread Eike Rathke
Hi rashi,

On Friday, 2010-08-13 17:13:56 +0300, rashi dhing wrote:

 Hi !! Can you tell me where exactly is the matrix fomula formed (i.e) where
 are the curly brackets added to
 form the matrix formula. Is it done by the edit engine ??

The surrounding '{' and '}' are UI display features and added when the
formula string is reconstructed from the token array and the formula
cell has cMatrixFlag!=0, see ScFormulaCell::GetFormula()

Btw, it is not necessary to Cc us when writing to the list, we do read
the list and just have to delete a copy of your mail..

  Eike

-- 
 OOo Calc core developer. Number formatter stricken i18n transpositionizer.
 Signature key 0x87F8D412 : 2F58 5236 DB02 F335 8304  7D6C 65C9 F9B5 87F8 D412
 OpenOffice.org Engineering at Oracle: http://blogs.sun.com/GullFOSS
 --
 Please don't send mail to the old e...@sun.com account that I used for mailing
 lists, it phased out. Use eike.rat...@oracle.com instead. Thanks.


pgpQ9HMQtNZ6M.pgp
Description: PGP signature


Re: [sc-dev] Changing values in matrix which is parameter

2010-08-13 Thread Regina Henschel

Hi Eike,

Eike Rathke schrieb:

Hi Regina,

On Thursday, 2010-08-12 16:38:33 +0200, Regina Henschel wrote:


The current implementation avoids to copy the matrices X or Y,
although that would ease and shorten the code. I thought there must
be a reason for that and tried to avoid it too. I hesitate to copy X
or Y, because they might have a huge number of lines.


Indeed.


I will try only using new matrices for products like X'X as it is
done in the current implementation. That will result in a lot of
nearly identical multiplication methods, but I think, that is better
than copying the matrices.


To avoid both, having overly complicated code and copying large
matrices, we could introduce a const/non-const flag in ScMatrix,
defaulted to const and set to non-const by GetNewMat(), but to const
again when stored in ScFormulaResult. The usual case is that a matrix
was constructed from a range reference by the interpreter and not as
a const array or formula cell result. Then having
a ScMatrix::CloneIfConst() method could just return the current matrix
if non-const and would have to actually clone only in rare const cases.

Just an idea..


The problem with constant parameters is already actual :(
http://www.openoffice.org/issues/show_bug.cgi?id=113879

Enter the formula
=LOGEST({2|3|5|8|13};{2|4|6|8|10})
Set the cursor into the formula range to see the formula in the input line.
Recalculate some times.
Notice, that the values in the first parameter changes.

This is done in the method ScInterpreter::CheckMatrix in the statement
if ( _bLOG )
{
for (SCSIZE nElem = 0; nElem  nCountY; nElem++)
{
const double fVal = pMatY-GetDouble(nElem);
if (fVal = 0.0)
{
PushIllegalArgument();
return false;
}
else
pMatY-PutDouble(log(fVal), nElem);    here
} // for (nElem = 0; nElem  nCountY; nElem++)
} // if ( _bRKP )

Kind regards
Regina

-
To unsubscribe, e-mail: dev-unsubscr...@sc.openoffice.org
For additional commands, e-mail: dev-h...@sc.openoffice.org