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
          * so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
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
       #endif // AUTO_BED_LEVELING_LINEAR_GRID
3557
       #endif // AUTO_BED_LEVELING_LINEAR_GRID
3557
 
3558
 
3558
-      int probePointCounter = 0;
3559
       bool zig = abl_grid_points_y & 1; //always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
3559
       bool zig = abl_grid_points_y & 1; //always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
3560
 
3560
 
3561
       for (uint8_t yCount = 0; yCount < abl_grid_points_y; yCount++) {
3561
       for (uint8_t yCount = 0; yCount < abl_grid_points_y; yCount++) {
3581
           float xBase = left_probe_bed_position + xGridSpacing * xCount;
3581
           float xBase = left_probe_bed_position + xGridSpacing * xCount;
3582
           xProbe = floor(xBase + (xBase < 0 ? 0 : 0.5));
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
           #endif
3592
           #endif
3589
 
3593
 
3590
           measured_z = probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
3594
           measured_z = probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
3596
             eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
3600
             eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
3597
             eqnAMatrix[probePointCounter + 1 * abl2] = yProbe;
3601
             eqnAMatrix[probePointCounter + 1 * abl2] = yProbe;
3598
             eqnAMatrix[probePointCounter + 2 * abl2] = 1;
3602
             eqnAMatrix[probePointCounter + 2 * abl2] = 1;
3599
-            indexIntoAB[xCount][yCount] = probePointCounter;
3600
 
3603
 
3601
           #elif ENABLED(AUTO_BED_LEVELING_NONLINEAR)
3604
           #elif ENABLED(AUTO_BED_LEVELING_NONLINEAR)
3602
 
3605
 
3604
 
3607
 
3605
           #endif
3608
           #endif
3606
 
3609
 
3607
-          probePointCounter++;
3608
-
3609
           idle();
3610
           idle();
3610
 
3611
 
3611
         } //xProbe
3612
         } //xProbe
3664
       // For LINEAR leveling calculate matrix, print reports, correct the position
3665
       // For LINEAR leveling calculate matrix, print reports, correct the position
3665
 
3666
 
3666
       // solve lsq problem
3667
       // solve lsq problem
3667
-      double plane_equation_coefficients[3];
3668
+      float plane_equation_coefficients[3];
3668
       qr_solve(plane_equation_coefficients, abl2, 3, eqnAMatrix, eqnBVector);
3669
       qr_solve(plane_equation_coefficients, abl2, 3, eqnAMatrix, eqnBVector);
3669
 
3670
 
3670
       mean /= abl2;
3671
       mean /= abl2;

+ 86
- 86
Marlin/qr_solve.cpp View File

59
   return (i1 < i2) ? i1 : i2;
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
 
89
 
90
   Parameters:
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
   return value;
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
 
118
 
119
   Parameters:
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
   return (y < x) ? x : y;
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
 
148
 
149
   Parameters:
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
   return (x < 0.0) ? -x : x;
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
 
178
 
179
   Parameters:
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
   return (x < 0.0) ? -1.0 : 1.0;
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
 
217
 
218
     Input, int N, the number of columns in A.
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
   for (int j = 0; j < n; j++) {
226
   for (int j = 0; j < n; j++) {
227
     for (int i = 0; i < m; i++) {
227
     for (int i = 0; i < m; i++) {
228
       NOLESS(value, r8_abs(a[i + j * m]));
228
       NOLESS(value, r8_abs(a[i + j * m]));
231
   return value;
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
 
260
 
261
     Input, int M, N, the number of rows and columns.
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
   for (int j = 0; j < n; j++) {
268
   for (int j = 0; j < n; j++) {
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
 
313
 
314
     Input, int N, the number of elements in DX and DY.
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
     Input, int INCX, the increment between successive entries of DX.
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
     On output, DY[*] has been replaced by DY[*] + DA * DX[*].
323
     On output, DY[*] has been replaced by DY[*] + DA * DX[*].
324
 
324
 
325
     Input, int INCY, the increment between successive entries of DY.
325
     Input, int INCY, the increment between successive entries of DY.
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
 
404
 
405
     Input, int N, the number of entries in the vectors.
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
     Input, int INCX, the increment between successive entries in DX.
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
     Input, int INCY, the increment between successive entries in DY.
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
     entries of DX and DY.
416
     entries of DX and DY.
417
 */
417
 */
418
 {
418
 {
420
   if (n <= 0) return 0.0;
420
   if (n <= 0) return 0.0;
421
 
421
 
422
   int i, m;
422
   int i, m;
423
-  double dtemp = 0.0;
423
+  float dtemp = 0.0;
424
 
424
 
425
   /**
425
   /**
426
     Code for unequal increments or equal increments
426
     Code for unequal increments or equal increments
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
 
494
 
495
     Input, int N, the number of entries in the vector.
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
     Input, int INCX, the increment between successive entries of X.
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
   if (n < 1 || incx < 1)
505
   if (n < 1 || incx < 1)
506
     norm = 0.0;
506
     norm = 0.0;
507
   else if (n == 1)
507
   else if (n == 1)
508
     norm = r8_abs(x[0]);
508
     norm = r8_abs(x[0]);
509
   else {
509
   else {
510
-    double scale = 0.0, ssq = 1.0;
510
+    float scale = 0.0, ssq = 1.0;
511
     int ix = 0;
511
     int ix = 0;
512
     for (int i = 0; i < n; i++) {
512
     for (int i = 0; i < n; i++) {
513
       if (x[ix] != 0.0) {
513
       if (x[ix] != 0.0) {
514
-        double absxi = r8_abs(x[ix]);
514
+        float absxi = r8_abs(x[ix]);
515
         if (scale < absxi) {
515
         if (scale < absxi) {
516
           ssq = 1.0 + ssq * (scale / absxi) * (scale / absxi);
516
           ssq = 1.0 + ssq * (scale / absxi) * (scale / absxi);
517
           scale = absxi;
517
           scale = absxi;
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
 
572
 
573
   Parameters:
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
     decomposition is to be computed.  On output, the information from DQRDC.
576
     decomposition is to be computed.  On output, the information from DQRDC.
577
     The triangular matrix R of the QR factorization is contained in the
577
     The triangular matrix R of the QR factorization is contained in the
578
     upper triangle and information needed to recover the orthogonal
578
     upper triangle and information needed to recover the orthogonal
585
 
585
 
586
     Input, int N, the number of columns of A.
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
     numerical rank.  The problem should be scaled so that all the elements
589
     numerical rank.  The problem should be scaled so that all the elements
590
     of A have roughly the same absolute accuracy, EPS.  Then a reasonable
590
     of A have roughly the same absolute accuracy, EPS.  Then a reasonable
591
     value for TOL is roughly EPS divided by the magnitude of the largest
591
     value for TOL is roughly EPS divided by the magnitude of the largest
598
     independent to within the tolerance TOL and the remaining columns
598
     independent to within the tolerance TOL and the remaining columns
599
     are linearly dependent.
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
     the QR factorization.
602
     the QR factorization.
603
 */
603
 */
604
 {
604
 {
605
-  double work[n];
605
+  float work[n];
606
 
606
 
607
   for (int i = 0; i < n; i++)
607
   for (int i = 0; i < n; i++)
608
     jpvt[i] = 0;
608
     jpvt[i] = 0;
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
 
660
 
661
   Parameters:
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
     whose decomposition is to be computed.  On output, A contains in
664
     whose decomposition is to be computed.  On output, A contains in
665
     its upper triangle the upper triangular matrix R of the QR
665
     its upper triangle the upper triangular matrix R of the QR
666
     factorization.  Below its diagonal A contains information from
666
     factorization.  Below its diagonal A contains information from
676
 
676
 
677
     Input, int P, the number of columns of the matrix A.
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
     to recover the orthogonal part of the decomposition.
680
     to recover the orthogonal part of the decomposition.
681
 
681
 
682
     Input/output, integer JPVT[P].  On input, JPVT contains integers that
682
     Input/output, integer JPVT[P].  On input, JPVT contains integers that
695
     original matrix that has been interchanged into the K-th column, if
695
     original matrix that has been interchanged into the K-th column, if
696
     pivoting was requested.
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
     Input, int JOB, initiates column pivoting.
700
     Input, int JOB, initiates column pivoting.
701
     0, no pivoting is done.
701
     0, no pivoting is done.
706
   int j;
706
   int j;
707
   int lup;
707
   int lup;
708
   int maxj;
708
   int maxj;
709
-  double maxnrm, nrmxl, t, tt;
709
+  float maxnrm, nrmxl, t, tt;
710
 
710
 
711
   int pl = 1, pu = 0;
711
   int pl = 1, pu = 0;
712
   /**
712
   /**
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
 
871
 
872
   Parameters:
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
     On input, the matrix whose decomposition is to be computed.
875
     On input, the matrix whose decomposition is to be computed.
876
     In a least squares data fitting problem, A(I,J) is the
876
     In a least squares data fitting problem, A(I,J) is the
877
     value of the J-th basis (model) function at the I-th data point.
877
     value of the J-th basis (model) function at the I-th data point.
886
 
886
 
887
     Input, int N, the number of columns of A.
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
     numerical rank.  The problem should be scaled so that all the elements
890
     numerical rank.  The problem should be scaled so that all the elements
891
     of A have roughly the same absolute accuracy EPS.  Then a reasonable
891
     of A have roughly the same absolute accuracy EPS.  Then a reasonable
892
     value for TOL is roughly EPS divided by the magnitude of the largest
892
     value for TOL is roughly EPS divided by the magnitude of the largest
894
 
894
 
895
     Output, int *KR, the numerical rank.
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
     system.
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
     overwrite B.
903
     overwrite B.
904
 
904
 
905
     Workspace, int JPVT[N], required if ITASK = 1.
905
     Workspace, int JPVT[N], required if ITASK = 1.
909
     of the condition number of the matrix of independent columns,
909
     of the condition number of the matrix of independent columns,
910
     and of R.  This estimate will be <= 1/TOL.
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
     Input, int ITASK.
914
     Input, int ITASK.
915
     1, DQRLS factors the matrix A and solves the least squares problem.
915
     1, DQRLS factors the matrix A and solves the least squares problem.
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
 
1004
 
1005
   Parameters:
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
     from DQRANK.  The triangular matrix R of the QR factorization is
1008
     from DQRANK.  The triangular matrix R of the QR factorization is
1009
     contained in the upper triangle and information needed to recover
1009
     contained in the upper triangle and information needed to recover
1010
     the orthogonal matrix Q is stored below the diagonal in A and in
1010
     the orthogonal matrix Q is stored below the diagonal in A and in
1019
 
1019
 
1020
     Input, int KR, the rank of the matrix, as estimated by DQRANK.
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
     linear system.
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
     overwrite B.
1028
     overwrite B.
1029
 
1029
 
1030
     Input, int JPVT[N], the pivot information from DQRANK.
1030
     Input, int JPVT[N], the pivot information from DQRANK.
1032
     independent to within the tolerance TOL and the remaining columns
1032
     independent to within the tolerance TOL and the remaining columns
1033
     are linearly dependent.
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
     defining the QR factorization.
1036
     defining the QR factorization.
1037
 */
1037
 */
1038
 {
1038
 {
1041
   int j;
1041
   int j;
1042
   int job;
1042
   int job;
1043
   int k;
1043
   int k;
1044
-  double t;
1044
+  float t;
1045
 
1045
 
1046
   if (kr != 0) {
1046
   if (kr != 0) {
1047
     job = 110;
1047
     job = 110;
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
 
1158
 
1159
   Parameters:
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
     Input, int LDA, the leading dimension of the array A.
1163
     Input, int LDA, the leading dimension of the array A.
1164
 
1164
 
1169
     must not be greater than min(N,P), where P is the same as in the
1169
     must not be greater than min(N,P), where P is the same as in the
1170
     calling sequence to DQRDC.
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
       minimize norm2 ( Y - AK * B),
1181
       minimize norm2 ( Y - AK * B),
1182
     if its computation has been requested.  Note that if pivoting was
1182
     if its computation has been requested.  Note that if pivoting was
1183
     requested in DQRDC, the J-th component of B will be associated with
1183
     requested in DQRDC, the J-th component of B will be associated with
1184
     column JPVT(J) of the original matrix A that was input into DQRDC.
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
     if its computation has been requested.  RSD is also the orthogonal
1187
     if its computation has been requested.  RSD is also the orthogonal
1188
     projection of Y onto the orthogonal complement of the column space
1188
     projection of Y onto the orthogonal complement of the column space
1189
     of AK.
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
     if its computation has been requested.  AB is also the orthogonal
1192
     if its computation has been requested.  AB is also the orthogonal
1193
     projection of Y onto the column space of A.
1193
     projection of Y onto the column space of A.
1194
 
1194
 
1220
   int j;
1220
   int j;
1221
   int jj;
1221
   int jj;
1222
   int ju;
1222
   int ju;
1223
-  double t;
1224
-  double temp;
1223
+  float t;
1224
+  float temp;
1225
   /**
1225
   /**
1226
     Set INFO flag.
1226
     Set INFO flag.
1227
   */
1227
   */
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
 
1402
 
1403
     Input, int N, the number of entries in the vector.
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
     Input, int INCX, the increment between successive entries of X.
1409
     Input, int INCX, the increment between successive entries of X.
1410
 */
1410
 */
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
 
1477
 
1478
     Input, int N, the number of entries in the vectors.
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
     Input, int INCX, the increment between successive entries of X.
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
     Input, int INCY, the increment between successive elements of Y.
1486
     Input, int INCY, the increment between successive elements of Y.
1487
 */
1487
 */
1489
   if (n <= 0) return;
1489
   if (n <= 0) return;
1490
 
1490
 
1491
   int i, ix, iy, m;
1491
   int i, ix, iy, m;
1492
-  double temp;
1492
+  float temp;
1493
 
1493
 
1494
   if (incx == 1 && incy == 1) {
1494
   if (incx == 1 && incy == 1) {
1495
     m = n % 3;
1495
     m = n % 3;
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
 
1569
 
1570
     Input, int N, the number of columns of A.
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
   int ind, itask, jpvt[n], kr, lda;
1580
   int ind, itask, jpvt[n], kr, lda;
1581
 
1581
 
1582
   r8mat_copy(a_qr, m, n, a);
1582
   r8mat_copy(a_qr, m, n, a);

+ 16
- 16
Marlin/qr_solve.h View File

24
 
24
 
25
 #if ENABLED(AUTO_BED_LEVELING_GRID)
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
 #endif
44
 #endif

Loading…
Cancel
Save