You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mahout.apache.org by "Max Heimel (JIRA)" <ji...@apache.org> on 2010/07/06 15:07:49 UTC

[jira] Created: (MAHOUT-435) Add assign(DenseVector)/assign(DenseMatrix) function to DenseVector/DenseMatrix

Add assign(DenseVector)/assign(DenseMatrix) function to DenseVector/DenseMatrix
-------------------------------------------------------------------------------

                 Key: MAHOUT-435
                 URL: https://issues.apache.org/jira/browse/MAHOUT-435
             Project: Mahout
          Issue Type: New Feature
          Components: Math
            Reporter: Max Heimel
            Priority: Minor


This new feature would add a new overloaded assign function to (Dense)Vector/(Dense)Matrix, that allows to assign the content of another  (Dense)Vector / (Dense)Matrix by overwriting the existing double[][] array. 

Compared to using .clone(), this feature would reduce the number of memory allocations. For example in case of an iterative algorithm, that needs to check for convergence;

{code:title=Convergence check using .clone()|borderStyle=solid}
Densematrix newMatrix = oldMatrix.clone();
while(!converged)
{
    // perform iteration computation on newMatrix
    converged=checkConvergence(newMatrix,oldMatrix);
    oldMatrix = newMatrix.clone(); // results in memory allocation
}
{code}

{code:title=Convergence check using .assign(Matrix)|borderStyle=solid}
Densematrix newMatrix = oldMatrix.clone();
while(!converged)
{
    // perform iteration computation on newMatrix
    converged=checkConvergence(newMatrix,oldMatrix);
    oldMatrix.assign(newMatrix); // no memory allocation
}
{code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MAHOUT-435) Add assign(DenseVector)/assign(DenseMatrix) function to DenseVector/DenseMatrix

Posted by "Ted Dunning (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MAHOUT-435?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12885591#action_12885591 ] 

Ted Dunning commented on MAHOUT-435:
------------------------------------


My only common on this patch is that it appears to not match the overall Mahout style.  Whoever commits it should fix the indentation (remove tabs!) and add braces to the if statement and for loops.
 

> Add assign(DenseVector)/assign(DenseMatrix) function to DenseVector/DenseMatrix
> -------------------------------------------------------------------------------
>
>                 Key: MAHOUT-435
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-435
>             Project: Mahout
>          Issue Type: New Feature
>          Components: Math
>            Reporter: Max Heimel
>            Priority: Minor
>         Attachments: MAHOUT-435.diff
>
>
> This new feature would add a new overloaded assign function to (Dense)Vector/(Dense)Matrix, that allows to assign the content of another (Dense)Vector / (Dense)Matrix by overwriting the content of the internal double array. Compared to using .clone(), this feature would reduce the number of memory allocations. 
> For example in case of an iterative algorithm, that needs to check for convergence;
> {code:title=Convergence check using .clone()|borderStyle=solid}
> Densematrix newMatrix = oldMatrix.clone();
> while(!converged)
> {
>     // perform iteration computation on newMatrix
>     converged=checkConvergence(newMatrix,oldMatrix);
>     oldMatrix = newMatrix.clone(); // results in memory allocation
> }
> {code}
> {code:title=Convergence check using .assign(Matrix)|borderStyle=solid}
> Densematrix newMatrix = oldMatrix.clone();
> while(!converged)
> {
>     // perform iteration computation on newMatrix
>     converged=checkConvergence(newMatrix,oldMatrix);
>     oldMatrix.assign(newMatrix); // no memory allocation
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MAHOUT-435) Add assign(DenseVector)/assign(DenseMatrix) function to DenseVector/DenseMatrix

Posted by "Ted Dunning (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MAHOUT-435?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12885590#action_12885590 ] 

Ted Dunning commented on MAHOUT-435:
------------------------------------


Max, can you test to see how much difference the lack of allocation actually makes to your code?  We should still add this patch, but it will help us all to have a reference point regarding how much difference it makes.

My question really pertains to the cost of relatively large highly ephemeral (on average) allocations.  Since there is quite a bit of work that goes on with the contents of the copy, it may be that the cost of allocating and then almost always collecting the copy would be very small.
 

> Add assign(DenseVector)/assign(DenseMatrix) function to DenseVector/DenseMatrix
> -------------------------------------------------------------------------------
>
>                 Key: MAHOUT-435
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-435
>             Project: Mahout
>          Issue Type: New Feature
>          Components: Math
>            Reporter: Max Heimel
>            Priority: Minor
>         Attachments: MAHOUT-435.diff
>
>
> This new feature would add a new overloaded assign function to (Dense)Vector/(Dense)Matrix, that allows to assign the content of another (Dense)Vector / (Dense)Matrix by overwriting the content of the internal double array. Compared to using .clone(), this feature would reduce the number of memory allocations. 
> For example in case of an iterative algorithm, that needs to check for convergence;
> {code:title=Convergence check using .clone()|borderStyle=solid}
> Densematrix newMatrix = oldMatrix.clone();
> while(!converged)
> {
>     // perform iteration computation on newMatrix
>     converged=checkConvergence(newMatrix,oldMatrix);
>     oldMatrix = newMatrix.clone(); // results in memory allocation
> }
> {code}
> {code:title=Convergence check using .assign(Matrix)|borderStyle=solid}
> Densematrix newMatrix = oldMatrix.clone();
> while(!converged)
> {
>     // perform iteration computation on newMatrix
>     converged=checkConvergence(newMatrix,oldMatrix);
>     oldMatrix.assign(newMatrix); // no memory allocation
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (MAHOUT-435) Add assign(DenseVector)/assign(DenseMatrix) function to DenseVector/DenseMatrix

Posted by "Max Heimel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MAHOUT-435?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Max Heimel updated MAHOUT-435:
------------------------------

    Status: Patch Available  (was: Open)

> Add assign(DenseVector)/assign(DenseMatrix) function to DenseVector/DenseMatrix
> -------------------------------------------------------------------------------
>
>                 Key: MAHOUT-435
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-435
>             Project: Mahout
>          Issue Type: New Feature
>          Components: Math
>            Reporter: Max Heimel
>            Priority: Minor
>         Attachments: MAHOUT-435.diff
>
>
> This new feature would add a new overloaded assign function to (Dense)Vector/(Dense)Matrix, that allows to assign the content of another (Dense)Vector / (Dense)Matrix by overwriting the content of the internal double array. Compared to using .clone(), this feature would reduce the number of memory allocations. 
> For example in case of an iterative algorithm, that needs to check for convergence;
> {code:title=Convergence check using .clone()|borderStyle=solid}
> Densematrix newMatrix = oldMatrix.clone();
> while(!converged)
> {
>     // perform iteration computation on newMatrix
>     converged=checkConvergence(newMatrix,oldMatrix);
>     oldMatrix = newMatrix.clone(); // results in memory allocation
> }
> {code}
> {code:title=Convergence check using .assign(Matrix)|borderStyle=solid}
> Densematrix newMatrix = oldMatrix.clone();
> while(!converged)
> {
>     // perform iteration computation on newMatrix
>     converged=checkConvergence(newMatrix,oldMatrix);
>     oldMatrix.assign(newMatrix); // no memory allocation
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (MAHOUT-435) Add assign(DenseVector)/assign(DenseMatrix) function to DenseVector/DenseMatrix

Posted by "Max Heimel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MAHOUT-435?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Max Heimel updated MAHOUT-435:
------------------------------

    Attachment: MAHOUT-435.diff

Patch to add assign(DenseVector) to DenseVector.java and assign(DenseMatrix) to DenseMatrix.java

> Add assign(DenseVector)/assign(DenseMatrix) function to DenseVector/DenseMatrix
> -------------------------------------------------------------------------------
>
>                 Key: MAHOUT-435
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-435
>             Project: Mahout
>          Issue Type: New Feature
>          Components: Math
>            Reporter: Max Heimel
>            Priority: Minor
>         Attachments: MAHOUT-435.diff
>
>
> This new feature would add a new overloaded assign function to (Dense)Vector/(Dense)Matrix, that allows to assign the content of another (Dense)Vector / (Dense)Matrix by overwriting the content of the internal double array. Compared to using .clone(), this feature would reduce the number of memory allocations. 
> For example in case of an iterative algorithm, that needs to check for convergence;
> {code:title=Convergence check using .clone()|borderStyle=solid}
> Densematrix newMatrix = oldMatrix.clone();
> while(!converged)
> {
>     // perform iteration computation on newMatrix
>     converged=checkConvergence(newMatrix,oldMatrix);
>     oldMatrix = newMatrix.clone(); // results in memory allocation
> }
> {code}
> {code:title=Convergence check using .assign(Matrix)|borderStyle=solid}
> Densematrix newMatrix = oldMatrix.clone();
> while(!converged)
> {
>     // perform iteration computation on newMatrix
>     converged=checkConvergence(newMatrix,oldMatrix);
>     oldMatrix.assign(newMatrix); // no memory allocation
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (MAHOUT-435) Add assign(DenseVector)/assign(DenseMatrix) function to DenseVector/DenseMatrix

Posted by "Max Heimel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MAHOUT-435?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Max Heimel updated MAHOUT-435:
------------------------------

    Description: 
This new feature would add a new overloaded assign function to (Dense)Vector/(Dense)Matrix, that allows to assign the content of another (Dense)Vector / (Dense)Matrix by overwriting the content of the internal double array. Compared to using .clone(), this feature would reduce the number of memory allocations. 

For example in case of an iterative algorithm, that needs to check for convergence;
{code:title=Convergence check using .clone()|borderStyle=solid}
Densematrix newMatrix = oldMatrix.clone();
while(!converged)
{
    // perform iteration computation on newMatrix
    converged=checkConvergence(newMatrix,oldMatrix);
    oldMatrix = newMatrix.clone(); // results in memory allocation
}
{code}

{code:title=Convergence check using .assign(Matrix)|borderStyle=solid}
Densematrix newMatrix = oldMatrix.clone();
while(!converged)
{
    // perform iteration computation on newMatrix
    converged=checkConvergence(newMatrix,oldMatrix);
    oldMatrix.assign(newMatrix); // no memory allocation
}
{code}

  was:
This new feature would add a new overloaded assign function to (Dense)Vector/(Dense)Matrix, that allows to assign the content of another  (Dense)Vector / (Dense)Matrix by overwriting the existing double[][] array. 

Compared to using .clone(), this feature would reduce the number of memory allocations. For example in case of an iterative algorithm, that needs to check for convergence;

{code:title=Convergence check using .clone()|borderStyle=solid}
Densematrix newMatrix = oldMatrix.clone();
while(!converged)
{
    // perform iteration computation on newMatrix
    converged=checkConvergence(newMatrix,oldMatrix);
    oldMatrix = newMatrix.clone(); // results in memory allocation
}
{code}

{code:title=Convergence check using .assign(Matrix)|borderStyle=solid}
Densematrix newMatrix = oldMatrix.clone();
while(!converged)
{
    // perform iteration computation on newMatrix
    converged=checkConvergence(newMatrix,oldMatrix);
    oldMatrix.assign(newMatrix); // no memory allocation
}
{code}


> Add assign(DenseVector)/assign(DenseMatrix) function to DenseVector/DenseMatrix
> -------------------------------------------------------------------------------
>
>                 Key: MAHOUT-435
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-435
>             Project: Mahout
>          Issue Type: New Feature
>          Components: Math
>            Reporter: Max Heimel
>            Priority: Minor
>
> This new feature would add a new overloaded assign function to (Dense)Vector/(Dense)Matrix, that allows to assign the content of another (Dense)Vector / (Dense)Matrix by overwriting the content of the internal double array. Compared to using .clone(), this feature would reduce the number of memory allocations. 
> For example in case of an iterative algorithm, that needs to check for convergence;
> {code:title=Convergence check using .clone()|borderStyle=solid}
> Densematrix newMatrix = oldMatrix.clone();
> while(!converged)
> {
>     // perform iteration computation on newMatrix
>     converged=checkConvergence(newMatrix,oldMatrix);
>     oldMatrix = newMatrix.clone(); // results in memory allocation
> }
> {code}
> {code:title=Convergence check using .assign(Matrix)|borderStyle=solid}
> Densematrix newMatrix = oldMatrix.clone();
> while(!converged)
> {
>     // perform iteration computation on newMatrix
>     converged=checkConvergence(newMatrix,oldMatrix);
>     oldMatrix.assign(newMatrix); // no memory allocation
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.