When can an autonomous system be written using a Hamiltonian?

D

djbinder

Guest
djbinder Asks: When can an autonomous system be written using a Hamiltonian?
If I have an autonomous series of differential equations $$\tag{1} \frac{dx_i}{dt} ~=~ A_i(x_1,...,x_n)$$ with the condition that $$\tag{2} \sum_{i=1}^n\frac{\partial A_i}{\partial x_i}~=~0$$ in all regions of phase space, can this be written as a Hamiltonian system in terms of some generalized position and momentum coordinates?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.
 
/forums/whats-new/news-feed

Unreplied Posts

`imageView.image` causes unbounded memory growth

Peter Tao Asks: `imageView.image` causes unbounded memory growth

The following steps causes unbounded memory growth:​

  1. Create UIImages
  2. Load UIImage into reusable collection view cell
  3. Scroll

enter image description here

Code that repros the issue​


Code:
import UIKit

class Cell: UICollectionViewCell {
  static let ReuseIdentifier = "reuseID"
  var imageView: UIImageView

  override init(frame: CGRect) {
    imageView = UIImageView()
    super.init(frame: frame)
    addSubview(imageView)
  }
  
  required init?(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }
  
  override func layoutSubviews() {
    imageView.frame = bounds
    super.layoutSubviews()
  }
  
  func configureWith(image: UIImage) {
    imageView.image = image
    layoutSubviews()
  }
}

class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
  
  var images:[UIImage] = []
  var collectionView: UICollectionView
  
  required init?(coder: NSCoder) {
    let layout = UICollectionViewFlowLayout()
    layout.minimumLineSpacing = 0
    layout.minimumInteritemSpacing = 0
    
    collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout)
    collectionView.register(Cell.self, forCellWithReuseIdentifier: Cell.ReuseIdentifier)
    super.init(coder: coder)
  }
  
  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    
    view.addSubview(collectionView)
    collectionView.frame = view.frame
    collectionView.backgroundColor = .green
    collectionView.dataSource = self
    collectionView.delegate = self
    
    loadMoreImages()
    collectionView.reloadData()
  }
  
  func loadMoreImages() {
    for _ in 0...50 {
      images.append(cloneImage(image: UIImage(named: "bigImage")!))
    }
  }
  
  // MARK: - UICollectionViewDataSource
  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    print(images.count)
    return images.count
  }
  
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: Cell.ReuseIdentifier, for: indexPath) as! Cell
    cell.configureWith(image: images[indexPath.row])
    return cell
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
    return view.frame.size
  }
  
}

func cloneImage(image:UIImage) -> UIImage {
  let newCgIm = image.cgImage!.copy()!
  let newImage = UIImage(cgImage: newCgIm, scale: image.scale, orientation: image.imageOrientation)
  return newImage
}

Video demo:

Things that resolve the issue​

  • Make UIImages optional, and set UIImages to nil after they've been displayed
  • Comment out imageView.image = image

Any idea what UIImageView is doing under the hood that causes unbounded memory growth? Seems like it's allocating a bunch of memory in the UIImage object that never gets released.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Uncaught FirebaseError: Expected type 'Ta', but it was: a custom Object object

Josh Wilson Asks: Uncaught FirebaseError: Expected type 'Ta', but it was: a custom Object object
I'm trying to get a basic field input using the following in Javascript/React

Code:
export default (value, docRef, field, label) => {
  return (
    <div className="pr-4 w-full">
      <input
        className="px-4 py-2 border w-full"
        value={value}
        placeholder={label}
        onChange={(e) => {
          const fs = getFirestore(app);
          setDoc(docRef, { [field]: e.target.value }, { merge: true });
        }}
      ></input>
    </div>
  );
};

I am populating this field like so:

Code:
{doctors.map((d) => {
            const ref = doc(getFirestore(app), d.path);
            console.log(ref);
            return (
              <tr key={ref.id}>
                <td className="py-4">
                  {console.log(d.firstName)}
                  <FirestoreFieldInput
                    value={d.firstName}
                    field="firstName"
                    docRef={ref}
                    label="First Name"
                  ></FirestoreFieldInput>
                </td>
              </tr>
            );
          })}

But anytime I try to edit the input it throws the following error: Uncaught FirebaseError: Expected type 'Ta', but it was: a custom Object object

and I am unsure why.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Tunnel openvpn ports

Pouya Poorrahman Asks: Tunnel openvpn ports
I have two VPS with Linux Ubuntu 18.04 OS,

One in our country with limited internet = VPS_1

One in EU with full access internet = VPS_2

I want to create OpenVpn server on VPS_2 and Forward OpenVpn ports on VPS_1.

If this is impossible,is there any way to create OpenVpn server on VPS_2 and connect VPS_1 to VPS_2 and create another openvpn server on VPS_1 that VPS_1 can access to all internet, and client connect to VPS_1 with OpenVpn?

This is a tunneling for openvpn.

I mention that I want to use UDP Ports for openvpn and

Code:
ssh -L 0.0.0.0:1194:DES_IP:1194 user@PASS

didn't work!

In our country, they limit us but we can access VPS_1 and VPS_1 can access to VPS_2 and VPS_2 have internet.

Can you explain how can I do that?

Thank you

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Why is exponentiation not atomic?

Ali Haider Asks: Why is exponentiation not atomic?
In calculating the efficiency of algorithms, I have read that the exponentiation operation is not considered to be an atomic operation (like multiplication).

Is it because exponentiation is the same as the multiplication operation repeated several times over?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

NullPointerException in Constructor in Spring Boot

Deonisos69 Asks: NullPointerException in Constructor in Spring Boot
I'm getting a NullPointerException ,but I don't know why.

My Cinema.java File looks like this:

Code:
package cinema;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class Cinema {

@Getter
@Setter
public class Seat {
    private int row;
    private int column;
}
public Cinema(int total_rows, int total_columns) {
    this.total_rows=total_rows;
    this.total_columns=total_columns;
    this.available_seats = new Seat[total_rows*total_columns];
    for (int i = 0; i < total_rows; i++) {
        for (int j = 0; j < total_columns; j++) {
            available_seats[i + j].setRow(i);
            available_seats[i + j].setColumn(j);
        }
    }
}
private int total_rows;
private int total_columns;
private Seat[] available_seats;



}

I'm initializing the Cinema like this in my CinemaController.java:

Code:
Cinema cinema = new Cinema(9,9);

This is my Error:

Code:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[cinema.CinemaController]: Constructor threw exception; nested exception is 
java.lang.NullPointerException: Cannot invoke "cinema.Cinema$Seat.setRow(int)" because 
"this.available_seats[...]" is null

I could post the whole error, but I think that every information needed is in there. I don't know why there's available_seats would be null if it's defined in the constructor.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

Latest posts

Top