Skip to content

Commit

Permalink
Update libqt normalize.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 f92005f commit c3e2a8e
Showing 1 changed file with 43 additions and 37 deletions.
80 changes: 43 additions & 37 deletions libqt/normalize.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 @@ -34,6 +35,7 @@
#include <cstdio>
#include <cmath>
#include "psi4/libciomr/libciomr.h"
#include "psi4/libqt/qt.h"

namespace psi {

Expand All @@ -54,41 +56,45 @@ namespace psi {
** \ingroup QT
*/

void normalize(double **A, int rows, int cols)
{
double normval;
int i, j;

/* divide each row by the square root of its norm */
for (i=0; i<rows; i++) {
dot_arr(A[i], A[i], cols, &normval);
normval = sqrt(normval);
for (j=0; j<cols; j++) A[i][j] /= normval;
}
void normalize(double **A, int rows, int cols) {
double normval;
int i, j;

/* divide each row by the square root of its norm */
for (i = 0; i < rows; i++) {
// dot_arr(A[i], A[i], cols, &normval);
normval = C_DDOT(cols, A[i], 1, A[i], 1);
normval = sqrt(normval);
for (j = 0; j < cols; j++) A[i][j] /= normval;
}
}

#ifdef STANDALONE
main()
{
std::string OutFileRMR ;
double **mat ;
void normalize(double **A, int rows, int cols) ;
main() {
std::string out_fname;
double **mat;
void normalize(double **A, int rows, int cols);

mat = init_matrix(3, 3) ;
mat[0][0] = 1.0 ; mat[0][1] = 0.0 ; mat[0][2] = 1.0 ;
mat[1][0] = 1.0 ; mat[1][1] = -1.0 ; mat[1][2] = 0.0 ;
mat[2][0] = 0.0 ; mat[2][1] = 0.0 ; mat[2][2] = 0.5 ;
mat = init_matrix(3, 3);
mat[0][0] = 1.0;
mat[0][1] = 0.0;
mat[0][2] = 1.0;
mat[1][0] = 1.0;
mat[1][1] = -1.0;
mat[1][2] = 0.0;
mat[2][0] = 0.0;
mat[2][1] = 0.0;
mat[2][2] = 0.5;

ffile(&outfile, "output.dat", 0) ;
outfile->Printf( "Matrix before normalization process\n") ;
print_mat(mat,3,3,outfile) ;
normalize(mat,3,3) ;
outfile->Printf( "\nMatrix after normalization process\n") ;
print_mat(mat,3,3,outfile) ;
ffile(&outfile, "output.dat", 0);
outfile->Printf("Matrix before normalization process\n");
print_mat(mat, 3, 3, outfile);
normalize(mat, 3, 3);
outfile->Printf("\nMatrix after normalization process\n");
print_mat(mat, 3, 3, outfile);

free_matrix(mat,3) ;
free_matrix(mat, 3);
}
#endif

}
} // namespace psi

0 comments on commit c3e2a8e

Please sign in to comment.