1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: scmatrix.cxx,v $
10 * $Revision: 1.17.136.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include <tools/debug.hxx>
36 #include "scmatrix.hxx"
38 #include "address.hxx"
39 #include "formula/errorcodes.hxx"
40 #include "interpre.hxx"
41 #include <svtools/zforlist.hxx>
42 #include <tools/stream.hxx>
43 #include <rtl/math.hxx>
47 //------------------------------------------------------------------------
49 void ScMatrix::CreateMatrix(SCSIZE nC
, SCSIZE nR
) // nur fuer ctor
51 pErrorInterpreter
= NULL
;
54 SCSIZE nCount
= nColCount
* nRowCount
;
55 if ( !nCount
|| nCount
> GetElementsMax() )
57 DBG_ERRORFILE("ScMatrix::CreateMatrix: dimension error");
58 nColCount
= nRowCount
= 1;
59 pMat
= new ScMatrixValue
[1];
60 pMat
[0].fVal
= CreateDoubleError( errStackOverflow
);
63 pMat
= new ScMatrixValue
[nCount
];
74 ScMatrix
* ScMatrix::Clone() const
76 ScMatrix
* pScMat
= new ScMatrix( nColCount
, nRowCount
);
78 pScMat
->SetErrorInterpreter( pErrorInterpreter
); // TODO: really?
82 ScMatrix
* ScMatrix::CloneAndExtend( SCSIZE nNewCols
, SCSIZE nNewRows
) const
84 ScMatrix
* pScMat
= new ScMatrix( nNewCols
, nNewRows
);
86 pScMat
->SetErrorInterpreter( pErrorInterpreter
);
90 void ScMatrix::SetErrorAtInterpreter( USHORT nError
) const
92 if ( pErrorInterpreter
)
93 pErrorInterpreter
->SetError( nError
);
97 // File format: USHORT columns, USHORT rows, (columns*rows) entries:
98 // BYTE type ( CELLTYPE_NONE, CELLTYPE_VALUE, CELLTYPE_STRING ); nothing, double or String
101 ScMatrix::ScMatrix(SvStream
& /* rStream */)
102 : pErrorInterpreter( NULL
)
105 #if SC_ROWLIMIT_STREAM_ACCESS
106 #error address types changed!
113 CreateMatrix(nC
, nR
);
114 DBG_ASSERT( pMat
, "pMat == NULL" );
118 rtl_TextEncoding eCharSet
= rStream
.GetStreamCharSet();
119 SCSIZE nCount
= nColCount
* nRowCount
;
120 SCSIZE nReadCount
= (SCSIZE
) nC
* nR
;
121 for (SCSIZE i
=0; i
<nReadCount
; i
++)
125 if ( nType
== CELLTYPE_VALUE
)
128 rStream
>> pMat
[i
].fVal
;
134 // For unknown types read and forget string (upwards compatibility)
136 if ( nType
!= CELLTYPE_NONE
)
137 rStream
.ReadByteString( aMatStr
, eCharSet
);
142 ResetIsString(); // init string flags
143 mnValType
[i
] = ( nType
== CELLTYPE_NONE
? SC_MATVAL_EMPTY
: SC_MATVAL_STRING
);
146 if ( nType
== CELLTYPE_STRING
)
147 pMat
[i
].pS
= new String(aMatStr
);
155 #endif // SC_ROWLIMIT_STREAM_ACCESS
158 void ScMatrix::Store(SvStream
& /* rStream */) const
160 #if SC_ROWLIMIT_STREAM_ACCESS
161 #error address types changed!
162 SCSIZE nCount
= nColCount
* nRowCount
;
163 // Don't store matrix with more than USHORT max elements, old versions
164 // might get confused in loops for(USHORT i=0; i<nC*nR; i++)
165 if ( !pMat
|| nCount
> ((USHORT
)(~0)) )
167 DBG_ASSERT( pMat
, "ScMatrix::Store: pMat == NULL" );
168 // We can't store a 0 dimension because old versions rely on some
169 // matrix being present, e.g. DDE link results, and old versions didn't
170 // create a matrix if dimension was 0. Store an error result.
171 rStream
<< (USHORT
) 1;
172 rStream
<< (USHORT
) 1;
173 rStream
<< (BYTE
) CELLTYPE_VALUE
;
175 ::rtl::math::setNan( &fVal
);
180 rStream
<< (USHORT
) nColCount
;
181 #if SC_ROWLIMIT_MORE_THAN_32K
184 rStream
<< (USHORT
) nRowCount
;
187 rtl_TextEncoding eCharSet
= rStream
.GetStreamCharSet();
188 for (SCSIZE i
=0; i
<nCount
; i
++)
190 BYTE nType
= CELLTYPE_VALUE
;
191 if ( mnValType
&& IsNonValueType( mnValType
[i
]))
194 aMatStr
= *pMat
[i
].pS
;
198 if ( mnValType
[i
] == SC_MATVAL_STRING
)
199 nType
= CELLTYPE_STRING
;
201 nType
= CELLTYPE_NONE
;
204 if ( nType
== CELLTYPE_VALUE
)
205 rStream
<< pMat
[i
].fVal
;
206 else if ( nType
== CELLTYPE_STRING
)
207 rStream
.WriteByteString( aMatStr
, eCharSet
);
209 #endif // SC_ROWLIMIT_STREAM_ACCESS
212 void ScMatrix::ResetIsString()
214 SCSIZE nCount
= nColCount
* nRowCount
;
217 for (SCSIZE i
= 0; i
< nCount
; i
++)
219 if ( IsNonValueType( mnValType
[i
]))
224 mnValType
= new BYTE
[nCount
];
225 memset( mnValType
, 0, nCount
* sizeof( BYTE
) );
229 void ScMatrix::DeleteIsString()
233 SCSIZE nCount
= nColCount
* nRowCount
;
234 for ( SCSIZE i
= 0; i
< nCount
; i
++ )
236 if (IsNonValueType( mnValType
[i
]))
245 void ScMatrix::PutDouble(double fVal
, SCSIZE nC
, SCSIZE nR
)
247 if (ValidColRow( nC
, nR
))
248 PutDouble( fVal
, CalcOffset( nC
, nR
) );
251 DBG_ERRORFILE("ScMatrix::PutDouble: dimension error");
255 void ScMatrix::PutString(const String
& rStr
, SCSIZE nC
, SCSIZE nR
)
257 if (ValidColRow( nC
, nR
))
258 PutString( rStr
, CalcOffset( nC
, nR
) );
261 DBG_ERRORFILE("ScMatrix::PutString: dimension error");
265 void ScMatrix::PutString(const String
& rStr
, SCSIZE nIndex
)
267 if (mnValType
== NULL
)
269 if ( IsNonValueType( mnValType
[nIndex
]) && pMat
[nIndex
].pS
)
270 *(pMat
[nIndex
].pS
) = rStr
;
273 pMat
[nIndex
].pS
= new String(rStr
);
276 mnValType
[nIndex
] = SC_MATVAL_STRING
;
279 void ScMatrix::PutStringEntry( const String
* pStr
, BYTE bFlag
, SCSIZE nIndex
)
281 DBG_ASSERT( bFlag
, "ScMatrix::PutStringEntry: bFlag == 0" );
282 if (mnValType
== NULL
)
284 // Make sure all bytes of the union are initialized to be able to access
285 // the value with if (IsValueOrEmpty()) GetDouble(). Backup pS first.
286 String
* pS
= pMat
[nIndex
].pS
;
287 pMat
[nIndex
].fVal
= 0.0;
288 // An EMPTY or EMPTYPATH entry must not have a string pointer therefor.
289 DBG_ASSERT( (((bFlag
& SC_MATVAL_EMPTY
) == SC_MATVAL_EMPTY
) && !pStr
) || TRUE
,
290 "ScMatrix::PutStringEntry: pStr passed through EMPTY entry");
291 if ( IsNonValueType( mnValType
[nIndex
]) && pS
)
293 if ((bFlag
& SC_MATVAL_EMPTY
) == SC_MATVAL_EMPTY
)
294 delete pS
, pS
= NULL
;
299 pMat
[nIndex
].pS
= pS
;
303 pMat
[nIndex
].pS
= (pStr
? new String(*pStr
) : NULL
);
306 mnValType
[nIndex
] = bFlag
;
309 void ScMatrix::PutEmpty(SCSIZE nC
, SCSIZE nR
)
311 if (ValidColRow( nC
, nR
))
312 PutEmpty( CalcOffset( nC
, nR
) );
315 DBG_ERRORFILE("ScMatrix::PutEmpty: dimension error");
319 void ScMatrix::PutEmpty(SCSIZE nIndex
)
321 if (mnValType
== NULL
)
323 if ( IsNonValueType( mnValType
[nIndex
]) && pMat
[nIndex
].pS
)
325 delete pMat
[nIndex
].pS
;
331 mnValType
[nIndex
] = SC_MATVAL_EMPTY
;
332 pMat
[nIndex
].pS
= NULL
;
333 pMat
[nIndex
].fVal
= 0.0;
336 void ScMatrix::PutEmptyPath(SCSIZE nC
, SCSIZE nR
)
338 if (ValidColRow( nC
, nR
))
339 PutEmptyPath( CalcOffset( nC
, nR
) );
342 DBG_ERRORFILE("ScMatrix::PutEmptyPath: dimension error");
346 void ScMatrix::PutEmptyPath(SCSIZE nIndex
)
348 if (mnValType
== NULL
)
350 if ( IsNonValueType( mnValType
[nIndex
]) && pMat
[nIndex
].pS
)
352 delete pMat
[nIndex
].pS
;
358 mnValType
[nIndex
] = SC_MATVAL_EMPTYPATH
;
359 pMat
[nIndex
].pS
= NULL
;
360 pMat
[nIndex
].fVal
= 0.0;
363 void ScMatrix::PutBoolean(bool bVal
, SCSIZE nC
, SCSIZE nR
)
365 if (ValidColRow( nC
, nR
))
366 PutBoolean( bVal
, CalcOffset( nC
, nR
) );
369 DBG_ERRORFILE("ScMatrix::PutBoolean: dimension error");
373 void ScMatrix::PutBoolean( bool bVal
, SCSIZE nIndex
)
375 if (mnValType
== NULL
)
377 if ( IsNonValueType( mnValType
[nIndex
]) && pMat
[nIndex
].pS
)
379 delete pMat
[nIndex
].pS
;
383 mnValType
[nIndex
] = SC_MATVAL_BOOLEAN
;
384 pMat
[nIndex
].pS
= NULL
;
385 pMat
[nIndex
].fVal
= bVal
? 1. : 0.;
388 USHORT
ScMatrix::GetError( SCSIZE nC
, SCSIZE nR
) const
390 if (ValidColRowOrReplicated( nC
, nR
))
391 return GetError( CalcOffset( nC
, nR
) );
394 DBG_ERRORFILE("ScMatrix::GetError: dimension error");
399 double ScMatrix::GetDouble(SCSIZE nC
, SCSIZE nR
) const
401 if (ValidColRowOrReplicated( nC
, nR
))
402 return GetDouble( CalcOffset( nC
, nR
) );
405 DBG_ERRORFILE("ScMatrix::GetDouble: dimension error");
406 return CreateDoubleError( errNoValue
);
410 const String
& ScMatrix::GetString(SCSIZE nC
, SCSIZE nR
) const
412 if (ValidColRowOrReplicated( nC
, nR
))
414 SCSIZE nIndex
= CalcOffset( nC
, nR
);
415 if ( IsString( nIndex
) )
416 return GetString( nIndex
);
419 SetErrorAtInterpreter( GetError( nIndex
));
420 DBG_ERRORFILE("ScMatrix::GetString: access error, no string");
425 DBG_ERRORFILE("ScMatrix::GetString: dimension error");
427 return ScGlobal::GetEmptyString();
431 String
ScMatrix::GetString( SvNumberFormatter
& rFormatter
, SCSIZE nIndex
) const
433 if (IsString( nIndex
))
435 if (IsEmptyPath( nIndex
))
436 { // result of empty FALSE jump path
437 ULONG nKey
= rFormatter
.GetStandardFormat( NUMBERFORMAT_LOGICAL
,
440 Color
* pColor
= NULL
;
441 rFormatter
.GetOutputString( 0.0, nKey
, aStr
, &pColor
);
444 return GetString( nIndex
);
447 USHORT nError
= GetError( nIndex
);
450 SetErrorAtInterpreter( nError
);
451 return ScGlobal::GetErrorString( nError
);
454 double fVal
= GetDouble( nIndex
);
455 ULONG nKey
= rFormatter
.GetStandardFormat( NUMBERFORMAT_NUMBER
,
458 rFormatter
.GetInputLineString( fVal
, nKey
, aStr
);
463 String
ScMatrix::GetString( SvNumberFormatter
& rFormatter
, SCSIZE nC
, SCSIZE nR
) const
465 if (ValidColRowOrReplicated( nC
, nR
))
467 SCSIZE nIndex
= CalcOffset( nC
, nR
);
468 return GetString( rFormatter
, nIndex
);
472 DBG_ERRORFILE("ScMatrix::GetString: dimension error");
478 const ScMatrixValue
* ScMatrix::Get(SCSIZE nC
, SCSIZE nR
, ScMatValType
& nType
) const
480 if (ValidColRowOrReplicated( nC
, nR
))
482 SCSIZE nIndex
= CalcOffset( nC
, nR
);
484 nType
= mnValType
[nIndex
];
486 nType
= SC_MATVAL_VALUE
;
487 return &pMat
[nIndex
];
491 DBG_ERRORFILE("ScMatrix::Get: dimension error");
493 nType
= SC_MATVAL_EMPTY
;
497 void ScMatrix::MatCopy(ScMatrix
& mRes
) const
499 if (nColCount
> mRes
.nColCount
|| nRowCount
> mRes
.nRowCount
)
501 DBG_ERRORFILE("ScMatrix::MatCopy: dimension error");
503 else if ( nColCount
== mRes
.nColCount
&& nRowCount
== mRes
.nRowCount
)
508 mRes
.ResetIsString();
509 for (SCSIZE i
= 0; i
< nColCount
; i
++)
511 SCSIZE nStart
= i
* nRowCount
;
512 for (SCSIZE j
= 0; j
< nRowCount
; j
++)
514 if (IsNonValueType( (nType
= mnValType
[nStart
+j
])))
515 mRes
.PutStringEntry( pMat
[nStart
+j
].pS
, nType
, nStart
+j
);
518 mRes
.pMat
[nStart
+j
].fVal
= pMat
[nStart
+j
].fVal
;
519 mRes
.mnValType
[nStart
+j
] = nType
;
526 mRes
.DeleteIsString();
527 SCSIZE nCount
= nColCount
* nRowCount
;
528 for (SCSIZE i
= 0; i
< nCount
; i
++)
529 mRes
.pMat
[i
].fVal
= pMat
[i
].fVal
;
534 // Copy this matrix to upper left rectangle of result matrix.
538 mRes
.ResetIsString();
539 for (SCSIZE i
= 0; i
< nColCount
; i
++)
541 SCSIZE nStart
= i
* nRowCount
;
542 SCSIZE nResStart
= i
* mRes
.nRowCount
;
543 for (SCSIZE j
= 0; j
< nRowCount
; j
++)
545 if (IsNonValueType( (nType
= mnValType
[nStart
+j
])))
546 mRes
.PutStringEntry( pMat
[nStart
+j
].pS
, nType
, nResStart
+j
);
549 mRes
.pMat
[nResStart
+j
].fVal
= pMat
[nStart
+j
].fVal
;
550 mRes
.mnValType
[nResStart
+j
] = nType
;
557 mRes
.DeleteIsString();
558 for (SCSIZE i
= 0; i
< nColCount
; i
++)
560 SCSIZE nStart
= i
* nRowCount
;
561 SCSIZE nResStart
= i
* mRes
.nRowCount
;
562 for (SCSIZE j
= 0; j
< nRowCount
; j
++)
563 mRes
.pMat
[nResStart
+j
].fVal
= pMat
[nStart
+j
].fVal
;
569 void ScMatrix::MatTrans(ScMatrix
& mRes
) const
571 if (nColCount
!= mRes
.nRowCount
|| nRowCount
!= mRes
.nColCount
)
573 DBG_ERRORFILE("ScMatrix::MatTrans: dimension error");
580 mRes
.ResetIsString();
581 for ( SCSIZE i
= 0; i
< nColCount
; i
++ )
583 SCSIZE nStart
= i
* nRowCount
;
584 for ( SCSIZE j
= 0; j
< nRowCount
; j
++ )
586 if (IsNonValueType( (nType
= mnValType
[nStart
+j
])))
587 mRes
.PutStringEntry( pMat
[nStart
+j
].pS
, nType
, j
*mRes
.nRowCount
+i
);
590 mRes
.pMat
[j
*mRes
.nRowCount
+i
].fVal
= pMat
[nStart
+j
].fVal
;
591 mRes
.mnValType
[j
*mRes
.nRowCount
+i
] = nType
;
598 mRes
.DeleteIsString();
599 for ( SCSIZE i
= 0; i
< nColCount
; i
++ )
601 SCSIZE nStart
= i
* nRowCount
;
602 for ( SCSIZE j
= 0; j
< nRowCount
; j
++ )
604 mRes
.pMat
[j
*mRes
.nRowCount
+i
].fVal
= pMat
[nStart
+j
].fVal
;
611 //UNUSED2009-05 void ScMatrix::MatCopyUpperLeft(ScMatrix& mRes) const
613 //UNUSED2009-05 if (nColCount < mRes.nColCount || nRowCount < mRes.nRowCount)
615 //UNUSED2009-05 DBG_ERRORFILE("ScMatrix::MatCopyUpperLeft: dimension error");
619 //UNUSED2009-05 if (mnValType)
621 //UNUSED2009-05 ScMatValType nType;
622 //UNUSED2009-05 mRes.ResetIsString();
623 //UNUSED2009-05 for ( SCSIZE i = 0; i < mRes.nColCount; i++ )
625 //UNUSED2009-05 SCSIZE nStart = i * nRowCount;
626 //UNUSED2009-05 for ( SCSIZE j = 0; j < mRes.nRowCount; j++ )
628 //UNUSED2009-05 if ( IsNonValueType( (nType = mnValType[nStart+j]) ))
629 //UNUSED2009-05 mRes.PutStringEntry( pMat[nStart+j].pS, nType,
630 //UNUSED2009-05 i*mRes.nRowCount+j );
633 //UNUSED2009-05 mRes.pMat[i*mRes.nRowCount+j].fVal = pMat[nStart+j].fVal;
634 //UNUSED2009-05 mRes.mnValType[i*mRes.nRowCount+j] = nType;
641 //UNUSED2009-05 mRes.DeleteIsString();
642 //UNUSED2009-05 for ( SCSIZE i = 0; i < mRes.nColCount; i++ )
644 //UNUSED2009-05 SCSIZE nStart = i * nRowCount;
645 //UNUSED2009-05 for ( SCSIZE j = 0; j < mRes.nRowCount; j++ )
647 //UNUSED2009-05 mRes.pMat[i*mRes.nRowCount+j].fVal = pMat[nStart+j].fVal;
654 void ScMatrix::FillDouble( double fVal
, SCSIZE nC1
, SCSIZE nR1
, SCSIZE nC2
, SCSIZE nR2
)
656 if (ValidColRow( nC1
, nR1
) && ValidColRow( nC2
, nR2
))
658 if ( nC1
== 0 && nR1
== 0 && nC2
== nColCount
-1 && nR2
== nRowCount
-1 )
660 SCSIZE nEnd
= nColCount
* nRowCount
;
661 for ( SCSIZE j
=0; j
<nEnd
; j
++ )
666 for ( SCSIZE i
=nC1
; i
<=nC2
; i
++ )
668 SCSIZE nOff1
= i
* nRowCount
+ nR1
;
669 SCSIZE nOff2
= nOff1
+ nR2
- nR1
;
670 for ( SCSIZE j
=nOff1
; j
<=nOff2
; j
++ )
677 DBG_ERRORFILE("ScMatrix::FillDouble: dimension error");
681 void ScMatrix::CompareEqual()
683 SCSIZE n
= nColCount
* nRowCount
;
686 for ( SCSIZE j
=0; j
<n
; j
++ )
687 if ( IsValueType( mnValType
[j
]) ) // else: #WERT!
688 if ( ::rtl::math::isFinite( pMat
[j
].fVal
)) // else: DoubleError
689 pMat
[j
].fVal
= (pMat
[j
].fVal
== 0.0);
693 for ( SCSIZE j
=0; j
<n
; j
++ )
694 if ( ::rtl::math::isFinite( pMat
[j
].fVal
)) // else: DoubleError
695 pMat
[j
].fVal
= (pMat
[j
].fVal
== 0.0);
699 void ScMatrix::CompareNotEqual()
701 SCSIZE n
= nColCount
* nRowCount
;
704 for ( SCSIZE j
=0; j
<n
; j
++ )
705 if ( IsValueType( mnValType
[j
]) ) // else: #WERT!
706 if ( ::rtl::math::isFinite( pMat
[j
].fVal
)) // else: DoubleError
707 pMat
[j
].fVal
= (pMat
[j
].fVal
!= 0.0);
711 for ( SCSIZE j
=0; j
<n
; j
++ )
712 if ( ::rtl::math::isFinite( pMat
[j
].fVal
)) // else: DoubleError
713 pMat
[j
].fVal
= (pMat
[j
].fVal
!= 0.0);
717 void ScMatrix::CompareLess()
719 SCSIZE n
= nColCount
* nRowCount
;
722 for ( SCSIZE j
=0; j
<n
; j
++ )
723 if ( IsValueType( mnValType
[j
]) ) // else: #WERT!
724 if ( ::rtl::math::isFinite( pMat
[j
].fVal
)) // else: DoubleError
725 pMat
[j
].fVal
= (pMat
[j
].fVal
< 0.0);
729 for ( SCSIZE j
=0; j
<n
; j
++ )
730 if ( ::rtl::math::isFinite( pMat
[j
].fVal
)) // else: DoubleError
731 pMat
[j
].fVal
= (pMat
[j
].fVal
< 0.0);
735 void ScMatrix::CompareGreater()
737 SCSIZE n
= nColCount
* nRowCount
;
740 for ( SCSIZE j
=0; j
<n
; j
++ )
741 if ( IsValueType( mnValType
[j
]) ) // else: #WERT!
742 if ( ::rtl::math::isFinite( pMat
[j
].fVal
)) // else: DoubleError
743 pMat
[j
].fVal
= (pMat
[j
].fVal
> 0.0);
747 for ( SCSIZE j
=0; j
<n
; j
++ )
748 if ( ::rtl::math::isFinite( pMat
[j
].fVal
)) // else: DoubleError
749 pMat
[j
].fVal
= (pMat
[j
].fVal
> 0.0);
753 void ScMatrix::CompareLessEqual()
755 SCSIZE n
= nColCount
* nRowCount
;
758 for ( SCSIZE j
=0; j
<n
; j
++ )
759 if ( IsValueType( mnValType
[j
]) ) // else: #WERT!
760 if ( ::rtl::math::isFinite( pMat
[j
].fVal
)) // else: DoubleError
761 pMat
[j
].fVal
= (pMat
[j
].fVal
<= 0.0);
765 for ( SCSIZE j
=0; j
<n
; j
++ )
766 if ( ::rtl::math::isFinite( pMat
[j
].fVal
)) // else: DoubleError
767 pMat
[j
].fVal
= (pMat
[j
].fVal
<= 0.0);
771 void ScMatrix::CompareGreaterEqual()
773 SCSIZE n
= nColCount
* nRowCount
;
776 for ( SCSIZE j
=0; j
<n
; j
++ )
777 if ( IsValueType( mnValType
[j
]) ) // else: #WERT!
778 if ( ::rtl::math::isFinite( pMat
[j
].fVal
)) // else: DoubleError
779 pMat
[j
].fVal
= (pMat
[j
].fVal
>= 0.0);
783 for ( SCSIZE j
=0; j
<n
; j
++ )
784 if ( ::rtl::math::isFinite( pMat
[j
].fVal
)) // else: DoubleError
785 pMat
[j
].fVal
= (pMat
[j
].fVal
>= 0.0);
789 double ScMatrix::And()
791 SCSIZE n
= nColCount
* nRowCount
;
795 for ( SCSIZE j
=0; bAnd
&& j
<n
; j
++ )
797 if ( !IsValueType( mnValType
[j
]) )
798 { // assuming a CompareMat this is an error
799 return CreateDoubleError( errIllegalArgument
);
801 else if ( ::rtl::math::isFinite( pMat
[j
].fVal
))
802 bAnd
= (pMat
[j
].fVal
!= 0.0);
804 return pMat
[j
].fVal
; // DoubleError
809 for ( SCSIZE j
=0; bAnd
&& j
<n
; j
++ )
811 if ( ::rtl::math::isFinite( pMat
[j
].fVal
))
812 bAnd
= (pMat
[j
].fVal
!= 0.0);
814 return pMat
[j
].fVal
; // DoubleError
820 double ScMatrix::Or()
822 SCSIZE n
= nColCount
* nRowCount
;
826 for ( SCSIZE j
=0; !bOr
&& j
<n
; j
++ )
827 if ( !IsValueType( mnValType
[j
]) )
828 { // assuming a CompareMat this is an error
829 return CreateDoubleError( errIllegalArgument
);
831 else if ( ::rtl::math::isFinite( pMat
[j
].fVal
))
832 bOr
= (pMat
[j
].fVal
!= 0.0);
834 return pMat
[j
].fVal
; // DoubleError
838 for ( SCSIZE j
=0; !bOr
&& j
<n
; j
++ )
839 if ( ::rtl::math::isFinite( pMat
[j
].fVal
))
840 bOr
= (pMat
[j
].fVal
!= 0.0);
842 return pMat
[j
].fVal
; // DoubleError