[devel_3.0_main] Cherry-pick Beautification of source-code. 80383
[platform/framework/native/appfw.git] / src / base / FBaseIntMatrix.cpp
index 142a65a..0c2cbb8 100644 (file)
@@ -18,7 +18,6 @@
  * @file       FBaseIntMatrix.cpp
  * @brief      This is the implementation for IntMatrix class.
  */
-
 #include <FBaseIntMatrix.h>
 #include <FBaseSysLog.h>
 #include <unique_ptr.h>
@@ -117,7 +116,7 @@ IntMatrix::IntMatrix(int rowCount, int columnCount, const int* pArray[])
 
 IntMatrix::~IntMatrix(void)
 {
-       for ( int i = 0 ; i < __row ; i++ )
+       for (int i = 0; i < __row; i++)
        {
                delete[] __pMatrix[i];
        }
@@ -184,7 +183,7 @@ IntMatrix::operator =(const IntMatrix& rhs)
 bool
 IntMatrix::Equals(const Tizen::Base::Object& obj) const
 {
-       const IntMatrix* pOther = dynamic_cast <const IntMatrix*>(&obj);
+       const IntMatrix* pOther = dynamic_cast< const IntMatrix* >(&obj);
 
        if (pOther == null)
        {
@@ -241,20 +240,20 @@ IntMatrix::AddToEachElement(int value)
 bool
 IntMatrix::AllocateCapacity(int rowCount, int columnCount)
 {
-       std::unique_ptr<int* []> pMatrix(new (std::nothrow) int* [rowCount]);
+       std::unique_ptr< int*[] > pMatrix(new (std::nothrow) int*[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) int[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,19 +274,19 @@ IntMatrix::CalculateDeterminant(int** pMatrix, int order) const  // For perfoman
        }
 
        int determinant = 0;
-       std::unique_ptr<int* []> pMinor(new (std::nothrow) int* [order - 1]);
+       std::unique_ptr< int*[] > pMinor(new (std::nothrow) int*[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++)
+       for (int i = 0; i < order - 1; i++)
        {
                pMinor[i] = new (std::nothrow) int[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;
                }
        }
 
@@ -298,17 +297,17 @@ IntMatrix::CalculateDeterminant(int** pMatrix, int order) const  // For perfoman
 
                if (signFlag == true)
                {
-                       determinant += pMatrix[0][i] * CalculateDeterminant(pMinor.get(), order -1);
+                       determinant += pMatrix[0][i] * CalculateDeterminant(pMinor.get(), order - 1);
                        signFlag = false;
                }
                else
                {
-                       determinant += -pMatrix[0][i] * CalculateDeterminant(pMinor.get(), order -1);
+                       determinant += -pMatrix[0][i] * CalculateDeterminant(pMinor.get(), order - 1);
                        signFlag = true;
                }
        }
 
-       for (int i = 0; i < order -1; i++)
+       for (int i = 0; i < order - 1; i++)
        {
                delete[] pMinor[i];
        }
@@ -329,7 +328,7 @@ IntMatrix::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<int []> pColumn(new (std::nothrow) int [__row]);
+       std::unique_ptr< int[] > pColumn(new (std::nothrow) int[__row]);
        SysTryReturn(NID_BASE, pColumn != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -365,7 +364,7 @@ IntMatrix::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<IntMatrix> pInverseMatrix(new (std::nothrow) IntMatrix(__row, __column));
+       std::unique_ptr< IntMatrix > pInverseMatrix(new (std::nothrow) IntMatrix(__row, __column));
        SysTryReturn(NID_BASE, pInverseMatrix != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -376,7 +375,7 @@ IntMatrix::GetInverseN(void) const
                return null;
        }
 
-       std::unique_ptr<int* []> pMinor(new (std::nothrow) int* [__row - 1]);
+       std::unique_ptr< int*[] > pMinor(new (std::nothrow) int*[__row - 1]);
        SysTryReturn(NID_BASE, pMinor != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -385,7 +384,7 @@ IntMatrix::GetInverseN(void) const
                pMinor[i] = new (std::nothrow) int[__row - 1];
                if (pMinor[i] == null)
                {
-                       for (int j = 0; j < i;  j++)
+                       for (int j = 0; j < i; j++)
                        {
                                delete[] pMinor[j];
                        }
@@ -406,7 +405,7 @@ IntMatrix::GetInverseN(void) const
                }
        }
 
-       for ( int i = 0 ; i < __row - 1 ; i++)
+       for (int i = 0; i < __row - 1; i++)
        {
                delete[] pMinor[i];
        }
@@ -457,7 +456,7 @@ IntMatrix::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<int []> pRow(new (std::nothrow) int [__column]);
+       std::unique_ptr< int[] > pRow(new (std::nothrow) int[__column]);
        SysTryReturn(NID_BASE, pRow != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -490,7 +489,7 @@ IntMatrix::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<IntMatrix> pTransposeMatrix(new (std::nothrow) IntMatrix(*this));
+       std::unique_ptr< IntMatrix > pTransposeMatrix(new (std::nothrow) IntMatrix(*this));
        SysTryReturn(NID_BASE, pTransposeMatrix != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -563,15 +562,15 @@ IntMatrix::Multiply(const IntMatrix& 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<int* []> pResult(new (std::nothrow) int* [__row]);
+       std::unique_ptr< int*[] > pResult(new (std::nothrow) int*[__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 int[matrix.__column];
                if (pResult[i] == null)
                {
-                       for (int j = 0; j < i;  j++)
+                       for (int j = 0; j < i; j++)
                        {
                                delete[] pResult[j];
                        }
@@ -592,7 +591,7 @@ IntMatrix::Multiply(const IntMatrix& matrix)
                }
        }
 
-       for ( int i = 0 ; i < __row ; i++ )
+       for (int i = 0; i < __row; i++)
        {
                delete[] __pMatrix[i];
        }
@@ -659,7 +658,7 @@ IntMatrix::Invert(void)
        int determinant = CalculateDeterminant(__pMatrix, __row);
        SysTryReturnResult(NID_BASE, determinant != 0, E_INVALID_OPERATION, "The current instance is not invertible.");
 
-       std::unique_ptr<int* []> pInverse(new (std::nothrow) int* [__row]);
+       std::unique_ptr< int*[] > pInverse(new (std::nothrow) int*[__row]);
        SysTryReturn(NID_BASE, pInverse != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                GetErrorMessage(E_OUT_OF_MEMORY));
 
@@ -668,18 +667,18 @@ IntMatrix::Invert(void)
                pInverse[i] = new (std::nothrow) int[__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<int* []> pMinor(new (std::nothrow) int* [__row - 1]);
+       std::unique_ptr< int*[] > pMinor(new (std::nothrow) int*[__row - 1]);
        if (pMinor == null)
        {
-               for ( int i = 0 ; i < __row ; i++ )
+               for (int i = 0; i < __row; i++)
                {
                        delete[] pInverse[i];
                }
@@ -691,12 +690,12 @@ IntMatrix::Invert(void)
                pMinor[i] = new int[__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];
                        }
@@ -711,14 +710,14 @@ IntMatrix::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];
        }
@@ -726,7 +725,7 @@ IntMatrix::Invert(void)
 
        __pMatrix = pInverse.release();
 
-       for ( int i = 0 ; i < __row - 1; i++ )
+       for (int i = 0; i < __row - 1; i++)
        {
                delete[] pMinor[i];
        }