[devel_3.0_main] Cherry-pick Beautification of source-code. 80383
[platform/framework/native/appfw.git] / src / base / FBaseFloatMatrix.cpp
index 05cb4de..bcd60e0 100644 (file)
@@ -18,7 +18,6 @@
  * @file       FBaseFloatMatrix.cpp
  * @brief      This is the implementation for FloatMatrix class.
  */
-
 #include <FBaseFloatMatrix.h>
 #include <FBaseSysLog.h>
 #include <unique_ptr.h>
@@ -117,7 +116,7 @@ FloatMatrix::FloatMatrix(int rowCount, int columnCount, const float* pArray[])
 
 FloatMatrix::~FloatMatrix(void)
 {
-       for ( int i = 0 ; i < __row ; i++ )
+       for (int i = 0; i < __row; i++)
        {
                delete[] __pMatrix[i];
        }
@@ -184,7 +183,7 @@ FloatMatrix::operator =(const FloatMatrix& rhs)
 bool
 FloatMatrix::Equals(const Tizen::Base::Object& obj) const
 {
-       const FloatMatrix* pOther = dynamic_cast <const FloatMatrix*>(&obj);
+       const FloatMatrix* pOther = dynamic_cast< const FloatMatrix* >(&obj);
 
        if (pOther == null)
        {
@@ -241,20 +240,20 @@ FloatMatrix::AddToEachElement(float value)
 bool
 FloatMatrix::AllocateCapacity(int rowCount, int columnCount)
 {
-       std::unique_ptr<float* []> pMatrix(new (std::nothrow) float* [rowCount]);
+       std::unique_ptr< float*[] > pMatrix(new (std::nothrow) float*[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) float[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 @@ FloatMatrix::CalculateDeterminant(float** pMatrix, int order) const  // For perf
        }
 
        float determinant = 0.0f;
-       std::unique_ptr<float* []> pMinor(new (std::nothrow) float* [order - 1]);
+       std::unique_ptr< float*[] > pMinor(new (std::nothrow) float*[order - 1]);
        SysTryReturn(NID_BASE, pMinor != null, false, 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 @@ FloatMatrix::CalculateDeterminant(float** pMatrix, int order) const  // For perf
                pMinor[i] = new (std::nothrow) float[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 @@ FloatMatrix::CalculateDeterminant(float** pMatrix, int order) const  // For perf
        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 @@ FloatMatrix::CalculateDeterminant(float** pMatrix, int order) const  // For perf
                else
                {
                        determinant += -pMatrix[0][i] * CalculateDeterminant(pMinor.get(), order - 1);
-                       signFlag = true;        
+                       signFlag = true;
                }
        }
 
@@ -329,7 +328,7 @@ FloatMatrix::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<float []> pColumn(new (std::nothrow) float [__row]);
+       std::unique_ptr< float[] > pColumn(new (std::nothrow) float[__row]);
        SysTryReturn(NID_BASE, pColumn != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -365,30 +364,30 @@ FloatMatrix::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<FloatMatrix> pInverseMatrix(new (std::nothrow) FloatMatrix(__row, __column));
+       std::unique_ptr< FloatMatrix > pInverseMatrix(new (std::nothrow) FloatMatrix(__row, __column));
        SysTryReturn(NID_BASE, pInverseMatrix != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
        float determinant = CalculateDeterminant(__pMatrix, __row);
 
-       if (Tizen::Base::Float::Compare(determinant,0.0f) == 0)
+       if (Tizen::Base::Float::Compare(determinant, 0.0f) == 0)
        {
                return null;
        }
 
-       std::unique_ptr<float* []> pMinor(new (std::nothrow) float* [__row - 1]);
+       std::unique_ptr< float*[] > pMinor(new (std::nothrow) float*[__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) float[__row - 1];
                if (pMinor[i] == null)
                {
-                       for (int j = 0; j < i;  j++)
+                       for (int j = 0; j < i; j++)
                        {
                                delete[] pMinor[j];
-                       }               
+                       }
 
                        return null;
                }
@@ -404,10 +403,10 @@ FloatMatrix::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];
        }
@@ -429,7 +428,7 @@ FloatMatrix::GetMinor(float** pSrc, float** pDest, int rowIndex, int columnIndex
                if (i != rowIndex)
                {
                        columnCount = 0;
-       
+
                        for (int j = 0; j < order; j++)
                        {
                                if (j != columnIndex)
@@ -456,7 +455,7 @@ FloatMatrix::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<float []> pRow(new (std::nothrow) float [__column]);
+       std::unique_ptr< float[] > pRow(new (std::nothrow) float[__column]);
        SysTryReturn(NID_BASE, pRow != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -489,7 +488,7 @@ FloatMatrix::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<FloatMatrix> pTransposeMatrix(new (std::nothrow) FloatMatrix(*this));
+       std::unique_ptr< FloatMatrix > pTransposeMatrix(new (std::nothrow) FloatMatrix(*this));
        SysTryReturn(NID_BASE, pTransposeMatrix != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -524,20 +523,20 @@ FloatMatrix::IsIdentity(void) const
                {
                        if (i == j)
                        {
-                               if (Tizen::Base::Float::Compare(__pMatrix[i][j],1.0f) != 0)
+                               if (Tizen::Base::Float::Compare(__pMatrix[i][j], 1.0f) != 0)
                                {
                                        return false;
                                }
                        }
                        else
                        {
-                               if (Tizen::Base::Float::Compare(__pMatrix[i][j],0.0f) != 0)
+                               if (Tizen::Base::Float::Compare(__pMatrix[i][j], 0.0f) != 0)
                                {
                                        return false;
                                }
                        }
 
-                       
+
                }
        }
        return true;
@@ -546,7 +545,7 @@ FloatMatrix::IsIdentity(void) const
 bool
 FloatMatrix::IsInvertible(void) const
 {
-       int ret = Tizen::Base::Float::Compare(GetDeterminant(),0.0f);
+       int ret = Tizen::Base::Float::Compare(GetDeterminant(), 0.0f);
 
        if (ret == 0)
        {
@@ -564,15 +563,15 @@ FloatMatrix::Multiply(const FloatMatrix& 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<float* []> pResult(new (std::nothrow) float* [__row]);
+       std::unique_ptr< float*[] > pResult(new (std::nothrow) float*[__row]);
        SysTryReturnResult(NID_BASE, pResult != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
 
-       for ( int i = 0 ; i < __row ; i++ )
+       for (int i = 0; i < __row; i++)
        {
                pResult[i] = new (std::nothrow) float[matrix.__column];
                if (pResult[i] == null)
                {
-                       for (int j = 0; j < i;  j++)
+                       for (int j = 0; j < i; j++)
                        {
                                delete[] pResult[j];
                        }
@@ -593,7 +592,7 @@ FloatMatrix::Multiply(const FloatMatrix& matrix)
                }
        }
 
-       for ( int i = 0 ; i < __row ; i++ )
+       for (int i = 0; i < __row; i++)
        {
                delete[] __pMatrix[i];
        }
@@ -633,7 +632,7 @@ FloatMatrix::SetAsIdentity(void)
 {
        SysTryReturnResult(NID_BASE, __row == __column, E_INVALID_OPERATION, "The current instance is not a square matrix.");
 
-       for (int i = 0; i < __row; i ++)
+       for (int i = 0; i < __row; i++)
        {
                for (int j = 0; j < __column; j++)
                {
@@ -644,7 +643,7 @@ FloatMatrix::SetAsIdentity(void)
                        else
                        {
                                __pMatrix[i][j] = 0.0f;
-                       }                               
+                       }
                }
        }
 
@@ -660,7 +659,7 @@ FloatMatrix::Invert(void)
        SysTryReturnResult(NID_BASE, Tizen::Base::Float::Compare(determinant, 0.0f) != 0, E_INVALID_OPERATION,
                "The current instance is not invertible.");
 
-       std::unique_ptr<float* []> pInverse(new (std::nothrow) float* [__row]);
+       std::unique_ptr< float*[] > pInverse(new (std::nothrow) float*[__row]);
        SysTryReturn(NID_BASE, pInverse != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -669,18 +668,18 @@ FloatMatrix::Invert(void)
                pInverse[i] = new (std::nothrow) float[__row];
                if (pInverse[i] == null)
                {
-                       for (int j = 0; j < i;  j++)
+                       for (int j = 0; j < i; j++)
                        {
                                delete[] pInverse[j];
-                       }                       
+                       }
                        return E_OUT_OF_MEMORY;
                }
        }
 
-       std::unique_ptr<float* []> pMinor(new (std::nothrow) float* [__row - 1]);
+       std::unique_ptr< float*[] > pMinor(new (std::nothrow) float*[__row - 1]);
        if (pMinor == null)
        {
-               for ( int i = 0 ; i < __row ; i++ )
+               for (int i = 0; i < __row; i++)
                {
                        delete[] pInverse[i];
                }
@@ -692,12 +691,12 @@ FloatMatrix::Invert(void)
                pMinor[i] = new (std::nothrow) float[__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];
                        }
@@ -712,14 +711,14 @@ FloatMatrix::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];
        }
@@ -727,7 +726,7 @@ FloatMatrix::Invert(void)
 
        __pMatrix = pInverse.release();
 
-       for ( int i = 0 ; i < __row -1; i++ )
+       for (int i = 0; i < __row - 1; i++)
        {
                delete[] pMinor[i];
        }
@@ -766,7 +765,7 @@ FloatMatrix::SetColumn(int columnIndex, const float* pArray)
 
        for (int i = 0; i < __row; i++)
        {
-               __pMatrix[i][columnIndex] = pArray[i];  
+               __pMatrix[i][columnIndex] = pArray[i];
        }
 
        return E_SUCCESS;
@@ -781,7 +780,7 @@ FloatMatrix::SetRow(int rowIndex, const float* pArray)
 
        for (int i = 0; i < __column; i++)
        {
-               __pMatrix[rowIndex][i] = pArray[i];     
+               __pMatrix[rowIndex][i] = pArray[i];
        }
 
        return E_SUCCESS;
@@ -836,7 +835,7 @@ FloatMatrix::SetAsNull(void)
        {
                for (int j = 0; j < __column; j++)
                {
-                       __pMatrix[i][j] = 0.0f; 
+                       __pMatrix[i][j] = 0.0f;
                }
        }
 }