Janosch Peters
2010-09-26 13:10:05 UTC
Hi list,
my code runs pretty slow, so I'm looking for speed improvements. I
read in the docs that iterators should be used instead of indexed
access. But Im not really sure what counts as "indexed access". Is
there a way to speed the following code snippet up with iterators?
("numpy_matrix<double> data" is part of the method signature.)
---------------------------------------------------------------------------------------
matrix_row< numpy_matrix< double > > pointVec = row(data, pointId);
for(unsigned int i = 0; i < data.size1(); i++)
{
if(static_cast<unsigned int>(assignments(i)) == clusterId && i !=
pointId)
{
avDist += norm_2(row(data,i) - pointVec);
numPoints++;
}
}
---------------------------------------------------------------------------------------
cheers,
Janosch
Janosch Peters, BSc.
Brunnerstra?e 39
80804 M?nchen
+49 (0)89 8908 1882
+49 (0)176 2418 2959
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Janosch Peters.vcf
Type: text/directory
Size: 394 bytes
Desc: not available
URL: <http://lists.tiker.net/pipermail/pyublas/attachments/20100926/b1902fca/attachment.bin>
-------------- next part --------------
my code runs pretty slow, so I'm looking for speed improvements. I
read in the docs that iterators should be used instead of indexed
access. But Im not really sure what counts as "indexed access". Is
there a way to speed the following code snippet up with iterators?
("numpy_matrix<double> data" is part of the method signature.)
---------------------------------------------------------------------------------------
matrix_row< numpy_matrix< double > > pointVec = row(data, pointId);
for(unsigned int i = 0; i < data.size1(); i++)
{
if(static_cast<unsigned int>(assignments(i)) == clusterId && i !=
pointId)
{
avDist += norm_2(row(data,i) - pointVec);
numPoints++;
}
}
---------------------------------------------------------------------------------------
cheers,
Janosch
Janosch Peters, BSc.
Brunnerstra?e 39
80804 M?nchen
+49 (0)89 8908 1882
+49 (0)176 2418 2959
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Janosch Peters.vcf
Type: text/directory
Size: 394 bytes
Desc: not available
URL: <http://lists.tiker.net/pipermail/pyublas/attachments/20100926/b1902fca/attachment.bin>
-------------- next part --------------