How to test a Spring batch application with @SpringBatchTest?

Question: I have a Sping batch application that has 3 steps like all batch jobs -> read from a DB2 database, process the data and write it to a csv file. I have followed the spring batch test documentation and created the basic structure. However, I have a lot of open questions.

Do I have to create a new datasource or can I use the data source config that I already have in the application to connect to the DB2 database?
If I can reuse the old datasource and its configuration, will it be automatically done?
The step uses beans that are created by executing .sql files. How can I immitate this process while testing a step?
I dont want to use any embedded database- is it possible to keep the same configuration and test the application?
I have to reach the maximum possible test covergae like 80%. What will be a better sapproach like testing individual steps or the whole end to end test to reach a good test coverage?
I have Flow in the application that uses different step. If I test the Flow will the step also tested?

I have created a basic structure for the test -
@EnableAutoConfiguration
@EnableBatchProcessing
@SpringJUnitConfig(xxxConfiguration.class)
@SpringBatchTest
public class BatchTest {

    @Autowired
    private JobLauncherTestUtils jobLauncherTestUtils;

    @Autowired
    private JobRepositoryTestUtils jobRepositoryTestUtils;

    @BeforeEach
    public void clearJobExecutions() {
        this.jobRepositoryTestUtils.removeJobExecutions();
    }

    @Test
    public void testMyJob() throws Exception {
        // given
        JobParameters jobParameters = this.jobLauncherTestUtils.getUniqueJobParameters();

        // when
        JobExecution jobExecution = this.jobLauncherTestUtils.launchJob(jobParameters);

        // then
        //Assertions.assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus());
    }

}

The errors that I have received looks like -
9:55:12.081 [main] DEBUG org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator - JDBC version : 4.1
19:55:12.239 [main] WARN  org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator - HHH000342: Could not obtain connection to query metadata
org.hibernate.HibernateException: Unable to determine Dialect to use [name=DB2, majorVersion=12]; user must register resolver or explicitly set 'hibernate.dialect'
    at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:109) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:97) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:175) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:173) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1460) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1494) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.25.jar:5.3.25]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.25.jar:5.3.25]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.25.jar:5.3.25]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.25.jar:5.3.25]

19:55:12.278 [main] DEBUG org.hibernate.service.spi.ServiceBinding - Overriding existing service binding [org.hibernate.engine.jdbc.connections.spi.ConnectionProvider]
19:55:12.279 [main] ERROR org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Failed to initialize JPA EntityManagerFactory: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
19:55:12.281 [main] WARN  org.springframework.context.support.GenericApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
19:55:12.289 [main] ERROR org.springframework.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@27a0a5a2] to prepare test instance [BatchTest@6b5f8707]
java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:98) ~[spring-test-5.3.25.jar:5.3.25]
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124) ~[spring-test-5.3.25.jar:5.3.25]
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118) ~[spring-test-5.3.25.jar:5.3.25]
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83) ~[spring-test-5.3.25.jar:5.3.25]
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248) ~[spring-test-5.3.25.jar:5.3.25]
    at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:138) ~[spring-test-5.3.25.jar:5.3.25]
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$8(ClassBasedTestDescriptor.java:363) ~[junit-jupiter-engine-5.8.1.jar:5.8.1]
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:368) ~[junit-jupiter-engine-5.8.1.jar:5.8.1]
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$9(ClassBasedTestDescriptor.java:363) ~[junit-jupiter-engine-5.8.1.jar:5.8.1]
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[?:?]
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) ~[?:?]
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) ~[?:?]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[?:?]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?]
    at java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312) ~[?:?]
    at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) ~[?:?]
    at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734) ~[?:?]
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) ~[?:?]
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:362) ~[junit-jupiter-engine-5.8.1.jar:5.8.1]
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$6(ClassBasedTestDescriptor.java:283) ~[junit-jupiter-engine-5.8.1.jar:5.8.1]
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:282) ~[junit-jupiter-engine-5.8.1.jar:5.8.1]
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:272) ~[junit-jupiter-engine-5.8.1.jar:5.8.1]
    at java.util.Optional.orElseGet(Optional.java:369) ~[?:?]
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:271) ~[junit-jupiter-engine-5.8.1.jar:5.8.1]
    at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31) ~[junit-jupiter-engine-5.8.1.jar:5.8.1]
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:102) ~[junit-jupiter-engine-5.8.1.jar:5.8.1]
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:101) ~[junit-jupiter-engine-5.8.1.jar:5.8.1]
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:66) ~[junit-jupiter-engine-5.8.1.jar:5.8.1]
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at java.util.ArrayList.forEach(ArrayList.java:1541) ~[?:?]
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at java.util.ArrayList.forEach(ArrayList.java:1541) ~[?:?]
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) ~[junit-platform-engine-1.8.2.jar:1.8.2]
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107) ~[junit-platform-launcher-1.8.2.jar:1.8.2]
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) ~[junit-platform-launcher-1.8.2.jar:1.8.2]
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) ~[junit-platform-launcher-1.8.2.jar:1.8.2]
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) ~[junit-platform-launcher-1.8.2.jar:1.8.2]
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) ~[junit-platform-launcher-1.8.2.jar:1.8.2]
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) ~[junit-platform-launcher-1.8.2.jar:1.8.2]
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) ~[junit-platform-launcher-1.8.2.jar:1.8.2]
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) ~[junit-platform-launcher-1.8.2.jar:1.8.2]
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) ~[junit-platform-launcher-1.8.2.jar:1.8.2]
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57) ~[junit5-rt.jar:?]
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) ~[junit-rt.jar:?]
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) ~[idea_rt.jar:?]
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) ~[junit-rt.jar:?]
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232) ~[junit-rt.jar:?]
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55) ~[junit-rt.jar:?]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.25.jar:5.3.25]

Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:275) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:175) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:173) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1460) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1494) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.25.jar:5.3.25]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.25.jar:5.3.25]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.25.jar:5.3.25]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.25.jar:5.3.25]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.25.jar:5.3.25]

I see all databse connection related errors. How should I proceed?
Answer: org.hibernate.service.spi.ServiceException error probably occurred because hibernate cannot find a data source bean.
You are using @SpringJUnitConfig annotation. It defines context configuration. You probably don't have a data source bean in your xxxConfiguration.class.
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/test/context/junit/jupiter/SpringJUnitConfig.html

Do I have to create a new datasource or can I use the data source config that I already have in the application to connect to the DB2 database?

You do not have to create new data source for test. Existing data source can be used.

If I can reuse the old datasource and its configuration, will it be automatically done?

No. You need to scan for dasource bean. If you are using Spring Boot, one way is to use @SpringBootTest annotation. You can also create data source bean in your xxxConfiguration.class

The step uses beans that are created by executing .sql files. How
can I immitate this process while testing a step?

You can place .sql files where the bean is looking for them. Depending on your code, you might be able to read the sql file directly or mock the bean.

I dont want to use any embedded database- is it possible to keep the same configuration and test the application?

Yes

I have to reach the maximum possible test covergae like 80%. What will be a better sapproach like testing individual steps or the whole end to end test to reach a good test coverage?

Chasing test coverage is bad idea. Your decision should be based on what is
most effective. I would do end to end test for all batch job. If a specific step is complex, you can test it separately. Separate step test is not required for simple step.

I have Flow in the application that uses different step. If I test the Flow will the step also tested?

Yes


Rails 3.2 how to make scoped resources

Question: I am using Rails 3.2 and am attempting to make a scoped nested resource (not sure if this is the right terminology).  I have several groups and I want each group to have its own set of pages, like so:
/groups/1/pages/1
/groups/1/pages/2
/groups/1/pages/3
/groups/2/pages/1
/groups/2/pages/2
/groups/3/pages/1
/groups/3/pages/2
/groups/4/pages/1
etc.

First I created a groups controller and a pages controller and nested them like
resources :groups do
  resources :pages
end

The problem I was having is that I could see group 1's pages from groups 2, 3, and 4 by changing the :group_id in the URL.  Also, the page ids were unique across all groups, not just limited to a single group.
Next I tried making a nested controller by doing rails g controller groups/pages index show new create edit update destroy but I was also unable to get this to work.  I do not know enough Rails terminology to figure out what to Google.
Answer: What I think you are trying to accomplish is associations.  And instead of generating controllers, you should probably generate scaffolds (which includes a model, controller, and default views).  At the very least, you will need group and page models.
Then add has_many :pages in your group model.  And add belongs_to :group in your page model.  Then you need to add a group_id column to your page model/database.
However, if I'm wrong and all you are trying to do is paginate groups, then use the will_paginate gem.
I would also suggest you go through Mike Hartl's tutorial.  It will give you a great background and you will learn rails terminology and basic techniques.

Rails 3.2 how to make scoped resources


How to see Hibernate into files categories on Netbeans IDE

Question: I'm currently trying to use Hibernate in a java project on Netbeans IDE.
Unfortunatly i'm not able to see "Hibernate" into files category while creating one..
https://i.stack.imgur.com/Y8HNA.jpg
Please help i'm getting crazy..
Answer: If you just download and run NetBeans 10.0 it isn't just the creation of Hibernate files that is unavailable. There is no Java EE functionality, nor the ability to create web applications. You don't mention which version of NetBeans you are using, but assuming it's the latest version (10.0), you just need to install some plug-ins:

Select Tools > Plugins > Settings and you should see an entry named NetBeans 8.2 Plugin Portal in the list of Update Centers on the left of the window:
Check that entry, select Every Startup from the Check Interval drop list, click Close and restart NetBeans.

After the restart select Tools > Plugins > Available Plugins. Select all of the entries in the list with a Category of HTML5, Java SE, Java Web and EE and Payara and click Install to install those plugins:

After restarting NetBeans, verify that the plugins have been properly installed. Use the project wizard to create a web application: File> New Project > Java Web > Web Application.
During the creation of the web project you should be invited to use the Hibernate framework:

Once the project has been created, select File > New File... to add a file to the project. In the New File window enter Hibernate in the Filter field and NetBeans should list the different File Types for Hibernate:

Notes

You don't need to install all of those plugin options if you are only using Hibernate, but they are reasonable defaults for general web development with NetBeans. Feel free not to check any of the proposed options that you definitely don't want/need.
While restarting NetBeans after installing the plugins I got the Warning screen shown below. I just clicked Disable Modules and Continue button.
Comment: @Tanzeel [1] If you have a problem then please post a new question. That way your issue is visible to the entire community. Be sure to link to this question, making it clear that it did not solve your problem to avoid the risk of yours being closed as a duplicate. [2] Chat on SO is not intended for the resolution of user problems for which there is no question. [3] Without knowing your exact problem, a potential solution is to try using a more recent version of NetBeans than 10.0. You don't have to unistall your existing installation of NetBeans to do that. Is that feasible?
Comment: Can we please continue in chat room. I seriously need help. I did exactly what you said. But there's no 'Hibernate' option for me.


How to interpret Mann-Whitney's statistical significance if median is equal?

Question: Testing the difference between the observations of two groups by using Mann-Whitney Test has given the following output (from minitab):
                N  Median
positives  137  1.0000
negatives  892  1.0000
Point estimate for η1 - η2 is 0.0000
99.0 Percent CI for η1 - η2 is (0.0001,-0.0001)
W = 56899.5
Test of η1 = η2 vs η1 ≠ η2 is significant at 0.0000
The test is significant at 0.0000 (adjusted for ties)

When I was testing other pairs of groups, I concluded that a group tends to have larger values than another group based on their medians, if the test shows a statistically significant difference. However, the example above shows that I may not be interpreting the results correctly.
Here is some additional descriptive statistics for the example above:
Variable   |  Mean | StDev  | Minimum | Q1 |Median| Q3 | Maximum
positives  |  4.13 | 13.17  |  1.00   |1.00| 1.00 |1.00| 116.00
negatives  | 6.851 | 20.503 |  0.000  |1.00| 1.00 |5.00| 434.000

What have I done wrong?
How can I figure out the direction of the difference? Can I conclude that the negatives tends to have larger values based on their larger Q3, for example?
Answer: The Mann-Whitney is not a test of medians. At best, the Mann-Whitney test can only be claimed to a be a test of differences in mean-rank between two populations' pooled ranking.
You can easily calculate medians empirically and perform a basic Wald test if you need a test of medians.
The Mann-Whitney test happens to be a reasonably powerful test of medians only when the underlying distributions are symmetric, an assumption that is clearly violated in these data. However, if a distribution is symmetric, the median also happens to be the mean (when variance is finite). This means the Mann-Whitney and the t-test are testing the same hypothesis in symmetric distributions.
Comment: (+1) ... "This means the Mann-Whitney and the t-test are testing the same hypothesis in symmetric distributions." ... for which the mean exists. If you had data from Cauchy random variables (say), then you couldn't really say you were testing for equality of medians.
Comment: @PatternRecognition I see. Then it's simply a matter of stating a clear hypothesis. The mean is a *very* natural measure to compare between two populations, it's almost expected by anyone in science or business. In any case where Mann Whitney is used, I almost always ask myself why they did not use a t-test: the t-test has measures of direction (the mean difference) as well as significance (p-value). Both can be presented very nicely with a 95% confidence interval.
Comment: @PatternRecognition with a sample size of over 1,000 you can be assured that there are no assumptions of normality necessary for the t-test. Basically, due to the central limit theorem, the sampling distribution of the test statistic will undoubtedly tend very closely toward a normal distribution anyway.
Comment: Thanks. I do not particularly care about the medians, all what I care about is (1) the significance and (2) the direction of the difference. How can I tell the difference direction?
Comment: @patternrecognition use a ttest
Comment: excuse my ignorance, could you please give me more details?
Comment: Thanks. I did not want to know how to fit a t-test. I however wanted to know more about how the test itself can meet my needs. Any way, I will try to figure this out.
Comment: Thanks. My data is not normally distributed and, so, can I still use the t-test? Please excuse my ignorance, I have a very basic understanding of statistics.
Comment: Which test to use instead of Mann-Whitney test when the underlying distributions are not symmetric?
Comment: @vasili111 It will depend on a number of factors. If you have a large sample size like 1000 mentioned previously, t-testing is likely to be fine. Do you have a particular situation in mind? And what do you want to test?
Comment: @Dave I may need to test 2 independent samples that have non-parametric continues data and I want to be prepared for it. I do not have details other than sample size is ~40 and it is most likely non-parametric data where I will need to compare 2 independent samples with continues data. I know that for non-parametric dependent samples Wilcox sign rank test is good if there is a symmetry if not it is advised to use sing test. What about two independent continues non-parametric data that has no symmetry? Which test is advised in that case?
Comment: @vasili111 What is non-parametric data?
Comment: @Dave not normally distributed.
Comment: @vasili111 Consider how your data are distributed, search through previous Cross Validated questions to see if your question has been addressed, and write a new post if you remain uncertain.
Answer: Mann-Whitney U test is a rank-sum test, hence it doesn't really care about distribution properties such as mean, media, etc, it only cares that one of your variables tends to have higher values than the other, hence the former has a higher sum of ranks. Nevertheless, if you look closely at this table:
Variable   |  Mean | StDev  | Minimum | Q1 |Median| Q3 | Maximum
positives  |  4.13 | 13.17  |  1.00   |1.00| 1.00 |1.00| 116.00
negatives  | 6.851 | 20.503 |  0.000  |1.00| 1.00 |5.00| 434.000

you might notice that both variables have equal 25-percentiles, means and medians, while the seconds one has a higher 75-percentile. That supports the observation that the second distribution is likely to have a higher rank-sum.
Edit
Inspired by AdamO's comment, I made a little research on the U-test. According to this published response in Arthritis and Rheumatism journal (impact-factor >7) the test can only compare two distributions of similar shape. This assumption is clearly violated.

The Mann-Whitney U test (2) and the Kruskal-Wallis test (3) are
  nonparametric methods designed to detect whether 2 or more samples
  come from the same distribution or to test whether medians between
  comparison groups are different, under the assumption that the shapes
  of the underlying distributions are the same. Thus, these
  nonparametric tests are commonly used to determine whether medians,
  not means, are different between comparison groups. Although these
  tests are often used to compare means when normality assumption is not
  violated, strictly speaking, interpreting the results of non-
  parametric tests for mean comparison is inaccurate. When the
  distribution of a variable is skewed (for example, as in the values
  for C-reactive protein that van der Helm-van Mil et al present in
  Table 2 of their article 1), only assertions on whether medians, and
  not means, were different between groups should be made using
  nonparametric methods.

Given that your sample is not small I would recommend you to try a permutation test to answer your question. Here is a good discussion on their limitations
Comment: You are confusing "parameters" with distributional properties. All continuous distributions have a median. The Mann-Whitney test is no less "non-parametric" than the t-test in that regard, except in the rare cases when a distribution doesn't have a mean. One can always make a test for differences in means or rank means regardless of the distribution, and it is the limiting distributions of their test statistics which tend to Gaussian, rather than exact probabilistic calculations on which inference is based.
Comment: Note first that the Mann-Whitney test is NOT a test for equality of medians. The sentence you quote doesn't mean that Mann-Whitney test assumes symmetry. Instead it explains that if you *also* assume symmetry (which is not normally an assumption of the test), *then* it becomes a test for equality of medians. That is, by adding an additional assumption to the test, you can have it test medians -- but as he says, then it also tests means (at least when population means exist)
Comment: @AdamO wow, it's the first time someone tells me that U-test assumes symmetrical distributions. As far as I remember it, being nonparametric, doesn't have this limitation. In fact, the only limitation I can think about is some huge difference in variance.
Comment: @EliKorvigo Can I say that the second distribution *does* have a higher rank-sum? [OR] should I say it is *likely* to have a higher rank-sum ?
Comment: @PatternRecognition see my edit
Comment: @EliKorvigo I don't think AdamO said that the U-test assumes symmetrical distributions.
Comment: @Glen_b An excerpt from AdamO's answer "The Mann-Whitney test happens to be a reasonably powerful test of medians only when the underlying distributions are symmetric"


Prove that if every root of $P(x)$ is real then every root of $P'(x),P''(x),.. $are real too

Question: I think this is not so difficult a question.
I want to make sure what I did is correct.
First take two immediate roots of $P(x)$, then there is a point $x_0$ such that $P'(x_0)$ is zero. This exactly is a solution and between every immediate roots, there is one such $x_n$. Since all roots of $P(x)$ lie in real plane, the points $x_n$ also lie in real plane.
This continues in the same pattern for $P^n(x)$
Is this correct?
Comment: is this $P$ a polynomial?
Comment: ...and if they coincide, the derivative has a root at that point.
Comment: yes. sorry missed that.
Answer: There is the added subtlety that if $P$ has degree $n$, and therefore $n$ real roots then there are $n-1$ of these intermediate critical points which coincide with the degree of $P'$ being $n-1$. Without this argument there is nothing to say that $P'$ doesn't have roots other than those described. Other than this you are spot on.
Comment: There's a bit more subtlety than that.  If $P$ has degree $n$ there may be fewer than $n$ **distinct** real roots.  However, if $r$ is a root of $P$ of multiplicity $m > 1$, then it is a root of $P'$ of multiplicity $m-1$, so the count still comes out OK.


Why are complex numbers defined as $a+bi$?

Question: I understand that a complex number $n = a + bi$ is defined as having real $a,b$ with $i = \sqrt{-1}$. However what I don't understand is the why. Why was it defined this way? How do we know this will be a useful way to define them? Was this emergent from previous mathematics or a defined "workaround" to address certain problems? Like what led to someone going, "Hmm, we should define a new type of number and represent it as $a + bi$ where $i = \sqrt{-1}$!" and so on.
I have been trying to understand the basics of complex analysis but I haven't yet understood why numbers are represented this way before I can wrap my head around why all these other interesting areas of mathematics work themselves out. Like I could easily envision myself defining a specific number in some way only to find later that it was a bad definition or an incomplete or inaccurate way to describe something. What makes $a + bi$ correct and why did it come about?
Comment: Numbers of the form $a+bi$ with $a,b \in \mathbb R$ are sufficient to solve every quadratic with real coefficients (clearly).  That already makes them interesting.  The Fundamental Theorem of Algebra (much harder) shows that such numbers also suffice to provide the roots of every polynomial with real coefficients.
Comment: We know that this will be useful because it is useful: we have been using coomplex numbers for a few centuries by now.
Comment: @lulu Why don't you post that as an answer?
Comment: [This isn't exactly the same, but seems related.](https://math.stackexchange.com/questions/2365475/)
Comment: Think of them as pairs of numbers with a multiplication operation that is consistent with the real multiplication operator. Then $i$ is just $(0,1)$. It turns out that with this multiplication, $(0,1) \cdot (0,1) = (-1,0)$ which is where we get the $\sqrt{-1}$ notation.
Comment: @lulu I think the statement is valid also for polynomials with complex coefficients, which is a real advantage, as demonstrates that the complex numbers are closed under this operation.
Comment: There is no reason. It is simply the outcome of a process of natural selection. Notations/definitions are created all the time. If enough people find one particular version useful enough, it start to attract other people to switch to use it. This in turn drive even more people using it...
Comment: @user355705  You are certainly correct, but as the OP was, I think, implicitly asking about the relevance of these numbers to other forms of analysis, I just focused on real coefficients.
Comment: This is the only way to generalize the real numbers further preserving associativity, commutativity, and distributivity laws of addition and multiplication. Only the ordering property will be sacrificed. And the generalization provides such advantages that one can probably say that the complex numbers are much more "real" than the real numbers.
Comment: I like the quadratics explanation, but what lets us add, subtract, and multiply them? What lets us treat them as vector quantity? For example we don't treat the point $4+3$ on an $xy$ real plane like it were Manhattan distance on a grid but we seem to treat complex numbers $a + bi$ that way (when we use a real and imaginary axes on a plane)
Comment: Complex numbers are not vectors. They are scalars.
Comment: What I mean is that if I have the complex number like $2 + 5i$ it's almost like coordinates $(2, 5)$, which here means move over $2$ on the real line and then move up $5$ units on the imaginary line. Meanwhile on a regular $xy$ plane if I have $(x,y)$ then $x+y$ tells us the length of the Manhattan distance to that point.
Answer: Historically, complex numbers were introduced by Cardan as far back as the 16th century. While people did not really understand them at the time (much like undergrads now!), introducing this famous notation $a+b\sqrt{-1}$ served in intermediate computations for finding explicit solutions to cubic equations (with real solutions!).
So if it Cardan's intuitive idea could be made rigorous (and it can, of course), then it at least has the merit of allowing one to do computations with more general numbers than just reals, before returning to reals. This is by the way also useful for factoring polynomials like $X^4+1$ over the reals.
Of course, by now we (mathematicians, physicists, engineers...) are so used to the abstract notion of complex numbers that we think of them as just as natural as reals or integers. Also, it turns out that they have this wonderful property that every polynomial (real or complex) can be factored into a product of complex polynomials of degree one. This means that complex numbers are enough to study any polynomial with real coefficients.
Comment: Why is it $a + bi$ and not just $bi$? If $a$ is real, then can't it be considered part of a separate operation?
Answer: You start with the question "What is $\sqrt {-1}$?"
And you answer that by creating a value for it that isn't a "real number", called $i$, and create a new number system that is linear combinations of $1$ and $i$ -
 that works. And gives sensible answers to other square roots, other polynomial roots, and has consistent algebra that goes beyond real number results, and then has natural (if sometimes unexpected) extensions of existing functions, etc.
If it didn't produce a set of sensible consistent results, we probably would never have heard of it.
Answer: Two questions
I think there are two main parts to this question:

Why were complex numbers first used, and what makes them useful now?
What makes $a+bi$ a useful/good representation?

1. Why are complex numbers useful?
This is addressed well in Glougloubarbaki's answer. Briefly, they were first conceived because when people were first solving cubic equations (with real coefficients) for real roots, they noticed that calculations involved square roots of negative numbers arising, but that things worked out if you just assumed that those were okay. It was later shown that these "imaginary roots" are unavoidable if you want to write down the roots of a cubic using radicals (and not trig functions or something); a key phrase is "casus irreducibilis".
Now there are lots of reasons that complex numbers are used in different contexts, but I'd bet the vast majority of them are either related to nice rotation-related properties beyond the scope of this answer (e.g. "phasors" in electrical engineering) or to the Fundamental Theorem of Algebra, which says that expanding the reals to the complex numbers is enough if you want all the polynomials to have as many roots as they should.

2. Why $a+bi$?
I think this is an excellent question that doesn't get explicitly discussed enough; this is by no means obvious. If you instead wanted to, say, add on a cube root of $2$ to the rationals (call it $j$), then "all numbers of the form $a+bj$" would not be good at all.
In answering, I want to directly address the comment "...what lets us add, subtract, and multiply them? What lets us treat them as vector quantity?". For what follows, I will suppose that $i$ satisfies $i^2=1$ and that we want to be able to do arithmetic with our complex numbers and follow the usual rules like commutativity of multiplication.
Why do we need at least $a+bi$?
Before we show that the numbers of the form $a+bi$ are good enough, we should check that we need all of them. For instance, maybe we only need nonnegative values of $b$ or something.
Pure imaginaries
Well, since we want to be able to multiply numbers, we need numbers of the form $bi$ since that would be a product of a real number $b$ and the new number $i$.
Why are all these products distinct/necessary? Well, $(bi)^2=b^2i^2=-b^2$, so for every nonnegative number $b$, these numbers have to be different. But that doesn't rule out something like $3i=-3i$ being true. But $3i+(-3i)=0$ and $3i+3i$ squares to $-36$, so they can't be equal. Similarly for any other real number in place of $3$.
Adding in $a$.
Then we could add a real number to these new "pure imaginary" numbers like $bi$, to get numbers like $a+bi$. But again we should check that we really need all of these.
If $a+bi=c+di$, then $a-c=di-bi$. Squaring both sides, we find that $(a-c)^2=-(d-b)^2$. Since the square of a real number is nonnegative, the only way this equation could be true is if both sides are $0$: $a=c$ and $b=d$.
This shows that there are no redundancies, and every number of the form $a+bi$ is distinct.
Addition and subtraction
The next thing to worry about is whether we need more numbers to be able to add and subtract. Note that $(a+bi)\pm(c+di)=(a\pm c)+(b\pm d)i$, and that if $a,b,c,d$ are real, then so are $a\pm c$ and $b\pm d$. So we don't get a new type of number when we add or subtract.
Vectors?
The above calculation says that when you add or subtract complex numbers written in the $a+bi$ form, you add/subtract the $a$'s and you add and subtract the $b$'s. This is just like the analogous operations on vectors: $\langle a,b\rangle\pm\langle c,d\rangle=\langle a\pm c,b\pm d\rangle$.
Multiplication
What about multiplication? Note that $(a+bi)(c+di)=ac+bci+adi+bdi^2=(ac-bd)+(ad+bc)i$ since $i^2=-1$. So when we multiply two numbers of this form, we get back a number that can be written in this form (even though it can also be written in other forms like one with $i^2$ in it).
Vectors?
If we look at the above calculation in the special case when $d=0$, it says $c(a+bi)=(ac)+(bc)i$. So when you multiply complex numbers written in $a+bi$ form by a real number, you just multiply the $a$ and the $b$ separately. This is just like the analogous scalar multiplication operation on 2-dimensional real vectors: $c\langle a,b\rangle=\langle ca,cb\rangle$.
So as far as addition, subtraction, and multiplication by real numbers is concerned, complex numbers are just like 2-d real vectors.
Division
What about division?
$$\begin{align*}&\frac{a+bi}{c+di} \\ &= \frac{(a+bi)(c-di)}{(c+di)(c-di)} \\ &= \frac{ac+bci-adi-bdi^2}{c^2-(di)^2} \\ &= \frac{(ac+bd)+(bc-ad)i}{c^2+d^2} \\ &= \left(\frac{ac+bd}{c^2+d^2}\right)+\left(\frac{bc-ad}{c^2+d^2}\right)i\end{align*}$$
This looks like it works, but we should worry about whether the denominator is zero. Since $c$ and $d$ are real numbers, their squares are nonnegative, so $c^2+d^2$ could only be zero if we had $c=d=0$. But that would make the original denominator $c+di=0+0i=0$. We don't expect division by zero to work, so division of these numbers works fine whenever it should.
Answer: The definition is "right" because it makes it into a complete minimal field extension of the real numbers that makes every polynomial with real coefficients have a solution.
Answer: This might not be the exact reason why they are defined this way (there might be many reasons, in fact), but it is sometimes useful to think of complex numbers as objects that are analogous to 2 dimensional vectors. We could define:
$f:\mathbb{C}\rightarrow\mathbb{R}^2$
such that $f(z)=(a,b)$ where $z=a+bi\in\mathbb{C}$ and $(a,b)\in\mathbb{R}^2$.
Hence the real and imaginary parts play the role of cartesian coordinates.
It is also a well-known fact that every complex numbers can be rewritten in polar form such that $z=re^{i\theta}$, where $r$ is the modulus of the vector and $\theta$ its orientation. In fact this form is another way to define complex numbers.
Answer: $C$ is the algebraic closure of $R$. That is all polynomials with real coefficients(even complex ones) split in $C[x]$. And $C$ is the smallest extension of $R$ with this property.


Math for fun: Determining the angle between matrices $A$ and $B$ with three columns and rows

Question: So I was bored, as there were no math problems on Youtube that I thought that I might be able to solve, let alone any math videos, so I decided to start to do some determining the angle between two matrices using the Euclidean Inner Product, and got bored of that when I started to feel like it was a little too easy to determine the angle between two matrices with two columns and rows, so I asked myself, "What if I tried to determine the angle between two matrices $A$ and $B$ with three columns and rows? Surely I would be able to do that with the Euclidean Inner Product." And so, I created these two matrices:$$\begin{bmatrix}1&3&4\\3&4&5\\6&1&3\end{bmatrix}\text{ and }\begin{bmatrix}4&3&2\\3&6&4\\5&6&1\end{bmatrix}$$which I thought that I might be able to determine the angle between these two matrices. Here is my attempt at doing that:
According to the Euclidean Inner Product, the angle between two matrices is defined as$$\def\a#1#2#3#4{\left(\dfrac{#1_1#1_2+#2_1#2_2+\dots+#3_1#3_2+#4_1#4_2}{\sqrt{#1_1^2+#2_1^2+\dots+#3_1^2+#4_1^2}\sqrt{#1_2^2+#2_2^2+\dots+#3_2^2+#4_2^2}}\right)} \theta=\arccos\a {{(a_1)}}{{(a_2)}}{{(a_{n-1})}}{{(a_n)}}$$$$\therefore\arccos\left(\dfrac{A\cdot B}{|A||B|}\right)\text{ in this case }$$$$\equiv\arccos\left(\dfrac{4+9+8+9+24+20+30+6+3}{\sqrt{1+9+16+9+16+25+36+1+9}\sqrt{16+9+4+9+36+16+25+36+1}}\right)$$Which simplifies to$$\arccos\left(\dfrac{113}{\sqrt{122}\sqrt{152}}\right)$$$$=\arccos\left(\dfrac{113}{4\sqrt{61}\sqrt{19}}\right)$$$$\approx\arccos(0.829806312318)$$$$\approx0.592035810547^{\text{rad}}\text{ or }\approx33.921153265\unicode{xB0}$$

My question

Am I right in assuming that I would be able to use for any two matrices $A$ and $B$ assuming that $A$ and $B$ both have the same amount of rows and columns, or what would I use to determine the angle between the matrices?

Mistakes I might have made

Simplifying the Euclidean Inner Product
Using the Euclidean Inner Product
Using math symbols incorrectly
Comment: This is known as [Frobenius inner product](https://en.wikipedia.org/wiki/Frobenius_inner_product). Yes, if you have inner product on real vector space, it allows you to define angles (if space is complex, angles become complex and multi-valued), but they are usually not very useful.
Answer: So firstly, you say you are determining the angle between two matrices but actually what you are doing is computing the angle between two vectors in $\mathbb{R}^9$ this is because depending on how you parameterize your matrix, the angles you get are different so really you are finding angles between points in $\mathbb{R}^9$. There is no natural identification in the sense that it works with matrix multiplication, this is mostly because there is no nice 'product' for points in $\mathbb{R}^k, k > 1$. Using your method you can compute the 'angle' between any two matrices that have the same number of elements, although this number really doesnt mean anything.
What you could try however if you really want to define an 'angle' between matrices you could try to define it on the spectrum of the product. Before going into detail there, an easy example to try is to define the angle between two complex numbers, this is done by this method. Once you understand that you can look at a commuting subalgebra of matrices and do something similar.


Weighted Average Over Time for Data Projection (aka Weighted Moving Average) - Mathematically Correct Way to Determine Weights?

Question: Consider the following data set:
Say graduation rates for a specific college's undergraduate program that are the following:

Year
# of Graduates

Year 11
10,500

Year 12
10,750

Year 13
11,000

Year 14
11,750

Year 15
9,000

Year 16
11,500

Year 17
12,125

Projected
# of Graduates

Year 18
?

Year 19
?

Year 20
?

Year 21
?

Year 22
?

If I wanted to generate a data projection for the next five years using only these seven data points given; specifically, projecting Year 18 to Year 22 (five projected data points); what would be the mathematically correct way for choosing the weights to mathematically correctly generate these projected five data points?
Specifically, given the following mathematical formula for weighted average (${{x}_{w}}$) as the sum of the: products of weights ($w$) of values ($v$), divided by the sum of the weights, given as:
${{x}_{w}}={[(w_1)(v_1)+(w_2)(v_2)+(w_3)(v_3)+{\cdot}{\cdot}{\cdot}+(w_n)(v_n) ]/[(w_1)+(w_2)+(w_3)+{\cdot}{\cdot}{\cdot}+(w_n)]}$
Then how do you mathematically correctly determine the values of the weights?
Remark: I'm sure this has something to do with time scale duration between each of the data points in this set; which in this case are equal to one another at 1 year each (365 days); but I don't know how that yields the mathematically correct determination of the weights?
Any help on this would be appreciated, thanks in advance.
Answer: There is no "mathematically correct" way.  This is not a matter of mathematics.  It is a matter of what model you believe best captures reality.  The model you choose is based on your belief about how reality works -- not on mathematics.


If $\triangle$ is the area of triangle with side lengths $a,b,c$, then show that $\triangle \le\dfrac{1}{4}\cdot\sqrt{(a+b+c)abc}$

Question: If $\triangle$ is the area of triangle with side lengths $a,b,c$, then show that $\triangle \le\dfrac{1}{4}\cdot\sqrt{(a+b+c)abc}$. Also show that equality occurs in the above inequality when $a=b=c$
My attempt is as follows:-
$$\triangle=\sqrt{s(s-a)(s-b)(s-c)}$$
$$\triangle=\dfrac{1}{4}\sqrt{(a+b+c)(b+c-a)(a+c-b)(a+b-c)}$$
$$b+c-a>0,a+c-b>0,a+b-c>0$$
So we can apply $A.M\ge G.M$
$$\dfrac{b+c-a+a+c-b+a+b-c}{3}\ge\left((b+c-a)(a+c-b)(a+b-c)\right)^\frac{1}{3}$$
$$\dfrac{a+b+c}{3}\ge\left((b+c-a)(a+c-b)(a+b-c)\right)^\frac{1}{3}\tag{1}$$
As $a>0,b>0,c>0$, we can also say
$$\dfrac{a+b+c}{3}\ge(abc)^\frac{1}{3}\tag{2}$$
But we can't say from this that $(abc)^\frac{1}{3}\ge\left((b+c-a)(a+c-b)(a+b-c)\right)^\frac{1}{3}$
So I tried $G.M\ge H.M$ for $a,b,c$
$$(abc)^\frac{1}{3}\ge\dfrac{3abc}{ab+bc+ca}$$
$$\dfrac{ab+bc+ca}{3}\ge(abc)^\frac{2}{3}\tag{3}$$
Seems like it didn't produce anything useful, so  I tried $G.M\ge H.M$ for $b+c-a,a+c-b,a+b-c$
$$\left((b+c-a)(a+c-b)(a+b-c)\right)^\frac{1}{3}\ge\dfrac{3(b+c-a)(a+c-b)(a+b-c)}{((b+c-a)(a+c-b)+(a+c-b)(a+b-c)+(b+c-a)(a+b-c))}$$
$$\left((b+c-a)(a+c-b)(a+b-c)\right)^\frac{1}{3}\ge\dfrac{3(b+c-a)(a+c-b)(a+b-c)}{2ab+2bc+2ca-a^2-b^2-c^2}\tag{4}$$
But again it didn't produce anything useful, so I tried something else.
Applying $A.M\ge G.M$ for $a+b+c,a+b-c,b+c-a,a+c-b$
$$\dfrac{2(a+b+c)}{4}\ge\left((a+b+c)(b+c-a)(a+c-b)(a+b-c)\right)^\frac{1}{4}$$
$$\dfrac{a+b+c}{2}\ge\left((a+b+c)(b+c-a)(a+c-b)(a+b-c)\right)^\frac{1}{4}$$
Squaring both sides
$$\dfrac{(a+b+c)^2}{4}\ge\left((a+b+c)(b+c-a)(a+c-b)(a+b-c)\right)^\frac{1}{2}$$
By cachy's inequality:-
$$(1^2+1^2+1^2)(a^2+b^2+c^2)\ge(a+b+c)^2$$
$$3(a^2+b^2+c^2)\ge(a+b+c)^2$$
$$\dfrac{3(a^2+b^2+c^2)}{4}\ge\dfrac{(a+b+c)^2}{4}\tag{5}$$
Hence
$$\dfrac{3(a^2+b^2+c^2)}{4}\ge\left((a+b+c)(b+c-a)(a+c-b)(a+b-c)\right)^\frac{1}{2}\tag{6}$$
Dividing by $4$
$$\dfrac{3(a^2+b^2+c^2)}{16}\ge\triangle$$
So I tried all these approaches, but unfortunately didn't arrive at the required result. What can we do here? Please help me in this.
Answer: $$\triangle=rs=\dfrac{abc}{4R}$$ where $2s=a+b+c$ and $R,r$ are the in-radius & circum-radius  respectively
$$\sqrt{(a+b+c)abc}=\sqrt{\dfrac{2\triangle}r\cdot4\cdot\triangle\cdot R}=4\triangle\sqrt{\dfrac R{2r}}$$
Now use
True or False: The circumradius of a triangle is twice its inradius if and only if the triangle is equilateral.
or
Why is the inradius of any triangle at most half its circumradius?
Answer: By your work we need to prove that
$$\sum_{cyc}(2a^2b^2-a^4)\leq\sum_{cyc}a^2bc$$ or
$$\sum_{cyc}(a^4-2a^2b^2+a^2bc)\geq0$$ or
$$\sum_{cyc}(a^4-a^3b-a^3c+a^2bc)+\sum_{cyc}(a^3b+a^3c-2a^2b^2)\geq0$$ or
$$\sum_{cyc}(a^4-a^3b-a^3c+a^2bc)+\sum_{cyc}ab(a-b)^2\geq0,$$
which is true by Schur.


Examples: (Symmetric) Quotients of Euclidean Space

Question: What are some examples of $n$-dimensional topological manifolds $M$ (possibly with boundary), which can be written as a quotient $\mathbb{R}^d/G$ for some topological group acting on $\mathbb{R}^d$?
Comment: @MoisheKohan: all connected manifolds can be realized as $\mathbb{R}^d/G$ really?
Comment: @C.F.G: I will write an answer in a few days. As for homogeneous spaces, the standard definition is that it is a Riemannian manifold with transitive isometry group. (Some authors allow for quotients of Lie groups by closed subgroups, without fixing a metric in advance.) A locally homogenous space is a Riemannian manifold locally isometric to a homogeneous space. This is very different from a manifold homeomorphic to the quotient of $R^n$ by a (proper) topological group action.
Comment: Assuming that by Lie algebra you mean a Lie group, your M will have to be a single point.
Comment: Only if the action is transitive
Comment: Now, with the edit, this is a totally different question. In particular, it now has nothing to do with symmetric spaces. What examples of manifolds do you know which satisfy this property? It is not unreasonable to conjecture that every connected manifold can be realized this way.
Comment: @C.F.G: This holds for all connected surfaces and all compact connected 3-manifolds. In higher dimensions, I am not sure, but I see no obstructions.
Comment: @MoisheKohan: Interesting!! where can I read about it? ~~~~~~~ i thought that $\mathbb{R}^d/G$ is the definition of homogeneous space if discrete Lie group $G$ act freely, properly discontinuously, but you say "it now has nothing to do with symmetric spaces"!!
Answer: I will interpret your question as asking about manifolds which are quotients of $R^d$ by proper continuous actions of topological groups.
First of all, if $M$ is a connected manifold and $p: \tilde M\to M$ is the universal covering then the discrete group $G=\pi_1(M)$ acts properly on $\tilde M$ by deck-transformations of $p$ so that $M= \tilde M/G$.
Thus, you obtain some easy examples: Manifolds whose universal  cover is homeomorphic to ${\mathbb R}^d$, e.g. tori $T^d$. Also, if $S$ is a connected surface not homeomorphic to $S^2$ or ${\mathbb R} P^2$, then the universal cover of $S$ is homeomorphic to ${\mathbb R}^2$: Once can derive this from the Uniformization Theorem.  This gives you more examples by taking products of surfaces and circles. With a bit more work, you also prove that if
$$
F\to M\to B
$$
is a fiber bundle, where the fiber and base ($F$ and $B$) have universal covers homeomorphic to ${\mathbb R}^k, {\mathbb R}^n$ respectively, then the universal cover $\tilde M$ of $M$ is homeomorphic to ${\mathbb R}^{n+k}$: This is because  the fiber bundle above lifts to a fiber bundle of universal covers:
$$
\tilde F\to \tilde M\to \tilde B
$$
and the latter is trivial since $\tilde B$ is contractible.
Conjecture. Every connected topological manifold $M^m$ (possibly with boundary) is homeomorphic to the quotient of some ${\mathbb R}^d$ ($d=m$ or $d=m+1$) by a proper continuous group action of a topological group.
I will prove this conjecture (when $d=m$) in the case of (arbitrary) surfaces and compact 3-manifolds ($m=3$). There is a strategy for proving the conjecture in higher dimensions, assuming that $M$ is compact and triangulated (the proof I have in mind may need $m+1$ instead of $m$ and a nondiscrete topological group $G$). I am not sure about topological manifolds.
Proof. In order to keep the discussion reasonably short, I will assume that $\partial M=\emptyset$.
If $M$ is a noncompact surface (without boundary), the universal cover of $M$ is homeomorphic to ${\mathbb R}^2$ and we are done. The same for closed (compact, with empty boundary) surfaces different from $S^2$ and ${\mathbb R} P^2$.
To represent $S^2$ as the quotient of the plane, start with a square $Q\subset {\mathbb R}^2$ and let $\Gamma$ denote the group of Euclidean isometries generated by reflections $\tau_1,...,\tau_4$ in the consecutive edges of $Q$. Then ${\mathbb R}^2/\Gamma$ is naturally homeomorphic to $Q$ (since every $\Gamma$-orbit in ${\mathbb R}^2$ intersects $Q$ exactly once). Let $G_1< \Gamma$ denote the index 2 subgroup consisting of orientation-preserving isometries. Then ${\mathbb R}^2/G_1$ is homeomorphic to $S^2$: You see this by taking the union $D$ of $Q$ and $Q'=\tau_1(Q)$ and checking the identification pattern on the boundary of $D$ given by the rotations $\tau_1 \circ \tau_i, i=1,2,3$. The key fact to keep in mind is that while $\Gamma$ (and, hence, its subgroups) acts properly on the plane, it does not act freely on the plane, so the action of $G_1$ is not by covering transformations (the universal cover of $S^2$, of course, is not ${\mathbb R}^2$).  In order to get ${\mathbb R}P^2$ as the quotient, let $\sigma$ denote the unique reflection $\ne \tau_1$ and preserving $D$. Define the group $G_2$  generated by $G_1$ and the composition $\tau_1\circ \tau_2\circ \sigma$. The group $G_2$ contains $G_1$ as an index 2 subgroup and one verifies that $R^2/G_2$ is homeomorphic to ${\mathbb R}P^2$.
In order to understand what is really going on here, it is better to use the language of orbifolds. The best reference I know is:
Scott, Peter, The geometries of 3-manifolds, Bull. Lond. Math. Soc. 15, 401-487 (1983). ZBL0561.57001.
What I am using is that both $S^2$ and ${\mathbb R}P^2$ appear as underlying spaces or parabolic (Euclidean) orbifolds: For $S^2$ I am placing four elliptic points of order 2 on the sphere and for ${\mathbb R}P^2$ I am placing two elliptic/cone  points of order 2 on ${\mathbb R}P^2$. This creates, respectively, parabolic orbifolds ${\mathcal O}_1$ and ${\mathcal O}_2$ with respective fundamental groups isomorphic to $G_1, G_2$: The Euclidean plane on which $G_1, G_2$ are acting serves as the universal covering space (in the orbifold sense!) of both orbifolds. The groups $G_1, G_2$ are acting   on the plane as the groups of covering transformations (again, in the orbifolds sense!), hence, fixed points are allowed (and even required). I could have used different parabolic or even hyperbolic orbifold structures with the underlying spaces $S^2$ and ${\mathbb R}P^2$ to the same effect. In the latter case, the universal covering space (as a metric space) would be the hyperbolic plane.
The latter generalizes to dimension 3. I will use a theorem mostly due to Thurston:
Theorem. Let $M$ be a closed oriented connected 3-manifold. Then there exists a link (even a knot) $L\subset M$ such that placing a suitable orbifold data at $L$, one obtains a hyperbolic orbifold ${\mathcal O}$ with the underlying space $M$ and the singular locus $L$.
You can find proofs for instance in
Myers, Robert, Simple knots in compact, orientable 3-manifolds, Trans. Am. Math. Soc. 273, 75-91 (1982). ZBL0508.57008.
Brooks, Robert, A construction of metrics of negative Ricci curvature, J. Differ. Geom. 29, No. 1, 85-94 (1989). ZBL0628.53043.
The proof in the second paper has a chance to generalize in higher dimensions, but one needs to weaken negative curvature to nonpositive curvature (in suitable sense).
The result also holds for compact manifolds with boundary (one needs to put suitable "boundary reflectors" on $\partial M$) and non-orientable 3-manifolds.
Now, given this, let $G=\pi_1({\mathcal O})$ be the orbifold-fundamental group of ${\mathcal O}$. The property that    ${\mathcal O}$ is hyperbolic means that $G$ acts isometrically and properly on the hyperbolic 3-space ${\mathbb H}^3$ so that the quotient-orbifold ${\mathbb H}^3/G$ is isomorphic (as an orbifold) to ${\mathcal O}$. In particular, this quotient, regarded as a topological space, is homeomorphic to $M$.


How to mix DHCP-provided DNS servers with statically written DNS servers?

Question: I am trying to make a combination of the DNS servers provided by my ISP and 3 static (188.8.131.52, 188.8.131.52 and 220.127.116.11).
On Ubuntu 18.04, I did it by adding the static DNS to "/etc/resolvconf/resolv.conf.d/tail" and running "resolvconf -u".
On CentOS 6, I did it with dhclient options "/etc/dhcp/dhclient.conf" by adding "append domain-name-servers 126.96.36.199 126.96.36.199 188.8.131.52".
In both cases it adds them after the DHCP-provided ones as I want and dig +trace confirms that it is using the DHCP-given DNS server for now(as its up, supposedly if its down it will move to next one and so on).
Question is: How to do the same thing on CentOS 9/AlmaLinux 9/RockyLinux 9?
Answer: You can configure the NetworkManager nmcli or systemd-resolved (Add the DNS option under the [Resolve] section


GestureDetector using Service

Question: i wish to implement the GestureDetector using service instead of activity. the code works on activity but not on service. In Service i am not able to @Override the onTouchEvent(MotionEvent e) method - is this the cause of the problem?
public class GestureService extends Service implements OnGestureListener {

private GestureDetector gestureScanner;

@Override
public IBinder onBind(Intent intent) {
    // TODO Auto-generated method stub
    return null;
}
@Override
public void onCreate() {
    super.onCreate();
    Toast.makeText(getBaseContext(),"onCreate", Toast.LENGTH_SHORT).show();
    gestureScanner = new GestureDetector(this);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Toast.makeText(getBaseContext(),"onStartCommand", Toast.LENGTH_SHORT).show();
    return START_STICKY;

 }

public boolean onTouchEvent(MotionEvent me) {
    return gestureScanner.onTouchEvent(me);
}

@Override
public boolean onDown(MotionEvent e) {
    // TODO Auto-generated method stub
    Toast.makeText(getBaseContext(),"onDown", Toast.LENGTH_SHORT).show();
    return false;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
        float velocityY) {
    // TODO Auto-generated method stub
    return false;
}
@Override
public void onLongPress(MotionEvent e) {
    // TODO Auto-generated method stub

}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
        float distanceY) {
    // TODO Auto-generated method stub
    return false;
}
@Override
public void onShowPress(MotionEvent e) {
    // TODO Auto-generated method stub

}
@Override
public boolean onSingleTapUp(MotionEvent e) {
    Toast.makeText(getBaseContext(),"onSingleTapUp", Toast.LENGTH_SHORT).show();
    // TODO Auto-generated method stub
    return false;
}

}
i started the service in an activity class using startService(new Intent(this,GestureService.class));
Answer: I'm guessing you want to make it a Service so that you can use it for all applications.  But from reading this article, it's really not the way it works: gestures are application specific.
Comment: ok. if i managed to get `onTouchEvent(MotionEvent event)` called, beside getting the x and y coordinate of the event, what other information can i get? i.e the action. i tried `event.getAction() == MotionEvent.ACTION_DOWN` but it seems it dont return true when i touch the screen

GestureDetector using Service


Error: dictionary update sequence element #0 has length 3; 2 is required

Question: When the onchange...() function is executed I am getting the error:
File "/opt/odoo/odoo/openerp/models.py", line 5652, in _onchange_eval
    result.setdefault('domain', {}).update(method_res['domain'])
ValueError: dictionary update sequence element #0 has length 3; 2 is required

Here is my code. I think error has something to do with domain:
def onchange_template_id(self, cr, uid, ids, id, context=None):
        print "\n\n on change template global_template_id ", global_template_id
        bom_ids = []
        pd_ids = []
        product_complete = []
        ptemplid = global_template_id
        mbl_obj = self.pool.get('mrp.bom.line')
        id_s = mbl_obj.search(cr, uid,  [('product_id', '=', ptemplid)])
        for rec in mbl_obj.browse(cr, uid, id_s, context=context):
            bom_ids.append(rec.bom_id.id)
        mb_obj = self.pool.get('mrp.bom')
        for rec in mb_obj.browse(cr, uid, bom_ids, context=context):
            pd_ids.append(rec.product_id.id)
        pp_obj = self.pool.get('product.product')
        for rec in pp_obj.browse(cr, uid, pd_ids, context=context):
            product_complete.append('['+ str(rec.default_code) + ']'+ ' ' + str(rec.name_template))
        print "\n\n bom_ids ", bom_ids
        domain = [('id','=',bom_ids)]
        return {
            'type': 'ir.actions.act_window',
            'name': _('BOM'),
            'res_model': 'mrp.bom',
            'view_mode': 'tree',
            'target': 'new',
            'domain': domain,
               }

Answer:
bom_ids = []

It is a list, means more then one value will be there.And the domain that you are passing is

[('id','=',bom_ids)]

so if we take small example then consider that bom_ids = [1,2,3]; then the domain will be

domain = [('id','=',bom_ids)] -> [('id','=',[1,2,3])]

Which is wrong as per SQL concept. the id = will always have single value. for multiple values you should use either in or like.
Here the solution you can try is

domain = [('id','in',bom_ids)]

Hope this will help you.
Thanks.


How to I generate a CSV file from a python list with each list item in a seperate row

Question: I've tried some code I got from another question (list_of_paths is a list I generated earlier in the code)
myfile = open('/home/graham/Desktop/Experiment/listcsv.csv', 'wb')
wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
wr.writerow(list_of_paths)

But it put the entire list in one cell. I want each item in a different row. The program I use for CSV files is LibreOffice Calc if that makes a difference.
Comment: What is the contents of `list_of_paths`? list-of-strings / list-of-list?
Comment: maybe `writerows()` instead of `writerow()`
Comment: @cmd if `list_of_paths` is indeed a list (or other iterable) then I think you're right :)
Comment: list_of_paths is a list of 77 file paths (ex. /home/graham/Desktop/Experiment/Experiment_images/1/which_image.csv)
I just tried writerows() and it worked except every character in the file path is within quotations. (ex. /,"h","o","m","e","/","g","r","a","h","a","m","/","D","e","s","k","t","o","p","/","E","x","p","e","r","i","m","e","n","t","/","E","x","p","e","r","i","m","e","n","t","_","i","m","a","g","e","s","/","1","/","w","h","i","c","h","_","i","m","a","g","e",".","c","s","v")
Answer: Use writerows as follow:
myfile = open('/home/graham/Desktop/Experiment/listcsv.csv', 'wb')
wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
wr.writerows([path] for path in list_of_paths)

Answer: I would use standard Input/Output to implement this.
$ cat getCSV.py
input_list = range(10)   # replace range(10) with your list
for elem in input_list:
    print '"' + str(elem) + '"'

$ python getCSV.py > output.csv
$ cat output.csv
"0"
"1"
"2"
"3"
"4"
"5"
"6"
"7"
"8"
"9"

And if each elem in your list is again, a list or tuple.. you could use join command to separate them into columns.
>>> row = [str(i) for i in range(10)]
>>> row
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
>>> ','.join(row)
'0,1,2,3,4,5,6,7,8,9'
>>> ','.join(['"' + col + '"' for col in row])
'"0","1","2","3","4","5","6","7","8","9"'


Criar um Jogo em linguagem c com o MCU 8051 IDE

Question: Estou a tentar desenvolver um jogo no âmbito da unidade curricular de microprocessadores, sendo assim, o jogo consiste num boneco que tem de se desviar de bombas, portanto tenho de criar o boneco, as bombas e pô-los a mexer. Já tenho uma boa parte de código mas acho que ele fica preso num ciclo while e não percebo o porque. Será que expondo aqui um pedaço do meu código são capazes de me ajudar??
void main (void)
{
unsigned char i,counter=1;

start=0;
end=0;
IE=0b10000101;
En=1;
LCD_init ();
while(start!=0);
while(end==1);
Inicio();
CriarBonecoBomba();
x=0;
y=0;
score=0;

for(i=0;i<16;i++)
{
    var[0][i]=' ';
    var[1][i]=' ';
}
while(end==0) // salta da 1a interrupção la ao fundo para aqui e não sai daqui
{
    while (start==1)
    {
        MovBoneco();
        desloca_esq();
        if((counter+3)%6==0)
            cria_bomba(1);
        else
            if(counter%6==0)
                cria_bomba(2);
            else
                cria_bomba(0);
        if(var[y][x]==1|| 1==var[y][x-1])
        {
            LCD_comando(0b10000000);
            LCD_date(' ');
            LCD_date(' ');
            LCD_date(' ');
            LCD_date('G');
            LCD_date('A');
            LCD_date('M');
            LCD_date('E');
            LCD_date(' ');
            LCD_date('O');
            LCD_date('V');
            LCD_date('E');
            LCD_date('R');
            while(1);
        }
    MovBoneco();
    AtualizarLCD();
    counter++;
    if(var[0][0]==1||var[1][0]==1)
        score=score+5;
    display7segmentos();
}
}
}

void RSIEXT0(void)__interrupt (0)
{
start=1;
}

void RSIEXT1(void)__interrupt (2)
{
end==1;
}

Comment: Qual o compilador que você está utilizando? Aonde você detecta a colisão com a bomba? Você está resetando o valor da variável *start* quando a bomba atinge o boneco?
Comment: Falta os includes no seu código para que seja possivel ao menos tentar compilar o seu script
Comment: Não me parece que essa pergunta deveria ser suspensa como não clara. A seguinte frase diz tudo: "Já tenho uma boa parte de código mas acho que ele fica preso num ciclo while e não percebo o porque".
Comment: Eu tenho os includes no meu codigo, e ele compila corretamente, o problema é que já fiz tudo e mais alguma coisa e nao consigo que ele inicie sequer.  o complilaqdor que estou a usar é o MCU 8051 IDE.
Comment: Em qual dos `while`'s ele fica preso?
Comment: Logo no primeiro while, while(start!=0).
Answer: Tanto start como end são inicializadas com o valor zero (0) logo ao início da sua função main. Elas não foram declaradas com um tipo (o compilador que você usa não gera nenhum aviso disso?) ou então você as declarou fora do escopo da função e não colocou esse código na pergunta.
Se for o caso 1, mesmo o compilador (possivelmente) não reclamando o escopo das variáveis é local (isto é, pertence somente à função main). E ai, qualquer alteração externa na verdade muda variáveis diferentes (de outro escopo).
Se for o caso 2 (que eu acho mais provável), as variáveis são globais e tudo deveria funcionar corretamente (supondo-se que as suas "interrupções" estejam sendo chamadas de fato). De todas as formas, há um errinho pequeno na função RSIEXT1 onde você usa o operador de igualdade (dois sinais de igual: ==) ao invés do operador de atribuição (um só sinal de igual: =). :)


Value of type [ViewModel] has no member nsPredicate

Question: I have a list of bookmarks stored with Core Data that i want to search through. But i'm getting this error next to vm.myBookmarks.nsPredicate = NSPredicate(value: true) in 'var query' below.

Value of type '[MyBookmarkViewModel]' has no member 'nsPredicate'

@ObservedObject var vm : MyBookmarksViewModel
@State private var searchText = ""

  ForEach(vm.myBookmarks) { myBookmark in

                    Text(myBookmark.name)
                    Text(myBookmark.url)
            }
                .searchable(text: query)

var query: Binding<String> {
    Binding {
        searchText
    } set: { newValue in
        searchText = newValue
        if newValue.isEmpty {
            vm.myBookmarks.nsPredicate = NSPredicate(value: true)
        } else {
            vm.myBookmarks.nsPredicate = NSPredicate(format: "name CONTAINS[cd] %@", newValue)            }
    }
}

MyBookmarksViewModel
class MyBookmarksViewModel: NSObject, ObservableObject {

    @Published var myBookmarks = [MyBookmarkViewModel]()

    private let fetchedResultsController: NSFetchedResultsController<MyBookmark>
    private var context: NSManagedObjectContext

    init(context: NSManagedObjectContext){
        self.context = context
        self.fetchedResultsController = NSFetchedResultsController(fetchRequest: MyBookmark.all  , managedObjectContext: context, sectionNameKeyPath: nil, cacheName: nil)
        super.init()
        fetchedResultsController.delegate = self
        fetchAll()

        }

private func fetchAll() {
    do {
        try fetchedResultsController.performFetch()
        guard let myBookmarks = fetchedResultsController.fetchedObjects else {
            return
        }
        self.myBookmarks =

myBookmarks.map(MyBookmarkViewModel.init)

        } catch {
            print(error)
        }
    }

}

extension MyBookmarksViewModel: NSFetchedResultsControllerDelegate {
    func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
        guard let myBookmarks = controller.fetchedObjects as? [MyBookmark] else {
            return
        }
        self.myBookmarks = myBookmarks.map(MyBookmarkViewModel.init)
    }
}

MyBookmarkViewModel
struct MyBookmarkViewModel: Identifiable, Hashable{

    init(myBM: MyBookmark) {
        self.myBM = myBM

    }
    private let myBM: MyBookmark

    var id: NSManagedObjectID {
        myBM.objectID
    }

    var name: String {
        myBM.name ?? ""
    }
}

MyBookmark
@objc(MyBookmark)
public class MyBookmark: NSManagedObject, BaseModel {
    static var all: NSFetchRequest<MyBookmark> {
        let request: NSFetchRequest<MyBookmark> = MyBookmark.fetchRequest()
        request.sortDescriptors = []
        return request
    }

}

extension MyBookmark {

    @nonobjc public class func fetchRequest() -> NSFetchRequest<MyBookmark> {
        return NSFetchRequest<MyBookmark>(entityName: "MyBookmark")
    }

    @NSManaged public var name: String?
    @NSManaged public var url: String?

}

extension MyBookmark : Identifiable {

}

This is for a macOS app.
Answer: nsPredicate belongs to the @FetchRequest property wrapper. But you are using NSFetchedResultsController.
Make the NSFetchedResultsController public
public let fetchedResultsController: NSFetchedResultsController<MyBookmark>

and assign the predicate to the controller
...
if newValue.isEmpty {
    vm.fetchedResultsController.fetchRequest.predicate = NSPredicate(value: true)
} else {
    vm.fetchedResultsController.fetchRequest.predicate = NSPredicate(format: "name CONTAINS[cd] %@", newValue)
}

Or shorter
vm.fetchedResultsController.fetchRequest.predicate = newValue.isEmpty
    ? nil
    : NSPredicate(format: "name CONTAINS[cd] %@", newValue)

If you don't want to make the controller public use a helper function in the view model.
Comment: I would put `searchText` into the view model and use Combine to observe and process the query.
Comment: Hello, I'm getting this error now 'Value of type 'NSFetchedResultsController' has no member 'predicate'
Comment: My bad. Please see the edit.
Comment: Errors have gone thanks! I'm testing out the search but nothing happens  in the view when i type in the search bar. Is there something else that needs to be changed in the model?


What does it mean when we say "the line x=2 y=5" etc in multivariable calculus

Question: Whilst studying my textbook, i came across the following notation: the line $x=2,y=3$. How does one graph that simple line out of two coordinates? I mean, in ordinary one-variable calculus it is very often used to say "the line $x=2$" or "the line $y=-13$". But how, in the three variable coordinate system can a line be graphed from knowing $2/3$ of the coordinates $(x=c_1,y=c_2$ or $z=c_1,x=c_2$ etc$)$?
Any thoughs appreciated!
Comment: I presume this is the line $\{(2,3,z):z\in\mathbb R\}$ - you get different points on the line by varying the $z$ coordinate. You can imagine a point $(2,3)$ on the $x,y$ plane, and then a line parallel to the $z$ axis going through that point.
Comment: Yes,that's it!Thanks for the really fast reply!
Answer: Quite simply, $z$ is unconstrained, so this is the line $(2,3,z)$, $z\in\mathbb R$.
Geometrically, the equations $x=2$ and $y=3$ define a pair of planes. The line is the intersection of these planes. More generally, we could say something like "the line $a_1x+b_1y+c_1z+d_1=0$, $a_2x+b_2y+c_2z+d_2=0$," defining the line as the intersection of the two planes given by those equations, but unless those equations are particularly simple, as in your example, there are less cumbersome ways to define a line in $\mathbb R^3$.
Answer: This line is the locus of the points $(x,y,z)=(2,5,t)$ with $t\in(-\infty,\infty)$. It is indeed a (vertical) line.
Note that in any 3D line, not all three coordinates are known upfront.


Should I translate string inside a Unit test?

Question: I have a Unit test where I need to print a string so I decide to use the t() function to translate it:
$this->assertTrue(is_numeric($expected), t('Parameter is numeric.'));

But the problem is that in the Unit test the t() function is not available. So I decide to check a similar Unit test in core (SortArrayTest) and the test don't translate the string:
$this->assertTrue(is_numeric($expected) && is_numeric($result), 'Parameters are numeric.');

I know that at this moment Drupal don't have integration with the Unit test from the UI, but this can be possible in future, so:
Should I translate string inside a Unit test? If the answer is Yes, How I can do it?
Answer: No, you should not. An assertion message is basically on the same level as a code comment, you're not translating that either.
We used to do that in core, also because it was all Simpletest then and the messages were shown in the UI, so an argument could be made that should be translatable. But we did massive patches to get rid of that, it just adds more complexity without any additional benefit.
Comment: In my opinion yes. I've also stopped using t() for things like button labels. Even if you'd test a multilingual site that really has a translation there could still be a problem then with mismatching languages or so, so in 99.9% of the time, it's just a waste of characters/function calls.
Comment: Thanks. So in all the tests (functionnal, kernel or unit) is better don't use the t() function?