Browse Source

Patch G29 for linear leveling, reachable with probe

Scott Lahteine 8 years ago
parent
commit
e242946ac3
3 changed files with 117 additions and 116 deletions
  1. 15
    14
      Marlin/Marlin_main.cpp
  2. 86
    86
      Marlin/qr_solve.cpp
  3. 16
    16
      Marlin/qr_solve.h

+ 15
- 14
Marlin/Marlin_main.cpp View File

@@ -3546,16 +3546,16 @@ inline void gcode_G28() {
3546 3546
          * so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
3547 3547
          */
3548 3548
 
3549
-        int abl2 = abl_grid_points_x * abl_grid_points_y;
3549
+        int abl2 = abl_grid_points_x * abl_grid_points_y,
3550
+            indexIntoAB[abl_grid_points_x][abl_grid_points_y],
3551
+            probePointCounter = -1;
3550 3552
 
3551
-        double eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
3552
-               eqnBVector[abl2],     // "B" vector of Z points
3553
-               mean = 0.0;
3554
-        int indexIntoAB[abl_grid_points_x][abl_grid_points_y];
3553
+        float eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
3554
+              eqnBVector[abl2],     // "B" vector of Z points
3555
+              mean = 0.0;
3555 3556
 
3556 3557
       #endif // AUTO_BED_LEVELING_LINEAR_GRID
3557 3558
 
3558
-      int probePointCounter = 0;
3559 3559
       bool zig = abl_grid_points_y & 1; //always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
3560 3560
 
3561 3561
       for (uint8_t yCount = 0; yCount < abl_grid_points_y; yCount++) {
@@ -3581,10 +3581,14 @@ inline void gcode_G28() {
3581 3581
           float xBase = left_probe_bed_position + xGridSpacing * xCount;
3582 3582
           xProbe = floor(xBase + (xBase < 0 ? 0 : 0.5));
3583 3583
 
3584
-          #if ENABLED(DELTA)
3585
-            // Avoid probing outside the round or hexagonal area of a delta printer
3586
-            float pos[XYZ] = { xProbe + X_PROBE_OFFSET_FROM_EXTRUDER, yProbe + Y_PROBE_OFFSET_FROM_EXTRUDER, 0 };
3587
-            if (!position_is_reachable(pos)) continue;
3584
+          #if ENABLED(AUTO_BED_LEVELING_LINEAR_GRID)
3585
+            indexIntoAB[xCount][yCount] = ++probePointCounter;
3586
+          #endif
3587
+
3588
+          #if IS_KINEMATIC
3589
+            // Avoid probing outside the round or hexagonal area
3590
+            float pos[XYZ] = { xProbe, yProbe, 0 };
3591
+            if (!position_is_reachable(pos, true)) continue;
3588 3592
           #endif
3589 3593
 
3590 3594
           measured_z = probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
@@ -3596,7 +3600,6 @@ inline void gcode_G28() {
3596 3600
             eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
3597 3601
             eqnAMatrix[probePointCounter + 1 * abl2] = yProbe;
3598 3602
             eqnAMatrix[probePointCounter + 2 * abl2] = 1;
3599
-            indexIntoAB[xCount][yCount] = probePointCounter;
3600 3603
 
3601 3604
           #elif ENABLED(AUTO_BED_LEVELING_NONLINEAR)
3602 3605
 
@@ -3604,8 +3607,6 @@ inline void gcode_G28() {
3604 3607
 
3605 3608
           #endif
3606 3609
 
3607
-          probePointCounter++;
3608
-
3609 3610
           idle();
3610 3611
 
3611 3612
         } //xProbe
@@ -3664,7 +3665,7 @@ inline void gcode_G28() {
3664 3665
       // For LINEAR leveling calculate matrix, print reports, correct the position
3665 3666
 
3666 3667
       // solve lsq problem
3667
-      double plane_equation_coefficients[3];
3668
+      float plane_equation_coefficients[3];
3668 3669
       qr_solve(plane_equation_coefficients, abl2, 3, eqnAMatrix, eqnBVector);
3669 3670
 
3670 3671
       mean /= abl2;

+ 86
- 86
Marlin/qr_solve.cpp View File

@@ -59,7 +59,7 @@ int i4_min(int i1, int i2)
59 59
   return (i1 < i2) ? i1 : i2;
60 60
 }
61 61
 
62
-double r8_epsilon(void)
62
+float r8_epsilon(void)
63 63
 
64 64
 /******************************************************************************/
65 65
 /**
@@ -89,14 +89,14 @@ double r8_epsilon(void)
89 89
 
90 90
   Parameters:
91 91
 
92
-    Output, double R8_EPSILON, the R8 round-off unit.
92
+    Output, float R8_EPSILON, the R8 round-off unit.
93 93
 */
94 94
 {
95
-  const double value = 2.220446049250313E-016;
95
+  const float value = 2.220446049250313E-016;
96 96
   return value;
97 97
 }
98 98
 
99
-double r8_max(double x, double y)
99
+float r8_max(float x, float y)
100 100
 
101 101
 /******************************************************************************/
102 102
 /**
@@ -118,15 +118,15 @@ double r8_max(double x, double y)
118 118
 
119 119
   Parameters:
120 120
 
121
-    Input, double X, Y, the quantities to compare.
121
+    Input, float X, Y, the quantities to compare.
122 122
 
123
-    Output, double R8_MAX, the maximum of X and Y.
123
+    Output, float R8_MAX, the maximum of X and Y.
124 124
 */
125 125
 {
126 126
   return (y < x) ? x : y;
127 127
 }
128 128
 
129
-double r8_abs(double x)
129
+float r8_abs(float x)
130 130
 
131 131
 /******************************************************************************/
132 132
 /**
@@ -148,15 +148,15 @@ double r8_abs(double x)
148 148
 
149 149
   Parameters:
150 150
 
151
-    Input, double X, the quantity whose absolute value is desired.
151
+    Input, float X, the quantity whose absolute value is desired.
152 152
 
153
-    Output, double R8_ABS, the absolute value of X.
153
+    Output, float R8_ABS, the absolute value of X.
154 154
 */
155 155
 {
156 156
   return (x < 0.0) ? -x : x;
157 157
 }
158 158
 
159
-double r8_sign(double x)
159
+float r8_sign(float x)
160 160
 
161 161
 /******************************************************************************/
162 162
 /**
@@ -178,15 +178,15 @@ double r8_sign(double x)
178 178
 
179 179
   Parameters:
180 180
 
181
-    Input, double X, the number whose sign is desired.
181
+    Input, float X, the number whose sign is desired.
182 182
 
183
-    Output, double R8_SIGN, the sign of X.
183
+    Output, float R8_SIGN, the sign of X.
184 184
 */
185 185
 {
186 186
   return (x < 0.0) ? -1.0 : 1.0;
187 187
 }
188 188
 
189
-double r8mat_amax(int m, int n, double a[])
189
+float r8mat_amax(int m, int n, float a[])
190 190
 
191 191
 /******************************************************************************/
192 192
 /**
@@ -217,12 +217,12 @@ double r8mat_amax(int m, int n, double a[])
217 217
 
218 218
     Input, int N, the number of columns in A.
219 219
 
220
-    Input, double A[M*N], the M by N matrix.
220
+    Input, float A[M*N], the M by N matrix.
221 221
 
222
-    Output, double R8MAT_AMAX, the maximum absolute value entry of A.
222
+    Output, float R8MAT_AMAX, the maximum absolute value entry of A.
223 223
 */
224 224
 {
225
-  double value = r8_abs(a[0 + 0 * m]);
225
+  float value = r8_abs(a[0 + 0 * m]);
226 226
   for (int j = 0; j < n; j++) {
227 227
     for (int i = 0; i < m; i++) {
228 228
       NOLESS(value, r8_abs(a[i + j * m]));
@@ -231,7 +231,7 @@ double r8mat_amax(int m, int n, double a[])
231 231
   return value;
232 232
 }
233 233
 
234
-void r8mat_copy(double a2[], int m, int n, double a1[])
234
+void r8mat_copy(float a2[], int m, int n, float a1[])
235 235
 
236 236
 /******************************************************************************/
237 237
 /**
@@ -260,9 +260,9 @@ void r8mat_copy(double a2[], int m, int n, double a1[])
260 260
 
261 261
     Input, int M, N, the number of rows and columns.
262 262
 
263
-    Input, double A1[M*N], the matrix to be copied.
263
+    Input, float A1[M*N], the matrix to be copied.
264 264
 
265
-    Output, double R8MAT_COPY_NEW[M*N], the copy of A1.
265
+    Output, float R8MAT_COPY_NEW[M*N], the copy of A1.
266 266
 */
267 267
 {
268 268
   for (int j = 0; j < n; j++) {
@@ -273,7 +273,7 @@ void r8mat_copy(double a2[], int m, int n, double a1[])
273 273
 
274 274
 /******************************************************************************/
275 275
 
276
-void daxpy(int n, double da, double dx[], int incx, double dy[], int incy)
276
+void daxpy(int n, float da, float dx[], int incx, float dy[], int incy)
277 277
 
278 278
 /******************************************************************************/
279 279
 /**
@@ -313,13 +313,13 @@ void daxpy(int n, double da, double dx[], int incx, double dy[], int incy)
313 313
 
314 314
     Input, int N, the number of elements in DX and DY.
315 315
 
316
-    Input, double DA, the multiplier of DX.
316
+    Input, float DA, the multiplier of DX.
317 317
 
318
-    Input, double DX[*], the first vector.
318
+    Input, float DX[*], the first vector.
319 319
 
320 320
     Input, int INCX, the increment between successive entries of DX.
321 321
 
322
-    Input/output, double DY[*], the second vector.
322
+    Input/output, float DY[*], the second vector.
323 323
     On output, DY[*] has been replaced by DY[*] + DA * DX[*].
324 324
 
325 325
     Input, int INCY, the increment between successive entries of DY.
@@ -364,7 +364,7 @@ void daxpy(int n, double da, double dx[], int incx, double dy[], int incy)
364 364
 }
365 365
 /******************************************************************************/
366 366
 
367
-double ddot(int n, double dx[], int incx, double dy[], int incy)
367
+float ddot(int n, float dx[], int incx, float dy[], int incy)
368 368
 
369 369
 /******************************************************************************/
370 370
 /**
@@ -404,15 +404,15 @@ double ddot(int n, double dx[], int incx, double dy[], int incy)
404 404
 
405 405
     Input, int N, the number of entries in the vectors.
406 406
 
407
-    Input, double DX[*], the first vector.
407
+    Input, float DX[*], the first vector.
408 408
 
409 409
     Input, int INCX, the increment between successive entries in DX.
410 410
 
411
-    Input, double DY[*], the second vector.
411
+    Input, float DY[*], the second vector.
412 412
 
413 413
     Input, int INCY, the increment between successive entries in DY.
414 414
 
415
-    Output, double DDOT, the sum of the product of the corresponding
415
+    Output, float DDOT, the sum of the product of the corresponding
416 416
     entries of DX and DY.
417 417
 */
418 418
 {
@@ -420,7 +420,7 @@ double ddot(int n, double dx[], int incx, double dy[], int incy)
420 420
   if (n <= 0) return 0.0;
421 421
 
422 422
   int i, m;
423
-  double dtemp = 0.0;
423
+  float dtemp = 0.0;
424 424
 
425 425
   /**
426 426
     Code for unequal increments or equal increments
@@ -454,7 +454,7 @@ double ddot(int n, double dx[], int incx, double dy[], int incy)
454 454
 }
455 455
 /******************************************************************************/
456 456
 
457
-double dnrm2(int n, double x[], int incx)
457
+float dnrm2(int n, float x[], int incx)
458 458
 
459 459
 /******************************************************************************/
460 460
 /**
@@ -494,24 +494,24 @@ double dnrm2(int n, double x[], int incx)
494 494
 
495 495
     Input, int N, the number of entries in the vector.
496 496
 
497
-    Input, double X[*], the vector whose norm is to be computed.
497
+    Input, float X[*], the vector whose norm is to be computed.
498 498
 
499 499
     Input, int INCX, the increment between successive entries of X.
500 500
 
501
-    Output, double DNRM2, the Euclidean norm of X.
501
+    Output, float DNRM2, the Euclidean norm of X.
502 502
 */
503 503
 {
504
-  double norm;
504
+  float norm;
505 505
   if (n < 1 || incx < 1)
506 506
     norm = 0.0;
507 507
   else if (n == 1)
508 508
     norm = r8_abs(x[0]);
509 509
   else {
510
-    double scale = 0.0, ssq = 1.0;
510
+    float scale = 0.0, ssq = 1.0;
511 511
     int ix = 0;
512 512
     for (int i = 0; i < n; i++) {
513 513
       if (x[ix] != 0.0) {
514
-        double absxi = r8_abs(x[ix]);
514
+        float absxi = r8_abs(x[ix]);
515 515
         if (scale < absxi) {
516 516
           ssq = 1.0 + ssq * (scale / absxi) * (scale / absxi);
517 517
           scale = absxi;
@@ -527,8 +527,8 @@ double dnrm2(int n, double x[], int incx)
527 527
 }
528 528
 /******************************************************************************/
529 529
 
530
-void dqrank(double a[], int lda, int m, int n, double tol, int* kr,
531
-            int jpvt[], double qraux[])
530
+void dqrank(float a[], int lda, int m, int n, float tol, int* kr,
531
+            int jpvt[], float qraux[])
532 532
 
533 533
 /******************************************************************************/
534 534
 /**
@@ -572,7 +572,7 @@ void dqrank(double a[], int lda, int m, int n, double tol, int* kr,
572 572
 
573 573
   Parameters:
574 574
 
575
-    Input/output, double A[LDA*N].  On input, the matrix whose
575
+    Input/output, float A[LDA*N].  On input, the matrix whose
576 576
     decomposition is to be computed.  On output, the information from DQRDC.
577 577
     The triangular matrix R of the QR factorization is contained in the
578 578
     upper triangle and information needed to recover the orthogonal
@@ -585,7 +585,7 @@ void dqrank(double a[], int lda, int m, int n, double tol, int* kr,
585 585
 
586 586
     Input, int N, the number of columns of A.
587 587
 
588
-    Input, double TOL, a relative tolerance used to determine the
588
+    Input, float TOL, a relative tolerance used to determine the
589 589
     numerical rank.  The problem should be scaled so that all the elements
590 590
     of A have roughly the same absolute accuracy, EPS.  Then a reasonable
591 591
     value for TOL is roughly EPS divided by the magnitude of the largest
@@ -598,11 +598,11 @@ void dqrank(double a[], int lda, int m, int n, double tol, int* kr,
598 598
     independent to within the tolerance TOL and the remaining columns
599 599
     are linearly dependent.
600 600
 
601
-    Output, double QRAUX[N], will contain extra information defining
601
+    Output, float QRAUX[N], will contain extra information defining
602 602
     the QR factorization.
603 603
 */
604 604
 {
605
-  double work[n];
605
+  float work[n];
606 606
 
607 607
   for (int i = 0; i < n; i++)
608 608
     jpvt[i] = 0;
@@ -621,8 +621,8 @@ void dqrank(double a[], int lda, int m, int n, double tol, int* kr,
621 621
 }
622 622
 /******************************************************************************/
623 623
 
624
-void dqrdc(double a[], int lda, int n, int p, double qraux[], int jpvt[],
625
-           double work[], int job)
624
+void dqrdc(float a[], int lda, int n, int p, float qraux[], int jpvt[],
625
+           float work[], int job)
626 626
 
627 627
 /******************************************************************************/
628 628
 /**
@@ -660,7 +660,7 @@ void dqrdc(double a[], int lda, int n, int p, double qraux[], int jpvt[],
660 660
 
661 661
   Parameters:
662 662
 
663
-    Input/output, double A(LDA,P).  On input, the N by P matrix
663
+    Input/output, float A(LDA,P).  On input, the N by P matrix
664 664
     whose decomposition is to be computed.  On output, A contains in
665 665
     its upper triangle the upper triangular matrix R of the QR
666 666
     factorization.  Below its diagonal A contains information from
@@ -676,7 +676,7 @@ void dqrdc(double a[], int lda, int n, int p, double qraux[], int jpvt[],
676 676
 
677 677
     Input, int P, the number of columns of the matrix A.
678 678
 
679
-    Output, double QRAUX[P], contains further information required
679
+    Output, float QRAUX[P], contains further information required
680 680
     to recover the orthogonal part of the decomposition.
681 681
 
682 682
     Input/output, integer JPVT[P].  On input, JPVT contains integers that
@@ -695,7 +695,7 @@ void dqrdc(double a[], int lda, int n, int p, double qraux[], int jpvt[],
695 695
     original matrix that has been interchanged into the K-th column, if
696 696
     pivoting was requested.
697 697
 
698
-    Workspace, double WORK[P].  WORK is not referenced if JOB == 0.
698
+    Workspace, float WORK[P].  WORK is not referenced if JOB == 0.
699 699
 
700 700
     Input, int JOB, initiates column pivoting.
701 701
     0, no pivoting is done.
@@ -706,7 +706,7 @@ void dqrdc(double a[], int lda, int n, int p, double qraux[], int jpvt[],
706 706
   int j;
707 707
   int lup;
708 708
   int maxj;
709
-  double maxnrm, nrmxl, t, tt;
709
+  float maxnrm, nrmxl, t, tt;
710 710
 
711 711
   int pl = 1, pu = 0;
712 712
   /**
@@ -815,8 +815,8 @@ void dqrdc(double a[], int lda, int n, int p, double qraux[], int jpvt[],
815 815
 }
816 816
 /******************************************************************************/
817 817
 
818
-int dqrls(double a[], int lda, int m, int n, double tol, int* kr, double b[],
819
-          double x[], double rsd[], int jpvt[], double qraux[], int itask)
818
+int dqrls(float a[], int lda, int m, int n, float tol, int* kr, float b[],
819
+          float x[], float rsd[], int jpvt[], float qraux[], int itask)
820 820
 
821 821
 /******************************************************************************/
822 822
 /**
@@ -871,7 +871,7 @@ int dqrls(double a[], int lda, int m, int n, double tol, int* kr, double b[],
871 871
 
872 872
   Parameters:
873 873
 
874
-    Input/output, double A[LDA*N], an M by N matrix.
874
+    Input/output, float A[LDA*N], an M by N matrix.
875 875
     On input, the matrix whose decomposition is to be computed.
876 876
     In a least squares data fitting problem, A(I,J) is the
877 877
     value of the J-th basis (model) function at the I-th data point.
@@ -886,7 +886,7 @@ int dqrls(double a[], int lda, int m, int n, double tol, int* kr, double b[],
886 886
 
887 887
     Input, int N, the number of columns of A.
888 888
 
889
-    Input, double TOL, a relative tolerance used to determine the
889
+    Input, float TOL, a relative tolerance used to determine the
890 890
     numerical rank.  The problem should be scaled so that all the elements
891 891
     of A have roughly the same absolute accuracy EPS.  Then a reasonable
892 892
     value for TOL is roughly EPS divided by the magnitude of the largest
@@ -894,12 +894,12 @@ int dqrls(double a[], int lda, int m, int n, double tol, int* kr, double b[],
894 894
 
895 895
     Output, int *KR, the numerical rank.
896 896
 
897
-    Input, double B[M], the right hand side of the linear system.
897
+    Input, float B[M], the right hand side of the linear system.
898 898
 
899
-    Output, double X[N], a least squares solution to the linear
899
+    Output, float X[N], a least squares solution to the linear
900 900
     system.
901 901
 
902
-    Output, double RSD[M], the residual, B - A*X.  RSD may
902
+    Output, float RSD[M], the residual, B - A*X.  RSD may
903 903
     overwrite B.
904 904
 
905 905
     Workspace, int JPVT[N], required if ITASK = 1.
@@ -909,7 +909,7 @@ int dqrls(double a[], int lda, int m, int n, double tol, int* kr, double b[],
909 909
     of the condition number of the matrix of independent columns,
910 910
     and of R.  This estimate will be <= 1/TOL.
911 911
 
912
-    Workspace, double QRAUX[N], required if ITASK = 1.
912
+    Workspace, float QRAUX[N], required if ITASK = 1.
913 913
 
914 914
     Input, int ITASK.
915 915
     1, DQRLS factors the matrix A and solves the least squares problem.
@@ -962,8 +962,8 @@ int dqrls(double a[], int lda, int m, int n, double tol, int* kr, double b[],
962 962
 }
963 963
 /******************************************************************************/
964 964
 
965
-void dqrlss(double a[], int lda, int m, int n, int kr, double b[], double x[],
966
-            double rsd[], int jpvt[], double qraux[])
965
+void dqrlss(float a[], int lda, int m, int n, int kr, float b[], float x[],
966
+            float rsd[], int jpvt[], float qraux[])
967 967
 
968 968
 /******************************************************************************/
969 969
 /**
@@ -1004,7 +1004,7 @@ void dqrlss(double a[], int lda, int m, int n, int kr, double b[], double x[],
1004 1004
 
1005 1005
   Parameters:
1006 1006
 
1007
-    Input, double A[LDA*N], the QR factorization information
1007
+    Input, float A[LDA*N], the QR factorization information
1008 1008
     from DQRANK.  The triangular matrix R of the QR factorization is
1009 1009
     contained in the upper triangle and information needed to recover
1010 1010
     the orthogonal matrix Q is stored below the diagonal in A and in
@@ -1019,12 +1019,12 @@ void dqrlss(double a[], int lda, int m, int n, int kr, double b[], double x[],
1019 1019
 
1020 1020
     Input, int KR, the rank of the matrix, as estimated by DQRANK.
1021 1021
 
1022
-    Input, double B[M], the right hand side of the linear system.
1022
+    Input, float B[M], the right hand side of the linear system.
1023 1023
 
1024
-    Output, double X[N], a least squares solution to the
1024
+    Output, float X[N], a least squares solution to the
1025 1025
     linear system.
1026 1026
 
1027
-    Output, double RSD[M], the residual, B - A*X.  RSD may
1027
+    Output, float RSD[M], the residual, B - A*X.  RSD may
1028 1028
     overwrite B.
1029 1029
 
1030 1030
     Input, int JPVT[N], the pivot information from DQRANK.
@@ -1032,7 +1032,7 @@ void dqrlss(double a[], int lda, int m, int n, int kr, double b[], double x[],
1032 1032
     independent to within the tolerance TOL and the remaining columns
1033 1033
     are linearly dependent.
1034 1034
 
1035
-    Input, double QRAUX[N], auxiliary information from DQRANK
1035
+    Input, float QRAUX[N], auxiliary information from DQRANK
1036 1036
     defining the QR factorization.
1037 1037
 */
1038 1038
 {
@@ -1041,7 +1041,7 @@ void dqrlss(double a[], int lda, int m, int n, int kr, double b[], double x[],
1041 1041
   int j;
1042 1042
   int job;
1043 1043
   int k;
1044
-  double t;
1044
+  float t;
1045 1045
 
1046 1046
   if (kr != 0) {
1047 1047
     job = 110;
@@ -1071,8 +1071,8 @@ void dqrlss(double a[], int lda, int m, int n, int kr, double b[], double x[],
1071 1071
 }
1072 1072
 /******************************************************************************/
1073 1073
 
1074
-int dqrsl(double a[], int lda, int n, int k, double qraux[], double y[],
1075
-          double qy[], double qty[], double b[], double rsd[], double ab[], int job)
1074
+int dqrsl(float a[], int lda, int n, int k, float qraux[], float y[],
1075
+          float qy[], float qty[], float b[], float rsd[], float ab[], int job)
1076 1076
 
1077 1077
 /******************************************************************************/
1078 1078
 /**
@@ -1158,7 +1158,7 @@ int dqrsl(double a[], int lda, int n, int k, double qraux[], double y[],
1158 1158
 
1159 1159
   Parameters:
1160 1160
 
1161
-    Input, double A[LDA*P], contains the output of DQRDC.
1161
+    Input, float A[LDA*P], contains the output of DQRDC.
1162 1162
 
1163 1163
     Input, int LDA, the leading dimension of the array A.
1164 1164
 
@@ -1169,26 +1169,26 @@ int dqrsl(double a[], int lda, int n, int k, double qraux[], double y[],
1169 1169
     must not be greater than min(N,P), where P is the same as in the
1170 1170
     calling sequence to DQRDC.
1171 1171
 
1172
-    Input, double QRAUX[P], the auxiliary output from DQRDC.
1172
+    Input, float QRAUX[P], the auxiliary output from DQRDC.
1173 1173
 
1174
-    Input, double Y[N], a vector to be manipulated by DQRSL.
1174
+    Input, float Y[N], a vector to be manipulated by DQRSL.
1175 1175
 
1176
-    Output, double QY[N], contains Q * Y, if requested.
1176
+    Output, float QY[N], contains Q * Y, if requested.
1177 1177
 
1178
-    Output, double QTY[N], contains Q' * Y, if requested.
1178
+    Output, float QTY[N], contains Q' * Y, if requested.
1179 1179
 
1180
-    Output, double B[K], the solution of the least squares problem
1180
+    Output, float B[K], the solution of the least squares problem
1181 1181
       minimize norm2 ( Y - AK * B),
1182 1182
     if its computation has been requested.  Note that if pivoting was
1183 1183
     requested in DQRDC, the J-th component of B will be associated with
1184 1184
     column JPVT(J) of the original matrix A that was input into DQRDC.
1185 1185
 
1186
-    Output, double RSD[N], the least squares residual Y - AK * B,
1186
+    Output, float RSD[N], the least squares residual Y - AK * B,
1187 1187
     if its computation has been requested.  RSD is also the orthogonal
1188 1188
     projection of Y onto the orthogonal complement of the column space
1189 1189
     of AK.
1190 1190
 
1191
-    Output, double AB[N], the least squares approximation Ak * B,
1191
+    Output, float AB[N], the least squares approximation Ak * B,
1192 1192
     if its computation has been requested.  AB is also the orthogonal
1193 1193
     projection of Y onto the column space of A.
1194 1194
 
@@ -1220,8 +1220,8 @@ int dqrsl(double a[], int lda, int n, int k, double qraux[], double y[],
1220 1220
   int j;
1221 1221
   int jj;
1222 1222
   int ju;
1223
-  double t;
1224
-  double temp;
1223
+  float t;
1224
+  float temp;
1225 1225
   /**
1226 1226
     Set INFO flag.
1227 1227
   */
@@ -1366,7 +1366,7 @@ int dqrsl(double a[], int lda, int n, int k, double qraux[], double y[],
1366 1366
 
1367 1367
 /******************************************************************************/
1368 1368
 
1369
-void dscal(int n, double sa, double x[], int incx)
1369
+void dscal(int n, float sa, float x[], int incx)
1370 1370
 
1371 1371
 /******************************************************************************/
1372 1372
 /**
@@ -1402,9 +1402,9 @@ void dscal(int n, double sa, double x[], int incx)
1402 1402
 
1403 1403
     Input, int N, the number of entries in the vector.
1404 1404
 
1405
-    Input, double SA, the multiplier.
1405
+    Input, float SA, the multiplier.
1406 1406
 
1407
-    Input/output, double X[*], the vector to be scaled.
1407
+    Input/output, float X[*], the vector to be scaled.
1408 1408
 
1409 1409
     Input, int INCX, the increment between successive entries of X.
1410 1410
 */
@@ -1441,7 +1441,7 @@ void dscal(int n, double sa, double x[], int incx)
1441 1441
 /******************************************************************************/
1442 1442
 
1443 1443
 
1444
-void dswap(int n, double x[], int incx, double y[], int incy)
1444
+void dswap(int n, float x[], int incx, float y[], int incy)
1445 1445
 
1446 1446
 /******************************************************************************/
1447 1447
 /**
@@ -1477,11 +1477,11 @@ void dswap(int n, double x[], int incx, double y[], int incy)
1477 1477
 
1478 1478
     Input, int N, the number of entries in the vectors.
1479 1479
 
1480
-    Input/output, double X[*], one of the vectors to swap.
1480
+    Input/output, float X[*], one of the vectors to swap.
1481 1481
 
1482 1482
     Input, int INCX, the increment between successive entries of X.
1483 1483
 
1484
-    Input/output, double Y[*], one of the vectors to swap.
1484
+    Input/output, float Y[*], one of the vectors to swap.
1485 1485
 
1486 1486
     Input, int INCY, the increment between successive elements of Y.
1487 1487
 */
@@ -1489,7 +1489,7 @@ void dswap(int n, double x[], int incx, double y[], int incy)
1489 1489
   if (n <= 0) return;
1490 1490
 
1491 1491
   int i, ix, iy, m;
1492
-  double temp;
1492
+  float temp;
1493 1493
 
1494 1494
   if (incx == 1 && incy == 1) {
1495 1495
     m = n % 3;
@@ -1526,7 +1526,7 @@ void dswap(int n, double x[], int incx, double y[], int incy)
1526 1526
 
1527 1527
 /******************************************************************************/
1528 1528
 
1529
-void qr_solve(double x[], int m, int n, double a[], double b[])
1529
+void qr_solve(float x[], int m, int n, float a[], float b[])
1530 1530
 
1531 1531
 /******************************************************************************/
1532 1532
 /**
@@ -1569,14 +1569,14 @@ void qr_solve(double x[], int m, int n, double a[], double b[])
1569 1569
 
1570 1570
     Input, int N, the number of columns of A.
1571 1571
 
1572
-    Input, double A[M*N], the matrix.
1572
+    Input, float A[M*N], the matrix.
1573 1573
 
1574
-    Input, double B[M], the right hand side.
1574
+    Input, float B[M], the right hand side.
1575 1575
 
1576
-    Output, double QR_SOLVE[N], the least squares solution.
1576
+    Output, float QR_SOLVE[N], the least squares solution.
1577 1577
 */
1578 1578
 {
1579
-  double a_qr[n * m], qraux[n], r[m], tol;
1579
+  float a_qr[n * m], qraux[n], r[m], tol;
1580 1580
   int ind, itask, jpvt[n], kr, lda;
1581 1581
 
1582 1582
   r8mat_copy(a_qr, m, n, a);

+ 16
- 16
Marlin/qr_solve.h View File

@@ -24,21 +24,21 @@
24 24
 
25 25
 #if ENABLED(AUTO_BED_LEVELING_GRID)
26 26
 
27
-void daxpy(int n, double da, double dx[], int incx, double dy[], int incy);
28
-double ddot(int n, double dx[], int incx, double dy[], int incy);
29
-double dnrm2(int n, double x[], int incx);
30
-void dqrank(double a[], int lda, int m, int n, double tol, int* kr,
31
-            int jpvt[], double qraux[]);
32
-void dqrdc(double a[], int lda, int n, int p, double qraux[], int jpvt[],
33
-           double work[], int job);
34
-int dqrls(double a[], int lda, int m, int n, double tol, int* kr, double b[],
35
-          double x[], double rsd[], int jpvt[], double qraux[], int itask);
36
-void dqrlss(double a[], int lda, int m, int n, int kr, double b[], double x[],
37
-            double rsd[], int jpvt[], double qraux[]);
38
-int dqrsl(double a[], int lda, int n, int k, double qraux[], double y[],
39
-          double qy[], double qty[], double b[], double rsd[], double ab[], int job);
40
-void dscal(int n, double sa, double x[], int incx);
41
-void dswap(int n, double x[], int incx, double y[], int incy);
42
-void qr_solve(double x[], int m, int n, double a[], double b[]);
27
+void daxpy(int n, float da, float dx[], int incx, float dy[], int incy);
28
+float ddot(int n, float dx[], int incx, float dy[], int incy);
29
+float dnrm2(int n, float x[], int incx);
30
+void dqrank(float a[], int lda, int m, int n, float tol, int* kr,
31
+            int jpvt[], float qraux[]);
32
+void dqrdc(float a[], int lda, int n, int p, float qraux[], int jpvt[],
33
+           float work[], int job);
34
+int dqrls(float a[], int lda, int m, int n, float tol, int* kr, float b[],
35
+          float x[], float rsd[], int jpvt[], float qraux[], int itask);
36
+void dqrlss(float a[], int lda, int m, int n, int kr, float b[], float x[],
37
+            float rsd[], int jpvt[], float qraux[]);
38
+int dqrsl(float a[], int lda, int n, int k, float qraux[], float y[],
39
+          float qy[], float qty[], float b[], float rsd[], float ab[], int job);
40
+void dscal(int n, float sa, float x[], int incx);
41
+void dswap(int n, float x[], int incx, float y[], int incy);
42
+void qr_solve(float x[], int m, int n, float a[], float b[]);
43 43
 
44 44
 #endif

Loading…
Cancel
Save