[trunk] Run fix_comment on invert.c
This commit is contained in:
parent
76947f0074
commit
a0977266b4
@ -115,85 +115,85 @@ opj_bool opj_lupDecompose(OPJ_FLOAT32 * matrix,OPJ_UINT32 * permutations,
|
|||||||
OPJ_UINT32 offset = 1;
|
OPJ_UINT32 offset = 1;
|
||||||
OPJ_UINT32 lStride = n-1;
|
OPJ_UINT32 lStride = n-1;
|
||||||
|
|
||||||
//initialize permutations
|
/*initialize permutations */
|
||||||
for (i = 0; i < n; ++i)
|
for (i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
*tmpPermutations++ = i;
|
*tmpPermutations++ = i;
|
||||||
}
|
}
|
||||||
// now make a pivot with colum switch
|
/* now make a pivot with colum switch */
|
||||||
tmpPermutations = permutations;
|
tmpPermutations = permutations;
|
||||||
for (k = 0; k < lLastColum; ++k) {
|
for (k = 0; k < lLastColum; ++k) {
|
||||||
p = 0.0;
|
p = 0.0;
|
||||||
|
|
||||||
// take the middle element
|
/* take the middle element */
|
||||||
lColumnMatrix = lTmpMatrix + k;
|
lColumnMatrix = lTmpMatrix + k;
|
||||||
|
|
||||||
// make permutation with the biggest value in the column
|
/* make permutation with the biggest value in the column */
|
||||||
for (i = k; i < n; ++i) {
|
for (i = k; i < n; ++i) {
|
||||||
temp = ((*lColumnMatrix > 0) ? *lColumnMatrix : -(*lColumnMatrix));
|
temp = ((*lColumnMatrix > 0) ? *lColumnMatrix : -(*lColumnMatrix));
|
||||||
if (temp > p) {
|
if (temp > p) {
|
||||||
p = temp;
|
p = temp;
|
||||||
k2 = i;
|
k2 = i;
|
||||||
}
|
}
|
||||||
// next line
|
/* next line */
|
||||||
lColumnMatrix += n;
|
lColumnMatrix += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a whole rest of 0 -> non singular
|
/* a whole rest of 0 -> non singular */
|
||||||
if (p == 0.0) {
|
if (p == 0.0) {
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// should we permute ?
|
/* should we permute ? */
|
||||||
if (k2 != k) {
|
if (k2 != k) {
|
||||||
//exchange of line
|
/*exchange of line */
|
||||||
// k2 > k
|
/* k2 > k */
|
||||||
dstPermutations = tmpPermutations + k2 - k;
|
dstPermutations = tmpPermutations + k2 - k;
|
||||||
// swap indices
|
/* swap indices */
|
||||||
t = *tmpPermutations;
|
t = *tmpPermutations;
|
||||||
*tmpPermutations = *dstPermutations;
|
*tmpPermutations = *dstPermutations;
|
||||||
*dstPermutations = t;
|
*dstPermutations = t;
|
||||||
|
|
||||||
// and swap entire line.
|
/* and swap entire line. */
|
||||||
lColumnMatrix = lTmpMatrix + (k2 - k) * n;
|
lColumnMatrix = lTmpMatrix + (k2 - k) * n;
|
||||||
memcpy(p_swap_area,lColumnMatrix,lSwapSize);
|
memcpy(p_swap_area,lColumnMatrix,lSwapSize);
|
||||||
memcpy(lColumnMatrix,lTmpMatrix,lSwapSize);
|
memcpy(lColumnMatrix,lTmpMatrix,lSwapSize);
|
||||||
memcpy(lTmpMatrix,p_swap_area,lSwapSize);
|
memcpy(lTmpMatrix,p_swap_area,lSwapSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now update data in the rest of the line and line after
|
/* now update data in the rest of the line and line after */
|
||||||
lDestMatrix = lTmpMatrix + k;
|
lDestMatrix = lTmpMatrix + k;
|
||||||
lColumnMatrix = lDestMatrix + n;
|
lColumnMatrix = lDestMatrix + n;
|
||||||
// take the middle element
|
/* take the middle element */
|
||||||
temp = *(lDestMatrix++);
|
temp = *(lDestMatrix++);
|
||||||
|
|
||||||
// now compute up data (i.e. coeff up of the diagonal).
|
/* now compute up data (i.e. coeff up of the diagonal). */
|
||||||
for (i = offset; i < n; ++i) {
|
for (i = offset; i < n; ++i) {
|
||||||
//lColumnMatrix;
|
/*lColumnMatrix; */
|
||||||
// divide the lower column elements by the diagonal value
|
/* divide the lower column elements by the diagonal value */
|
||||||
|
|
||||||
// matrix[i][k] /= matrix[k][k];
|
/* matrix[i][k] /= matrix[k][k]; */
|
||||||
// p = matrix[i][k]
|
/* p = matrix[i][k] */
|
||||||
p = *lColumnMatrix / temp;
|
p = *lColumnMatrix / temp;
|
||||||
*(lColumnMatrix++) = p;
|
*(lColumnMatrix++) = p;
|
||||||
|
|
||||||
for (j = /* k + 1 */ offset; j < n; ++j) {
|
for (j = /* k + 1 */ offset; j < n; ++j) {
|
||||||
// matrix[i][j] -= matrix[i][k] * matrix[k][j];
|
/* matrix[i][j] -= matrix[i][k] * matrix[k][j]; */
|
||||||
*(lColumnMatrix++) -= p * (*(lDestMatrix++));
|
*(lColumnMatrix++) -= p * (*(lDestMatrix++));
|
||||||
}
|
}
|
||||||
// come back to the k+1th element
|
/* come back to the k+1th element */
|
||||||
lDestMatrix -= lStride;
|
lDestMatrix -= lStride;
|
||||||
// go to kth element of the next line
|
/* go to kth element of the next line */
|
||||||
lColumnMatrix += k;
|
lColumnMatrix += k;
|
||||||
}
|
}
|
||||||
|
|
||||||
// offset is now k+2
|
/* offset is now k+2 */
|
||||||
++offset;
|
++offset;
|
||||||
// 1 element less for stride
|
/* 1 element less for stride */
|
||||||
--lStride;
|
--lStride;
|
||||||
// next line
|
/* next line */
|
||||||
lTmpMatrix+=n;
|
lTmpMatrix+=n;
|
||||||
// next permutation element
|
/* next permutation element */
|
||||||
++tmpPermutations;
|
++tmpPermutations;
|
||||||
}
|
}
|
||||||
return OPJ_TRUE;
|
return OPJ_TRUE;
|
||||||
@ -228,18 +228,18 @@ void opj_lupSolve (OPJ_FLOAT32 * pResult,
|
|||||||
lTmpMatrix = lLineMatrix;
|
lTmpMatrix = lLineMatrix;
|
||||||
for (j = 1; j <= i; ++j)
|
for (j = 1; j <= i; ++j)
|
||||||
{
|
{
|
||||||
// sum += matrix[i][j-1] * y[j-1];
|
/* sum += matrix[i][j-1] * y[j-1]; */
|
||||||
sum += (*(lTmpMatrix++)) * (*(lCurrentPtr++));
|
sum += (*(lTmpMatrix++)) * (*(lCurrentPtr++));
|
||||||
}
|
}
|
||||||
//y[i] = pVector[pPermutations[i]] - sum;
|
/*y[i] = pVector[pPermutations[i]] - sum; */
|
||||||
*(lIntermediatePtr++) = pVector[*(lCurrentPermutationPtr++)] - sum;
|
*(lIntermediatePtr++) = pVector[*(lCurrentPermutationPtr++)] - sum;
|
||||||
lLineMatrix += n;
|
lLineMatrix += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we take the last point of the matrix
|
/* we take the last point of the matrix */
|
||||||
lLineMatrix = pMatrix + n*n - 1;
|
lLineMatrix = pMatrix + n*n - 1;
|
||||||
|
|
||||||
// and we take after the last point of the destination vector
|
/* and we take after the last point of the destination vector */
|
||||||
lDestPtr = pResult + n;
|
lDestPtr = pResult + n;
|
||||||
|
|
||||||
for (i = n - 1; i != -1 ; --i) {
|
for (i = n - 1; i != -1 ; --i) {
|
||||||
@ -248,10 +248,10 @@ void opj_lupSolve (OPJ_FLOAT32 * pResult,
|
|||||||
u = *(lTmpMatrix++);
|
u = *(lTmpMatrix++);
|
||||||
lCurrentPtr = lDestPtr--;
|
lCurrentPtr = lDestPtr--;
|
||||||
for (j = i + 1; j < n; ++j) {
|
for (j = i + 1; j < n; ++j) {
|
||||||
// sum += matrix[i][j] * x[j]
|
/* sum += matrix[i][j] * x[j] */
|
||||||
sum += (*(lTmpMatrix++)) * (*(lCurrentPtr++));
|
sum += (*(lTmpMatrix++)) * (*(lCurrentPtr++));
|
||||||
}
|
}
|
||||||
//x[i] = (y[i] - sum) / u;
|
/*x[i] = (y[i] - sum) / u; */
|
||||||
*(lBeginPtr--) = (*(lGeneratedData--) - sum) / u;
|
*(lBeginPtr--) = (*(lGeneratedData--) - sum) / u;
|
||||||
lLineMatrix -= lStride;
|
lLineMatrix -= lStride;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user