Skip to content

Commit

Permalink
Optimisation of MatrixVectorProduct to improve performance when multi…
Browse files Browse the repository at this point in the history
…plying matrix by vector of ones

If you are multiplying the matrix by a vector of ones you don't need to do any multiplication.  You can just sum each row of the matrix.
This is now used to calculate this type of matrix-vector product.  The change speeds up the code slightly in an operation that is done reasonably often.
Changes to regtests are due to the derivatives on the constant vector of ones no longer being stored or used.
  • Loading branch information
Gareth Aneurin Tribello committed Jul 16, 2024
1 parent 2a1e7d3 commit a24a72a
Show file tree
Hide file tree
Showing 7 changed files with 455 additions and 432 deletions.
238 changes: 119 additions & 119 deletions regtest/adjmat/rt-basic-matrix/deriv.reference
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
0.000000 27 -0.2261
0.000000 28 0.2433
0.000000 29 12.0120
0.000000 30 3.1500
0.000000 31 2.0092
0.000000 32 2.5569
0.000000 33 2.6536
0.000000 34 2.5500
0.000000 35 2.0168
0.000000 36 1.8642
0.000000 30 0.0000
0.000000 31 0.0000
0.000000 32 0.0000
0.000000 33 0.0000
0.000000 34 0.0000
0.000000 35 0.0000
0.000000 36 0.0000
1.000000 0 -4.1853
1.000000 1 1.1156
1.000000 2 -0.1042
Expand Down Expand Up @@ -66,13 +66,13 @@
1.000000 27 0.6358
1.000000 28 4.9862
1.000000 29 10.1720
1.000000 30 2.1750
1.000000 31 3.4387
1.000000 32 3.1960
1.000000 33 2.2718
1.000000 34 3.4027
1.000000 35 3.3940
1.000000 36 2.4658
1.000000 30 0.0000
1.000000 31 0.0000
1.000000 32 0.0000
1.000000 33 0.0000
1.000000 34 0.0000
1.000000 35 0.0000
1.000000 36 0.0000
2.000000 0 -1.1577
2.000000 1 0.3744
2.000000 2 -0.0623
Expand Down Expand Up @@ -103,13 +103,13 @@
2.000000 27 -0.3126
2.000000 28 3.6636
2.000000 29 7.0672
2.000000 30 1.9864
2.000000 31 1.2723
2.000000 32 1.7105
2.000000 33 1.6167
2.000000 34 1.6259
2.000000 35 1.7598
2.000000 36 2.0571
2.000000 30 0.0000
2.000000 31 0.0000
2.000000 32 0.0000
2.000000 33 0.0000
2.000000 34 0.0000
2.000000 35 0.0000
2.000000 36 0.0000
3.000000 0 -3.0752
3.000000 1 0.0004
3.000000 2 0.0961
Expand Down Expand Up @@ -140,13 +140,13 @@
3.000000 27 0.0486
3.000000 28 0.0444
3.000000 29 9.5142
3.000000 30 1.6184
3.000000 31 2.4247
3.000000 32 2.1079
3.000000 33 1.9399
3.000000 34 1.8526
3.000000 35 2.2500
3.000000 36 2.3311
3.000000 30 0.0000
3.000000 31 0.0000
3.000000 32 0.0000
3.000000 33 0.0000
3.000000 34 0.0000
3.000000 35 0.0000
3.000000 36 0.0000
4.000000 0 -1.6243
4.000000 1 -0.1528
4.000000 2 0.1406
Expand Down Expand Up @@ -177,13 +177,13 @@
4.000000 27 -1.1831
4.000000 28 0.5552
4.000000 29 12.6378
4.000000 30 2.6553
4.000000 31 1.7604
4.000000 32 2.5729
4.000000 33 2.4249
4.000000 34 2.1443
4.000000 35 2.1089
4.000000 36 2.4091
4.000000 30 0.0000
4.000000 31 0.0000
4.000000 32 0.0000
4.000000 33 0.0000
4.000000 34 0.0000
4.000000 35 0.0000
4.000000 36 0.0000
5.000000 0 0.5418
5.000000 1 0.1694
5.000000 2 0.2520
Expand Down Expand Up @@ -214,13 +214,13 @@
5.000000 27 0.0001
5.000000 28 -0.0004
5.000000 29 3.5041
5.000000 30 0.6401
5.000000 31 0.6401
5.000000 32 0.6516
5.000000 33 0.6516
5.000000 34 0.6351
5.000000 35 0.6351
5.000000 36 0.6582
5.000000 30 0.0000
5.000000 31 0.0000
5.000000 32 0.0000
5.000000 33 0.0000
5.000000 34 0.0000
5.000000 35 0.0000
5.000000 36 0.0000
6.000000 0 1.6176
6.000000 1 2.4456
6.000000 2 -0.9183
Expand Down Expand Up @@ -251,13 +251,13 @@
6.000000 27 2.8834
6.000000 28 -3.3605
6.000000 29 5.1466
6.000000 30 1.3643
6.000000 31 2.7047
6.000000 32 1.2990
6.000000 33 2.6892
6.000000 34 2.5161
6.000000 35 1.0621
6.000000 36 1.0309
6.000000 30 0.0000
6.000000 31 0.0000
6.000000 32 0.0000
6.000000 33 0.0000
6.000000 34 0.0000
6.000000 35 0.0000
6.000000 36 0.0000
7.000000 0 1.5828
7.000000 1 0.6758
7.000000 2 0.2480
Expand Down Expand Up @@ -288,13 +288,13 @@
7.000000 27 -0.1813
7.000000 28 -0.6017
7.000000 29 0.7069
7.000000 30 1.2467
7.000000 31 2.8112
7.000000 32 2.5584
7.000000 33 1.2594
7.000000 34 2.8544
7.000000 35 1.4572
7.000000 36 1.6125
7.000000 30 0.0000
7.000000 31 0.0000
7.000000 32 0.0000
7.000000 33 0.0000
7.000000 34 0.0000
7.000000 35 0.0000
7.000000 36 0.0000
8.000000 0 -0.9176
8.000000 1 0.4528
8.000000 2 -1.1395
Expand Down Expand Up @@ -325,13 +325,13 @@
8.000000 27 2.6078
8.000000 28 -2.0658
8.000000 29 2.8882
8.000000 30 3.4515
8.000000 31 3.4521
8.000000 32 2.1283
8.000000 33 3.3715
8.000000 34 2.1283
8.000000 35 2.1510
8.000000 36 1.2032
8.000000 30 0.0000
8.000000 31 0.0000
8.000000 32 0.0000
8.000000 33 0.0000
8.000000 34 0.0000
8.000000 35 0.0000
8.000000 36 0.0000
9.000000 0 -0.4583
9.000000 1 0.0332
9.000000 2 -0.1815
Expand Down Expand Up @@ -362,13 +362,13 @@
9.000000 27 -0.3805
9.000000 28 1.5300
9.000000 29 0.6692
9.000000 30 3.0861
9.000000 31 1.2940
9.000000 32 2.7151
9.000000 33 2.7151
9.000000 34 1.2940
9.000000 35 1.8200
9.000000 36 0.4348
9.000000 30 0.0000
9.000000 31 0.0000
9.000000 32 0.0000
9.000000 33 0.0000
9.000000 34 0.0000
9.000000 35 0.0000
9.000000 36 0.0000
10.000000 0 0.2296
10.000000 1 -0.0319
10.000000 2 0.2869
Expand Down Expand Up @@ -399,13 +399,13 @@
10.000000 27 0.7413
10.000000 28 -2.6069
10.000000 29 6.7351
10.000000 30 2.8118
10.000000 31 1.1821
10.000000 32 2.4341
10.000000 33 2.4662
10.000000 34 1.0432
10.000000 35 1.7090
10.000000 36 0.3802
10.000000 30 0.0000
10.000000 31 0.0000
10.000000 32 0.0000
10.000000 33 0.0000
10.000000 34 0.0000
10.000000 35 0.0000
10.000000 36 0.0000
11.000000 0 -0.0008
11.000000 1 0.0000
11.000000 2 -0.0015
Expand Down Expand Up @@ -436,13 +436,13 @@
11.000000 27 0.0098
11.000000 28 0.0000
11.000000 29 0.0337
11.000000 30 0.0079
11.000000 31 0.0043
11.000000 32 0.0019
11.000000 33 0.0081
11.000000 34 0.0055
11.000000 35 0.0025
11.000000 36 0.0008
11.000000 30 0.0000
11.000000 31 0.0000
11.000000 32 0.0000
11.000000 33 0.0000
11.000000 34 0.0000
11.000000 35 0.0000
11.000000 36 0.0000
12.000000 0 0.5252
12.000000 1 3.2121
12.000000 2 0.5459
Expand Down Expand Up @@ -473,13 +473,13 @@
12.000000 27 -1.2697
12.000000 28 1.4907
12.000000 29 0.6659
12.000000 30 1.2423
12.000000 31 3.1151
12.000000 32 1.2424
12.000000 33 2.6744
12.000000 34 2.6744
12.000000 35 1.6248
12.000000 36 0.4961
12.000000 30 0.0000
12.000000 31 0.0000
12.000000 32 0.0000
12.000000 33 0.0000
12.000000 34 0.0000
12.000000 35 0.0000
12.000000 36 0.0000
13.000000 0 0.2000
13.000000 1 3.3301
13.000000 2 -0.0176
Expand Down Expand Up @@ -510,13 +510,13 @@
13.000000 27 0.0043
13.000000 28 -0.0463
13.000000 29 0.0003
13.000000 30 1.2007
13.000000 31 3.0617
13.000000 32 1.2025
13.000000 33 2.6169
13.000000 34 2.6467
13.000000 35 1.6902
13.000000 36 0.5966
13.000000 30 0.0000
13.000000 31 0.0000
13.000000 32 0.0000
13.000000 33 0.0000
13.000000 34 0.0000
13.000000 35 0.0000
13.000000 36 0.0000
14.000000 0 0.3029
14.000000 1 3.0058
14.000000 2 -0.6902
Expand Down Expand Up @@ -547,13 +547,13 @@
14.000000 27 0.1165
14.000000 28 -0.5887
14.000000 29 0.7712
14.000000 30 1.3378
14.000000 31 2.9302
14.000000 32 1.1877
14.000000 33 2.6162
14.000000 34 2.5164
14.000000 35 1.6436
14.000000 36 0.6848
14.000000 30 0.0000
14.000000 31 0.0000
14.000000 32 0.0000
14.000000 33 0.0000
14.000000 34 0.0000
14.000000 35 0.0000
14.000000 36 0.0000
15.000000 0 1.1413
15.000000 1 -1.8689
15.000000 2 0.0495
Expand Down Expand Up @@ -584,13 +584,13 @@
15.000000 27 0.0378
15.000000 28 -0.2717
15.000000 29 0.0068
15.000000 30 2.5001
15.000000 31 2.0389
15.000000 32 2.9140
15.000000 33 2.1558
15.000000 34 2.4064
15.000000 35 2.5594
15.000000 36 1.6052
15.000000 30 0.0000
15.000000 31 0.0000
15.000000 32 0.0000
15.000000 33 0.0000
15.000000 34 0.0000
15.000000 35 0.0000
15.000000 36 0.0000
16.000000 0 -1.5136
16.000000 1 -2.5965
16.000000 2 1.5726
Expand Down Expand Up @@ -621,10 +621,10 @@
16.000000 27 -0.6392
16.000000 28 -0.7778
16.000000 29 5.9309
16.000000 30 2.1657
16.000000 31 3.6819
16.000000 32 2.1658
16.000000 33 2.2287
16.000000 34 3.5447
16.000000 35 2.2288
16.000000 36 2.6660
16.000000 30 0.0000
16.000000 31 0.0000
16.000000 32 0.0000
16.000000 33 0.0000
16.000000 34 0.0000
16.000000 35 0.0000
16.000000 36 0.0000
Loading

1 comment on commit a24a72a

@PlumedBot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found broken examples in automatic/ANGLES.tmp
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/CAVITY.tmp
Found broken examples in automatic/CLASSICAL_MDS.tmp
Found broken examples in automatic/CLUSTER_DIAMETER.tmp
Found broken examples in automatic/CLUSTER_DISTRIBUTION.tmp
Found broken examples in automatic/CLUSTER_PROPERTIES.tmp
Found broken examples in automatic/CONSTANT.tmp
Found broken examples in automatic/CONTACT_MATRIX.tmp
Found broken examples in automatic/CONTACT_MATRIX_PROPER.tmp
Found broken examples in automatic/COORDINATIONNUMBER.tmp
Found broken examples in automatic/DFSCLUSTERING.tmp
Found broken examples in automatic/DISTANCE_FROM_CONTOUR.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/ENVIRONMENTSIMILARITY.tmp
Found broken examples in automatic/FIND_CONTOUR.tmp
Found broken examples in automatic/FIND_CONTOUR_SURFACE.tmp
Found broken examples in automatic/FIND_SPHERICAL_CONTOUR.tmp
Found broken examples in automatic/FOURIER_TRANSFORM.tmp
Found broken examples in automatic/FUNCPATHGENERAL.tmp
Found broken examples in automatic/FUNCPATHMSD.tmp
Found broken examples in automatic/FUNNEL.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/GHBFIX.tmp
Found broken examples in automatic/GPROPERTYMAP.tmp
Found broken examples in automatic/HBOND_MATRIX.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/INCYLINDER.tmp
Found broken examples in automatic/INENVELOPE.tmp
Found broken examples in automatic/INTERPOLATE_GRID.tmp
Found broken examples in automatic/LOCAL_AVERAGE.tmp
Found broken examples in automatic/MAZE_OPTIMIZER_BIAS.tmp
Found broken examples in automatic/MAZE_RANDOM_ACCELERATION_MD.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/METATENSOR.tmp
Found broken examples in automatic/MULTICOLVARDENS.tmp
Found broken examples in automatic/OUTPUT_CLUSTER.tmp
Found broken examples in automatic/PAMM.tmp
Found broken examples in automatic/PCA.tmp
Found broken examples in automatic/PCAVARS.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in automatic/PYCVINTERFACE.tmp
Found broken examples in automatic/PYTHONFUNCTION.tmp
Found broken examples in automatic/Q3.tmp
Found broken examples in automatic/Q4.tmp
Found broken examples in automatic/Q6.tmp
Found broken examples in automatic/QUATERNION.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_LINEAR_PROJ.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_MAHA_DIST.tmp
Found broken examples in automatic/SPRINT.tmp
Found broken examples in automatic/TETRAHEDRALPORE.tmp
Found broken examples in automatic/TORSIONS.tmp
Found broken examples in automatic/WHAM_WEIGHTS.tmp
Found broken examples in AnalysisPP.md
Found broken examples in CollectiveVariablesPP.md
Found broken examples in MiscelaneousPP.md

Please sign in to comment.