[devel_3.0_main] Cherry-pick Beautification of source-code. 80383
[platform/framework/native/appfw.git] / src / base / FBaseDoubleMatrix.cpp
index a893c36..e9a2ed7 100644 (file)
@@ -18,7 +18,6 @@
  * @file       FBaseDoubleMatrix.cpp
  * @brief      This is the implementation for DoubleMatrix class.
  */
-
 #include <FBaseDoubleMatrix.h>
 #include <FBaseSysLog.h>
 #include <unique_ptr.h>
@@ -117,7 +116,7 @@ DoubleMatrix::DoubleMatrix(int rowCount, int columnCount, const double* pArray[]
 
 DoubleMatrix::~DoubleMatrix(void)
 {
-       for ( int i = 0 ; i < __row ; i++ )
+       for (int i = 0; i < __row; i++)
        {
                delete[] __pMatrix[i];
        }
@@ -184,7 +183,7 @@ DoubleMatrix::operator =(const DoubleMatrix& rhs)
 bool
 DoubleMatrix::Equals(const Tizen::Base::Object& obj) const
 {
-       const DoubleMatrix* pOther = dynamic_cast <const DoubleMatrix*>(&obj);
+       const DoubleMatrix* pOther = dynamic_cast< const DoubleMatrix* >(&obj);
 
        if (pOther == null)
        {
@@ -241,20 +240,20 @@ DoubleMatrix::AddToEachElement(double value)
 bool
 DoubleMatrix::AllocateCapacity(int rowCount, int columnCount)
 {
-       std::unique_ptr<double* []> pMatrix(new (std::nothrow) double* [rowCount]);
+       std::unique_ptr< double*[] > pMatrix(new (std::nothrow) double*[rowCount]);
        SysTryReturn(NID_BASE, pMatrix != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
-       for ( int i = 0 ; i < rowCount ; i++ )
+       for (int i = 0; i < rowCount; i++)
        {
                pMatrix[i] = new (std::nothrow) double[columnCount];
                if (pMatrix[i] == null)
                {
-                       for (int j = 0; j < i;  j++)
+                       for (int j = 0; j < i; j++)
                        {
                                delete[] pMatrix[j];
                        }
-                       return  false;
+                       return false;
                }
        }
 
@@ -275,7 +274,7 @@ DoubleMatrix::CalculateDeterminant(double** pMatrix, int order) const  // For pe
        }
 
        double determinant = 0.0f;
-       std::unique_ptr<double* []> pMinor(new (std::nothrow) double* [order - 1]);
+       std::unique_ptr< double*[] > pMinor(new (std::nothrow) double*[order - 1]);
        SysTryReturn(NID_BASE, pMinor != null, determinant, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
        for (int i = 0; i < order - 1; i++)
@@ -283,11 +282,11 @@ DoubleMatrix::CalculateDeterminant(double** pMatrix, int order) const  // For pe
                pMinor[i] = new (std::nothrow) double[order - 1];
                if (pMinor[i] == null)
                {
-                       for (int j = 0; j < i;  j++)
+                       for (int j = 0; j < i; j++)
                        {
                                delete[] pMinor[j];
                        }
-                       return  determinant;
+                       return determinant;
                }
        }
 
@@ -295,7 +294,7 @@ DoubleMatrix::CalculateDeterminant(double** pMatrix, int order) const  // For pe
        for (int i = 0; i < order; i++)
        {
                GetMinor(pMatrix, pMinor.get(), 0, i, order);
-       
+
                if (signFlag == true)
                {
                        determinant += pMatrix[0][i] * CalculateDeterminant(pMinor.get(), order - 1);
@@ -304,7 +303,7 @@ DoubleMatrix::CalculateDeterminant(double** pMatrix, int order) const  // For pe
                else
                {
                        determinant += -pMatrix[0][i] * CalculateDeterminant(pMinor.get(), order - 1);
-                       signFlag = true;        
+                       signFlag = true;
                }
        }
 
@@ -329,7 +328,7 @@ DoubleMatrix::GetColumnN(int columnIndex) const
                "[%s] Invalid argument is used. The columnIndex is larger than the column count of the current instance.",
                GetErrorMessage(E_INVALID_ARG));
 
-       std::unique_ptr<double []> pColumn(new (std::nothrow) double [__row]);
+       std::unique_ptr< double[] > pColumn(new (std::nothrow) double[__row]);
        SysTryReturn(NID_BASE, pColumn != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -365,27 +364,27 @@ DoubleMatrix::GetInverseN(void) const
        SysTryReturn(NID_BASE, __row == __column, null, E_INVALID_OPERATION,
                "[%s] The current instance is not a square matrix.", GetErrorMessage(E_INVALID_OPERATION));
 
-       std::unique_ptr<DoubleMatrix> pInverseMatrix(new (std::nothrow) DoubleMatrix(__row, __column));
+       std::unique_ptr< DoubleMatrix > pInverseMatrix(new (std::nothrow) DoubleMatrix(__row, __column));
        SysTryReturn(NID_BASE, pInverseMatrix != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
        double determinant = CalculateDeterminant(__pMatrix, __row);
 
-       if (Tizen::Base::Double::Compare(determinant,0.0f) == 0)
+       if (Tizen::Base::Double::Compare(determinant, 0.0f) == 0)
        {
                return null;
        }
 
-       std::unique_ptr<double* []> pMinor(new (std::nothrow) double* [__row - 1]);
+       std::unique_ptr< double*[] > pMinor(new (std::nothrow) double*[__row - 1]);
        SysTryReturn(NID_BASE, pMinor != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
-       for (int i = 0; i < __row -1; i++)
+       for (int i = 0; i < __row - 1; i++)
        {
                pMinor[i] = new (std::nothrow) double[__row - 1];
                if (pMinor[i] == null)
                {
-                       for (int j = 0; j < i;  j++)
+                       for (int j = 0; j < i; j++)
                        {
                                delete[] pMinor[j];
                        }
@@ -403,10 +402,10 @@ DoubleMatrix::GetInverseN(void) const
                        {
                                pInverseMatrix->__pMatrix[j][i] = -pInverseMatrix->__pMatrix[j][i];
                        }
-               }       
+               }
        }
 
-       for ( int i = 0 ; i < __row -1 ; i++ )
+       for (int i = 0; i < __row - 1; i++)
        {
                delete[] pMinor[i];
        }
@@ -430,7 +429,7 @@ DoubleMatrix::GetMinor(double** pSrc, double** pDest, int rowIndex, int columnIn
                if (i != rowIndex)
                {
                        columnCount = 0;
-       
+
                        for (int j = 0; j < order; j++)
                        {
                                if (j != columnIndex)
@@ -457,7 +456,7 @@ DoubleMatrix::GetRowN(int rowIndex) const
                "[%s] Invalid argument is used. The rowIndex is larger than the row count of the current instance.",
                GetErrorMessage(E_INVALID_ARG));
 
-       std::unique_ptr<double []> pRow(new (std::nothrow) double [__column]);
+       std::unique_ptr< double[] > pRow(new (std::nothrow) double[__column]);
        SysTryReturn(NID_BASE, pRow != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -490,7 +489,7 @@ DoubleMatrix::GetTransposeN(void) const
        SysTryReturn(NID_BASE, __row == __column, null, E_INVALID_OPERATION,
                "[%s] The current instance is not a square matrix.", GetErrorMessage(E_INVALID_OPERATION));
 
-       std::unique_ptr<DoubleMatrix> pTransposeMatrix(new (std::nothrow) DoubleMatrix(*this));
+       std::unique_ptr< DoubleMatrix > pTransposeMatrix(new (std::nothrow) DoubleMatrix(*this));
        SysTryReturn(NID_BASE, pTransposeMatrix != null, null, E_OUT_OF_MEMORY,
                "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -525,20 +524,20 @@ DoubleMatrix::IsIdentity(void) const
                {
                        if (i == j)
                        {
-                               if (Tizen::Base::Double::Compare(__pMatrix[i][j],1.0f) != 0)
+                               if (Tizen::Base::Double::Compare(__pMatrix[i][j], 1.0f) != 0)
                                {
                                        return false;
                                }
                        }
                        else
                        {
-                               if (Tizen::Base::Double::Compare(__pMatrix[i][j],0.0f) != 0)
+                               if (Tizen::Base::Double::Compare(__pMatrix[i][j], 0.0f) != 0)
                                {
                                        return false;
                                }
                        }
 
-                       
+
                }
        }
        return true;
@@ -547,7 +546,7 @@ DoubleMatrix::IsIdentity(void) const
 bool
 DoubleMatrix::IsInvertible(void) const
 {
-       int ret = Tizen::Base::Double::Compare(GetDeterminant(),0.0f);
+       int ret = Tizen::Base::Double::Compare(GetDeterminant(), 0.0f);
 
        if (ret == 0)
        {
@@ -565,15 +564,15 @@ DoubleMatrix::Multiply(const DoubleMatrix& matrix)
        SysTryReturnResult(NID_BASE, __column == matrix.__row, E_INVALID_ARG,
                "The column count of the current instance is not same with the row count of the specified instance.");
 
-       std::unique_ptr<double* []> pResult(new (std::nothrow) double* [__row]);
+       std::unique_ptr< double*[] > pResult(new (std::nothrow) double*[__row]);
        SysTryReturnResult(NID_BASE, pResult != null, E_OUT_OF_MEMORY, "Allocating memory is failed.");
 
-       for ( int i = 0 ; i < __row ; i++ )
+       for (int i = 0; i < __row; i++)
        {
                pResult[i] = new (std::nothrow) double[matrix.__column];
                if (pResult[i] == null)
                {
-                       for (int j = 0; j < i;  j++)
+                       for (int j = 0; j < i; j++)
                        {
                                delete[] pResult[j];
                        }
@@ -594,7 +593,7 @@ DoubleMatrix::Multiply(const DoubleMatrix& matrix)
                }
        }
 
-       for ( int i = 0 ; i < __row ; i++ )
+       for (int i = 0; i < __row; i++)
        {
                delete[] __pMatrix[i];
        }
@@ -646,7 +645,7 @@ DoubleMatrix::SetAsIdentity(void)
                        else
                        {
                                __pMatrix[i][j] = 0.0f;
-                       }                               
+                       }
                }
        }
 
@@ -662,7 +661,7 @@ DoubleMatrix::Invert(void)
        SysTryReturnResult(NID_BASE, Tizen::Base::Double::Compare(determinant, 0.0f) != 0, E_INVALID_OPERATION,
                "The current instance is not invertible.");
 
-       std::unique_ptr<double* []> pInverse(new (std::nothrow) double* [__row]);
+       std::unique_ptr< double*[] > pInverse(new (std::nothrow) double*[__row]);
        SysTryReturnResult(NID_BASE, pInverse != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -671,7 +670,7 @@ DoubleMatrix::Invert(void)
                pInverse[i] = new (std::nothrow) double[__row];
                if (pInverse[i] == null)
                {
-                       for (int j = 0; j < i;  j++)
+                       for (int j = 0; j < i; j++)
                        {
                                delete[] pInverse[j];
                        }
@@ -679,27 +678,27 @@ DoubleMatrix::Invert(void)
                }
        }
 
-       std::unique_ptr<double* []> pMinor(new (std::nothrow) double* [__row - 1]);
+       std::unique_ptr< double*[] > pMinor(new (std::nothrow) double*[__row - 1]);
        if (pMinor == null)
        {
-               for ( int i = 0 ; i < __row ; i++ )
+               for (int i = 0; i < __row; i++)
                {
                        delete[] pInverse[i];
                }
                return E_OUT_OF_MEMORY;
        }
 
-       for (int i = 0; i < __row -1; i++)
+       for (int i = 0; i < __row - 1; i++)
        {
                pMinor[i] = new double[__row - 1];
                if (pMinor[i] == null)
                {
-                       for( int k = 0 ; k < __row ; k++ )
+                       for (int k = 0; k < __row; k++)
                        {
                                delete[] pInverse[k];
                        }
 
-                       for (int j = 0; j < i;  j++)
+                       for (int j = 0; j < i; j++)
                        {
                                delete[] pMinor[j];
                        }
@@ -713,14 +712,14 @@ DoubleMatrix::Invert(void)
                {
                        GetMinor(__pMatrix, pMinor.get(), i, j, __row);
                        pInverse[j][i] = CalculateDeterminant(pMinor.get(), __row - 1) / determinant;
-                       if ((i +j +2) % 2 == 1)
+                       if ((i + j + 2) % 2 == 1)
                        {
                                pInverse[j][i] = -pInverse[j][i];
                        }
-               }       
+               }
        }
 
-       for ( int i = 0 ; i < __row ; i++ )
+       for (int i = 0; i < __row; i++)
        {
                delete[] __pMatrix[i];
        }
@@ -728,7 +727,7 @@ DoubleMatrix::Invert(void)
 
        __pMatrix = pInverse.release();
 
-       for (int i = 0 ; i < __row -1; i++ )
+       for (int i = 0; i < __row - 1; i++)
        {
                delete[] pMinor[i];
        }
@@ -767,7 +766,7 @@ DoubleMatrix::SetColumn(int columnIndex, const double* pArray)
 
        for (int i = 0; i < __row; i++)
        {
-               __pMatrix[i][columnIndex] = pArray[i];  
+               __pMatrix[i][columnIndex] = pArray[i];
        }
 
        return E_SUCCESS;
@@ -782,7 +781,7 @@ DoubleMatrix::SetRow(int rowIndex, const double* pArray)
 
        for (int i = 0; i < __column; i++)
        {
-               __pMatrix[rowIndex][i] = pArray[i];     
+               __pMatrix[rowIndex][i] = pArray[i];
        }
 
        return E_SUCCESS;
@@ -837,7 +836,7 @@ DoubleMatrix::SetAsNull(void)
        {
                for (int j = 0; j < __column; j++)
                {
-                       __pMatrix[i][j] = 0.0f; 
+                       __pMatrix[i][j] = 0.0f;
                }
        }
 }