On 04/14/2017 04:21 AM, Peter Otten wrote:
Stephen P. Molnar wrote:

However, what I want to do is multiply each element ob D by each element
of s and sum all of the products.

If you *really* want this:

sum_of_all_products = s.sum() * D.sum()

example:

s = [a b c]

D = [[a1 a2]
      [a3 a4]]

a*a1 + a*a2 + a*a3 + a*a4 = a * D.sum()

d := D.sum()
a*d + b*d + c*d = s.sum() * d

Even if that's what you want you should heed Steven's advice.




_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Thanks for the replies to my message.

First of all, allow me to apologize for the imprecise nature of my request.

Then I want t assure everyone that I am not asking someone else to write a program for me, I am not a student with a homework problem.

Rather as I wrote in my email I am attempting to port a program from FORTRAN to Python.

The equation that I a want to evaluate (the one that I programmed in FORTRAN) is equation (7) in the attached scan of one of the pages of

Stephen P. Molnar and James W. King, Theory and Applications of the Integrated Molecular Transform and the Normalized Molecular Moment Structure Descriptors: QSAR and QSPR Paradigms, Int. J Quantum Chem., 85, 662 (2001).

What I have managed to do so far is:

import numpy as np
import numpy, pandas, scipy.spatial.distance as dist


start=1
finish=31
points=300
s = np.linspace(start,finish,points) #300 points between 1.0 and 31.0

name = input("Enter Molecule ID: ")
name = str(name)
name_in = name+'.dat'

df = pandas.read_table(name_in, skiprows=2, sep=" ", skipinitialspace=True)
mass_data = numpy.array(df["MASS"])
print('MASS = ',mass_data)
N =  numpy.ma.size(mass_data)
a = numpy.array(df[["X", "Y", "Z"]])
dist.squareform(dist.pdist(a, "euclidean"))
anrows, ancols = np.shape(a)
a_new = a.reshape(anrows, 1, ancols)
diff = a_new - a

D = (diff ** 2).sum(2)
D = np.sqrt(D)

df = pandas.read_table(name_in, skiprows=2, sep=" ", skipinitialspace=True)
mass_data = numpy.array(df["MASS"])
print('MASS = ',mass_data)
N =  numpy.ma.size(mass_data)
a = numpy.array(df[["X", "Y", "Z"]])
dist.squareform(dist.pdist(a, "euclidean"))
anrows, ancols = np.shape(a)
a_new = a.reshape(anrows, 1, ancols)
diff = a_new - a

D = (diff ** 2).sum(2)
D = np.sqrt(D)
print(D)

for i in range(numpy.ma.size(mass_data)):
    for j in range(0, N-1):
        for k in range(j+1,N):
            print(D[j,k])

np.savetxt('D(ij)',D,delimiter=' ')

for k in range(0, N-1):

    for k in range(k+1,N):
        A = (mass_data[j]*mass_data[k])

Now, the problem with which I am struggling is the evaluation of the s times the r_sub_i_sub_j term. This should result in 300 floating point numbers between 1.0 and 31.0.

I hope that I have eliminated the confusion at this point.

This is, of course, not the end point of my modeling, but what I feel is an important result in QSAR studies.

I will be very appreciative of help at this point.

Thanks in advance.

--
Stephen P. Molnar, Ph.D.                Life is a fuzzy set
www.molecular-modeling.net              Stochastic and multivariate
(614)312-7528 (c)
Skype: smolnar1
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to