Skip to content

Commit

Permalink
Update libqt schmidt_add.cc to its final version
Browse files Browse the repository at this point in the history
Removed by psi4/psi4#2927
  • Loading branch information
TiborGY committed Apr 22, 2023
1 parent c7e5360 commit 01461d3
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions libqt/schmidt_add.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@
*
* Psi4: an open-source quantum chemistry software package
*
* Copyright (c) 2007-2016 The Psi4 Developers.
* Copyright (c) 2007-2023 The Psi4 Developers.
*
* The copyrights for code used from other parties are included in
* the corresponding files.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This file is part of Psi4.
*
* This program is distributed in the hope that it will be useful,
* Psi4 is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* Psi4 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* You should have received a copy of the GNU Lesser General Public License along
* with Psi4; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @END LICENSE
Expand All @@ -33,7 +34,10 @@

#include <cstdio>
#include <cmath>

#include "psi4/pragma.h"
#include "psi4/libciomr/libciomr.h"
#include "psi4/libqt/qt.h"

namespace psi {

Expand All @@ -57,26 +61,26 @@ namespace psi {
** Returns: 1 if a vector is added to A, 0 otherwise
** \ingroup QT
*/
int schmidt_add(double **A, int rows, int cols, double *v)
{
double dotval, normval ;
int i, I ;
PSI_API int schmidt_add(double **A, int rows, int cols, double *v) {
double dotval, normval;
int i, I;

for (i=0; i<rows; i++) {
dot_arr(A[i], v, cols, &dotval) ;
for (I=0; I<cols; I++) v[I] -= dotval * A[i][I] ;
}
for (i = 0; i < rows; i++) {
// dot_arr(A[i], v, cols, &dotval) ;
dotval = C_DDOT(cols, A[i], 1, v, 1);
for (I = 0; I < cols; I++) v[I] -= dotval * A[i][I];
}

dot_arr(v, v, cols, &normval) ;
normval = sqrt(normval) ;
// dot_arr(v, v, cols, &normval) ;
normval = C_DDOT(cols, v, 1, v, 1);
normval = sqrt(normval);

if (normval < NORM_TOL)
return(0) ;
else {
if (A[rows] == NULL) A[rows] = init_array(cols) ;
for (I=0; I<cols; I++) A[rows][I] = v[I] / normval ;
return(1) ;
}
if (normval < NORM_TOL)
return (0);
else {
if (A[rows] == nullptr) A[rows] = init_array(cols);
for (I = 0; I < cols; I++) A[rows][I] = v[I] / normval;
return (1);
}
}

}

0 comments on commit 01461d3

Please sign in to comment.